Module: Ccp::Receivers::SaveFixture
- Included in:
- Base
- Defined in:
- lib/ccp/receivers/save_fixture.rb
Instance Attribute Summary collapse
-
#save_fixture_dir ⇒ Object
Returns the value of attribute save_fixture_dir.
Instance Method Summary collapse
- #execute(cmd) ⇒ Object
- #parse!(options) ⇒ Object
- #save_fixture?(cmd) ⇒ Boolean
- #save_fixture_default_dir ⇒ Object
- #save_fixture_path_for(cmd) ⇒ Object
Instance Attribute Details
#save_fixture_dir ⇒ Object
Returns the value of attribute save_fixture_dir.
4 5 6 |
# File 'lib/ccp/receivers/save_fixture.rb', line 4 def save_fixture_dir @save_fixture_dir end |
Instance Method Details
#execute(cmd) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/ccp/receivers/save_fixture.rb', line 6 def execute(cmd) if save_fixture?(cmd) observer = Ccp::Fixtures::Observer.new(data) observer.start super observer.stop path = save_fixture_path_for(cmd) Ccp::Fixtures::Writers::YamlWriter[path + "in.yaml" ] = observer.read Ccp::Fixtures::Writers::YamlWriter[path + "out.yaml"] = observer.write else super end end |
#parse!(options) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/ccp/receivers/save_fixture.rb', line 20 def parse!() dir = .delete(:save_fixture_dir) @save_fixture_dir = dir if dir super end |
#save_fixture?(cmd) ⇒ Boolean
27 28 29 30 31 32 33 34 |
# File 'lib/ccp/receivers/save_fixture.rb', line 27 def save_fixture?(cmd) if data?(:save_fixture) return true else # indivisual fixture is not supported yet return false end end |
#save_fixture_default_dir ⇒ Object
40 41 42 |
# File 'lib/ccp/receivers/save_fixture.rb', line 40 def save_fixture_default_dir "tmp/fixtures" end |
#save_fixture_path_for(cmd) ⇒ Object
36 37 38 |
# File 'lib/ccp/receivers/save_fixture.rb', line 36 def save_fixture_path_for(cmd) Pathname(save_fixture_dir || save_fixture_default_dir) + cmd.class.name.underscore end |