resubject 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.travis.yml +2 -0
- data/CHANGELOG.md +3 -0
- data/Gemfile +4 -10
- data/README.md +7 -6
- data/lib/resubject/extensions/template_methods.rb +10 -3
- data/lib/resubject/rspec.rb +9 -3
- data/lib/resubject/version.rb +1 -1
- data/resubject.gemspec +1 -1
- metadata +37 -54
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9622a9c1f2e6e745fb007dfb4c5171feefaafcf1
|
4
|
+
data.tar.gz: 31a1819fdd559781b98612dfaf2f336a46d4bc31
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 58bdd1ed48e037f0b4774baf8cbe264f4274c4ffbf00658a4adafba2857f1bfb86877d4435322afca3e4f3cb02c73ac3f2d52912a4848fab7a1b2f2a12fe8a65
|
7
|
+
data.tar.gz: caa9e377c606d3512ade4ec8fa23d3a3aad78ae534cc34dc073b97c77d06c71056c9c525cc6150472313409df300928012c33d57a682cf503864365720daace0
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
@@ -1,18 +1,12 @@
|
|
1
1
|
ENV['rails'] ||= '3.2'
|
2
2
|
|
3
|
-
source
|
3
|
+
source 'https://rubygems.org'
|
4
4
|
|
5
5
|
rails_version = ENV['rails']
|
6
|
-
|
7
|
-
case rails_version
|
8
|
-
when '3.2'
|
9
|
-
gem 'actionpack', "~> #{rails_version}"
|
10
|
-
when '4.0'
|
11
|
-
# Waiting for beta release of actionpack
|
12
|
-
gem 'rails', github: 'rails/rails'
|
13
|
-
end
|
6
|
+
gem 'actionpack', "~> #{rails_version}"
|
14
7
|
|
15
8
|
gem 'redcarpet'
|
16
|
-
|
9
|
+
gem 'rake', '< 11.0'
|
10
|
+
gem 'nokogiri', '~> 1.8'
|
17
11
|
# Specify your gem's dependencies in resubject.gemspec
|
18
12
|
gemspec
|
data/README.md
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
# Resubject
|
2
2
|
|
3
|
-
[![Build Status](https://travis-ci.org/felipeelias/resubject.
|
4
|
-
[![Gem Version](https://
|
3
|
+
[![Build Status](https://travis-ci.org/felipeelias/resubject.svg?branch=master)](https://travis-ci.org/felipeelias/resubject)
|
4
|
+
[![Gem Version](https://badge.fury.io/rb/resubject.svg)](https://badge.fury.io/rb/resubject)
|
5
|
+
[![Code Climate](https://codeclimate.com/github/felipeelias/resubject/badges/gpa.svg)](https://codeclimate.com/github/felipeelias/resubject)
|
5
6
|
|
6
7
|
Uber simple presenters using Ruby's SimpleDelegator.
|
7
8
|
|
@@ -10,7 +11,7 @@ Uber simple presenters using Ruby's SimpleDelegator.
|
|
10
11
|
Add this line to your application's Gemfile:
|
11
12
|
|
12
13
|
```ruby
|
13
|
-
gem 'resubject', '~> 0.2.
|
14
|
+
gem 'resubject', '~> 0.2.1'
|
14
15
|
```
|
15
16
|
|
16
17
|
And then execute:
|
@@ -29,7 +30,7 @@ Checkout the documentation in [rdoc.info/resubject](http://rdoc.info/github/feli
|
|
29
30
|
|
30
31
|
Resubject uses Ruby's [SimpleDelegator](http://apidock.com/ruby/SimpleDelegator) class to create its presenters.
|
31
32
|
|
32
|
-
SimpleDelegator is a concrete
|
33
|
+
SimpleDelegator is a concrete implementation of the Delegator class. Basically, it delegates any method calls to the object passed into the constructor:
|
33
34
|
|
34
35
|
```ruby
|
35
36
|
require 'delegate'
|
@@ -204,7 +205,7 @@ More helpers will be added. Feel free to contribute with yours! Also, Check out
|
|
204
205
|
|
205
206
|
If you'd like to use the generated helpers but you're not using Rails, you can either use `ActionView` or create your own template handler:
|
206
207
|
|
207
|
-
```
|
208
|
+
```ruby
|
208
209
|
require 'action_view'
|
209
210
|
|
210
211
|
post = PostPresenter.new(post, ActionView::Base.new)
|
@@ -216,7 +217,7 @@ If you want to use your own template handler and still use Resubject helpers, yo
|
|
216
217
|
|
217
218
|
## Testing
|
218
219
|
|
219
|
-
Resubject
|
220
|
+
Resubject introduces a new context for RSpec that helps testing your presenters:
|
220
221
|
|
221
222
|
```ruby
|
222
223
|
# spec/presenters/my_presenter_spec.rb
|
@@ -47,9 +47,16 @@ module Resubject
|
|
47
47
|
# @param [Symbol] attribute the name of the attribute to be generated
|
48
48
|
# @see http://apidock.com/rails/ActionView/Helpers/DateHelper/time_ago_in_words
|
49
49
|
def time_ago(attribute, include_seconds = false)
|
50
|
-
|
51
|
-
|
52
|
-
|
50
|
+
if Gem::Version.new(ActiveSupport::VERSION::STRING) < Gem::Version.new("4")
|
51
|
+
define_method attribute do
|
52
|
+
return if to_model.send(attribute).nil?
|
53
|
+
template.time_ago_in_words to_model.send(attribute), include_seconds
|
54
|
+
end
|
55
|
+
else
|
56
|
+
define_method attribute do
|
57
|
+
return if to_model.send(attribute).nil?
|
58
|
+
template.time_ago_in_words to_model.send(attribute), include_seconds: include_seconds
|
59
|
+
end
|
53
60
|
end
|
54
61
|
end
|
55
62
|
|
data/lib/resubject/rspec.rb
CHANGED
@@ -46,7 +46,13 @@ module Resubject
|
|
46
46
|
end
|
47
47
|
|
48
48
|
::RSpec.configure do |c|
|
49
|
-
|
50
|
-
|
51
|
-
|
49
|
+
if ::RSpec::Core::Version::STRING.split(".").first.to_i >= 3
|
50
|
+
c.include Resubject::Rspec,
|
51
|
+
type: :presenter,
|
52
|
+
file_path: %r(spec/presenters)
|
53
|
+
else
|
54
|
+
c.include Resubject::Rspec,
|
55
|
+
type: :presenter,
|
56
|
+
example_group: { file_path: %r(spec/presenters) }
|
57
|
+
end
|
52
58
|
end
|
data/lib/resubject/version.rb
CHANGED
data/resubject.gemspec
CHANGED
metadata
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: resubject
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
version: 0.2.0
|
4
|
+
version: 0.2.1
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Felipe Elias Philipp
|
@@ -10,72 +9,64 @@ authors:
|
|
10
9
|
autorequire:
|
11
10
|
bindir: bin
|
12
11
|
cert_chain: []
|
13
|
-
date:
|
12
|
+
date: 2017-12-31 00:00:00.000000000 Z
|
14
13
|
dependencies:
|
15
14
|
- !ruby/object:Gem::Dependency
|
16
15
|
name: activesupport
|
17
|
-
version_requirements: !ruby/object:Gem::Requirement
|
18
|
-
none: false
|
19
|
-
requirements:
|
20
|
-
- - ! '>='
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: '3.2'
|
23
16
|
requirement: !ruby/object:Gem::Requirement
|
24
|
-
none: false
|
25
17
|
requirements:
|
26
|
-
- -
|
18
|
+
- - ">="
|
27
19
|
- !ruby/object:Gem::Version
|
28
20
|
version: '3.2'
|
29
|
-
prerelease: false
|
30
21
|
type: :runtime
|
31
|
-
|
32
|
-
name: rake
|
22
|
+
prerelease: false
|
33
23
|
version_requirements: !ruby/object:Gem::Requirement
|
34
|
-
none: false
|
35
24
|
requirements:
|
36
|
-
- -
|
25
|
+
- - ">="
|
37
26
|
- !ruby/object:Gem::Version
|
38
|
-
version: '
|
27
|
+
version: '3.2'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: rake
|
39
30
|
requirement: !ruby/object:Gem::Requirement
|
40
|
-
none: false
|
41
31
|
requirements:
|
42
|
-
- -
|
32
|
+
- - ">="
|
43
33
|
- !ruby/object:Gem::Version
|
44
34
|
version: '0'
|
45
|
-
prerelease: false
|
46
35
|
type: :development
|
47
|
-
|
48
|
-
name: rspec
|
36
|
+
prerelease: false
|
49
37
|
version_requirements: !ruby/object:Gem::Requirement
|
50
|
-
none: false
|
51
38
|
requirements:
|
52
|
-
- -
|
39
|
+
- - ">="
|
53
40
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
41
|
+
version: '0'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: rspec
|
55
44
|
requirement: !ruby/object:Gem::Requirement
|
56
|
-
none: false
|
57
45
|
requirements:
|
58
|
-
- - ~>
|
46
|
+
- - "~>"
|
59
47
|
- !ruby/object:Gem::Version
|
60
48
|
version: 2.12.0
|
61
|
-
prerelease: false
|
62
49
|
type: :development
|
63
|
-
|
64
|
-
name: yard
|
50
|
+
prerelease: false
|
65
51
|
version_requirements: !ruby/object:Gem::Requirement
|
66
|
-
none: false
|
67
52
|
requirements:
|
68
|
-
- - ~>
|
53
|
+
- - "~>"
|
69
54
|
- !ruby/object:Gem::Version
|
70
|
-
version:
|
55
|
+
version: 2.12.0
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: yard
|
71
58
|
requirement: !ruby/object:Gem::Requirement
|
72
|
-
none: false
|
73
59
|
requirements:
|
74
|
-
- - ~>
|
60
|
+
- - "~>"
|
75
61
|
- !ruby/object:Gem::Version
|
76
|
-
version: 0.
|
77
|
-
prerelease: false
|
62
|
+
version: '0.9'
|
78
63
|
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0.9'
|
79
70
|
description: Uber simple presenters
|
80
71
|
email:
|
81
72
|
- felipe@applicake.com
|
@@ -84,10 +75,10 @@ executables: []
|
|
84
75
|
extensions: []
|
85
76
|
extra_rdoc_files: []
|
86
77
|
files:
|
87
|
-
- .gitignore
|
88
|
-
- .rspec
|
89
|
-
- .travis.yml
|
90
|
-
- .yardopts
|
78
|
+
- ".gitignore"
|
79
|
+
- ".rspec"
|
80
|
+
- ".travis.yml"
|
81
|
+
- ".yardopts"
|
91
82
|
- CHANGELOG.md
|
92
83
|
- Gemfile
|
93
84
|
- IDEAS.md
|
@@ -114,33 +105,26 @@ files:
|
|
114
105
|
homepage: https://github.com/felipeelias/resubject
|
115
106
|
licenses:
|
116
107
|
- MIT
|
108
|
+
metadata: {}
|
117
109
|
post_install_message:
|
118
110
|
rdoc_options: []
|
119
111
|
require_paths:
|
120
112
|
- lib
|
121
113
|
required_ruby_version: !ruby/object:Gem::Requirement
|
122
|
-
none: false
|
123
114
|
requirements:
|
124
|
-
- -
|
115
|
+
- - ">="
|
125
116
|
- !ruby/object:Gem::Version
|
126
117
|
version: '0'
|
127
|
-
hash: -249672256597893339
|
128
|
-
segments:
|
129
|
-
- 0
|
130
118
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
131
|
-
none: false
|
132
119
|
requirements:
|
133
|
-
- -
|
120
|
+
- - ">="
|
134
121
|
- !ruby/object:Gem::Version
|
135
122
|
version: '0'
|
136
|
-
hash: -249672256597893339
|
137
|
-
segments:
|
138
|
-
- 0
|
139
123
|
requirements: []
|
140
124
|
rubyforge_project:
|
141
|
-
rubygems_version:
|
125
|
+
rubygems_version: 2.6.12
|
142
126
|
signing_key:
|
143
|
-
specification_version:
|
127
|
+
specification_version: 4
|
144
128
|
summary: Uber simple presenters using Ruby's SimpleDelegator
|
145
129
|
test_files:
|
146
130
|
- spec/resubject/builder_spec.rb
|
@@ -148,4 +132,3 @@ test_files:
|
|
148
132
|
- spec/resubject/naming_spec.rb
|
149
133
|
- spec/resubject/presenter_spec.rb
|
150
134
|
- spec/spec_helper.rb
|
151
|
-
has_rdoc:
|