Class: StormForge::Dsl::TestCase::DataSource::FileFixture
- Inherits:
-
Object
- Object
- StormForge::Dsl::TestCase::DataSource::FileFixture
- Includes:
- ActiveModel::Serializers::JSON, ActiveModel::Validations, AttributeAccess
- Defined in:
- lib/stormforge/dsl/test_case/data_source/file_fixture.rb
Defined Under Namespace
Classes: FixtureSourceValidator, ItemProxy
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
Instance Method Summary collapse
- #as_json(*args) ⇒ Object
- #available_attributes ⇒ Object
- #count ⇒ Object
-
#initialize(name, options) ⇒ FileFixture
constructor
A new instance of FileFixture.
- #md5_hash ⇒ Object
- #next ⇒ Object
Methods included from AttributeAccess
#method_missing, #respond_to_missing?
Constructor Details
#initialize(name, options) ⇒ FileFixture
Returns a new instance of FileFixture.
51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/stormforge/dsl/test_case/data_source/file_fixture.rb', line 51 def initialize(name, ) @attributes = { name: name }.merge() unless @attributes[:simple_file] @attributes[:order] = :sequentially unless @attributes[:order] @attributes[:delimiter] = ";" unless @attributes[:delimiter] end @sequence = 0 end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class StormForge::Dsl::TestCase::AttributeAccess
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
33 34 35 |
# File 'lib/stormforge/dsl/test_case/data_source/file_fixture.rb', line 33 def attributes @attributes end |
Instance Method Details
#as_json(*args) ⇒ Object
79 80 81 82 83 84 85 |
# File 'lib/stormforge/dsl/test_case/data_source/file_fixture.rb', line 79 def as_json(*args) hash = super hash[:type] = "file_fixture" hash[:md5_hash] = self.md5_hash hash[:source] = File.basename(self.source) hash end |
#available_attributes ⇒ Object
64 65 66 67 68 69 70 71 72 73 |
# File 'lib/stormforge/dsl/test_case/data_source/file_fixture.rb', line 64 def available_attributes [ :name, :source, :fields, :delimiter, :order, :simple_file ] end |
#count ⇒ Object
100 101 102 |
# File 'lib/stormforge/dsl/test_case/data_source/file_fixture.rb', line 100 def count @sequence end |
#md5_hash ⇒ Object
75 76 77 |
# File 'lib/stormforge/dsl/test_case/data_source/file_fixture.rb', line 75 def md5_hash ::Digest::MD5.file(self.source).hexdigest if File.exist? self.source end |
#next ⇒ Object
87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/stormforge/dsl/test_case/data_source/file_fixture.rb', line 87 def next args = { n: name, seq: (@sequence += 1) } if fields.present? ItemProxy.new(args, fields) else StormForge::Dsl::TestCase::DataSource.build_marker("FILEFIXTURE", args) end end |