burgundy 0.3.0 → 0.4.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.
- checksums.yaml +4 -4
- data/.rubocop.yml +13 -0
- data/.travis.yml +6 -5
- data/CHANGELOG.md +8 -0
- data/CODE_OF_CONDUCT.md +76 -0
- data/Gemfile +2 -0
- data/README.md +30 -0
- data/Rakefile +3 -1
- data/burgundy.gemspec +6 -2
- data/lib/burgundy.rb +2 -0
- data/lib/burgundy/collection.rb +4 -2
- data/lib/burgundy/item.rb +8 -2
- data/lib/burgundy/rails.rb +10 -6
- data/lib/burgundy/version.rb +3 -1
- data/test/dummy/Rakefile +3 -1
- data/test/dummy/app/controllers/application_controller.rb +2 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/bin/bundle +4 -2
- data/test/dummy/bin/rails +5 -3
- data/test/dummy/bin/rake +4 -2
- data/test/dummy/config.ru +3 -1
- data/test/dummy/config/application.rb +3 -3
- data/test/dummy/config/boot.rb +5 -3
- data/test/dummy/config/environment.rb +3 -1
- data/test/dummy/config/environments/development.rb +2 -0
- data/test/dummy/config/environments/production.rb +3 -1
- data/test/dummy/config/environments/test.rb +2 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +1 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +2 -0
- data/test/dummy/config/initializers/inflections.rb +1 -0
- data/test/dummy/config/initializers/mime_types.rb +1 -0
- data/test/dummy/config/initializers/secret_token.rb +3 -1
- data/test/dummy/config/initializers/session_store.rb +3 -1
- data/test/dummy/config/initializers/wrap_parameters.rb +2 -0
- data/test/dummy/config/routes.rb +2 -0
- data/test/test_helper.rb +2 -0
- data/test/unit/burgundy_test.rb +42 -6
- metadata +35 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7b33ddf407012b8721c8c5c26266a676fe714a54adf4591587745c3aecd5fa2b
|
4
|
+
data.tar.gz: ebf9996be106b868511e5ed13ca78bc37c1d8442f72bd7a0b94cd7e3c09184fd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6c12a95c9d67b134241b436e5014b4fc87c8a5e7a43a537049df0ac38dab5389c36254c6b76728c227708c2dcc2cbf8efa72c80b10e699336d652a1b727ffb8e
|
7
|
+
data.tar.gz: 329a4ebf4eb90f7ed15dd50675a33546ca26f426f667c5810e32bc4f050d72b2dc2a51aa23f0dffe4bdb216c170cbac0069375e1d24cf285a67d5894e2fb7627
|
data/.rubocop.yml
ADDED
data/.travis.yml
CHANGED
@@ -1,16 +1,17 @@
|
|
1
|
+
---
|
1
2
|
language: ruby
|
2
3
|
sudo: false
|
3
4
|
cache: bundler
|
4
5
|
notifications:
|
5
6
|
email: false
|
6
7
|
rvm:
|
7
|
-
- 2.5.2
|
8
|
+
- 2.5.2
|
8
9
|
before_script:
|
9
|
-
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
10
|
-
- chmod +x ./cc-test-reporter
|
11
|
-
- "./cc-test-reporter before-build"
|
10
|
+
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
11
|
+
- chmod +x ./cc-test-reporter
|
12
|
+
- "./cc-test-reporter before-build"
|
12
13
|
after_script:
|
13
|
-
- "./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT"
|
14
|
+
- "./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT"
|
14
15
|
env:
|
15
16
|
global:
|
16
17
|
secure: LIU2voUl12O5yOXGTwOFOJgdv49YOpFN4FyH3Eqvc48tvy3cRypMuqvFiG/KL4jQvE2IydZZmG+DtsgTsi6kOe5cYlxeU2fTiK9dflNqBIV7+CfwXqguUAcwJLW1dt6Gtmis2VuOffJDBqpojTpFDrUosDdISc1gkOXh4+8yHQA=
|
data/CHANGELOG.md
CHANGED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, sex characteristics, gender identity and expression,
|
9
|
+
level of experience, education, socio-economic status, nationality, personal
|
10
|
+
appearance, race, religion, or sexual identity and orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at me@fnando.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
|
72
|
+
|
73
|
+
[homepage]: https://www.contributor-covenant.org
|
74
|
+
|
75
|
+
For answers to common questions about this code of conduct, see
|
76
|
+
https://www.contributor-covenant.org/faq
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -122,8 +122,13 @@ UserPresenter.new(User.first).to_hash
|
|
122
122
|
|
123
123
|
UserPresenter.new(User.first).to_h
|
124
124
|
#=> {:username=>'johndoe', :name=>'John Doe', :email=>'john@example.org'}
|
125
|
+
|
126
|
+
UserPresenter.new(User.first).as_json
|
127
|
+
#=> {:username=>'johndoe', :name=>'John Doe', :email=>'john@example.org'}
|
125
128
|
```
|
126
129
|
|
130
|
+
Notice that `as_json` will ignore any options provided.
|
131
|
+
|
127
132
|
If you want to remap an attribute, provide a hash.
|
128
133
|
|
129
134
|
```ruby
|
@@ -146,3 +151,28 @@ UserPresenter.new(User.first).attributes
|
|
146
151
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
147
152
|
4. Push to the branch (`git push origin my-new-feature`)
|
148
153
|
5. Create new Pull Request
|
154
|
+
|
155
|
+
## License
|
156
|
+
|
157
|
+
Copyright (c) 2013 Nando Vieira
|
158
|
+
|
159
|
+
MIT License
|
160
|
+
|
161
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
162
|
+
a copy of this software and associated documentation files (the
|
163
|
+
"Software"), to deal in the Software without restriction, including
|
164
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
165
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
166
|
+
permit persons to whom the Software is furnished to do so, subject to
|
167
|
+
the following conditions:
|
168
|
+
|
169
|
+
The above copyright notice and this permission notice shall be
|
170
|
+
included in all copies or substantial portions of the Software.
|
171
|
+
|
172
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
173
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
174
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
175
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
176
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
177
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
178
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
CHANGED
data/burgundy.gemspec
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "./lib/burgundy/version"
|
2
4
|
|
3
5
|
Gem::Specification.new do |spec|
|
@@ -5,12 +7,12 @@ Gem::Specification.new do |spec|
|
|
5
7
|
spec.version = Burgundy::VERSION
|
6
8
|
spec.authors = ["Nando Vieira"]
|
7
9
|
spec.email = ["fnando.vieira@gmail.com"]
|
8
|
-
spec.description = "A simple wrapper for objects
|
10
|
+
spec.description = "A simple wrapper for objects in less than 100 lines."
|
9
11
|
spec.summary = spec.description
|
10
12
|
spec.homepage = "http://github.com/fnando/burgundy"
|
11
13
|
spec.license = "MIT"
|
12
14
|
|
13
|
-
spec.files = `git ls-files`.split(
|
15
|
+
spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
|
14
16
|
spec.executables = spec.files.grep(%r{^bin/}) {|f| File.basename(f) }
|
15
17
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
16
18
|
spec.require_paths = ["lib"]
|
@@ -20,5 +22,7 @@ Gem::Specification.new do |spec|
|
|
20
22
|
spec.add_development_dependency "pry-meta"
|
21
23
|
spec.add_development_dependency "rails"
|
22
24
|
spec.add_development_dependency "rake"
|
25
|
+
spec.add_development_dependency "rubocop"
|
26
|
+
spec.add_development_dependency "rubocop-fnando"
|
23
27
|
spec.add_development_dependency "simplecov"
|
24
28
|
end
|
data/lib/burgundy.rb
CHANGED
data/lib/burgundy/collection.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Burgundy
|
2
4
|
class Collection
|
3
5
|
def initialize(items, wrapping_class = nil, *args)
|
@@ -6,7 +8,7 @@ module Burgundy
|
|
6
8
|
@args = args
|
7
9
|
end
|
8
10
|
|
9
|
-
def method_missing(name, *args, &block)
|
11
|
+
def method_missing(name, *args, &block) # rubocop:disable Style/MissingRespondToMissing, Style/MethodMissingSuper
|
10
12
|
to_ary.send(name, *args, &block)
|
11
13
|
end
|
12
14
|
|
@@ -21,6 +23,6 @@ module Burgundy
|
|
21
23
|
@items.to_a
|
22
24
|
end
|
23
25
|
end
|
24
|
-
|
26
|
+
alias to_a to_ary
|
25
27
|
end
|
26
28
|
end
|
data/lib/burgundy/item.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Burgundy
|
2
4
|
class Item < SimpleDelegator
|
3
5
|
attr_reader :item
|
@@ -38,7 +40,11 @@ module Burgundy
|
|
38
40
|
end
|
39
41
|
end
|
40
42
|
|
41
|
-
|
42
|
-
|
43
|
+
def as_json(*)
|
44
|
+
attributes
|
45
|
+
end
|
46
|
+
|
47
|
+
alias to_hash attributes
|
48
|
+
alias to_h attributes
|
43
49
|
end
|
44
50
|
end
|
data/lib/burgundy/rails.rb
CHANGED
@@ -1,12 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Burgundy
|
2
4
|
module UrlMethods
|
3
5
|
def default_url_options
|
4
6
|
action_mailer_default_url_options ||
|
5
|
-
|
7
|
+
Rails.application.routes.default_url_options
|
6
8
|
end
|
7
9
|
|
8
10
|
def action_mailer_default_url_options
|
9
|
-
|
11
|
+
return unless Rails.configuration.respond_to?(:action_mailer)
|
12
|
+
|
13
|
+
Rails.configuration.action_mailer.default_url_options
|
10
14
|
end
|
11
15
|
end
|
12
16
|
|
@@ -20,7 +24,7 @@ module Burgundy
|
|
20
24
|
def helpers
|
21
25
|
ApplicationController.helpers
|
22
26
|
end
|
23
|
-
|
27
|
+
alias h helpers
|
24
28
|
end
|
25
29
|
|
26
30
|
module RouteHelpers
|
@@ -43,14 +47,14 @@ module Burgundy
|
|
43
47
|
item.to_param
|
44
48
|
end
|
45
49
|
|
46
|
-
def eql?(
|
47
|
-
|
50
|
+
def eql?(other)
|
51
|
+
other == self || item.eql?(other)
|
48
52
|
end
|
49
53
|
|
50
54
|
def routes
|
51
55
|
self.class.routes
|
52
56
|
end
|
53
|
-
|
57
|
+
alias r routes
|
54
58
|
end
|
55
59
|
|
56
60
|
class Item
|
data/lib/burgundy/version.rb
CHANGED
data/test/dummy/Rakefile
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
2
4
|
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
3
5
|
|
4
|
-
require File.expand_path(
|
6
|
+
require File.expand_path("config/application", __dir__)
|
5
7
|
|
6
8
|
Dummy::Application.load_tasks
|
data/test/dummy/bin/bundle
CHANGED
@@ -1,3 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
|
5
|
+
load Gem.bin_path("bundler", "bundle")
|
data/test/dummy/bin/rails
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
|
4
|
-
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
APP_PATH = File.expand_path("../config/application", __dir__)
|
5
|
+
require_relative "../config/boot"
|
6
|
+
require "rails/commands"
|
data/test/dummy/bin/rake
CHANGED
data/test/dummy/config.ru
CHANGED
@@ -1,8 +1,9 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require File.expand_path("boot", __dir__)
|
2
4
|
|
3
5
|
require "action_controller/railtie"
|
4
6
|
require "action_mailer/railtie"
|
5
|
-
require "sprockets/railtie"
|
6
7
|
|
7
8
|
Bundler.require(*Rails.groups)
|
8
9
|
require "burgundy"
|
@@ -11,4 +12,3 @@ module Dummy
|
|
11
12
|
class Application < Rails::Application
|
12
13
|
end
|
13
14
|
end
|
14
|
-
|
data/test/dummy/config/boot.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Set up gems listed in the Gemfile.
|
2
|
-
ENV[
|
4
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../../Gemfile", __dir__)
|
3
5
|
|
4
|
-
require
|
5
|
-
$LOAD_PATH.unshift File.expand_path(
|
6
|
+
require "bundler/setup" if File.exist?(ENV["BUNDLE_GEMFILE"])
|
7
|
+
$LOAD_PATH.unshift File.expand_path("../../../lib", __dir__)
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
Dummy::Application.configure do
|
2
4
|
# Settings specified here will take precedence over those in config/application.rb.
|
3
5
|
|
@@ -33,7 +35,7 @@ Dummy::Application.configure do
|
|
33
35
|
config.assets.digest = true
|
34
36
|
|
35
37
|
# Version of your assets, change this if you want to expire all your assets.
|
36
|
-
config.assets.version =
|
38
|
+
config.assets.version = "1.0"
|
37
39
|
|
38
40
|
# Specifies the header that your server uses for sending files.
|
39
41
|
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Be sure to restart your server when you modify this file.
|
2
4
|
|
3
5
|
# Your secret key is used for verifying the integrity of signed cookies.
|
@@ -9,4 +11,4 @@
|
|
9
11
|
|
10
12
|
# Make sure your secret_key_base is kept private
|
11
13
|
# if you're sharing your code publicly.
|
12
|
-
Dummy::Application.config.secret_key_base =
|
14
|
+
Dummy::Application.config.secret_key_base = "ad57e0c56963bee4eca9bccd6a9a0f3d5a176af9fed341f4debccbb050326066a9181b9502ea296e838548f75b7df7962268ed89c51e13466975606c8737afef"
|
data/test/dummy/config/routes.rb
CHANGED
data/test/test_helper.rb
CHANGED
data/test/unit/burgundy_test.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "test_helper"
|
2
4
|
|
3
5
|
class BurgundyTest < Minitest::Test
|
@@ -27,7 +29,8 @@ class BurgundyTest < Minitest::Test
|
|
27
29
|
end
|
28
30
|
|
29
31
|
test "deprecates Burgundy::Item.map" do
|
30
|
-
message =
|
32
|
+
message =
|
33
|
+
"Burgundy::Item.map is deprecated; use Burgundy::Item.wrap instead."
|
31
34
|
|
32
35
|
_, err = capture_io do
|
33
36
|
wrapper.map([1, 2, 3])
|
@@ -80,6 +83,12 @@ class BurgundyTest < Minitest::Test
|
|
80
83
|
assert_respond_to item, :h
|
81
84
|
end
|
82
85
|
|
86
|
+
test "makes helpers accessible" do
|
87
|
+
item = wrapper.new("hello")
|
88
|
+
|
89
|
+
assert_equal "less than a minute", item.helpers.time_ago_in_words(Time.now)
|
90
|
+
end
|
91
|
+
|
83
92
|
test "responds to the I18n methods" do
|
84
93
|
item = wrapper.new("hello")
|
85
94
|
|
@@ -96,7 +105,11 @@ class BurgundyTest < Minitest::Test
|
|
96
105
|
end
|
97
106
|
end
|
98
107
|
|
99
|
-
Rails
|
108
|
+
Rails
|
109
|
+
.configuration
|
110
|
+
.action_mailer
|
111
|
+
.default_url_options = {host: "example.com"}
|
112
|
+
|
100
113
|
item = wrapper.new OpenStruct.new(username: "johndoe")
|
101
114
|
|
102
115
|
assert_equal "http://example.com/johndoe", item.profile_url
|
@@ -115,12 +128,29 @@ class BurgundyTest < Minitest::Test
|
|
115
128
|
assert_equal "http://example.com/johndoe", item.profile_url
|
116
129
|
end
|
117
130
|
|
131
|
+
test "returns to_param" do
|
132
|
+
klass = Class.new do
|
133
|
+
def to_param
|
134
|
+
"some-param"
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
wrapper = Class.new(Burgundy::Item)
|
139
|
+
item = wrapper.new(klass.new)
|
140
|
+
|
141
|
+
assert_equal "some-param", item.to_param
|
142
|
+
end
|
143
|
+
|
118
144
|
test "returns attributes" do
|
119
145
|
wrapper = Class.new(Burgundy::Item) do
|
120
146
|
attributes :name, :email
|
121
147
|
end
|
122
148
|
|
123
|
-
object = OpenStruct.new(
|
149
|
+
object = OpenStruct.new(
|
150
|
+
name: "John Doe",
|
151
|
+
email: "john@example.com",
|
152
|
+
username: "johndoe"
|
153
|
+
)
|
124
154
|
item = wrapper.new(object)
|
125
155
|
|
126
156
|
expected = {name: "John Doe", email: "john@example.com"}
|
@@ -130,7 +160,7 @@ class BurgundyTest < Minitest::Test
|
|
130
160
|
|
131
161
|
test "returns remaps attribute" do
|
132
162
|
wrapper = Class.new(Burgundy::Item) do
|
133
|
-
attributes :name, :
|
163
|
+
attributes :name, username: :login
|
134
164
|
end
|
135
165
|
|
136
166
|
object = OpenStruct.new(name: "John Doe", username: "johndoe")
|
@@ -141,16 +171,22 @@ class BurgundyTest < Minitest::Test
|
|
141
171
|
assert_equal expected, item.attributes
|
142
172
|
end
|
143
173
|
|
144
|
-
test "implements to_hash/to_h
|
174
|
+
test "implements to_hash/to_h/as_json protocols" do
|
145
175
|
wrapper = Class.new(Burgundy::Item) do
|
146
176
|
attributes :name, :email
|
147
177
|
end
|
148
178
|
|
149
|
-
object = OpenStruct.new(
|
179
|
+
object = OpenStruct.new(
|
180
|
+
name: "John Doe",
|
181
|
+
email: "john@example.com",
|
182
|
+
username: "johndoe"
|
183
|
+
)
|
150
184
|
item = wrapper.new(object)
|
151
185
|
|
152
186
|
assert_equal item.to_hash, item.attributes
|
153
187
|
assert_equal item.to_h, item.attributes
|
188
|
+
assert_equal item.as_json, item.attributes
|
189
|
+
assert_equal item.as_json(:name), item.attributes
|
154
190
|
end
|
155
191
|
|
156
192
|
test "inherits attributes" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: burgundy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nando Vieira
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-12-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -80,6 +80,34 @@ dependencies:
|
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rubocop
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rubocop-fnando
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
83
111
|
- !ruby/object:Gem::Dependency
|
84
112
|
name: simplecov
|
85
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,8 +122,7 @@ dependencies:
|
|
94
122
|
- - ">="
|
95
123
|
- !ruby/object:Gem::Version
|
96
124
|
version: '0'
|
97
|
-
description: A simple wrapper for objects
|
98
|
-
in less than 100 lines.
|
125
|
+
description: A simple wrapper for objects in less than 100 lines.
|
99
126
|
email:
|
100
127
|
- fnando.vieira@gmail.com
|
101
128
|
executables: []
|
@@ -103,8 +130,10 @@ extensions: []
|
|
103
130
|
extra_rdoc_files: []
|
104
131
|
files:
|
105
132
|
- ".gitignore"
|
133
|
+
- ".rubocop.yml"
|
106
134
|
- ".travis.yml"
|
107
135
|
- CHANGELOG.md
|
136
|
+
- CODE_OF_CONDUCT.md
|
108
137
|
- Gemfile
|
109
138
|
- LICENSE.txt
|
110
139
|
- README.md
|
@@ -175,12 +204,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
175
204
|
- !ruby/object:Gem::Version
|
176
205
|
version: '0'
|
177
206
|
requirements: []
|
178
|
-
|
179
|
-
rubygems_version: 2.7.6
|
207
|
+
rubygems_version: 3.0.3
|
180
208
|
signing_key:
|
181
209
|
specification_version: 4
|
182
|
-
summary: A simple wrapper for objects
|
183
|
-
in less than 100 lines.
|
210
|
+
summary: A simple wrapper for objects in less than 100 lines.
|
184
211
|
test_files:
|
185
212
|
- test/dummy/README.rdoc
|
186
213
|
- test/dummy/Rakefile
|