Class: Rdm::Gen::Init
- Inherits:
-
Object
- Object
- Rdm::Gen::Init
- Includes:
- Concerns::TemplateHandling
- Defined in:
- lib/rdm/gen/init.rb
Instance Attribute Summary collapse
-
#console ⇒ Object
Returns the value of attribute console.
-
#current_dir ⇒ Object
Returns the value of attribute current_dir.
-
#test ⇒ Object
Returns the value of attribute test.
Class Method Summary collapse
Instance Method Summary collapse
- #check_preconditions! ⇒ Object
- #generate ⇒ Object
-
#initialize(current_dir:, test:, console:) ⇒ Init
constructor
A new instance of Init.
- #move_templates ⇒ Object
Methods included from Concerns::TemplateHandling
Constructor Details
#initialize(current_dir:, test:, console:) ⇒ Init
Returns a new instance of Init.
17 18 19 20 21 |
# File 'lib/rdm/gen/init.rb', line 17 def initialize(current_dir:, test:, console:) @current_dir = File.(current_dir) @test = test @console = console end |
Instance Attribute Details
#console ⇒ Object
Returns the value of attribute console.
16 17 18 |
# File 'lib/rdm/gen/init.rb', line 16 def console @console end |
#current_dir ⇒ Object
Returns the value of attribute current_dir.
16 17 18 |
# File 'lib/rdm/gen/init.rb', line 16 def current_dir @current_dir end |
#test ⇒ Object
Returns the value of attribute test.
16 17 18 |
# File 'lib/rdm/gen/init.rb', line 16 def test @test end |
Class Method Details
Instance Method Details
#check_preconditions! ⇒ Object
46 47 48 49 50 |
# File 'lib/rdm/gen/init.rb', line 46 def check_preconditions! if File.exist?(File.join(current_dir, Rdm::SOURCE_FILENAME)) raise Rdm::Errors::ProjectAlreadyInitialized, "#{current_dir} has already #{Rdm::SOURCE_FILENAME}" end end |
#generate ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/rdm/gen/init.rb', line 23 def generate check_preconditions! Dir.chdir(current_dir) do ensure_file(['.gitignore']) ensure_file( ['Rdm.packages'], template_content('Rdm.packages.erb') ) ensure_file( ['Gemfile'], template_content('Gemfile.erb') ) ensure_file( ['Readme.md'], template_content('Readme.md.erb') ) move_templates end end |
#move_templates ⇒ Object
52 53 54 55 56 |
# File 'lib/rdm/gen/init.rb', line 52 def move_templates Dir.chdir(templates_path) do copy_template('tests/run') end end |