Class: JSONRB::RakeTask
- Inherits:
-
Object
- Object
- JSONRB::RakeTask
- Defined in:
- lib/jsonrb/rake_task.rb
Constant Summary collapse
- DESCRIPTION =
'Builds JSON template'
Instance Attribute Summary collapse
-
#default_file_ext ⇒ Object
Returns the value of attribute default_file_ext.
-
#description ⇒ Object
Returns the value of attribute description.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#output_file ⇒ Object
Returns the value of attribute output_file.
-
#pretty ⇒ Object
Returns the value of attribute pretty.
-
#template_name ⇒ Object
Returns the value of attribute template_name.
-
#template_path ⇒ Object
Returns the value of attribute template_path.
Instance Method Summary collapse
- #define ⇒ Object
- #execute ⇒ Object
-
#initialize(name, options = {}) {|config| ... } ⇒ RakeTask
constructor
A new instance of RakeTask.
Constructor Details
#initialize(name, options = {}) {|config| ... } ⇒ RakeTask
Returns a new instance of RakeTask.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/jsonrb/rake_task.rb', line 14 def initialize(name, = {}) @name = name @default_file_ext = .fetch(:default_file_ext, '.json.rb') @description = .fetch(:description, DESCRIPTION) @output_file = .fetch(:output_file, nil) @pretty = .fetch(:pretty, false) @template_name = .fetch(:template_name, nil) @template_path = .fetch(:template_path, nil) yield(self) if block_given? raise ArgumentError, "invalid template_path: #{template_path.inspect}" unless File.directory?(template_path) raise ArgumentError, 'template_name cannot be blank' if template_name.nil? || template_name.empty? raise ArgumentError, 'output_file cannot be blank' if output_file.nil? || output_file.empty? define end |
Instance Attribute Details
#default_file_ext ⇒ Object
Returns the value of attribute default_file_ext.
9 10 11 |
# File 'lib/jsonrb/rake_task.rb', line 9 def default_file_ext @default_file_ext end |
#description ⇒ Object
Returns the value of attribute description.
9 10 11 |
# File 'lib/jsonrb/rake_task.rb', line 9 def description @description end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/jsonrb/rake_task.rb', line 8 def name @name end |
#output_file ⇒ Object
Returns the value of attribute output_file.
9 10 11 |
# File 'lib/jsonrb/rake_task.rb', line 9 def output_file @output_file end |
#pretty ⇒ Object
Returns the value of attribute pretty.
9 10 11 |
# File 'lib/jsonrb/rake_task.rb', line 9 def pretty @pretty end |
#template_name ⇒ Object
Returns the value of attribute template_name.
9 10 11 |
# File 'lib/jsonrb/rake_task.rb', line 9 def template_name @template_name end |
#template_path ⇒ Object
Returns the value of attribute template_path.
9 10 11 |
# File 'lib/jsonrb/rake_task.rb', line 9 def template_path @template_path end |
Instance Method Details
#define ⇒ Object
33 34 35 36 |
# File 'lib/jsonrb/rake_task.rb', line 33 def define desc(description) task(name, &method(:execute)) end |