grape-entity 1.0.1 → 1.0.3

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.
data/CONTRIBUTING.md DELETED
@@ -1,118 +0,0 @@
1
- Contributing to Grape-Entity
2
- ============================
3
-
4
- Grape-Entity is work of [many of contributors](https://github.com/ruby-grape/grape-entity/graphs/contributors). You're encouraged to submit [pull requests](https://github.com/ruby-grape/grape-entity/pulls), [propose features and discuss issues](https://github.com/ruby-grape/grape-entity/issues). When in doubt, ask a question in the [Grape Google Group](http://groups.google.com/group/ruby-grape).
5
-
6
- #### Fork the Project
7
-
8
- Fork the [project on Github](https://github.com/ruby-grape/grape-entity) and check out your copy.
9
-
10
- ```
11
- git clone https://github.com/contributor/grape-entity.git
12
- cd grape-entity
13
- git remote add upstream https://github.com/ruby-grape/grape-entity.git
14
- ```
15
-
16
- #### Create a Topic Branch
17
-
18
- Make sure your fork is up-to-date and create a topic branch for your feature or bug fix.
19
-
20
- ```
21
- git checkout master
22
- git pull upstream master
23
- git checkout -b my-feature-branch
24
- ```
25
-
26
- #### Bundle Install and Test
27
-
28
- Ensure that you can build the project and run tests.
29
-
30
- ```
31
- bundle install
32
- bundle exec rake
33
- ```
34
-
35
- #### Write Tests
36
-
37
- Try to write a test that reproduces the problem you're trying to fix or describes a feature that you want to build. Add to [spec/grape-entity](spec/grape-entity).
38
-
39
- We definitely appreciate pull requests that highlight or reproduce a problem, even without a fix.
40
-
41
- #### Write Code
42
-
43
- Implement your feature or bug fix.
44
-
45
- Ruby style is enforced with [Rubocop](https://github.com/bbatsov/rubocop), run `bundle exec rubocop` and fix any style issues highlighted.
46
-
47
- Make sure that `bundle exec rake` completes without errors.
48
-
49
- #### Write Documentation
50
-
51
- Document any external behavior in the [README](README.md).
52
-
53
- #### Update Changelog
54
-
55
- Add a line to [CHANGELOG](CHANGELOG.md) under *Next Release*. Make it look like every other line, including your name and link to your Github account.
56
-
57
- #### Commit Changes
58
-
59
- Make sure git knows your name and email address:
60
-
61
- ```
62
- git config --global user.name "Your Name"
63
- git config --global user.email "contributor@example.com"
64
- ```
65
-
66
- Writing good commit logs is important. A commit log should describe what changed and why.
67
-
68
- ```
69
- git add ...
70
- git commit
71
- ```
72
-
73
- #### Push
74
-
75
- ```
76
- git push origin my-feature-branch
77
- ```
78
-
79
- #### Make a Pull Request
80
-
81
- Go to https://github.com/ruby-grape/grape-entity and select your feature branch. Click the 'Pull Request' button and fill out the form. Pull requests are usually reviewed within a few days.
82
-
83
- #### Rebase
84
-
85
- If you've been working on a change for a while, rebase with upstream/master.
86
-
87
- ```
88
- git fetch upstream
89
- git rebase upstream/master
90
- git push origin my-feature-branch -f
91
- ```
92
-
93
- #### Update CHANGELOG Again
94
-
95
- Update the [CHANGELOG](CHANGELOG.md) with the pull request number. A typical entry looks as follows.
96
-
97
- ```
98
- * [#123](https://github.com/ruby-grape/grape-entity/pull/123): Reticulated splines - [@contributor](https://github.com/contributor).
99
- ```
100
-
101
- Amend your previous commit and force push the changes.
102
-
103
- ```
104
- git commit --amend
105
- git push origin my-feature-branch -f
106
- ```
107
-
108
- #### Check on Your Pull Request
109
-
110
- Go back to your pull request after a few minutes and see whether it passed muster with Travis-CI. Everything should look green, otherwise fix issues and amend your commit as described above.
111
-
112
- #### Be Patient
113
-
114
- It's likely that your change will not be merged and that the nitpicky maintainers will ask you to do more, or fix seemingly benign problems. Hang on there!
115
-
116
- #### Thank You
117
-
118
- Please do know that we really appreciate and value your time and work. We love you, really.
data/Dangerfile DELETED
@@ -1,3 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- danger.import_dangerfile(gem: 'ruby-grape-danger')
data/Gemfile DELETED
@@ -1,28 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source 'http://rubygems.org'
4
-
5
- gemspec
6
-
7
- group :development, :test do
8
- gem 'bundler'
9
- gem 'maruku'
10
- gem 'pry' unless RUBY_PLATFORM.eql?('java') || RUBY_ENGINE.eql?('rbx')
11
- gem 'pry-byebug' unless RUBY_PLATFORM.eql?('java') || RUBY_ENGINE.eql?('rbx')
12
- gem 'rack-test'
13
- gem 'rake'
14
- gem 'rspec', '~> 3.9'
15
- gem 'rubocop', '~> 1.0'
16
- gem 'yard'
17
- end
18
-
19
- group :test do
20
- gem 'coveralls_reborn', require: false
21
- gem 'growl'
22
- gem 'guard'
23
- gem 'guard-bundler'
24
- gem 'guard-rspec'
25
- gem 'rb-fsevent'
26
- gem 'ruby-grape-danger', '~> 0.2', require: false
27
- gem 'simplecov', require: false
28
- end
data/Guardfile DELETED
@@ -1,16 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # A sample Guardfile
4
- # More info at https://github.com/guard/guard#readme
5
-
6
- guard 'rspec', version: 2 do
7
- watch(%r{^spec/.+_spec\.rb$})
8
- watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
9
- watch(%r{^spec/support/shared_versioning_examples.rb$}) { |_m| 'spec/' }
10
- watch('spec/spec_helper.rb') { 'spec/' }
11
- end
12
-
13
- guard 'bundler' do
14
- watch('Gemfile')
15
- watch(/^.+\.gemspec/)
16
- end
data/RELEASING.md DELETED
@@ -1,84 +0,0 @@
1
- Releasing Grape-Entity
2
- ======================
3
-
4
- There're no particular rules about when to release grape-entity. Release bug fixes frequenty, features not so frequently and breaking API changes rarely.
5
-
6
- ### Release
7
-
8
- Run tests, check that all tests succeed locally.
9
-
10
- ```
11
- bundle install
12
- rake
13
- ```
14
-
15
- Check that the last build succeeded in [Travis CI](https://travis-ci.org/ruby-grape/grape-entity) for all supported platforms.
16
-
17
- Increment the version, modify [lib/grape-entity/version.rb](lib/grape-entity/version.rb).
18
-
19
- * Increment the third number if the release has bug fixes and/or very minor features, only (eg. change `0.5.1` to `0.5.2`).
20
- * Increment the second number if the release contains major features or breaking API changes (eg. change `0.5.1` to `0.4.0`).
21
-
22
- Change "Next Release" in [CHANGELOG.md](CHANGELOG.md) to the new version.
23
-
24
- ```
25
- 0.4.0 (2014-01-27)
26
- ==================
27
- ```
28
-
29
- Remove the line with "Your contribution here.", since there will be no more contributions to this release.
30
-
31
- Commit your changes.
32
-
33
- ```
34
- git add CHANGELOG.md lib/grape-entity/version.rb
35
- git commit -m "Preparing for release, 0.4.0."
36
- git push origin master
37
- ```
38
-
39
- Release.
40
-
41
- ```
42
- $ rake release
43
-
44
- grape-entity 0.4.0 built to pkg/grape-entity-0.4.0.gem.
45
- Tagged v0.4.0.
46
- Pushed git commits and tags.
47
- Pushed grape-entity 0.4.0 to rubygems.org.
48
- ```
49
-
50
- ### Prepare for the Next Version
51
-
52
- Add the next release to [CHANGELOG.md](CHANGELOG.md).
53
-
54
- ```
55
- Next Release
56
- ============
57
-
58
- * Your contribution here.
59
- ```
60
-
61
- Increment the minor version, modify [lib/grape-entity/version.rb](lib/grape-entity/version.rb).
62
-
63
- Comit your changes.
64
-
65
- ```
66
- git add CHANGELOG.md lib/grape-entity/version.rb
67
- git commit -m "Preparing for next release, 0.4.1."
68
- git push origin master
69
- ```
70
-
71
- ### Make an Announcement
72
-
73
- Make an announcement on the [ruby-grape@googlegroups.com](mailto:ruby-grape@googlegroups.com) mailing list. The general format is as follows.
74
-
75
- ```
76
- Grape-entity 0.4.0 has been released.
77
-
78
- There were 8 contributors to this release, not counting documentation.
79
-
80
- Please note the breaking API change in ...
81
-
82
- [copy/paste CHANGELOG here]
83
-
84
- ```
data/Rakefile DELETED
@@ -1,20 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'rubygems'
4
- require 'bundler'
5
-
6
- Bundler.setup(:default, :development)
7
-
8
- require 'rake'
9
-
10
- Bundler::GemHelper.install_tasks
11
-
12
- require 'rspec/core'
13
- require 'rspec/core/rake_task'
14
-
15
- RSpec::Core::RakeTask.new(:spec)
16
-
17
- require 'rubocop/rake_task'
18
- RuboCop::RakeTask.new(:rubocop)
19
-
20
- task default: %i[spec rubocop]
data/UPGRADING.md DELETED
@@ -1,40 +0,0 @@
1
- # Upgrading Grape Entity
2
-
3
-
4
- ### Upgrading to >= 0.10.2
5
- Official support for `FetchableObject` was removed.
6
-
7
- See [#352](https://github.com/ruby-grape/grape-entity/pull/369) for more information.
8
-
9
- ### Upgrading to >= 0.8.2
10
-
11
- Official support for ruby < 2.5 removed, ruby 2.5 only in testing mode, but no support.
12
-
13
- In Ruby 3.0: the block handling will be changed
14
- [language-changes point 3, Proc](https://github.com/ruby/ruby/blob/v3_0_0_preview1/NEWS.md#language-changes).
15
- This:
16
- ```ruby
17
- expose :that_method_without_args, &:method_without_args
18
- ```
19
- will be deprecated.
20
-
21
- Prefer to use this pattern for simple setting a value
22
- ```ruby
23
- expose :method_without_args, as: :that_method_without_args
24
- ```
25
-
26
- ### Upgrading to >= 0.6.0
27
-
28
- #### Changes in Grape::Entity#inspect
29
-
30
- The `Grape::Entity#inspect` method will no longer serialize the entity presenter with its options and delegator, but the exposed entity itself, using `#serializable_hash`.
31
-
32
- See [#250](https://github.com/ruby-grape/grape-entity/pull/250) for more information.
33
-
34
- ### Upgrading to >= 0.5.1
35
-
36
- #### Changes in NestedExposures.delete_if
37
-
38
- `Grape::Entity::Exposure::NestingExposure::NestedExposures.delete_if` always returns exposures, regardless of delete result (used to be `nil` in negative case).
39
-
40
- See [#203](https://github.com/ruby-grape/grape-entity/pull/203) for more information.
data/bench/serializing.rb DELETED
@@ -1,105 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
4
- require 'grape-entity'
5
- require 'benchmark'
6
-
7
- module Models
8
- class School
9
- attr_reader :classrooms
10
-
11
- def initialize
12
- @classrooms = []
13
- end
14
- end
15
-
16
- class ClassRoom
17
- attr_reader :students
18
- attr_accessor :teacher
19
-
20
- def initialize(opts = {})
21
- @teacher = opts[:teacher]
22
- @students = []
23
- end
24
- end
25
-
26
- class Person
27
- attr_accessor :name
28
-
29
- def initialize(opts = {})
30
- @name = opts[:name]
31
- end
32
- end
33
-
34
- class Teacher < Models::Person
35
- attr_accessor :tenure
36
-
37
- def initialize(opts = {})
38
- super(opts)
39
- @tenure = opts[:tenure]
40
- end
41
- end
42
-
43
- class Student < Models::Person
44
- attr_reader :grade
45
-
46
- def initialize(opts = {})
47
- super(opts)
48
- @grade = opts[:grade]
49
- end
50
- end
51
- end
52
-
53
- module Entities
54
- class School < Grape::Entity
55
- expose :classrooms, using: 'Entities::ClassRoom'
56
- end
57
-
58
- class ClassRoom < Grape::Entity
59
- expose :teacher, using: 'Entities::Teacher'
60
- expose :students, using: 'Entities::Student'
61
- expose :size do |model, _opts|
62
- model.students.count
63
- end
64
- end
65
-
66
- class Person < Grape::Entity
67
- expose :name
68
- end
69
-
70
- class Student < Entities::Person
71
- expose :grade
72
- expose :failing do |model, _opts|
73
- model.grade == 'F'
74
- end
75
- end
76
-
77
- class Teacher < Entities::Person
78
- expose :tenure
79
- end
80
- end
81
-
82
- teacher1 = Models::Teacher.new(name: 'John Smith', tenure: 2)
83
- classroom1 = Models::ClassRoom.new(teacher: teacher1)
84
- classroom1.students << Models::Student.new(name: 'Bobby', grade: 'A')
85
- classroom1.students << Models::Student.new(name: 'Billy', grade: 'B')
86
-
87
- teacher2 = Models::Teacher.new(name: 'Lisa Barns')
88
- classroom2 = Models::ClassRoom.new(teacher: teacher2, tenure: 15)
89
- classroom2.students << Models::Student.new(name: 'Eric', grade: 'A')
90
- classroom2.students << Models::Student.new(name: 'Eddie', grade: 'C')
91
- classroom2.students << Models::Student.new(name: 'Arnie', grade: 'C')
92
- classroom2.students << Models::Student.new(name: 'Alvin', grade: 'F')
93
- school = Models::School.new
94
- school.classrooms << classroom1
95
- school.classrooms << classroom2
96
-
97
- iters = 5000
98
-
99
- Benchmark.bm do |bm|
100
- bm.report('serializing') do
101
- iters.times do
102
- Entities::School.represent(school, serializable: true)
103
- end
104
- end
105
- end
data/grape-entity.gemspec DELETED
@@ -1,26 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- $LOAD_PATH.push File.expand_path('lib', __dir__)
4
- require 'grape_entity/version'
5
-
6
- Gem::Specification.new do |s|
7
- s.name = 'grape-entity'
8
- s.version = GrapeEntity::VERSION
9
- s.platform = Gem::Platform::RUBY
10
- s.authors = ['LeFnord', 'Michael Bleigh']
11
- s.email = ['pscholz.le@gmail.com', 'michael@intridea.com']
12
- s.homepage = 'https://github.com/ruby-grape/grape-entity'
13
- s.summary = 'A simple facade for managing the relationship between your model and API.'
14
- s.description = 'Extracted from Grape, A Ruby framework for rapid API development with great conventions.'
15
- s.license = 'MIT'
16
-
17
- s.required_ruby_version = '>= 3.0'
18
-
19
- s.add_runtime_dependency 'activesupport', '>= 3.0.0'
20
- # FIXME: remove dependecy
21
- s.add_runtime_dependency 'multi_json', '>= 1.3.2'
22
-
23
- s.files = `git ls-files`.split("\n")
24
- s.test_files = `git ls-files -- {test,spec}/*`.split("\n")
25
- s.require_paths = ['lib']
26
- end