odata-model 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/odata/model/railtie.rb +51 -0
- data/lib/odata/model/version.rb +1 -1
- data/lib/odata/model.rb +2 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6d9d0c38d9a9e5b4480cc15ec55c330911e4b79f
|
4
|
+
data.tar.gz: 5090acae175c544469e672293e617cf93ad94f3a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 79d40b08cec2be355243b83c4b0ed47d35515daf9d26f47c9b470c45d29e198789140bb4affff9d1f40c65ca5254c0e3c7c839f8739e81dd295890564503cc35
|
7
|
+
data.tar.gz: c1ff959f5ae6818b7fe1c1aa2e4e291bf6a90d72d155382c56258ec70a582e28c3cc407c80718cb5cd458147f42139ccc7a73bc970d227dc81bbed1e0ef2ff04
|
data/CHANGELOG.md
CHANGED
@@ -0,0 +1,51 @@
|
|
1
|
+
module OData
|
2
|
+
module Model
|
3
|
+
# Defines the necessary hooks to work correctly with Ruby on Rails.
|
4
|
+
# @api private
|
5
|
+
class Railtie < ::Rails::Railtie
|
6
|
+
attr_accessor :configuration
|
7
|
+
|
8
|
+
config.odata = ActiveSupport::OrderedOptions.new
|
9
|
+
|
10
|
+
initializer('odata_configuration') do |app|
|
11
|
+
parse_configuration(app)
|
12
|
+
process_configuration(app)
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def parse_configuration(app)
|
18
|
+
config_file = File.open(File.join(Rails.root, 'config/odata.yml'))
|
19
|
+
configuration = YAML.load(config_file).symbolize_keys[Rails.env]
|
20
|
+
end
|
21
|
+
|
22
|
+
def process_configuration(app)
|
23
|
+
configuration.each do |service_name, service_details|
|
24
|
+
url = service_details[:url]
|
25
|
+
options = generate_options(service_name, service_details)
|
26
|
+
OData::Service.open(url, options)
|
27
|
+
validate_service_setup(service_name)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def generate_options(service_name, service_details)
|
32
|
+
options = { name: service_name }
|
33
|
+
if service_details[:username] && service_details[:password]
|
34
|
+
options[:typohoeus] = {
|
35
|
+
username: service_details[:username],
|
36
|
+
password: service_details[:password]
|
37
|
+
}
|
38
|
+
options[:typhoeus][:auth_type] = service_details[:auth_type]
|
39
|
+
end
|
40
|
+
options
|
41
|
+
end
|
42
|
+
|
43
|
+
def validate_service_setup(service_name)
|
44
|
+
service = OData::ServiceRegistry[service_name]
|
45
|
+
service.namespace
|
46
|
+
rescue StandardError
|
47
|
+
raise RuntimeError, "could not access service at #{service.service_url}"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
data/lib/odata/model/version.rb
CHANGED
data/lib/odata/model.rb
CHANGED
@@ -12,6 +12,8 @@ require 'odata/model/persistence'
|
|
12
12
|
require 'odata/model/query'
|
13
13
|
require 'odata/model/query_proxy'
|
14
14
|
|
15
|
+
require 'odata/model/railtie' if defined?(::Rails)
|
16
|
+
|
15
17
|
# OData is the parent namespace for the OData::Model project.
|
16
18
|
module OData
|
17
19
|
# OData::Model provides a way to map from OData::Entity instances, as
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: odata-model
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Thompson
|
@@ -163,6 +163,7 @@ files:
|
|
163
163
|
- lib/odata/model/persistence.rb
|
164
164
|
- lib/odata/model/query.rb
|
165
165
|
- lib/odata/model/query_proxy.rb
|
166
|
+
- lib/odata/model/railtie.rb
|
166
167
|
- lib/odata/model/version.rb
|
167
168
|
- odata-model.gemspec
|
168
169
|
- spec/example_models/bare_model.rb
|