grape-entity 1.0.2 → 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/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
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
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,24 +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_dependency 'activesupport', '>= 3.0.0'
20
-
21
- s.files = `git ls-files`.split("\n")
22
- s.test_files = `git ls-files -- {test,spec}/*`.split("\n")
23
- s.require_paths = ['lib']
24
- end