odata 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +3 -0
- data/LICENSE.txt +1 -1
- data/Rakefile +5 -0
- data/lib/odata.rb +6 -0
- data/lib/odata/railtie.rb +16 -0
- data/lib/odata/service.rb +32 -0
- data/lib/odata/version.rb +1 -1
- data/odata.gemspec +2 -1
- data/spec/fixtures/sample_service/metadata.xml +1 -0
- data/spec/odata/service_spec.rb +36 -0
- data/spec/spec_helper.rb +33 -0
- metadata +29 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5222186af73a13b4382caef7005ce6e559de9ca7
|
4
|
+
data.tar.gz: d64b6b28802f4dce330111603ee2f79690e1c77f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c767f57d37c80d68bd9c61d9186d1e3660cd62e0aeea4325b3c731b43e1d0c223fed8f03365012b3fa567355af8d55ff5ba41ac4fbc60f7d3e3aa47e7d616155
|
7
|
+
data.tar.gz: d868c25cc93edde95dfe2a6989b8c081983ef94f1da33a2bedd07829413d4a99c9a2ffcab3617558e79a879959563e0c3ec93f06744f4da6a76ecb0e18015513
|
data/.rspec
ADDED
data/LICENSE.txt
CHANGED
data/Rakefile
CHANGED
data/lib/odata.rb
CHANGED
@@ -0,0 +1,16 @@
|
|
1
|
+
module OData
|
2
|
+
class Railtie < Rails::Railtie
|
3
|
+
config.before_initialize do
|
4
|
+
::OData::Railtie.load_configuration!
|
5
|
+
::OData::Railtie.setup_service_registry!
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.load_configuration!
|
9
|
+
# load environment config from config/odata.yml
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.setup_service_registry!
|
13
|
+
# use configuration to setup registry of OData::Services
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module OData
|
2
|
+
class Service
|
3
|
+
attr_reader :service_url
|
4
|
+
|
5
|
+
def initialize(service_url)
|
6
|
+
@service_url = service_url
|
7
|
+
self
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.open(service_url)
|
11
|
+
Service.new(service_url)
|
12
|
+
end
|
13
|
+
|
14
|
+
def entities
|
15
|
+
@entities ||= metadata.xpath('//EntityType').collect {|entity| entity.attributes['Name'].value}
|
16
|
+
end
|
17
|
+
|
18
|
+
def complex_types
|
19
|
+
@complex_types ||= metadata.xpath('//ComplexType').collect {|entity| entity.attributes['Name'].value}
|
20
|
+
end
|
21
|
+
|
22
|
+
def namespace
|
23
|
+
@namespace ||= metadata.xpath('//Schema').first.attributes['Namespace'].value
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def metadata
|
29
|
+
@metadata ||= ::Nokogiri::XML(open("#{service_url}/$metadata")).remove_namespaces!
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/odata/version.rb
CHANGED
data/odata.gemspec
CHANGED
@@ -20,8 +20,9 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.add_development_dependency 'bundler', '~> 1.6'
|
22
22
|
spec.add_development_dependency 'rake'
|
23
|
+
spec.add_development_dependency 'simplecov', '~> 0.8.2'
|
23
24
|
spec.add_development_dependency 'rspec', '~> 3.0.0'
|
24
|
-
spec.add_development_dependency '
|
25
|
+
spec.add_development_dependency 'webmock', '~> 1.18.0'
|
25
26
|
|
26
27
|
spec.add_dependency 'nokogiri', '~> 1.6.2'
|
27
28
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?><edmx:Edmx Version="1.0" xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx"><edmx:DataServices m:DataServiceVersion="3.0" m:MaxDataServiceVersion="3.0" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"><Schema Namespace="ODataDemo" xmlns="http://schemas.microsoft.com/ado/2009/11/edm"><EntityType Name="Product"><Key><PropertyRef Name="ID" /></Key><Property Name="ID" Type="Edm.Int32" Nullable="false" /><Property Name="Name" Type="Edm.String" m:FC_TargetPath="SyndicationTitle" m:FC_ContentKind="text" m:FC_KeepInContent="false" /><Property Name="Description" Type="Edm.String" m:FC_TargetPath="SyndicationSummary" m:FC_ContentKind="text" m:FC_KeepInContent="false" /><Property Name="ReleaseDate" Type="Edm.DateTime" Nullable="false" /><Property Name="DiscontinuedDate" Type="Edm.DateTime" /><Property Name="Rating" Type="Edm.Int16" Nullable="false" /><Property Name="Price" Type="Edm.Double" Nullable="false" /><NavigationProperty Name="Categories" Relationship="ODataDemo.Product_Categories_Category_Products" ToRole="Category_Products" FromRole="Product_Categories" /><NavigationProperty Name="Supplier" Relationship="ODataDemo.Product_Supplier_Supplier_Products" ToRole="Supplier_Products" FromRole="Product_Supplier" /><NavigationProperty Name="ProductDetail" Relationship="ODataDemo.Product_ProductDetail_ProductDetail_Product" ToRole="ProductDetail_Product" FromRole="Product_ProductDetail" /></EntityType><EntityType Name="FeaturedProduct" BaseType="ODataDemo.Product"><NavigationProperty Name="Advertisement" Relationship="ODataDemo.FeaturedProduct_Advertisement_Advertisement_FeaturedProduct" ToRole="Advertisement_FeaturedProduct" FromRole="FeaturedProduct_Advertisement" /></EntityType><EntityType Name="ProductDetail"><Key><PropertyRef Name="ProductID" /></Key><Property Name="ProductID" Type="Edm.Int32" Nullable="false" /><Property Name="Details" Type="Edm.String" /><NavigationProperty Name="Product" Relationship="ODataDemo.Product_ProductDetail_ProductDetail_Product" ToRole="Product_ProductDetail" FromRole="ProductDetail_Product" /></EntityType><EntityType Name="Category" OpenType="true"><Key><PropertyRef Name="ID" /></Key><Property Name="ID" Type="Edm.Int32" Nullable="false" /><Property Name="Name" Type="Edm.String" m:FC_TargetPath="SyndicationTitle" m:FC_ContentKind="text" m:FC_KeepInContent="true" /><NavigationProperty Name="Products" Relationship="ODataDemo.Product_Categories_Category_Products" ToRole="Product_Categories" FromRole="Category_Products" /></EntityType><EntityType Name="Supplier"><Key><PropertyRef Name="ID" /></Key><Property Name="ID" Type="Edm.Int32" Nullable="false" /><Property Name="Name" Type="Edm.String" m:FC_TargetPath="SyndicationTitle" m:FC_ContentKind="text" m:FC_KeepInContent="true" /><Property Name="Address" Type="ODataDemo.Address" /><Property Name="Location" Type="Edm.GeographyPoint" SRID="Variable" /><Property Name="Concurrency" Type="Edm.Int32" ConcurrencyMode="Fixed" Nullable="false" /><NavigationProperty Name="Products" Relationship="ODataDemo.Product_Supplier_Supplier_Products" ToRole="Product_Supplier" FromRole="Supplier_Products" /></EntityType><ComplexType Name="Address"><Property Name="Street" Type="Edm.String" /><Property Name="City" Type="Edm.String" /><Property Name="State" Type="Edm.String" /><Property Name="ZipCode" Type="Edm.String" /><Property Name="Country" Type="Edm.String" /></ComplexType><EntityType Name="Person"><Key><PropertyRef Name="ID" /></Key><Property Name="ID" Type="Edm.Int32" Nullable="false" /><Property Name="Name" Type="Edm.String" /><NavigationProperty Name="PersonDetail" Relationship="ODataDemo.Person_PersonDetail_PersonDetail_Person" ToRole="PersonDetail_Person" FromRole="Person_PersonDetail" /></EntityType><EntityType Name="Customer" BaseType="ODataDemo.Person"><Property Name="TotalExpense" Type="Edm.Decimal" Nullable="false" /></EntityType><EntityType Name="Employee" BaseType="ODataDemo.Person"><Property Name="EmployeeID" Type="Edm.Int64" Nullable="false" /><Property Name="HireDate" Type="Edm.DateTime" Nullable="false" /><Property Name="Salary" Type="Edm.Single" Nullable="false" /></EntityType><EntityType Name="PersonDetail"><Key><PropertyRef Name="PersonID" /></Key><Property Name="PersonID" Type="Edm.Int32" Nullable="false" /><Property Name="Age" Type="Edm.Byte" Nullable="false" /><Property Name="Gender" Type="Edm.Boolean" Nullable="false" /><Property Name="Phone" Type="Edm.String" /><Property Name="Address" Type="ODataDemo.Address" /><Property Name="Photo" Type="Edm.Stream" Nullable="false" /><NavigationProperty Name="Person" Relationship="ODataDemo.Person_PersonDetail_PersonDetail_Person" ToRole="Person_PersonDetail" FromRole="PersonDetail_Person" /></EntityType><EntityType Name="Advertisement" m:HasStream="true"><Key><PropertyRef Name="ID" /></Key><Property Name="ID" Type="Edm.Guid" Nullable="false" /><Property Name="Name" Type="Edm.String" /><Property Name="AirDate" Type="Edm.DateTime" Nullable="false" /><NavigationProperty Name="FeaturedProduct" Relationship="ODataDemo.FeaturedProduct_Advertisement_Advertisement_FeaturedProduct" ToRole="FeaturedProduct_Advertisement" FromRole="Advertisement_FeaturedProduct" /></EntityType><Association Name="Product_Categories_Category_Products"><End Type="ODataDemo.Category" Role="Category_Products" Multiplicity="*" /><End Type="ODataDemo.Product" Role="Product_Categories" Multiplicity="*" /></Association><Association Name="Product_Supplier_Supplier_Products"><End Type="ODataDemo.Supplier" Role="Supplier_Products" Multiplicity="0..1" /><End Type="ODataDemo.Product" Role="Product_Supplier" Multiplicity="*" /></Association><Association Name="Product_ProductDetail_ProductDetail_Product"><End Type="ODataDemo.ProductDetail" Role="ProductDetail_Product" Multiplicity="0..1" /><End Type="ODataDemo.Product" Role="Product_ProductDetail" Multiplicity="0..1" /></Association><Association Name="FeaturedProduct_Advertisement_Advertisement_FeaturedProduct"><End Type="ODataDemo.Advertisement" Role="Advertisement_FeaturedProduct" Multiplicity="0..1" /><End Type="ODataDemo.FeaturedProduct" Role="FeaturedProduct_Advertisement" Multiplicity="0..1" /></Association><Association Name="Person_PersonDetail_PersonDetail_Person"><End Type="ODataDemo.PersonDetail" Role="PersonDetail_Person" Multiplicity="0..1" /><End Type="ODataDemo.Person" Role="Person_PersonDetail" Multiplicity="0..1" /></Association><EntityContainer Name="DemoService" m:IsDefaultEntityContainer="true"><EntitySet Name="Products" EntityType="ODataDemo.Product" /><EntitySet Name="ProductDetails" EntityType="ODataDemo.ProductDetail" /><EntitySet Name="Categories" EntityType="ODataDemo.Category" /><EntitySet Name="Suppliers" EntityType="ODataDemo.Supplier" /><EntitySet Name="Persons" EntityType="ODataDemo.Person" /><EntitySet Name="PersonDetails" EntityType="ODataDemo.PersonDetail" /><EntitySet Name="Advertisements" EntityType="ODataDemo.Advertisement" /><FunctionImport Name="GetProductsByRating" ReturnType="Collection(ODataDemo.Product)" EntitySet="Products" m:HttpMethod="GET"><Parameter Name="rating" Type="Edm.Int16" Nullable="false" /></FunctionImport><AssociationSet Name="Products_Advertisement_Advertisements" Association="ODataDemo.FeaturedProduct_Advertisement_Advertisement_FeaturedProduct"><End Role="FeaturedProduct_Advertisement" EntitySet="Products" /><End Role="Advertisement_FeaturedProduct" EntitySet="Advertisements" /></AssociationSet><AssociationSet Name="Products_Categories_Categories" Association="ODataDemo.Product_Categories_Category_Products"><End Role="Product_Categories" EntitySet="Products" /><End Role="Category_Products" EntitySet="Categories" /></AssociationSet><AssociationSet Name="Products_Supplier_Suppliers" Association="ODataDemo.Product_Supplier_Supplier_Products"><End Role="Product_Supplier" EntitySet="Products" /><End Role="Supplier_Products" EntitySet="Suppliers" /></AssociationSet><AssociationSet Name="Products_ProductDetail_ProductDetails" Association="ODataDemo.Product_ProductDetail_ProductDetail_Product"><End Role="Product_ProductDetail" EntitySet="Products" /><End Role="ProductDetail_Product" EntitySet="ProductDetails" /></AssociationSet><AssociationSet Name="Persons_PersonDetail_PersonDetails" Association="ODataDemo.Person_PersonDetail_PersonDetail_Person"><End Role="Person_PersonDetail" EntitySet="Persons" /><End Role="PersonDetail_Person" EntitySet="PersonDetails" /></AssociationSet></EntityContainer><Annotations Target="ODataDemo.DemoService"><ValueAnnotation Term="Org.OData.Display.V1.Description" String="This is a sample OData service with vocabularies" /></Annotations><Annotations Target="ODataDemo.Product"><ValueAnnotation Term="Org.OData.Display.V1.Description" String="All Products available in the online store" /></Annotations><Annotations Target="ODataDemo.Product/Name"><ValueAnnotation Term="Org.OData.Display.V1.DisplayName" String="Product Name" /></Annotations><Annotations Target="ODataDemo.DemoService/Suppliers"><ValueAnnotation Term="Org.OData.Publication.V1.PublisherName" String="Microsoft Corp." /><ValueAnnotation Term="Org.OData.Publication.V1.PublisherId" String="MSFT" /><ValueAnnotation Term="Org.OData.Publication.V1.Keywords" String="Inventory, Supplier, Advertisers, Sales, Finance" /><ValueAnnotation Term="Org.OData.Publication.V1.AttributionUrl" String="http://www.odata.org/" /><ValueAnnotation Term="Org.OData.Publication.V1.AttributionDescription" String="All rights reserved" /><ValueAnnotation Term="Org.OData.Publication.V1.DocumentationUrl " String="http://www.odata.org/" /><ValueAnnotation Term="Org.OData.Publication.V1.TermsOfUseUrl" String="All rights reserved" /><ValueAnnotation Term="Org.OData.Publication.V1.PrivacyPolicyUrl" String="http://www.odata.org/" /><ValueAnnotation Term="Org.OData.Publication.V1.LastModified" String="4/2/2013" /><ValueAnnotation Term="Org.OData.Publication.V1.ImageUrl " String="http://www.odata.org/" /></Annotations></Schema></edmx:DataServices></edmx:Edmx>
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe OData::Service do
|
4
|
+
let(:subject) { OData::Service.open('http://services.odata.org/OData/OData.svc') }
|
5
|
+
let(:entity_types) { %w{Product FeaturedProduct ProductDetail Category Supplier Person Customer Employee PersonDetail Advertisement} }
|
6
|
+
let(:complex_types) { %w{Address} }
|
7
|
+
|
8
|
+
describe 'class methods' do
|
9
|
+
it { expect(OData::Service).to respond_to(:open) }
|
10
|
+
end
|
11
|
+
|
12
|
+
describe 'instance methods' do
|
13
|
+
it { expect(subject).to respond_to(:service_url) }
|
14
|
+
it { expect(subject).to respond_to(:entities) }
|
15
|
+
it { expect(subject).to respond_to(:complex_types) }
|
16
|
+
it { expect(subject).to respond_to(:namespace) }
|
17
|
+
end
|
18
|
+
|
19
|
+
describe '#service_url' do
|
20
|
+
it { expect(subject.service_url).to eq('http://services.odata.org/OData/OData.svc') }
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '#entities' do
|
24
|
+
it { expect(subject.entities.size).to eq(10) }
|
25
|
+
it { expect(subject.entities).to eq(entity_types) }
|
26
|
+
end
|
27
|
+
|
28
|
+
describe '#complex_types' do
|
29
|
+
it { expect(subject.complex_types.size).to eq(1) }
|
30
|
+
it { expect(subject.complex_types).to eq(complex_types) }
|
31
|
+
end
|
32
|
+
|
33
|
+
describe '#namespace' do
|
34
|
+
it { expect(subject.namespace).to eq('ODataDemo') }
|
35
|
+
end
|
36
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'simplecov'
|
2
|
+
SimpleCov.start do
|
3
|
+
add_filter '/spec/'
|
4
|
+
end
|
5
|
+
|
6
|
+
require 'odata'
|
7
|
+
|
8
|
+
require 'webmock/rspec'
|
9
|
+
WebMock.disable_net_connect!(allow_localhost: true)
|
10
|
+
|
11
|
+
RSpec.configure do |config|
|
12
|
+
if config.files_to_run.one?
|
13
|
+
config.default_formatter = 'doc'
|
14
|
+
end
|
15
|
+
|
16
|
+
config.profile_examples = 3
|
17
|
+
config.order = :random
|
18
|
+
Kernel.srand config.seed
|
19
|
+
|
20
|
+
config.expect_with :rspec do |expectations|
|
21
|
+
expectations.syntax = :expect
|
22
|
+
end
|
23
|
+
|
24
|
+
config.mock_with :rspec do |mocks|
|
25
|
+
mocks.syntax = :expect
|
26
|
+
mocks.verify_partial_doubles = true
|
27
|
+
end
|
28
|
+
|
29
|
+
config.before(:example) do
|
30
|
+
WebMock.stub_request(:get, 'http://services.odata.org/OData/OData.svc/$metadata').
|
31
|
+
to_return(status: 200, body: File.open('spec/fixtures/sample_service/metadata.xml'))
|
32
|
+
end
|
33
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Thompson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-06-
|
11
|
+
date: 2014-06-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: simplecov
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.8.2
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.8.2
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: rspec
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -53,19 +67,19 @@ dependencies:
|
|
53
67
|
- !ruby/object:Gem::Version
|
54
68
|
version: 3.0.0
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
70
|
+
name: webmock
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
58
72
|
requirements:
|
59
73
|
- - "~>"
|
60
74
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
75
|
+
version: 1.18.0
|
62
76
|
type: :development
|
63
77
|
prerelease: false
|
64
78
|
version_requirements: !ruby/object:Gem::Requirement
|
65
79
|
requirements:
|
66
80
|
- - "~>"
|
67
81
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
82
|
+
version: 1.18.0
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: nokogiri
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -88,13 +102,19 @@ extensions: []
|
|
88
102
|
extra_rdoc_files: []
|
89
103
|
files:
|
90
104
|
- ".gitignore"
|
105
|
+
- ".rspec"
|
91
106
|
- Gemfile
|
92
107
|
- LICENSE.txt
|
93
108
|
- README.md
|
94
109
|
- Rakefile
|
95
110
|
- lib/odata.rb
|
111
|
+
- lib/odata/railtie.rb
|
112
|
+
- lib/odata/service.rb
|
96
113
|
- lib/odata/version.rb
|
97
114
|
- odata.gemspec
|
115
|
+
- spec/fixtures/sample_service/metadata.xml
|
116
|
+
- spec/odata/service_spec.rb
|
117
|
+
- spec/spec_helper.rb
|
98
118
|
homepage: https://github.com/plainprogrammer/odata
|
99
119
|
licenses:
|
100
120
|
- MIT
|
@@ -119,4 +139,7 @@ rubygems_version: 2.2.2
|
|
119
139
|
signing_key:
|
120
140
|
specification_version: 4
|
121
141
|
summary: Simple OData library
|
122
|
-
test_files:
|
142
|
+
test_files:
|
143
|
+
- spec/fixtures/sample_service/metadata.xml
|
144
|
+
- spec/odata/service_spec.rb
|
145
|
+
- spec/spec_helper.rb
|