Class: Ablerc::StubGenerator
- Inherits:
-
Object
- Object
- Ablerc::StubGenerator
- Defined in:
- lib/ablerc/stub_generator.rb
Instance Attribute Summary collapse
-
#footer ⇒ Object
Returns the value of attribute footer.
-
#header ⇒ Object
Returns the value of attribute header.
-
#options ⇒ Object
Returns the value of attribute options.
-
#path ⇒ Object
Returns the value of attribute path.
Instance Method Summary collapse
- #generate(context = nil) ⇒ Object
-
#initialize(options) ⇒ StubGenerator
constructor
A new instance of StubGenerator.
- #write_description(description) ⇒ Object
Constructor Details
#initialize(options) ⇒ StubGenerator
Returns a new instance of StubGenerator.
7 8 9 10 11 |
# File 'lib/ablerc/stub_generator.rb', line 7 def initialize() self.header = .delete :header self. = .delete :footer self. = .delete :options end |
Instance Attribute Details
#footer ⇒ Object
Returns the value of attribute footer.
4 5 6 |
# File 'lib/ablerc/stub_generator.rb', line 4 def @footer end |
#header ⇒ Object
Returns the value of attribute header.
4 5 6 |
# File 'lib/ablerc/stub_generator.rb', line 4 def header @header end |
#options ⇒ Object
Returns the value of attribute options.
4 5 6 |
# File 'lib/ablerc/stub_generator.rb', line 4 def @options end |
#path ⇒ Object
Returns the value of attribute path.
4 5 6 |
# File 'lib/ablerc/stub_generator.rb', line 4 def path @path end |
Instance Method Details
#generate(context = nil) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/ablerc/stub_generator.rb', line 14 def generate(context = nil) begin context ||= Ablerc.contexts.names.last.to_sym path = File.(Ablerc.contexts.send(context.to_sym).path) rescue raise "Context does not exist" end puts "Generating Stub for #{context} in #{path + '/' + Ablerc.rc_file_name}".color :green begin File.open(path + '/' + Ablerc.rc_file_name, 'w') do |rc_file| rc_file << header.to_s unless header.nil? self..each do |option| rc_file << option.to_stub end rc_file << .to_s unless .nil? end rescue e puts "Error".color :red puts e end true end |
#write_description(description) ⇒ Object
40 41 |
# File 'lib/ablerc/stub_generator.rb', line 40 def write_description(description) end |