burgundy 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +1 -0
  3. data/.travis.yml +12 -2
  4. data/Gemfile +1 -1
  5. data/README.md +4 -1
  6. data/Rakefile +7 -3
  7. data/burgundy.gemspec +15 -16
  8. data/lib/burgundy.rb +5 -5
  9. data/lib/burgundy/collection.rb +8 -7
  10. data/lib/burgundy/item.rb +2 -2
  11. data/lib/burgundy/version.rb +1 -1
  12. data/{spec → test}/dummy/README.rdoc +0 -0
  13. data/{spec → test}/dummy/Rakefile +0 -0
  14. data/{spec → test}/dummy/app/assets/images/.keep +0 -0
  15. data/{spec → test}/dummy/app/assets/javascripts/application.js +0 -0
  16. data/{spec → test}/dummy/app/assets/stylesheets/application.css +0 -0
  17. data/{spec → test}/dummy/app/controllers/application_controller.rb +0 -0
  18. data/{spec → test}/dummy/app/controllers/concerns/.keep +0 -0
  19. data/{spec → test}/dummy/app/helpers/application_helper.rb +0 -0
  20. data/{spec → test}/dummy/app/mailers/.keep +0 -0
  21. data/{spec → test}/dummy/app/models/.keep +0 -0
  22. data/{spec → test}/dummy/app/models/concerns/.keep +0 -0
  23. data/{spec → test}/dummy/app/views/layouts/application.html.erb +0 -0
  24. data/{spec → test}/dummy/app/views/site/contact.html.erb +0 -0
  25. data/{spec → test}/dummy/bin/bundle +0 -0
  26. data/{spec → test}/dummy/bin/rails +0 -0
  27. data/{spec → test}/dummy/bin/rake +0 -0
  28. data/{spec → test}/dummy/config.ru +0 -0
  29. data/{spec → test}/dummy/config/application.rb +0 -0
  30. data/{spec → test}/dummy/config/boot.rb +0 -0
  31. data/{spec → test}/dummy/config/database.yml +0 -0
  32. data/{spec → test}/dummy/config/environment.rb +0 -0
  33. data/{spec → test}/dummy/config/environments/development.rb +0 -0
  34. data/{spec → test}/dummy/config/environments/production.rb +0 -0
  35. data/{spec → test}/dummy/config/environments/test.rb +1 -0
  36. data/{spec → test}/dummy/config/initializers/backtrace_silencers.rb +0 -0
  37. data/{spec → test}/dummy/config/initializers/filter_parameter_logging.rb +0 -0
  38. data/{spec → test}/dummy/config/initializers/inflections.rb +0 -0
  39. data/{spec → test}/dummy/config/initializers/mime_types.rb +0 -0
  40. data/{spec → test}/dummy/config/initializers/secret_token.rb +0 -0
  41. data/{spec → test}/dummy/config/initializers/session_store.rb +0 -0
  42. data/{spec → test}/dummy/config/initializers/wrap_parameters.rb +0 -0
  43. data/{spec → test}/dummy/config/locales/en.yml +0 -0
  44. data/{spec → test}/dummy/config/routes.rb +0 -0
  45. data/{spec → test}/dummy/lib/assets/.keep +0 -0
  46. data/{spec → test}/dummy/log/.keep +0 -0
  47. data/{spec → test}/dummy/public/404.html +0 -0
  48. data/{spec → test}/dummy/public/422.html +0 -0
  49. data/{spec → test}/dummy/public/500.html +0 -0
  50. data/{spec → test}/dummy/public/favicon.ico +0 -0
  51. data/test/test_helper.rb +26 -0
  52. data/test/unit/burgundy_test.rb +186 -0
  53. metadata +94 -97
  54. data/.rspec +0 -1
  55. data/spec/burgundy_spec.rb +0 -154
  56. data/spec/dummy/log/test.log +0 -45
  57. data/spec/spec_helper.rb +0 -19
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: a912d242cbf7bad7a67bef01678a5964279965fc
4
- data.tar.gz: 0633c91f18a8eee40f4f328a3d1a0181266dd73b
2
+ SHA256:
3
+ metadata.gz: 627aed370f1235851c0330858cb8132589b2763dd1e98ce217950a4e3f610285
4
+ data.tar.gz: 83c93daace0616835204810154b38b34c3ac9f325ca08d1dc4656118a2c30597
5
5
  SHA512:
6
- metadata.gz: d2f2258741ebac195140cde6d01af8114d304106d74f0c26f7bc8a3cb07401c8d00141dc899cf1cf62520c157f152ea2367b2b43306e5163bc29a9d6fe29903f
7
- data.tar.gz: b4b6d4977c7b71b43499f8ea3c7590257a3882dfa1d14351db00fc1f8c037893bae9c09f5d2bcf94f92b39cd3fffefdc73de939db97ab66e34ccde639127c172
6
+ metadata.gz: 1c732548588122cda059ec94dbab67f6e3a722249df688f339b812a75ba45e0d1809538771a2f9979f7fc08ae07f360c70969363d426047c82a8405c6cf9eaa7
7
+ data.tar.gz: 5dc524c77481653f1949e79ed8981e00cd9e1cfa1ab44781bdcd0ab2ef15b6e32bb9ed9fc1c0cf2ce6299c839b0f81a792f6419df1beaec20499e112d9da3e08
data/.gitignore CHANGED
@@ -15,3 +15,4 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
+ *.log
@@ -1,6 +1,16 @@
1
1
  language: ruby
2
2
  sudo: false
3
3
  cache: bundler
4
+ notifications:
5
+ email: false
4
6
  rvm:
5
- - '2.1'
6
- - '2.2'
7
+ - 2.5.2
8
+ 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"
12
+ after_script:
13
+ - "./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT"
14
+ env:
15
+ global:
16
+ secure: LIU2voUl12O5yOXGTwOFOJgdv49YOpFN4FyH3Eqvc48tvy3cRypMuqvFiG/KL4jQvE2IydZZmG+DtsgTsi6kOe5cYlxeU2fTiK9dflNqBIV7+CfwXqguUAcwJLW1dt6Gtmis2VuOffJDBqpojTpFDrUosDdISc1gkOXh4+8yHQA=
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in burgundy.gemspec
4
4
  gemspec
data/README.md CHANGED
@@ -1,7 +1,10 @@
1
1
  # Burgundy
2
2
 
3
- [![Build Status](https://travis-ci.org/fnando/burgundy.svg)](https://travis-ci.org/fnando/burgundy)
3
+ [![Travis-CI](https://travis-ci.org/fnando/burgundy.svg)](https://travis-ci.org/fnando/burgundy)
4
4
  [![Code Climate](https://codeclimate.com/github/fnando/burgundy/badges/gpa.svg)](https://codeclimate.com/github/fnando/burgundy)
5
+ [![Test Coverage](https://codeclimate.com/github/fnando/burgundy/badges/coverage.svg)](https://codeclimate.com/github/fnando/burgundy/coverage)
6
+ [![Gem](https://img.shields.io/gem/v/burgundy.svg)](https://rubygems.org/gems/burgundy)
7
+ [![Gem](https://img.shields.io/gem/dt/burgundy.svg)](https://rubygems.org/gems/burgundy)
5
8
 
6
9
  A simple wrapper for objects (think of Burgundy as a decorator/presenter) in less than 150 lines.
7
10
 
data/Rakefile CHANGED
@@ -1,6 +1,10 @@
1
1
  require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
2
+ require "rake/testtask"
3
3
 
4
- RSpec::Core::RakeTask.new(:spec)
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.test_files = FileList["test/**/*_test.rb"]
7
+ t.warning = false
8
+ end
5
9
 
6
- task :default => :spec
10
+ task :default => :test
@@ -1,25 +1,24 @@
1
- require './lib/burgundy/version'
1
+ require "./lib/burgundy/version"
2
2
 
3
3
  Gem::Specification.new do |spec|
4
- spec.required_ruby_version = '>= 2.1.0'
5
- spec.name = 'burgundy'
4
+ spec.name = "burgundy"
6
5
  spec.version = Burgundy::VERSION
7
- spec.authors = ['Nando Vieira']
8
- spec.email = ['fnando.vieira@gmail.com']
9
- spec.description = 'A simple wrapper for objects (think of Burgundy as a decorator/presenter) in less than 100 lines.'
6
+ spec.authors = ["Nando Vieira"]
7
+ spec.email = ["fnando.vieira@gmail.com"]
8
+ spec.description = "A simple wrapper for objects (think of Burgundy as a decorator/presenter) in less than 100 lines."
10
9
  spec.summary = spec.description
11
- spec.homepage = 'http://github.com/fnando/burgundy'
12
- spec.license = 'MIT'
10
+ spec.homepage = "http://github.com/fnando/burgundy"
11
+ spec.license = "MIT"
13
12
 
14
13
  spec.files = `git ls-files`.split($/)
15
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
14
+ spec.executables = spec.files.grep(%r{^bin/}) {|f| File.basename(f) }
16
15
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
17
- spec.require_paths = ['lib']
16
+ spec.require_paths = ["lib"]
18
17
 
19
- spec.add_development_dependency 'bundler', '~> 1.3'
20
- spec.add_development_dependency 'rake'
21
- spec.add_development_dependency 'rspec'
22
- spec.add_development_dependency 'rails'
23
- spec.add_development_dependency 'rspec-rails'
24
- spec.add_development_dependency 'pry-meta'
18
+ spec.add_development_dependency "bundler"
19
+ spec.add_development_dependency "minitest-utils"
20
+ spec.add_development_dependency "pry-meta"
21
+ spec.add_development_dependency "rails"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "simplecov"
25
24
  end
@@ -1,5 +1,5 @@
1
- require 'delegate'
2
- require 'burgundy/version'
3
- require 'burgundy/item'
4
- require 'burgundy/collection'
5
- require 'burgundy/rails' if defined?(Rails)
1
+ require "delegate"
2
+ require "burgundy/version"
3
+ require "burgundy/item"
4
+ require "burgundy/collection"
5
+ require "burgundy/rails" if defined?(Rails)
@@ -1,20 +1,21 @@
1
1
  module Burgundy
2
- class Collection < SimpleDelegator
3
- include Enumerable
4
-
2
+ class Collection
5
3
  def initialize(items, wrapping_class = nil, *args)
6
4
  @items = items
7
5
  @wrapping_class = wrapping_class
8
6
  @args = args
9
- __setobj__(@items)
10
7
  end
11
8
 
12
- def each(&block)
13
- to_ary.each(&block)
9
+ def method_missing(name, *args, &block)
10
+ to_ary.send(name, *args, &block)
11
+ end
12
+
13
+ def respond_to?(name, include_all = false)
14
+ to_ary.respond_to?(name, include_all)
14
15
  end
15
16
 
16
17
  def to_ary
17
- @cache ||= if @wrapping_class
18
+ @to_ary ||= if @wrapping_class
18
19
  @items.map {|item| @wrapping_class.new(item, *@args) }
19
20
  else
20
21
  @items.to_a
@@ -11,7 +11,7 @@ module Burgundy
11
11
  end
12
12
 
13
13
  def self.map(collection)
14
- warn 'Burgundy::Item.map is deprecated; use Burgundy::Item.wrap instead.'
14
+ warn "Burgundy::Item.map is deprecated; use Burgundy::Item.wrap instead."
15
15
  wrap(collection)
16
16
  end
17
17
 
@@ -20,7 +20,7 @@ module Burgundy
20
20
 
21
21
  if args.any?
22
22
  @attributes = {}
23
- @attributes = args.pop if args.last.kind_of?(Hash)
23
+ @attributes = args.pop if args.last.is_a?(Hash)
24
24
  @attributes.merge!(args.zip(args).to_h)
25
25
  end
26
26
 
@@ -1,3 +1,3 @@
1
1
  module Burgundy
2
- VERSION = '0.2.0'
2
+ VERSION = "0.3.0"
3
3
  end
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -28,4 +28,5 @@ Dummy::Application.configure do
28
28
 
29
29
  # Print deprecation notices to the stderr.
30
30
  config.active_support.deprecation = :stderr
31
+ config.active_support.test_order = :random
31
32
  end
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,26 @@
1
+ require "simplecov"
2
+ SimpleCov.start do
3
+ add_filter "/test/"
4
+ end
5
+
6
+ require "bundler/setup"
7
+ Bundler.setup
8
+
9
+ require "minitest/utils"
10
+ require "minitest/autorun"
11
+
12
+ ENV["RAILS_ENV"] = "test"
13
+
14
+ require File.expand_path("dummy/config/environment.rb", __dir__)
15
+
16
+ require "burgundy"
17
+ I18n.locale = :en
18
+
19
+ class ItemWithAdditionalArgs < Burgundy::Item
20
+ attr_reader :args
21
+
22
+ def initialize(target, *args)
23
+ super(target)
24
+ @args = args
25
+ end
26
+ end
@@ -0,0 +1,186 @@
1
+ require "test_helper"
2
+
3
+ class BurgundyTest < Minitest::Test
4
+ let(:wrapper) { Class.new(Burgundy::Item) }
5
+ let(:wrapper_with_args) { ItemWithAdditionalArgs }
6
+
7
+ test "delegates everything" do
8
+ item = wrapper.new("hello")
9
+ assert_equal "HELLO", item.upcase
10
+ end
11
+
12
+ test "wraps items" do
13
+ items = wrapper.wrap([1, 2, 3])
14
+
15
+ assert_equal Burgundy::Collection, items.class
16
+ assert_kind_of wrapper, items.first
17
+ assert_equal 1, items.first.to_i
18
+ end
19
+
20
+ test "wraps items with additional arguments" do
21
+ items = wrapper_with_args.wrap([1], 2, 3)
22
+
23
+ assert_equal Burgundy::Collection, items.class
24
+ assert_kind_of wrapper_with_args, items.first
25
+ assert_equal 1, items.first.item
26
+ assert_equal [2, 3], items.first.args
27
+ end
28
+
29
+ test "deprecates Burgundy::Item.map" do
30
+ message = "Burgundy::Item.map is deprecated; use Burgundy::Item.wrap instead."
31
+
32
+ _, err = capture_io do
33
+ wrapper.map([1, 2, 3])
34
+ end
35
+
36
+ assert err.include?(message)
37
+ end
38
+
39
+ test "wraps items in collection" do
40
+ collection = Burgundy::Collection.new([1, 2, 3], wrapper)
41
+ assert_equal 1, collection.first
42
+ end
43
+
44
+ test "delegates collection calls" do
45
+ collection = Burgundy::Collection.new([1, 2, 3], wrapper)
46
+ assert_equal 3, collection.size
47
+ end
48
+
49
+ test "collection uses to_a result when have no wrapper class" do
50
+ items = Class.new do
51
+ def to_a
52
+ [1, 2, 3]
53
+ end
54
+ end.new
55
+
56
+ collection = Burgundy::Collection.new(items)
57
+
58
+ assert_equal [1, 2, 3], collection.to_ary
59
+ end
60
+
61
+ test "implements #empty?" do
62
+ collection = Burgundy::Collection.new([1, 2, 3])
63
+ refute collection.empty?
64
+
65
+ collection = Burgundy::Collection.new([])
66
+ assert collection.empty?
67
+ end
68
+
69
+ test "responds to the routes method" do
70
+ item = wrapper.new("hello")
71
+
72
+ assert_respond_to item, :routes
73
+ assert_respond_to item, :r
74
+ end
75
+
76
+ test "responds to the helpers method" do
77
+ item = wrapper.new("hello")
78
+
79
+ assert_respond_to item, :helpers
80
+ assert_respond_to item, :h
81
+ end
82
+
83
+ test "responds to the I18n methods" do
84
+ item = wrapper.new("hello")
85
+
86
+ assert_respond_to item, :translate
87
+ assert_respond_to item, :t
88
+ assert_respond_to item, :localize
89
+ assert_respond_to item, :l
90
+ end
91
+
92
+ test "returns route using action mailer options" do
93
+ wrapper = Class.new(Burgundy::Item) do
94
+ def profile_url
95
+ routes.profile_url(username)
96
+ end
97
+ end
98
+
99
+ Rails.configuration.action_mailer.default_url_options = {host: "example.com"}
100
+ item = wrapper.new OpenStruct.new(username: "johndoe")
101
+
102
+ assert_equal "http://example.com/johndoe", item.profile_url
103
+ end
104
+
105
+ test "returns route using action controller options" do
106
+ wrapper = Class.new(Burgundy::Item) do
107
+ def profile_url
108
+ routes.profile_url(username)
109
+ end
110
+ end
111
+
112
+ Rails.application.routes.default_url_options = {host: "example.com"}
113
+ item = wrapper.new OpenStruct.new(username: "johndoe")
114
+
115
+ assert_equal "http://example.com/johndoe", item.profile_url
116
+ end
117
+
118
+ test "returns attributes" do
119
+ wrapper = Class.new(Burgundy::Item) do
120
+ attributes :name, :email
121
+ end
122
+
123
+ object = OpenStruct.new(name: "John Doe", email: "john@example.com", username: "johndoe")
124
+ item = wrapper.new(object)
125
+
126
+ expected = {name: "John Doe", email: "john@example.com"}
127
+
128
+ assert_equal expected, item.attributes
129
+ end
130
+
131
+ test "returns remaps attribute" do
132
+ wrapper = Class.new(Burgundy::Item) do
133
+ attributes :name, :username => :login
134
+ end
135
+
136
+ object = OpenStruct.new(name: "John Doe", username: "johndoe")
137
+ item = wrapper.new(object)
138
+
139
+ expected = {name: "John Doe", login: "johndoe"}
140
+
141
+ assert_equal expected, item.attributes
142
+ end
143
+
144
+ test "implements to_hash/to_h protocol" do
145
+ wrapper = Class.new(Burgundy::Item) do
146
+ attributes :name, :email
147
+ end
148
+
149
+ object = OpenStruct.new(name: "John Doe", email: "john@example.com", username: "johndoe")
150
+ item = wrapper.new(object)
151
+
152
+ assert_equal item.to_hash, item.attributes
153
+ assert_equal item.to_h, item.attributes
154
+ end
155
+
156
+ test "inherits attributes" do
157
+ parent_wrapper = Class.new(Burgundy::Item) do
158
+ attributes :name, :username
159
+ end
160
+
161
+ wrapper = Class.new(parent_wrapper)
162
+ object = OpenStruct.new(name: "John Doe", username: "johndoe")
163
+ item = wrapper.new(object)
164
+
165
+ expected = {name: "John Doe", username: "johndoe"}
166
+
167
+ assert_equal expected, item.attributes
168
+ end
169
+
170
+ test "always wrap items fetched from collection" do
171
+ wrapper = Class.new(Burgundy::Item)
172
+ collection = wrapper.wrap([1])
173
+
174
+ assert_kind_of wrapper, collection[0]
175
+ assert_kind_of wrapper, collection.fetch(0)
176
+ assert_kind_of wrapper, collection.at(0)
177
+ end
178
+
179
+ test "responds to methods present on the underying wrapped object" do
180
+ wrapper = Class.new(Burgundy::Item)
181
+ collection = wrapper.wrap([1])
182
+
183
+ assert collection.respond_to?(:first)
184
+ refute collection.respond_to?(:missing)
185
+ end
186
+ end
metadata CHANGED
@@ -1,31 +1,31 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: burgundy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.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: 2015-10-14 00:00:00.000000000 Z
11
+ date: 2018-12-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '1.3'
19
+ version: '0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '1.3'
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: rake
28
+ name: minitest-utils
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
@@ -39,7 +39,7 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: rspec
42
+ name: pry-meta
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
@@ -67,7 +67,7 @@ dependencies:
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: rspec-rails
70
+ name: rake
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - ">="
@@ -81,7 +81,7 @@ dependencies:
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
- name: pry-meta
84
+ name: simplecov
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - ">="
@@ -103,7 +103,6 @@ extensions: []
103
103
  extra_rdoc_files: []
104
104
  files:
105
105
  - ".gitignore"
106
- - ".rspec"
107
106
  - ".travis.yml"
108
107
  - CHANGELOG.md
109
108
  - Gemfile
@@ -116,48 +115,47 @@ files:
116
115
  - lib/burgundy/item.rb
117
116
  - lib/burgundy/rails.rb
118
117
  - lib/burgundy/version.rb
119
- - spec/burgundy_spec.rb
120
- - spec/dummy/README.rdoc
121
- - spec/dummy/Rakefile
122
- - spec/dummy/app/assets/images/.keep
123
- - spec/dummy/app/assets/javascripts/application.js
124
- - spec/dummy/app/assets/stylesheets/application.css
125
- - spec/dummy/app/controllers/application_controller.rb
126
- - spec/dummy/app/controllers/concerns/.keep
127
- - spec/dummy/app/helpers/application_helper.rb
128
- - spec/dummy/app/mailers/.keep
129
- - spec/dummy/app/models/.keep
130
- - spec/dummy/app/models/concerns/.keep
131
- - spec/dummy/app/views/layouts/application.html.erb
132
- - spec/dummy/app/views/site/contact.html.erb
133
- - spec/dummy/bin/bundle
134
- - spec/dummy/bin/rails
135
- - spec/dummy/bin/rake
136
- - spec/dummy/config.ru
137
- - spec/dummy/config/application.rb
138
- - spec/dummy/config/boot.rb
139
- - spec/dummy/config/database.yml
140
- - spec/dummy/config/environment.rb
141
- - spec/dummy/config/environments/development.rb
142
- - spec/dummy/config/environments/production.rb
143
- - spec/dummy/config/environments/test.rb
144
- - spec/dummy/config/initializers/backtrace_silencers.rb
145
- - spec/dummy/config/initializers/filter_parameter_logging.rb
146
- - spec/dummy/config/initializers/inflections.rb
147
- - spec/dummy/config/initializers/mime_types.rb
148
- - spec/dummy/config/initializers/secret_token.rb
149
- - spec/dummy/config/initializers/session_store.rb
150
- - spec/dummy/config/initializers/wrap_parameters.rb
151
- - spec/dummy/config/locales/en.yml
152
- - spec/dummy/config/routes.rb
153
- - spec/dummy/lib/assets/.keep
154
- - spec/dummy/log/.keep
155
- - spec/dummy/log/test.log
156
- - spec/dummy/public/404.html
157
- - spec/dummy/public/422.html
158
- - spec/dummy/public/500.html
159
- - spec/dummy/public/favicon.ico
160
- - spec/spec_helper.rb
118
+ - test/dummy/README.rdoc
119
+ - test/dummy/Rakefile
120
+ - test/dummy/app/assets/images/.keep
121
+ - test/dummy/app/assets/javascripts/application.js
122
+ - test/dummy/app/assets/stylesheets/application.css
123
+ - test/dummy/app/controllers/application_controller.rb
124
+ - test/dummy/app/controllers/concerns/.keep
125
+ - test/dummy/app/helpers/application_helper.rb
126
+ - test/dummy/app/mailers/.keep
127
+ - test/dummy/app/models/.keep
128
+ - test/dummy/app/models/concerns/.keep
129
+ - test/dummy/app/views/layouts/application.html.erb
130
+ - test/dummy/app/views/site/contact.html.erb
131
+ - test/dummy/bin/bundle
132
+ - test/dummy/bin/rails
133
+ - test/dummy/bin/rake
134
+ - test/dummy/config.ru
135
+ - test/dummy/config/application.rb
136
+ - test/dummy/config/boot.rb
137
+ - test/dummy/config/database.yml
138
+ - test/dummy/config/environment.rb
139
+ - test/dummy/config/environments/development.rb
140
+ - test/dummy/config/environments/production.rb
141
+ - test/dummy/config/environments/test.rb
142
+ - test/dummy/config/initializers/backtrace_silencers.rb
143
+ - test/dummy/config/initializers/filter_parameter_logging.rb
144
+ - test/dummy/config/initializers/inflections.rb
145
+ - test/dummy/config/initializers/mime_types.rb
146
+ - test/dummy/config/initializers/secret_token.rb
147
+ - test/dummy/config/initializers/session_store.rb
148
+ - test/dummy/config/initializers/wrap_parameters.rb
149
+ - test/dummy/config/locales/en.yml
150
+ - test/dummy/config/routes.rb
151
+ - test/dummy/lib/assets/.keep
152
+ - test/dummy/log/.keep
153
+ - test/dummy/public/404.html
154
+ - test/dummy/public/422.html
155
+ - test/dummy/public/500.html
156
+ - test/dummy/public/favicon.ico
157
+ - test/test_helper.rb
158
+ - test/unit/burgundy_test.rb
161
159
  homepage: http://github.com/fnando/burgundy
162
160
  licenses:
163
161
  - MIT
@@ -170,7 +168,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
170
168
  requirements:
171
169
  - - ">="
172
170
  - !ruby/object:Gem::Version
173
- version: 2.1.0
171
+ version: '0'
174
172
  required_rubygems_version: !ruby/object:Gem::Requirement
175
173
  requirements:
176
174
  - - ">="
@@ -178,51 +176,50 @@ required_rubygems_version: !ruby/object:Gem::Requirement
178
176
  version: '0'
179
177
  requirements: []
180
178
  rubyforge_project:
181
- rubygems_version: 2.4.5.1
179
+ rubygems_version: 2.7.6
182
180
  signing_key:
183
181
  specification_version: 4
184
182
  summary: A simple wrapper for objects (think of Burgundy as a decorator/presenter)
185
183
  in less than 100 lines.
186
184
  test_files:
187
- - spec/burgundy_spec.rb
188
- - spec/dummy/README.rdoc
189
- - spec/dummy/Rakefile
190
- - spec/dummy/app/assets/images/.keep
191
- - spec/dummy/app/assets/javascripts/application.js
192
- - spec/dummy/app/assets/stylesheets/application.css
193
- - spec/dummy/app/controllers/application_controller.rb
194
- - spec/dummy/app/controllers/concerns/.keep
195
- - spec/dummy/app/helpers/application_helper.rb
196
- - spec/dummy/app/mailers/.keep
197
- - spec/dummy/app/models/.keep
198
- - spec/dummy/app/models/concerns/.keep
199
- - spec/dummy/app/views/layouts/application.html.erb
200
- - spec/dummy/app/views/site/contact.html.erb
201
- - spec/dummy/bin/bundle
202
- - spec/dummy/bin/rails
203
- - spec/dummy/bin/rake
204
- - spec/dummy/config.ru
205
- - spec/dummy/config/application.rb
206
- - spec/dummy/config/boot.rb
207
- - spec/dummy/config/database.yml
208
- - spec/dummy/config/environment.rb
209
- - spec/dummy/config/environments/development.rb
210
- - spec/dummy/config/environments/production.rb
211
- - spec/dummy/config/environments/test.rb
212
- - spec/dummy/config/initializers/backtrace_silencers.rb
213
- - spec/dummy/config/initializers/filter_parameter_logging.rb
214
- - spec/dummy/config/initializers/inflections.rb
215
- - spec/dummy/config/initializers/mime_types.rb
216
- - spec/dummy/config/initializers/secret_token.rb
217
- - spec/dummy/config/initializers/session_store.rb
218
- - spec/dummy/config/initializers/wrap_parameters.rb
219
- - spec/dummy/config/locales/en.yml
220
- - spec/dummy/config/routes.rb
221
- - spec/dummy/lib/assets/.keep
222
- - spec/dummy/log/.keep
223
- - spec/dummy/log/test.log
224
- - spec/dummy/public/404.html
225
- - spec/dummy/public/422.html
226
- - spec/dummy/public/500.html
227
- - spec/dummy/public/favicon.ico
228
- - spec/spec_helper.rb
185
+ - test/dummy/README.rdoc
186
+ - test/dummy/Rakefile
187
+ - test/dummy/app/assets/images/.keep
188
+ - test/dummy/app/assets/javascripts/application.js
189
+ - test/dummy/app/assets/stylesheets/application.css
190
+ - test/dummy/app/controllers/application_controller.rb
191
+ - test/dummy/app/controllers/concerns/.keep
192
+ - test/dummy/app/helpers/application_helper.rb
193
+ - test/dummy/app/mailers/.keep
194
+ - test/dummy/app/models/.keep
195
+ - test/dummy/app/models/concerns/.keep
196
+ - test/dummy/app/views/layouts/application.html.erb
197
+ - test/dummy/app/views/site/contact.html.erb
198
+ - test/dummy/bin/bundle
199
+ - test/dummy/bin/rails
200
+ - test/dummy/bin/rake
201
+ - test/dummy/config.ru
202
+ - test/dummy/config/application.rb
203
+ - test/dummy/config/boot.rb
204
+ - test/dummy/config/database.yml
205
+ - test/dummy/config/environment.rb
206
+ - test/dummy/config/environments/development.rb
207
+ - test/dummy/config/environments/production.rb
208
+ - test/dummy/config/environments/test.rb
209
+ - test/dummy/config/initializers/backtrace_silencers.rb
210
+ - test/dummy/config/initializers/filter_parameter_logging.rb
211
+ - test/dummy/config/initializers/inflections.rb
212
+ - test/dummy/config/initializers/mime_types.rb
213
+ - test/dummy/config/initializers/secret_token.rb
214
+ - test/dummy/config/initializers/session_store.rb
215
+ - test/dummy/config/initializers/wrap_parameters.rb
216
+ - test/dummy/config/locales/en.yml
217
+ - test/dummy/config/routes.rb
218
+ - test/dummy/lib/assets/.keep
219
+ - test/dummy/log/.keep
220
+ - test/dummy/public/404.html
221
+ - test/dummy/public/422.html
222
+ - test/dummy/public/500.html
223
+ - test/dummy/public/favicon.ico
224
+ - test/test_helper.rb
225
+ - test/unit/burgundy_test.rb
data/.rspec DELETED
@@ -1 +0,0 @@
1
- --color
@@ -1,154 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Burgundy do
4
- let(:wrapper) { Class.new(Burgundy::Item) }
5
- let(:wrapper_with_args) { ItemWithAdditionalArgs }
6
-
7
- it 'delegates everything' do
8
- item = wrapper.new('hello')
9
- expect(item.upcase).to eql('HELLO')
10
- end
11
-
12
- it 'wraps items' do
13
- items = wrapper.wrap([1,2,3])
14
-
15
- expect(items.class).to eql(Burgundy::Collection)
16
- expect(items.first).to be_a(wrapper)
17
- expect(items.first.to_i).to eql(1)
18
- end
19
-
20
- it 'wraps items with additional arguments' do
21
- items = wrapper_with_args.wrap([1], 2, 3)
22
-
23
- expect(items.class).to eql(Burgundy::Collection)
24
- expect(items.first).to be_a(wrapper_with_args)
25
- expect(items.first.item).to eql(1)
26
- expect(items.first.args).to eql([2, 3])
27
- end
28
-
29
- it 'deprecates Burgundy::Item.map' do
30
- message = 'Burgundy::Item.map is deprecated; use Burgundy::Item.wrap instead.'
31
- expect(wrapper).to receive(:warn).with(message)
32
- wrapper.map([1,2,3])
33
- end
34
-
35
- it 'wraps items in collection' do
36
- collection = Burgundy::Collection.new([1,2,3], wrapper)
37
- expect(collection.first).to eql(1)
38
- end
39
-
40
- it 'wraps items with additional arguments' do
41
- collection = Burgundy::Collection.new([1], wrapper_with_args, 2, 3)
42
-
43
- expect(collection.first.item).to eq(1)
44
- expect(collection.first.args).to eq([2, 3])
45
- end
46
-
47
- it 'delegates collection calls' do
48
- collection = Burgundy::Collection.new([1,2,3], wrapper)
49
- expect(collection.size).to eql(3)
50
- end
51
-
52
- it 'includes Enumerable' do
53
- expect(Burgundy::Collection).to include(Enumerable)
54
- end
55
-
56
- it 'implements #empty?' do
57
- collection = Burgundy::Collection.new([1,2,3])
58
- expect(collection).not_to be_empty
59
-
60
- collection = Burgundy::Collection.new([])
61
- expect(collection).to be_empty
62
- end
63
-
64
- it 'responds to the routes method' do
65
- item = wrapper.new('hello')
66
-
67
- expect(item).to respond_to(:routes)
68
- expect(item).to respond_to(:r)
69
- end
70
-
71
- it 'responds to the helpers method' do
72
- item = wrapper.new('hello')
73
-
74
- expect(item).to respond_to(:helpers)
75
- expect(item).to respond_to(:h)
76
- end
77
-
78
- it 'responds to the I18n methods' do
79
- item = wrapper.new('hello')
80
-
81
- expect(item).to respond_to(:translate)
82
- expect(item).to respond_to(:t)
83
- expect(item).to respond_to(:localize)
84
- expect(item).to respond_to(:l)
85
- end
86
-
87
- it 'returns route using action mailer options' do
88
- wrapper = Class.new(Burgundy::Item) do
89
- def profile_url; routes.profile_url(username) end
90
- end
91
-
92
- Rails.configuration.action_mailer.default_url_options = {host: 'example.org'}
93
- item = wrapper.new OpenStruct.new(username: 'johndoe')
94
-
95
- expect(item.profile_url).to eql('http://example.org/johndoe')
96
- end
97
-
98
- it 'returns route using action controller options' do
99
- wrapper = Class.new(Burgundy::Item) do
100
- def profile_url; routes.profile_url(username) end
101
- end
102
-
103
- Rails.application.routes.default_url_options = {host: 'example.org'}
104
- item = wrapper.new OpenStruct.new(username: 'johndoe')
105
-
106
- expect(item.profile_url).to eql('http://example.org/johndoe')
107
- end
108
-
109
- it 'returns attributes' do
110
- wrapper = Class.new(Burgundy::Item) do
111
- attributes :name, :email
112
- end
113
-
114
- object = OpenStruct.new(name: 'John Doe', email: 'john@example.org', username: 'johndoe')
115
- item = wrapper.new(object)
116
-
117
- expect(item.attributes).to eq(name: 'John Doe', email: 'john@example.org')
118
- end
119
-
120
- it 'returns remaps attribute' do
121
- wrapper = Class.new(Burgundy::Item) do
122
- attributes :name, :username => :login
123
- end
124
-
125
- object = OpenStruct.new(name: 'John Doe', username: 'johndoe')
126
- item = wrapper.new(object)
127
-
128
- expect(item.attributes).to eq(name: 'John Doe', login: 'johndoe')
129
- end
130
-
131
- it 'implements to_hash/to_h protocol' do
132
- wrapper = Class.new(Burgundy::Item) do
133
- attributes :name, :email
134
- end
135
-
136
- object = OpenStruct.new(name: 'John Doe', email: 'john@example.org', username: 'johndoe')
137
- item = wrapper.new(object)
138
-
139
- expect(item.attributes).to eq(item.to_hash)
140
- expect(item.attributes).to eq(item.to_h)
141
- end
142
-
143
- it 'inherits attributes' do
144
- parent_wrapper = Class.new(Burgundy::Item) do
145
- attributes :name, :username
146
- end
147
-
148
- wrapper = Class.new(parent_wrapper)
149
- object = OpenStruct.new(name: 'John Doe', username: 'johndoe')
150
- item = wrapper.new(object)
151
-
152
- expect(item.attributes).to eq(name: 'John Doe', username: 'johndoe')
153
- end
154
- end
@@ -1,45 +0,0 @@
1
- Processing by SiteController#index as HTML
2
- Rendered text template (0.0ms)
3
- Completed 200 OK in 12ms (Views: 11.8ms)
4
- Processing by Admin::CategoriesController#index as HTML
5
- Completed 200 OK in 1ms (Views: 0.5ms)
6
- Processing by CategoriesController#show as HTML
7
- Completed 200 OK in 1ms (Views: 0.6ms)
8
- Processing by SiteController#contact as HTML
9
- Completed 200 OK in 30ms (Views: 30.2ms)
10
- Processing by SiteController#index as HTML
11
- Rendered text template (0.0ms)
12
- Completed 200 OK in 31ms (Views: 30.7ms)
13
- Processing by Admin::CategoriesController#index as HTML
14
- Completed 200 OK in 1ms (Views: 0.5ms)
15
- Processing by CategoriesController#show as HTML
16
- Completed 200 OK in 1ms (Views: 0.5ms)
17
- Processing by SiteController#contact as HTML
18
- Completed 200 OK in 25ms (Views: 25.3ms)
19
- Processing by SiteController#index as HTML
20
- Rendered text template (0.1ms)
21
- Completed 200 OK in 36ms (Views: 36.1ms)
22
- Processing by Admin::CategoriesController#index as HTML
23
- Completed 200 OK in 1ms (Views: 0.6ms)
24
- Processing by CategoriesController#show as HTML
25
- Completed 200 OK in 1ms (Views: 0.5ms)
26
- Processing by SiteController#contact as HTML
27
- Completed 200 OK in 26ms (Views: 25.8ms)
28
- Processing by SiteController#index as HTML
29
- Rendered text template (0.0ms)
30
- Completed 200 OK in 37ms (Views: 37.0ms)
31
- Processing by Admin::CategoriesController#index as HTML
32
- Completed 200 OK in 1ms (Views: 0.5ms)
33
- Processing by CategoriesController#show as HTML
34
- Completed 200 OK in 1ms (Views: 0.5ms)
35
- Processing by SiteController#contact as HTML
36
- Completed 200 OK in 28ms (Views: 28.1ms)
37
- Processing by SiteController#index as HTML
38
- Rendered text template (0.0ms)
39
- Completed 200 OK in 33ms (Views: 32.9ms)
40
- Processing by Admin::CategoriesController#index as HTML
41
- Completed 200 OK in 1ms (Views: 0.9ms)
42
- Processing by CategoriesController#show as HTML
43
- Completed 200 OK in 1ms (Views: 0.5ms)
44
- Processing by SiteController#contact as HTML
45
- Completed 200 OK in 25ms (Views: 25.2ms)
@@ -1,19 +0,0 @@
1
- require 'bundler/setup'
2
- Bundler.setup
3
-
4
- ENV['RAILS_ENV'] = 'test'
5
-
6
- require File.expand_path('../dummy/config/environment.rb', __FILE__)
7
- require 'rspec/rails'
8
-
9
- require 'burgundy'
10
- I18n.locale = :en
11
-
12
- class ItemWithAdditionalArgs < Burgundy::Item
13
- attr_reader :args
14
-
15
- def initialize(target, *args)
16
- super(target)
17
- @args = args
18
- end
19
- end