Class: Rwm::Workspace
- Inherits:
-
Object
- Object
- Rwm::Workspace
- Defined in:
- lib/rwm/workspace.rb
Constant Summary collapse
- RWM_DIR =
".rwm"- PACKAGE_DIRS =
%w[libs apps].freeze
- GRAPH_FILE =
"graph.json"
Instance Attribute Summary collapse
-
#root ⇒ Object
readonly
Returns the value of attribute root.
Class Method Summary collapse
-
.find(start_dir = Dir.pwd) ⇒ Object
Find the workspace root via git.
Instance Method Summary collapse
- #apps_dir ⇒ Object
- #find_package(name) ⇒ Object
- #graph_path ⇒ Object
-
#initialize(root) ⇒ Workspace
constructor
A new instance of Workspace.
- #libs_dir ⇒ Object
-
#packages ⇒ Object
Discover all packages by scanning libs/ and apps/ for directories with a Gemfile.
- #rwm_dir ⇒ Object
Constructor Details
Instance Attribute Details
#root ⇒ Object (readonly)
Returns the value of attribute root.
9 10 11 |
# File 'lib/rwm/workspace.rb', line 9 def root @root end |
Class Method Details
.find(start_dir = Dir.pwd) ⇒ Object
Find the workspace root via git
16 17 18 19 20 21 22 23 |
# File 'lib/rwm/workspace.rb', line 16 def self.find(start_dir = Dir.pwd) dir = File.(start_dir) git_root = `git -C #{dir} rev-parse --show-toplevel 2>/dev/null`.chomp raise WorkspaceNotFoundError if git_root.empty? new(git_root) end |
Instance Method Details
#apps_dir ⇒ Object
37 38 39 |
# File 'lib/rwm/workspace.rb', line 37 def apps_dir File.join(root, "apps") end |
#find_package(name) ⇒ Object
46 47 48 |
# File 'lib/rwm/workspace.rb', line 46 def find_package(name) packages.find { |p| p.name == name } || raise(PackageNotFoundError, name) end |
#graph_path ⇒ Object
29 30 31 |
# File 'lib/rwm/workspace.rb', line 29 def graph_path File.join(rwm_dir, GRAPH_FILE) end |
#libs_dir ⇒ Object
33 34 35 |
# File 'lib/rwm/workspace.rb', line 33 def libs_dir File.join(root, "libs") end |
#packages ⇒ Object
Discover all packages by scanning libs/ and apps/ for directories with a Gemfile
42 43 44 |
# File 'lib/rwm/workspace.rb', line 42 def packages @packages ||= discover_packages end |