Class: Shuttle::Generator
- Inherits:
-
Object
- Object
- Shuttle::Generator
- Includes:
- TerminalHelpers
- Defined in:
- lib/shuttle/generator.rb
Constant Summary collapse
- STRATEGIES =
%w(static wordpress rails)
Instance Attribute Summary collapse
-
#git ⇒ Object
readonly
Returns the value of attribute git.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#strategy ⇒ Object
readonly
Returns the value of attribute strategy.
Instance Method Summary collapse
-
#initialize(strategy = 'static') ⇒ Generator
constructor
A new instance of Generator.
- #run ⇒ Object
Constructor Details
#initialize(strategy = 'static') ⇒ Generator
Returns a new instance of Generator.
10 11 12 13 14 15 16 17 |
# File 'lib/shuttle/generator.rb', line 10 def initialize(strategy='static') unless STRATEGIES.include?(strategy) raise ArgumentError, "Invalid strategy: #{strategy}" end @strategy = strategy @path = File.join(Dir.pwd, 'shuttle.yml') end |
Instance Attribute Details
#git ⇒ Object (readonly)
Returns the value of attribute git.
8 9 10 |
# File 'lib/shuttle/generator.rb', line 8 def git @git end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/shuttle/generator.rb', line 8 def name @name end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
8 9 10 |
# File 'lib/shuttle/generator.rb', line 8 def path @path end |
#strategy ⇒ Object (readonly)
Returns the value of attribute strategy.
7 8 9 |
# File 'lib/shuttle/generator.rb', line 7 def strategy @strategy end |
Instance Method Details
#run ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/shuttle/generator.rb', line 19 def run @name = ask('Application name', :required => true) @git = ask('Git repository', :required => true) hash = send("generate_#{strategy}") File.open(path, 'w') do |f| f.write(YAML.dump(hash)) end display "New shuttle config has been generated at ./shuttle.yml" end |