Class: Appifier::Actors::Collector
- Inherits:
-
Object
- Object
- Appifier::Actors::Collector
- Extended by:
- Carioca::Injector
- Defined in:
- lib/appifier/actors/collector.rb
Instance Attribute Summary collapse
-
#dataset ⇒ Object
Returns the value of attribute dataset.
-
#template ⇒ Object
readonly
Returns the value of attribute template.
Instance Method Summary collapse
- #collect ⇒ Object
- #collected? ⇒ Boolean
-
#initialize(template:, dataset: nil, force: false) ⇒ Collector
constructor
A new instance of Collector.
Constructor Details
#initialize(template:, dataset: nil, force: false) ⇒ Collector
Returns a new instance of Collector.
15 16 17 18 19 |
# File 'lib/appifier/actors/collector.rb', line 15 def initialize(template: ,dataset: nil,force: false ) @force = force @template = template get_defined_dataset(dataset) end |
Instance Attribute Details
#dataset ⇒ Object
Returns the value of attribute dataset.
12 13 14 |
# File 'lib/appifier/actors/collector.rb', line 12 def dataset @dataset end |
#template ⇒ Object (readonly)
Returns the value of attribute template.
13 14 15 |
# File 'lib/appifier/actors/collector.rb', line 13 def template @template end |
Instance Method Details
#collect ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/appifier/actors/collector.rb', line 22 def collect begin appifilename = "#{File.(Appifier::DEFAULT_TEMPLATES_PATH)}/#{template}/Appifile" appifile = Appifier::Components::Appifile::new path: appifilename prompt = TTY::Prompt.new @dataset = {} appifile.dataset_rules.each do |name, rule| default = (rule[:default])? rule[:default] : "" @dataset[name] = prompt.ask("Give #{rule[:description]} : ", default: default) do |q| q.required true q.validate Regexp.new(rule[:format]) if rule[:format] end end write_dataset template: @template, data: @dataset @collected = true output.info "Dataset recorded for #{@template}" rescue TTY::Reader::InputInterrupt output.warn "Interactive collect interrupted" finisher.terminate exit_case: :interrupt end end |
#collected? ⇒ Boolean
44 45 46 |
# File 'lib/appifier/actors/collector.rb', line 44 def collected? return @collected end |