frodo 0.10.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.
Files changed (153) hide show
  1. checksums.yaml +7 -0
  2. data/.autotest +2 -0
  3. data/.circleci/config.yml +54 -0
  4. data/.gitignore +24 -0
  5. data/.gitlab-ci.yml +9 -0
  6. data/.rspec +2 -0
  7. data/.ruby-gemset +1 -0
  8. data/.ruby-version +1 -0
  9. data/.travis.yml +75 -0
  10. data/CHANGELOG.md +163 -0
  11. data/Gemfile +4 -0
  12. data/LICENSE.txt +23 -0
  13. data/README.md +479 -0
  14. data/Rakefile +7 -0
  15. data/TODO.md +55 -0
  16. data/frodo.gemspec +39 -0
  17. data/images/frodo.jpg +0 -0
  18. data/lib/frodo/abstract_client.rb +11 -0
  19. data/lib/frodo/client.rb +6 -0
  20. data/lib/frodo/concerns/api.rb +292 -0
  21. data/lib/frodo/concerns/authentication.rb +32 -0
  22. data/lib/frodo/concerns/base.rb +84 -0
  23. data/lib/frodo/concerns/caching.rb +26 -0
  24. data/lib/frodo/concerns/connection.rb +79 -0
  25. data/lib/frodo/concerns/verbs.rb +68 -0
  26. data/lib/frodo/config.rb +143 -0
  27. data/lib/frodo/entity.rb +335 -0
  28. data/lib/frodo/entity_container.rb +75 -0
  29. data/lib/frodo/entity_set.rb +131 -0
  30. data/lib/frodo/errors.rb +70 -0
  31. data/lib/frodo/middleware/authentication/token.rb +13 -0
  32. data/lib/frodo/middleware/authentication.rb +87 -0
  33. data/lib/frodo/middleware/authorization.rb +18 -0
  34. data/lib/frodo/middleware/caching.rb +30 -0
  35. data/lib/frodo/middleware/custom_headers.rb +14 -0
  36. data/lib/frodo/middleware/gzip.rb +33 -0
  37. data/lib/frodo/middleware/instance_url.rb +20 -0
  38. data/lib/frodo/middleware/logger.rb +42 -0
  39. data/lib/frodo/middleware/multipart.rb +64 -0
  40. data/lib/frodo/middleware/odata_headers.rb +13 -0
  41. data/lib/frodo/middleware/raise_error.rb +47 -0
  42. data/lib/frodo/middleware.rb +33 -0
  43. data/lib/frodo/navigation_property/proxy.rb +80 -0
  44. data/lib/frodo/navigation_property.rb +29 -0
  45. data/lib/frodo/properties/binary.rb +50 -0
  46. data/lib/frodo/properties/boolean.rb +37 -0
  47. data/lib/frodo/properties/collection.rb +50 -0
  48. data/lib/frodo/properties/complex.rb +114 -0
  49. data/lib/frodo/properties/date.rb +27 -0
  50. data/lib/frodo/properties/date_time.rb +83 -0
  51. data/lib/frodo/properties/date_time_offset.rb +17 -0
  52. data/lib/frodo/properties/decimal.rb +54 -0
  53. data/lib/frodo/properties/enum.rb +62 -0
  54. data/lib/frodo/properties/float.rb +67 -0
  55. data/lib/frodo/properties/geography/base.rb +162 -0
  56. data/lib/frodo/properties/geography/line_string.rb +33 -0
  57. data/lib/frodo/properties/geography/point.rb +31 -0
  58. data/lib/frodo/properties/geography/polygon.rb +38 -0
  59. data/lib/frodo/properties/geography.rb +13 -0
  60. data/lib/frodo/properties/guid.rb +17 -0
  61. data/lib/frodo/properties/integer.rb +107 -0
  62. data/lib/frodo/properties/number.rb +14 -0
  63. data/lib/frodo/properties/string.rb +72 -0
  64. data/lib/frodo/properties/time.rb +40 -0
  65. data/lib/frodo/properties/time_of_day.rb +27 -0
  66. data/lib/frodo/properties.rb +32 -0
  67. data/lib/frodo/property.rb +139 -0
  68. data/lib/frodo/property_registry.rb +41 -0
  69. data/lib/frodo/query/criteria/comparison_operators.rb +49 -0
  70. data/lib/frodo/query/criteria/date_functions.rb +61 -0
  71. data/lib/frodo/query/criteria/geography_functions.rb +21 -0
  72. data/lib/frodo/query/criteria/lambda_operators.rb +27 -0
  73. data/lib/frodo/query/criteria/string_functions.rb +40 -0
  74. data/lib/frodo/query/criteria.rb +92 -0
  75. data/lib/frodo/query/in_batches.rb +58 -0
  76. data/lib/frodo/query.rb +221 -0
  77. data/lib/frodo/railtie.rb +19 -0
  78. data/lib/frodo/schema/complex_type.rb +79 -0
  79. data/lib/frodo/schema/enum_type.rb +95 -0
  80. data/lib/frodo/schema.rb +164 -0
  81. data/lib/frodo/service.rb +199 -0
  82. data/lib/frodo/service_registry.rb +52 -0
  83. data/lib/frodo/version.rb +3 -0
  84. data/lib/frodo.rb +67 -0
  85. data/spec/fixtures/auth_success_response.json +11 -0
  86. data/spec/fixtures/error.json +11 -0
  87. data/spec/fixtures/files/entity_to_xml.xml +18 -0
  88. data/spec/fixtures/files/error.xml +5 -0
  89. data/spec/fixtures/files/metadata.xml +150 -0
  90. data/spec/fixtures/files/metadata_with_error.xml +157 -0
  91. data/spec/fixtures/files/product_0.json +10 -0
  92. data/spec/fixtures/files/product_0.xml +28 -0
  93. data/spec/fixtures/files/products.json +106 -0
  94. data/spec/fixtures/files/products.xml +308 -0
  95. data/spec/fixtures/files/supplier_0.json +26 -0
  96. data/spec/fixtures/files/supplier_0.xml +32 -0
  97. data/spec/fixtures/leads.json +923 -0
  98. data/spec/fixtures/refresh_error_response.json +8 -0
  99. data/spec/frodo/abstract_client_spec.rb +13 -0
  100. data/spec/frodo/client_spec.rb +57 -0
  101. data/spec/frodo/concerns/authentication_spec.rb +79 -0
  102. data/spec/frodo/concerns/base_spec.rb +68 -0
  103. data/spec/frodo/concerns/caching_spec.rb +40 -0
  104. data/spec/frodo/concerns/connection_spec.rb +65 -0
  105. data/spec/frodo/config_spec.rb +127 -0
  106. data/spec/frodo/entity/shared_examples.rb +83 -0
  107. data/spec/frodo/entity_container_spec.rb +38 -0
  108. data/spec/frodo/entity_set_spec.rb +169 -0
  109. data/spec/frodo/entity_spec.rb +153 -0
  110. data/spec/frodo/errors_spec.rb +48 -0
  111. data/spec/frodo/middleware/authentication/token_spec.rb +87 -0
  112. data/spec/frodo/middleware/authentication_spec.rb +83 -0
  113. data/spec/frodo/middleware/authorization_spec.rb +17 -0
  114. data/spec/frodo/middleware/custom_headers_spec.rb +21 -0
  115. data/spec/frodo/middleware/gzip_spec.rb +68 -0
  116. data/spec/frodo/middleware/instance_url_spec.rb +27 -0
  117. data/spec/frodo/middleware/logger_spec.rb +21 -0
  118. data/spec/frodo/middleware/odata_headers_spec.rb +15 -0
  119. data/spec/frodo/middleware/raise_error_spec.rb +66 -0
  120. data/spec/frodo/navigation_property/proxy_spec.rb +46 -0
  121. data/spec/frodo/navigation_property_spec.rb +55 -0
  122. data/spec/frodo/properties/binary_spec.rb +50 -0
  123. data/spec/frodo/properties/boolean_spec.rb +72 -0
  124. data/spec/frodo/properties/collection_spec.rb +44 -0
  125. data/spec/frodo/properties/date_spec.rb +23 -0
  126. data/spec/frodo/properties/date_time_offset_spec.rb +30 -0
  127. data/spec/frodo/properties/date_time_spec.rb +23 -0
  128. data/spec/frodo/properties/decimal_spec.rb +50 -0
  129. data/spec/frodo/properties/float_spec.rb +45 -0
  130. data/spec/frodo/properties/geography/line_string_spec.rb +33 -0
  131. data/spec/frodo/properties/geography/point_spec.rb +29 -0
  132. data/spec/frodo/properties/geography/polygon_spec.rb +55 -0
  133. data/spec/frodo/properties/geography/shared_examples.rb +72 -0
  134. data/spec/frodo/properties/guid_spec.rb +17 -0
  135. data/spec/frodo/properties/integer_spec.rb +58 -0
  136. data/spec/frodo/properties/string_spec.rb +46 -0
  137. data/spec/frodo/properties/time_of_day_spec.rb +23 -0
  138. data/spec/frodo/properties/time_spec.rb +15 -0
  139. data/spec/frodo/property_registry_spec.rb +16 -0
  140. data/spec/frodo/property_spec.rb +71 -0
  141. data/spec/frodo/query/criteria_spec.rb +229 -0
  142. data/spec/frodo/query_spec.rb +156 -0
  143. data/spec/frodo/schema/complex_type_spec.rb +97 -0
  144. data/spec/frodo/schema/enum_type_spec.rb +112 -0
  145. data/spec/frodo/schema_spec.rb +113 -0
  146. data/spec/frodo/service_registry_spec.rb +19 -0
  147. data/spec/frodo/service_spec.rb +153 -0
  148. data/spec/frodo/usage_example_spec.rb +161 -0
  149. data/spec/spec_helper.rb +35 -0
  150. data/spec/support/coverage.rb +2 -0
  151. data/spec/support/fixture_helpers.rb +14 -0
  152. data/spec/support/middleware.rb +19 -0
  153. metadata +479 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b8f56d9927d67dbbd6ffd716c73efde55b370083
4
+ data.tar.gz: bf09fc5ca9a219c6f6eb0593ef8e7890cbf240c6
5
+ SHA512:
6
+ metadata.gz: 9ee5bef44ae2d6ff783deea44efeb4b3a562471e02ad0ea1d2204c6d19a8a77509a36ad36faecc7449e15cddd923f2485628b59a7239ca0ae74f9bd6fb92a4ac
7
+ data.tar.gz: 5a508d979808942225b9c68bcf1438aecff8404d90f3735f0d47caaff9a446c507d6ef80148d15b40838e9d5ce66350752175af407ffc586f30fa51a1e27d1fd
data/.autotest ADDED
@@ -0,0 +1,2 @@
1
+ require 'autotest/bundler'
2
+
@@ -0,0 +1,54 @@
1
+ # Ruby CircleCI 2.0 configuration file
2
+ #
3
+ # Check https://circleci.com/docs/2.0/language-ruby/ for more details
4
+ #
5
+ version: 2
6
+ jobs:
7
+ build:
8
+ docker:
9
+ # specify the version you desire here
10
+ - image: circleci/ruby:2.4.1-node-browsers
11
+
12
+ working_directory: ~/repo
13
+
14
+ steps:
15
+ - checkout
16
+
17
+ # Download and cache dependencies
18
+ - restore_cache:
19
+ keys:
20
+ - v1-dependencies-{{ checksum "Gemfile.lock" }}
21
+ # fallback to using the latest cache if no exact match is found
22
+ - v1-dependencies-
23
+
24
+ - run:
25
+ name: install dependencies
26
+ command: |
27
+ bundle install --jobs=4 --retry=3 --path vendor/bundle
28
+
29
+ - save_cache:
30
+ paths:
31
+ - ./vendor/bundle
32
+ key: v1-dependencies-{{ checksum "Gemfile.lock" }}
33
+
34
+ # run tests!
35
+ - run:
36
+ name: run tests
37
+ command: |
38
+ mkdir /tmp/test-results
39
+ TEST_FILES="$(circleci tests glob "spec/**/*_spec.rb" | \
40
+ circleci tests split --split-by=timings)"
41
+
42
+ bundle exec rspec \
43
+ --format progress \
44
+ --format RspecJunitFormatter \
45
+ --out /tmp/test-results/rspec.xml \
46
+ --format progress \
47
+ $TEST_FILES
48
+
49
+ # collect reports
50
+ - store_test_results:
51
+ path: /tmp/test-results
52
+ - store_artifacts:
53
+ path: /tmp/test-results
54
+ destination: test-results
data/.gitignore ADDED
@@ -0,0 +1,24 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .idea
6
+ .yardoc
7
+ Gemfile.lock
8
+ InstalledFiles
9
+ _yardoc
10
+ coverage
11
+ doc/
12
+ lib/bundler/man
13
+ pkg
14
+ rdoc
15
+ spec/reports
16
+ test/tmp
17
+ test/version_tmp
18
+ tmp
19
+ *.bundle
20
+ *.so
21
+ *.o
22
+ *.a
23
+ mkmf.log
24
+ private
data/.gitlab-ci.yml ADDED
@@ -0,0 +1,9 @@
1
+ rspec:
2
+ image: ruby:2.2
3
+ script:
4
+ - bundle install --path /cache --jobs $(nproc)
5
+ - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
6
+ - chmod +x ./cc-test-reporter
7
+ - ./cc-test-reporter before-build
8
+ - bundle exec rspec
9
+ - ./cc-test-reporter after-build --exit-code $?
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ odata
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.2
data/.travis.yml ADDED
@@ -0,0 +1,75 @@
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
+ - 2.1.3
9
+ - 2.1.4
10
+ - 2.1.5
11
+ - jruby
12
+ - jruby-head
13
+ jdk:
14
+ - openjdk6
15
+ - openjdk7
16
+ - oraclejdk7
17
+ - oraclejdk8
18
+ branches:
19
+ only:
20
+ - master
21
+ matrix:
22
+ exclude:
23
+ - rvm: 1.9.3
24
+ jdk: openjdk6
25
+ - rvm: 1.9.3
26
+ jdk: oraclejdk7
27
+ - rvm: 1.9.3
28
+ jdk: oraclejdk8
29
+ - rvm: 2.0.0
30
+ jdk: openjdk6
31
+ - rvm: 2.0.0
32
+ jdk: oraclejdk7
33
+ - rvm: 2.0.0
34
+ jdk: oraclejdk8
35
+ - rvm: 2.1.0
36
+ jdk: openjdk6
37
+ - rvm: 2.1.0
38
+ jdk: oraclejdk7
39
+ - rvm: 2.1.0
40
+ jdk: oraclejdk8
41
+ - rvm: 2.1.1
42
+ jdk: openjdk6
43
+ - rvm: 2.1.1
44
+ jdk: oraclejdk7
45
+ - rvm: 2.1.1
46
+ jdk: oraclejdk8
47
+ - rvm: 2.1.2
48
+ jdk: openjdk6
49
+ - rvm: 2.1.2
50
+ jdk: oraclejdk7
51
+ - rvm: 2.1.2
52
+ jdk: oraclejdk8
53
+ - rvm: 2.1.3
54
+ jdk: openjdk6
55
+ - rvm: 2.1.3
56
+ jdk: oraclejdk7
57
+ - rvm: 2.1.3
58
+ jdk: oraclejdk8
59
+ - rvm: 2.1.4
60
+ jdk: openjdk6
61
+ - rvm: 2.1.4
62
+ jdk: oraclejdk7
63
+ - rvm: 2.1.4
64
+ jdk: oraclejdk8
65
+ - rvm: 2.1.5
66
+ jdk: openjdk6
67
+ - rvm: 2.1.5
68
+ jdk: oraclejdk7
69
+ - rvm: 2.1.5
70
+ jdk: oraclejdk8
71
+ allow_failures:
72
+ - rvm: jruby-head
73
+ addons:
74
+ code_climate:
75
+ repo_token: 56e2763b5bfe138f566c5f2bf23c14deee4f8990324436dbde07ee2a34bb87f8
data/CHANGELOG.md ADDED
@@ -0,0 +1,163 @@
1
+ # CHANGELOG
2
+
3
+ ## 0.9.3
4
+
5
+ * Fix broken stack traces in response errors
6
+ * Ensure that `Service#service_url` always returns a string
7
+ * Require Ruby 2.2 in gemspec
8
+
9
+ ## 0.9.2
10
+
11
+ * Ignore connection options when connection object is passed in
12
+ * Don't send `Accept` header unless explicitly configured
13
+ * Use middleware for request/response logging
14
+ * Specifying an adapter is no longer necessary when passing a block to the constructor
15
+
16
+ ## 0.9.1
17
+
18
+ * [New] Raising specific error classes instead of `RuntimeError` when request fails
19
+
20
+ ## 0.9.0
21
+
22
+ * [Breaking] Use Faraday instead of Typhoeus as HTTP connection adapter.
23
+ * [Breaking] Deprecate `Service.open` in favor of using constructor directly.
24
+
25
+ ## 0.8.2
26
+
27
+ * [Refactor] Moved `ComplexType` and `EnumType` class into `Schema`, respective property types into `Properties` namespace
28
+
29
+ ## 0.8.1
30
+
31
+ * [New Feature] Basic support for `Collection` property type
32
+ * [Refactor] Moved all HTTP-related code into `Service::Request`,
33
+ renamed `Query::Result` to `Service::Response`
34
+ * [Bugfix] Fixed incorrect `OData-Version` header being sent
35
+ * [Bugfix] Fixed duplicate namespace in Atom serialization
36
+
37
+ ## 0.8.0
38
+
39
+ * [New Feature] Support for multiple schemas
40
+ * [Breaking] `Service#complex_types`, `Service#entity_types`,
41
+ `Service#enum_types` and `Service#entity_sets` now return fully qualified
42
+ type names
43
+ * [New Feature] Optional lenient property validation
44
+ * [Fixed] Incorrect URL representation for Decimal properties
45
+
46
+ ## 0.7.0
47
+
48
+ Major rewrite
49
+
50
+ * Added support for OData 4.0
51
+ * Dropped support for OData 3.0
52
+
53
+ ## 0.6.18
54
+
55
+ * Minor internal fixes to OData::Query::Criteria.
56
+
57
+ ## 0.6.17
58
+
59
+ * Added more graceful handling of manually passed advanced queries to
60
+ OData::Query::Criteria.
61
+
62
+ ## 0.6.16
63
+
64
+ * Implemented OData::Query#empty? and fixed OData::Query#count.
65
+
66
+ ## 0.6.15
67
+
68
+ * Fixed minor bug in last release.
69
+
70
+ ## 0.6.14
71
+
72
+ * Changed implementation of OData::Association::Proxy#[] to properly handle
73
+ empty associations.
74
+
75
+ ## 0.6.13
76
+
77
+ * Minor bug fix in OData::Query::Result#each implementation.
78
+
79
+ ## 0.6.12
80
+
81
+ * Minor bug fix in OData::Query::Result#each implementation.
82
+
83
+ ## 0.6.11
84
+
85
+ * Added logic to allow OData::Query::Result#each to handle paginated results.
86
+
87
+ ## 0.6.10
88
+
89
+ * Changed how associations behave with mulitiplicity of one.
90
+
91
+ ## 0.6.9
92
+
93
+ * Changed how OData::Entity#from_xml functions to better work with feed results.
94
+
95
+ ## 0.6.8
96
+
97
+ * Added empty checking when checking for a nil value.
98
+
99
+ ## 0.6.7
100
+
101
+ * Changed how commit failures are handled to use logging instead of raising an
102
+ error.
103
+ * Added errors array to OData::Entity.
104
+
105
+ ## 0.6.6
106
+
107
+ * Updated OData::EntitySet#setup_entity_post_request to properly format primary
108
+ key values when posting an entity.
109
+
110
+ ## 0.6.5
111
+
112
+ * Fixed problem in OData::ComplexType#to_xml implementation.
113
+
114
+ ## 0.6.4
115
+
116
+ * Added implementation of OData::ComplexType#type.
117
+
118
+ ## 0.6.3
119
+
120
+ * Added OData::ComplexType#to_xml to make entity saving work correctly.
121
+
122
+ ## 0.6.1
123
+
124
+ * Made a minor change to internals of OData::Query::Criteria.
125
+
126
+ ## 0.6.0
127
+
128
+ * Added ability to handle associations in a reasonable way.
129
+
130
+ ## 0.5.1-8
131
+
132
+ * Tons of changes throughout the code base
133
+
134
+ ## 0.5.0
135
+
136
+ * Stopped using namespace from OData service as unique identifier in favor of
137
+ a supplied name option when opening a service.
138
+
139
+ ## 0.4.0
140
+
141
+ * Added OData::Query#execute to run query and return a result.
142
+ * Added OData::Query::Result to handle enumeration of query results.
143
+
144
+ ## 0.3.2
145
+
146
+ * Refactored internals of the query interface.
147
+
148
+ ## 0.3.1
149
+
150
+ * Resolved issues causing failure on Ruby 1.9 and JRuby.
151
+
152
+ ## 0.3.0
153
+
154
+ * Removed dependency on ActiveSupport
155
+
156
+ ## 0.2.0
157
+
158
+ * Added query interface for [System Query Options](http://www.odata.org/documentation/odata-version-3-0/odata-version-3-0-core-protocol#queryingcollections)
159
+ * Refactored internal uses of System Query Options
160
+
161
+ ## 0.1.0
162
+
163
+ * Core read/write behavior for OData v1-3
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in odata.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,23 @@
1
+ Copyright (c) 2018 Christoph Wagner <christoph@wrstudios.com>
2
+ 2014 James Thompson <james@plainprograms.com>
3
+
4
+ MIT License
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining
7
+ a copy of this software and associated documentation files (the
8
+ "Software"), to deal in the Software without restriction, including
9
+ without limitation the rights to use, copy, modify, merge, publish,
10
+ distribute, sublicense, and/or sell copies of the Software, and to
11
+ permit persons to whom the Software is furnished to do so, subject to
12
+ the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be
15
+ included in all copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.