Class: Zirconia::Application
- Inherits:
-
Object
- Object
- Zirconia::Application
- Defined in:
- lib/zirconia/application.rb
Instance Attribute Summary collapse
-
#dir ⇒ Object
readonly
Returns the value of attribute dir.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #create! ⇒ Object
- #created? ⇒ Boolean
- #exec(command) ⇒ Object
- #gem_path(*fragments, ext: nil) ⇒ Object
-
#initialize(dir:, name:) ⇒ Application
constructor
A new instance of Application.
- #lib_path(*fragments, ext: :rb) ⇒ Object
- #load! ⇒ Object
- #main_file ⇒ Object
- #path(*fragments, ext: :rb) ⇒ Object
- #spec_path(*fragments, ext: :rb) ⇒ Object
- #to_sym ⇒ Object
Constructor Details
#initialize(dir:, name:) ⇒ Application
Returns a new instance of Application.
5 6 7 8 |
# File 'lib/zirconia/application.rb', line 5 def initialize(dir:, name:) @dir = Pathname.new(dir).join(name) @name = name end |
Instance Attribute Details
#dir ⇒ Object (readonly)
Returns the value of attribute dir.
3 4 5 |
# File 'lib/zirconia/application.rb', line 3 def dir @dir end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/zirconia/application.rb', line 3 def name @name end |
Instance Method Details
#create! ⇒ Object
14 15 16 17 18 |
# File 'lib/zirconia/application.rb', line 14 def create! `bundle gem #{dir}` @created = true end |
#created? ⇒ Boolean
10 11 12 |
# File 'lib/zirconia/application.rb', line 10 def created? @created == true end |
#exec(command) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/zirconia/application.rb', line 24 def exec(command) validate_gem_exists! Dir.chdir(dir.to_s) do `bundle exec #{command}` end end |
#gem_path(*fragments, ext: nil) ⇒ Object
32 33 34 |
# File 'lib/zirconia/application.rb', line 32 def gem_path(*fragments, ext: nil) build_path(*fragments, dir:, ext:) end |
#lib_path(*fragments, ext: :rb) ⇒ Object
36 37 38 |
# File 'lib/zirconia/application.rb', line 36 def lib_path(*fragments, ext: :rb) build_path(*fragments, dir: lib_dir, ext:) end |
#load! ⇒ Object
20 21 22 |
# File 'lib/zirconia/application.rb', line 20 def load! require main_file.to_s end |
#main_file ⇒ Object
48 49 50 |
# File 'lib/zirconia/application.rb', line 48 def main_file @main_file ||= lib_path(name, ext: :rb) end |
#path(*fragments, ext: :rb) ⇒ Object
40 41 42 |
# File 'lib/zirconia/application.rb', line 40 def path(*fragments, ext: :rb) build_path(*fragments, dir: gem_dir, ext:) end |
#spec_path(*fragments, ext: :rb) ⇒ Object
44 45 46 |
# File 'lib/zirconia/application.rb', line 44 def spec_path(*fragments, ext: :rb) build_path(*fragments, dir: spec_dir, ext:) end |
#to_sym ⇒ Object
52 53 54 |
# File 'lib/zirconia/application.rb', line 52 def to_sym name.split("_").map(&:capitalize).join.to_sym end |