odata 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +51 -0
- data/README.md +4 -0
- data/lib/odata.rb +1 -0
- data/lib/odata/service.rb +5 -0
- data/lib/odata/service_registry.rb +42 -0
- data/lib/odata/version.rb +1 -1
- data/odata.gemspec +1 -0
- data/spec/odata/service_registry_spec.rb +24 -0
- data/spec/odata/service_spec.rb +16 -0
- data/spec/spec_helper.rb +9 -4
- metadata +19 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d911a37f1ddabb81a5436e902be0eb9d9d04e1e8
|
4
|
+
data.tar.gz: 5d824862ef9be51ebf937d6504e08d6a778581a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 86c8c16380794a64e35e0395b306c5d07d1debe05e4f5c227d934aa62720f8945f04f0282e4d0c40ef0b69c3279850336ede3967d9d3d9aafd8fd118da795026
|
7
|
+
data.tar.gz: b72b3b5176ddbc539477a549d185a63a44aa872beb8ede934b3c3f8dc174560b6c2b856cb0d7d0d090f152ab6a47a6661a638acc2704b5538010c37b31e5cb9d
|
data/.travis.yml
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
language: ruby
|
2
|
+
rvm:
|
3
|
+
- 1.9.3
|
4
|
+
- 2.0.0
|
5
|
+
- 2.1.0
|
6
|
+
- 2.1.1
|
7
|
+
- 2.1.2
|
8
|
+
- jruby
|
9
|
+
jdk:
|
10
|
+
- openjdk6
|
11
|
+
- openjdk7
|
12
|
+
- oraclejdk7
|
13
|
+
- oraclejdk8
|
14
|
+
branches:
|
15
|
+
only:
|
16
|
+
- master
|
17
|
+
matrix:
|
18
|
+
exclude:
|
19
|
+
- rvm: 1.9.3
|
20
|
+
jdk: openjdk6
|
21
|
+
- rvm: 1.9.3
|
22
|
+
jdk: oraclejdk7
|
23
|
+
- rvm: 1.9.3
|
24
|
+
jdk: oraclejdk8
|
25
|
+
- rvm: 2.0.0
|
26
|
+
jdk: openjdk6
|
27
|
+
- rvm: 2.0.0
|
28
|
+
jdk: oraclejdk7
|
29
|
+
- rvm: 2.0.0
|
30
|
+
jdk: oraclejdk8
|
31
|
+
- rvm: 2.1.0
|
32
|
+
jdk: openjdk6
|
33
|
+
- rvm: 2.1.0
|
34
|
+
jdk: oraclejdk7
|
35
|
+
- rvm: 2.1.0
|
36
|
+
jdk: oraclejdk8
|
37
|
+
- rvm: 2.1.1
|
38
|
+
jdk: openjdk6
|
39
|
+
- rvm: 2.1.1
|
40
|
+
jdk: oraclejdk7
|
41
|
+
- rvm: 2.1.1
|
42
|
+
jdk: oraclejdk8
|
43
|
+
- rvm: 2.1.2
|
44
|
+
jdk: openjdk6
|
45
|
+
- rvm: 2.1.2
|
46
|
+
jdk: oraclejdk7
|
47
|
+
- rvm: 2.1.2
|
48
|
+
jdk: oraclejdk8
|
49
|
+
addons:
|
50
|
+
code_climate:
|
51
|
+
repo_token: 323644d852f6ba54213f25446d6f4276dbec0adb74fefce770b083cd3e83ea1e
|
data/README.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# OData
|
2
2
|
|
3
|
+
[![Build Status](https://travis-ci.org/plainprogrammer/odata.svg?branch=master)](https://travis-ci.org/plainprogrammer/odata)
|
4
|
+
[![Code Climate](https://codeclimate.com/github/plainprogrammer/odata.png)](https://codeclimate.com/github/plainprogrammer/odata)
|
5
|
+
[![Coverage](https://codeclimate.com/github/plainprogrammer/odata/coverage.png)](https://codeclimate.com/github/plainprogrammer/odata)
|
6
|
+
|
3
7
|
The OData gem provides a simple wrapper around the OData API protocol. It has
|
4
8
|
the ability to automatically inspect compliant APIs and expose the relevant
|
5
9
|
Ruby objects dynamically. It also provides a set of code generation tools for
|
data/lib/odata.rb
CHANGED
data/lib/odata/service.rb
CHANGED
@@ -4,6 +4,7 @@ module OData
|
|
4
4
|
|
5
5
|
def initialize(service_url)
|
6
6
|
@service_url = service_url
|
7
|
+
OData::ServiceRegistry.add(self)
|
7
8
|
self
|
8
9
|
end
|
9
10
|
|
@@ -23,6 +24,10 @@ module OData
|
|
23
24
|
@namespace ||= metadata.xpath('//Schema').first.attributes['Namespace'].value
|
24
25
|
end
|
25
26
|
|
27
|
+
def inspect
|
28
|
+
"#<#{self.class.name}:#{self.object_id} namespace='#{self.namespace}' service_url='#{self.service_url}'>"
|
29
|
+
end
|
30
|
+
|
26
31
|
private
|
27
32
|
|
28
33
|
def metadata
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'singleton'
|
2
|
+
|
3
|
+
module OData
|
4
|
+
class ServiceRegistry
|
5
|
+
include Singleton
|
6
|
+
|
7
|
+
def add(service)
|
8
|
+
initialize_instance_variables
|
9
|
+
@services << service if service.is_a?(OData::Service) && !@services.include?(service)
|
10
|
+
@services_by_namespace[service.namespace] = @services.find_index(service)
|
11
|
+
@services_by_url[service.service_url] = @services.find_index(service)
|
12
|
+
end
|
13
|
+
|
14
|
+
def [](lookup_key)
|
15
|
+
initialize_instance_variables
|
16
|
+
index = @services_by_namespace[lookup_key] || @services_by_url[lookup_key]
|
17
|
+
index.nil? ? nil : @services[index]
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.add(service)
|
21
|
+
OData::ServiceRegistry.instance.add(service)
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.[](lookup_key)
|
25
|
+
OData::ServiceRegistry.instance[lookup_key]
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def initialize_instance_variables
|
31
|
+
@services ||= []
|
32
|
+
@services_by_namespace ||= {}
|
33
|
+
@services_by_url ||= {}
|
34
|
+
end
|
35
|
+
|
36
|
+
def flush
|
37
|
+
@services = []
|
38
|
+
@services_by_namespace = {}
|
39
|
+
@services_by_url = {}
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
data/lib/odata/version.rb
CHANGED
data/odata.gemspec
CHANGED
@@ -21,6 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.add_development_dependency 'bundler', '~> 1.6'
|
22
22
|
spec.add_development_dependency 'rake'
|
23
23
|
spec.add_development_dependency 'simplecov', '~> 0.8.2'
|
24
|
+
spec.add_development_dependency 'codeclimate-test-reporter'
|
24
25
|
spec.add_development_dependency 'rspec', '~> 3.0.0'
|
25
26
|
spec.add_development_dependency 'webmock', '~> 1.18.0'
|
26
27
|
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe OData::ServiceRegistry do
|
4
|
+
let(:subject) { OData::ServiceRegistry }
|
5
|
+
let(:sample_service) { OData::Service.open('http://services.odata.org/OData/OData.svc') }
|
6
|
+
|
7
|
+
# We're calling this as a private method because there should not be any
|
8
|
+
# reasons to have to flush the service registry except in testing.
|
9
|
+
after :each do
|
10
|
+
OData::ServiceRegistry.instance.send(:flush)
|
11
|
+
end
|
12
|
+
|
13
|
+
it { expect(subject).to respond_to(:add) }
|
14
|
+
it { expect(subject).to respond_to(:[]) }
|
15
|
+
|
16
|
+
describe '#add' do
|
17
|
+
before :each do
|
18
|
+
subject.add(sample_service)
|
19
|
+
end
|
20
|
+
|
21
|
+
it { expect(subject[sample_service.namespace]).to eq(sample_service) }
|
22
|
+
it { expect(subject[sample_service.service_url]).to eq(sample_service) }
|
23
|
+
end
|
24
|
+
end
|
data/spec/odata/service_spec.rb
CHANGED
@@ -5,6 +5,12 @@ describe OData::Service do
|
|
5
5
|
let(:entity_types) { %w{Product FeaturedProduct ProductDetail Category Supplier Person Customer Employee PersonDetail Advertisement} }
|
6
6
|
let(:complex_types) { %w{Address} }
|
7
7
|
|
8
|
+
# We're calling this as a private method because there should not be any
|
9
|
+
# reasons to have to flush the service registry except in testing.
|
10
|
+
after :each do
|
11
|
+
OData::ServiceRegistry.instance.send(:flush)
|
12
|
+
end
|
13
|
+
|
8
14
|
describe 'class methods' do
|
9
15
|
it { expect(OData::Service).to respond_to(:open) }
|
10
16
|
end
|
@@ -33,4 +39,14 @@ describe OData::Service do
|
|
33
39
|
describe '#namespace' do
|
34
40
|
it { expect(subject.namespace).to eq('ODataDemo') }
|
35
41
|
end
|
42
|
+
|
43
|
+
it 'adds itself to OData::ServiceRegistry on creation' do
|
44
|
+
expect(OData::ServiceRegistry['ODataDemo']).to be_nil
|
45
|
+
expect(OData::ServiceRegistry['http://services.odata.org/OData/OData.svc']).to be_nil
|
46
|
+
|
47
|
+
service = OData::Service.open('http://services.odata.org/OData/OData.svc')
|
48
|
+
|
49
|
+
expect(OData::ServiceRegistry['ODataDemo']).to eq(service)
|
50
|
+
expect(OData::ServiceRegistry['http://services.odata.org/OData/OData.svc']).to eq(service)
|
51
|
+
end
|
36
52
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,12 +1,17 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
if ENV['CI']
|
2
|
+
require 'codeclimate-test-reporter'
|
3
|
+
CodeClimate::TestReporter.start
|
4
|
+
else
|
5
|
+
require 'simplecov'
|
6
|
+
SimpleCov.start do
|
7
|
+
add_filter '/spec/'
|
8
|
+
end
|
4
9
|
end
|
5
10
|
|
6
11
|
require 'odata'
|
7
12
|
|
8
13
|
require 'webmock/rspec'
|
9
|
-
WebMock.disable_net_connect!(allow_localhost: true)
|
14
|
+
WebMock.disable_net_connect!(allow_localhost: true, allow: 'codeclimate.com')
|
10
15
|
|
11
16
|
RSpec.configure do |config|
|
12
17
|
if config.files_to_run.one?
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: odata
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Thompson
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 0.8.2
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: codeclimate-test-reporter
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: rspec
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -103,6 +117,7 @@ extra_rdoc_files: []
|
|
103
117
|
files:
|
104
118
|
- ".gitignore"
|
105
119
|
- ".rspec"
|
120
|
+
- ".travis.yml"
|
106
121
|
- Gemfile
|
107
122
|
- LICENSE.txt
|
108
123
|
- README.md
|
@@ -110,9 +125,11 @@ files:
|
|
110
125
|
- lib/odata.rb
|
111
126
|
- lib/odata/railtie.rb
|
112
127
|
- lib/odata/service.rb
|
128
|
+
- lib/odata/service_registry.rb
|
113
129
|
- lib/odata/version.rb
|
114
130
|
- odata.gemspec
|
115
131
|
- spec/fixtures/sample_service/metadata.xml
|
132
|
+
- spec/odata/service_registry_spec.rb
|
116
133
|
- spec/odata/service_spec.rb
|
117
134
|
- spec/spec_helper.rb
|
118
135
|
homepage: https://github.com/plainprogrammer/odata
|
@@ -141,5 +158,6 @@ specification_version: 4
|
|
141
158
|
summary: Simple OData library
|
142
159
|
test_files:
|
143
160
|
- spec/fixtures/sample_service/metadata.xml
|
161
|
+
- spec/odata/service_registry_spec.rb
|
144
162
|
- spec/odata/service_spec.rb
|
145
163
|
- spec/spec_helper.rb
|