Class: Snowly::ProtocolSchemaFinder
- Inherits:
-
Object
- Object
- Snowly::ProtocolSchemaFinder
- Defined in:
- lib/snowly/protocol_schema_finder.rb
Constant Summary collapse
- PROTOCOL_FILE_NAME =
'snowplow_protocol.json'
Instance Attribute Summary collapse
-
#schema ⇒ Object
readonly
Returns the value of attribute schema.
Instance Method Summary collapse
- #alternative_protocol_schema ⇒ Object
- #find_protocol_schema ⇒ Object
-
#initialize(custom_schema = nil) ⇒ ProtocolSchemaFinder
constructor
A new instance of ProtocolSchemaFinder.
-
#load_protocol_schema ⇒ Hash
Loads the protocol schema created to describe snowplow events table attributes.
- #resolver ⇒ Object
Constructor Details
#initialize(custom_schema = nil) ⇒ ProtocolSchemaFinder
Returns a new instance of ProtocolSchemaFinder.
6 7 8 9 |
# File 'lib/snowly/protocol_schema_finder.rb', line 6 def initialize(custom_schema = nil) @custom_schema = custom_schema @schema = load_protocol_schema end |
Instance Attribute Details
#schema ⇒ Object (readonly)
Returns the value of attribute schema.
4 5 6 |
# File 'lib/snowly/protocol_schema_finder.rb', line 4 def schema @schema end |
Instance Method Details
#alternative_protocol_schema ⇒ Object
24 25 26 |
# File 'lib/snowly/protocol_schema_finder.rb', line 24 def alternative_protocol_schema Dir[File.join(resolver,"/**/*")].select{ |f| File.basename(f) == PROTOCOL_FILE_NAME }[0] end |
#find_protocol_schema ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/snowly/protocol_schema_finder.rb', line 11 def find_protocol_schema return @custom_schema if @custom_schema if resolver && alternative_protocol_schema alternative_protocol_schema else File.("../../schemas/#{PROTOCOL_FILE_NAME}", __FILE__) end end |
#load_protocol_schema ⇒ Hash
Loads the protocol schema created to describe snowplow events table attributes
30 31 32 |
# File 'lib/snowly/protocol_schema_finder.rb', line 30 def load_protocol_schema JSON.parse File.read(find_protocol_schema) end |
#resolver ⇒ Object
20 21 22 |
# File 'lib/snowly/protocol_schema_finder.rb', line 20 def resolver Snowly.development_iglu_resolver_path end |