odata-model 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: dcef84e8ecc5149a6a18c69532677a69bb5febad
4
+ data.tar.gz: ce363fbfb1866a67e3705b0260e9fc80e0ac004b
5
+ SHA512:
6
+ metadata.gz: 5d171f64ab550e40f4fe064e5d83afb4c595348b9239a5c3efd0b7aa35be874b31d5205478690497eac5494bcc7dac8c18db2702c31004a132393e6f0f18ba68
7
+ data.tar.gz: cbc3a736fee2b716381ccaaf357dd7cb9037c3e4969f5b71f1e81d021345d80fe80af95c53b974f96b0e1f9f0d22ec6f7c6d01fe115feea32ec55325bb6f6e68
data/.gitignore ADDED
@@ -0,0 +1,23 @@
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
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.1.2
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: 4bc0ad89c0f1d04811ac287acb4a8e999c44ad65940bbf96cfe6545dc3c4a918
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in odata-model.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 James Thompson
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,37 @@
1
+ # OData::Model
2
+
3
+ [![Build Status](https://travis-ci.org/ruby-odata/odata-model.svg?branch=master)](https://travis-ci.org/ruby-odata/odata-model)
4
+ [![Code Climate](https://codeclimate.com/github/ruby-odata/odata-model.png)](https://codeclimate.com/github/ruby-odata/odata-model)
5
+ [![Coverage](https://codeclimate.com/github/ruby-odata/odata-model/coverage.png)](https://codeclimate.com/github/ruby-odata/odata-model)
6
+ [![Gem Version](https://badge.fury.io/rb/odata-model.svg)](http://badge.fury.io/rb/odata-model)
7
+ [![Dependency Status](https://gemnasium.com/ruby-odata/odata-model.svg)](https://gemnasium.com/ruby-odata/odata-model)
8
+ [![Documentation](http://inch-ci.org/github/ruby-odata/odata-model.png?branch=master)](http://rubydoc.info/github/ruby-odata/odata-model/master/frames)
9
+
10
+ The `OData::Model` gem provides a mapping layer for the [`OData`](https://github.com/ruby-odata/odata)
11
+ gem that is meant to work in tandem with [`ActiveModel`](https://github.com/rails/rails/tree/master/activemodel).
12
+
13
+ ## Installation
14
+
15
+ Add this line to your application's Gemfile:
16
+
17
+ gem 'odata-model'
18
+
19
+ And then execute:
20
+
21
+ $ bundle
22
+
23
+ Or install it yourself as:
24
+
25
+ $ gem install odata-model
26
+
27
+ ## Usage
28
+
29
+ TODO: Write usage instructions here
30
+
31
+ ## Contributing
32
+
33
+ 1. Fork it ( https://github.com/[my-github-username]/odata-model/fork )
34
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
35
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
36
+ 4. Push to the branch (`git push origin my-new-feature`)
37
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
7
+
@@ -0,0 +1,5 @@
1
+ module OData
2
+ module Model
3
+ VERSION = '0.0.1'
4
+ end
5
+ end
@@ -0,0 +1,57 @@
1
+ require 'odata'
2
+ require 'odata/model/version'
3
+
4
+ require 'active_model'
5
+ require 'active_support/concern'
6
+
7
+ # OData is the parent namespace for the OData::Model project.
8
+ module OData
9
+ # OData::Model provides a way to map from OData::Entity instances, as
10
+ # returned by the OData gem, to Ruby objects that will work with Rails via
11
+ # the ActiveModel semantics.
12
+ module Model
13
+ extend ActiveSupport::Concern
14
+
15
+ extend ActiveModel::Naming
16
+ include ActiveModel::Validations
17
+ include ActiveModel::Conversion
18
+
19
+ included do
20
+ # ...
21
+ end
22
+
23
+ # Integrates ActiveModel's error handling capabilities
24
+ # @return [ActiveModel::Errors]
25
+ def errors
26
+ @errors ||= ActiveModel::Errors.new(self)
27
+ end
28
+
29
+ # Returns whether the current instance has been persisted.
30
+ # @return [Boolean]
31
+ def persisted?
32
+ false
33
+ end
34
+
35
+ # Used for ActiveModel validations
36
+ # @api private
37
+ def read_attribute_for_validation(attr)
38
+ send(attr)
39
+ end
40
+
41
+ # Methods integrated at the class level when OData::Model is included into
42
+ # a given class.
43
+ module ClassMethods
44
+ # Used for ActiveModel validations
45
+ # @api private
46
+ def human_attribute_name(attr, options = {})
47
+ attr
48
+ end
49
+
50
+ # Used for ActiveModel validations
51
+ # @api private
52
+ def lookup_ancestors
53
+ [self]
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'odata/model/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'odata-model'
8
+ spec.version = OData::Model::VERSION
9
+ spec.authors = ['James Thompson']
10
+ spec.email = %w{james@buypd.com}
11
+ spec.summary = 'An ActiveModel mapping layer for the OData gem'
12
+ spec.description = 'A mapping layer for the OData gem that integrates with ActiveModel'
13
+ spec.homepage = 'https://github.com/ruby-odata/odata-model'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = %w{lib}
20
+
21
+ spec.add_development_dependency 'bundler', '~> 1.6'
22
+ spec.add_development_dependency 'rake'
23
+ spec.add_development_dependency 'simplecov', '~> 0.8.2'
24
+ spec.add_development_dependency 'codeclimate-test-reporter'
25
+ spec.add_development_dependency 'rspec', '~> 3.0.0'
26
+
27
+ spec.add_dependency 'odata', '~> 0.1.0'
28
+ spec.add_dependency 'activesupport', '>= 3.0.0'
29
+ spec.add_dependency 'activemodel', '>= 3.0.0'
30
+ end
@@ -0,0 +1,62 @@
1
+ require 'spec_helper'
2
+
3
+ class BareModel
4
+ include OData::Model
5
+ end
6
+
7
+ describe OData::Model do
8
+ let(:subject) { BareModel.new }
9
+
10
+ it { expect(BareModel).to respond_to(:model_name) }
11
+
12
+ it { expect(subject).to respond_to(:to_key) }
13
+ it { expect(subject).to respond_to(:to_param) }
14
+ it { expect(subject).to respond_to(:to_partial_path) }
15
+ it { expect(subject).to respond_to(:persisted?) }
16
+ it { expect(subject).to respond_to(:to_model) }
17
+ it { expect(subject).to respond_to(:errors) }
18
+
19
+ describe '#to_key' do
20
+ it 'returns nil when #persisted? is false' do
21
+ def subject.persisted?() false end
22
+
23
+ expect(subject.to_key).to be_nil
24
+ end
25
+ end
26
+
27
+ describe '#to_param' do
28
+ it 'returns nil when #persisted? is false' do
29
+ def subject.to_key() [1] end
30
+ def subject.persisted?() false end
31
+
32
+ expect(subject.to_param).to be_nil
33
+ end
34
+ end
35
+
36
+ describe '#to_partial_path' do
37
+ it 'returns a String' do
38
+ expect(subject.to_partial_path).to be_a_kind_of(String)
39
+ end
40
+ end
41
+
42
+ describe '#persisted?' do
43
+ it 'returns a boolean' do
44
+ expect(subject.persisted?).to be_boolean
45
+ end
46
+ end
47
+
48
+ describe '.model_name' do
49
+ let(:model_name) { BareModel.model_name }
50
+
51
+ it { expect(model_name).to respond_to(:to_str) }
52
+ it { expect(model_name.human).to respond_to(:to_str) }
53
+ it { expect(model_name.singular).to respond_to(:to_str) }
54
+ it { expect(model_name.plural).to respond_to(:to_str) }
55
+ end
56
+
57
+ describe '#errors[]' do
58
+ it 'returns an Array' do
59
+ expect(subject.errors[:hello]).to be_a(Array)
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,36 @@
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
9
+ end
10
+
11
+ require 'odata/model'
12
+
13
+ RSpec::Matchers.define :be_boolean do
14
+ match do |actual|
15
+ expect(actual).to satisfy { |x| x == true || x == false }
16
+ end
17
+ end
18
+
19
+ RSpec.configure do |config|
20
+ if config.files_to_run.one?
21
+ config.default_formatter = 'doc'
22
+ end
23
+
24
+ config.profile_examples = 3
25
+ config.order = :random
26
+ Kernel.srand config.seed
27
+
28
+ config.expect_with :rspec do |expectations|
29
+ expectations.syntax = :expect
30
+ end
31
+
32
+ config.mock_with :rspec do |mocks|
33
+ mocks.syntax = :expect
34
+ mocks.verify_partial_doubles = true
35
+ end
36
+ end
metadata ADDED
@@ -0,0 +1,171 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: odata-model
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - James Thompson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-07-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
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
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'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 3.0.0
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 3.0.0
83
+ - !ruby/object:Gem::Dependency
84
+ name: odata
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 0.1.0
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 0.1.0
97
+ - !ruby/object:Gem::Dependency
98
+ name: activesupport
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: 3.0.0
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: 3.0.0
111
+ - !ruby/object:Gem::Dependency
112
+ name: activemodel
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: 3.0.0
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: 3.0.0
125
+ description: A mapping layer for the OData gem that integrates with ActiveModel
126
+ email:
127
+ - james@buypd.com
128
+ executables: []
129
+ extensions: []
130
+ extra_rdoc_files: []
131
+ files:
132
+ - ".gitignore"
133
+ - ".rspec"
134
+ - ".ruby-version"
135
+ - ".travis.yml"
136
+ - Gemfile
137
+ - LICENSE.txt
138
+ - README.md
139
+ - Rakefile
140
+ - lib/odata/model.rb
141
+ - lib/odata/model/version.rb
142
+ - odata-model.gemspec
143
+ - spec/active_model_lint_spec.rb
144
+ - spec/spec_helper.rb
145
+ homepage: https://github.com/ruby-odata/odata-model
146
+ licenses:
147
+ - MIT
148
+ metadata: {}
149
+ post_install_message:
150
+ rdoc_options: []
151
+ require_paths:
152
+ - lib
153
+ required_ruby_version: !ruby/object:Gem::Requirement
154
+ requirements:
155
+ - - ">="
156
+ - !ruby/object:Gem::Version
157
+ version: '0'
158
+ required_rubygems_version: !ruby/object:Gem::Requirement
159
+ requirements:
160
+ - - ">="
161
+ - !ruby/object:Gem::Version
162
+ version: '0'
163
+ requirements: []
164
+ rubyforge_project:
165
+ rubygems_version: 2.2.2
166
+ signing_key:
167
+ specification_version: 4
168
+ summary: An ActiveModel mapping layer for the OData gem
169
+ test_files:
170
+ - spec/active_model_lint_spec.rb
171
+ - spec/spec_helper.rb