Class: Genio::Parser::Format::Base
- Inherits:
-
Object
- Object
- Genio::Parser::Format::Base
- Includes:
- Logging
- Defined in:
- lib/genio/parser/format/base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#data_types ⇒ Object
Returns the value of attribute data_types.
-
#endpoint ⇒ Object
Returns the value of attribute endpoint.
-
#enum_types ⇒ Object
Returns the value of attribute enum_types.
-
#files ⇒ Object
Returns the value of attribute files.
-
#options ⇒ Object
Returns the value of attribute options.
-
#services ⇒ Object
Returns the value of attribute services.
Instance Method Summary collapse
- #expand_path(file) ⇒ Object
-
#initialize(options = {}) ⇒ Base
constructor
A new instance of Base.
- #load_files ⇒ Object
- #open(file, options = {}) ⇒ Object
- #read_file(file, &block) ⇒ Object
- #to_iodocs ⇒ Object
Methods included from Logging
Constructor Details
#initialize(options = {}) ⇒ Base
Returns a new instance of Base.
29 30 31 32 33 34 35 36 |
# File 'lib/genio/parser/format/base.rb', line 29 def initialize( = {}) @options = @files = Types::Base.new( "#" => "self" ) @services = Types::Base.new @data_types = Types::Base.new @enum_types = Types::Base.new end |
Instance Attribute Details
#data_types ⇒ Object
Returns the value of attribute data_types.
27 28 29 |
# File 'lib/genio/parser/format/base.rb', line 27 def data_types @data_types end |
#endpoint ⇒ Object
Returns the value of attribute endpoint.
27 28 29 |
# File 'lib/genio/parser/format/base.rb', line 27 def endpoint @endpoint end |
#enum_types ⇒ Object
Returns the value of attribute enum_types.
27 28 29 |
# File 'lib/genio/parser/format/base.rb', line 27 def enum_types @enum_types end |
#files ⇒ Object
Returns the value of attribute files.
27 28 29 |
# File 'lib/genio/parser/format/base.rb', line 27 def files @files end |
#options ⇒ Object
Returns the value of attribute options.
27 28 29 |
# File 'lib/genio/parser/format/base.rb', line 27 def @options end |
#services ⇒ Object
Returns the value of attribute services.
27 28 29 |
# File 'lib/genio/parser/format/base.rb', line 27 def services @services end |
Instance Method Details
#expand_path(file) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/genio/parser/format/base.rb', line 51 def (file) if load_files.any? and file !~ /^(\/|https?:\/\/)/ parent_file = load_files.last if parent_file =~ /^https?:/ file = URI.join(parent_file, file).to_s else file = File.(file, File.dirname(parent_file)) end end file end |
#load_files ⇒ Object
47 48 49 |
# File 'lib/genio/parser/format/base.rb', line 47 def load_files @load_files ||= [] end |
#open(file, options = {}) ⇒ Object
42 43 44 45 |
# File 'lib/genio/parser/format/base.rb', line 42 def open(file, = {}) [:ssl_verify_mode] ||= 0 super(file, ) end |
#read_file(file, &block) ⇒ Object
63 64 65 66 67 68 69 70 |
# File 'lib/genio/parser/format/base.rb', line 63 def read_file(file, &block) file = (file) load_files.push(file) logger.info("GET #{file}") block.call(open(file).read) ensure load_files.pop end |