simpre 0.4.1 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +18 -0
- data/Gemfile +1 -1
- data/Rakefile +0 -1
- data/lib/simpre.rb +4 -4
- data/lib/simpre/helper.rb +6 -2
- data/lib/simpre/presenter.rb +1 -1
- data/lib/simpre/version.rb +1 -1
- data/simpre.gemspec +3 -2
- data/spec/helper_spec.rb +34 -0
- data/spec/spec_helper.rb +8 -0
- metadata +22 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7b6c9f637c65670750169022f2aebb2db40a0c76
|
4
|
+
data.tar.gz: 4e41f5bdc80a39a058980f48e83a8a3b68e8e9e3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8ae92a31777a940108788e30a2f19ad13e10904551307c80c928166053c3b8a2dc933bb0cc2dc69aa84973cc57115a58b59df630a141aaf84439b600a971042e
|
7
|
+
data.tar.gz: 54894be55b507d5dfda3ede69ccb970d9f378cc9346506584c9f50e8ef180ff6a18bb04a03a8193131132d6fc2df33a0ac4c67216669b65fa1ff8d19c7dba6f3
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
###########################
|
2
|
+
# Configuration for rubocop
|
3
|
+
# in .rubocop.yml
|
4
|
+
# Most of these are disabling existing cops, primarily
|
5
|
+
# due to a smattering of different styles and loose
|
6
|
+
# guidlines for contributions.
|
7
|
+
#
|
8
|
+
# Any of these may be changed.
|
9
|
+
|
10
|
+
Style/StringLiterals:
|
11
|
+
EnforcedStyle: double_quotes
|
12
|
+
|
13
|
+
LineLength:
|
14
|
+
Max: 120
|
15
|
+
|
16
|
+
Style/Documentation:
|
17
|
+
Exclude:
|
18
|
+
- 'spec/**/*'
|
data/Gemfile
CHANGED
data/Rakefile
CHANGED
data/lib/simpre.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
1
|
+
require "simpre/helper"
|
2
|
+
require "simpre/presenter"
|
3
|
+
require "simpre/version"
|
4
4
|
|
5
5
|
module Simpre
|
6
6
|
end
|
7
7
|
|
8
|
-
require
|
8
|
+
require "simpre/railtie" if defined?(Rails) && Rails::VERSION::MAJOR >= 3
|
data/lib/simpre/helper.rb
CHANGED
@@ -6,8 +6,8 @@ module Simpre
|
|
6
6
|
item_or_collection.map { |item| decorate(item) }
|
7
7
|
else
|
8
8
|
item = item_or_collection
|
9
|
+
return item if item.is_a?(Presenter)
|
9
10
|
presenter = "#{item.class}Presenter".constantize
|
10
|
-
return item if item.instance_of?(presenter)
|
11
11
|
presenter.new(item, current_view_context)
|
12
12
|
end
|
13
13
|
end
|
@@ -18,7 +18,11 @@ module Simpre
|
|
18
18
|
# if calling `decorate` from another presenter return the existing
|
19
19
|
# view_context
|
20
20
|
return h if is_a?(Presenter)
|
21
|
-
|
21
|
+
if defined?(ApplicationController) && is_a?(ApplicationController)
|
22
|
+
view_context
|
23
|
+
else
|
24
|
+
self
|
25
|
+
end
|
22
26
|
end
|
23
27
|
end
|
24
28
|
end
|
data/lib/simpre/presenter.rb
CHANGED
data/lib/simpre/version.rb
CHANGED
data/simpre.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# coding: utf-8
|
2
|
-
lib = File.expand_path(
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require
|
4
|
+
require "simpre/version"
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "simpre"
|
@@ -21,4 +21,5 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.add_development_dependency "bundler", "~> 1.7"
|
22
22
|
spec.add_development_dependency "rake", "~> 10.0"
|
23
23
|
spec.add_development_dependency "rspec", "~> 3.4"
|
24
|
+
spec.add_development_dependency "rails", "~> 4.2"
|
24
25
|
end
|
data/spec/helper_spec.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "rails"
|
3
|
+
|
4
|
+
class TestClass
|
5
|
+
end
|
6
|
+
|
7
|
+
class TestClassPresenter < Simpre::Presenter
|
8
|
+
end
|
9
|
+
|
10
|
+
describe Simpre::Helper do
|
11
|
+
include Simpre::Helper
|
12
|
+
|
13
|
+
describe "#decorate" do
|
14
|
+
context "decorating a single object" do
|
15
|
+
subject { decorate TestClass.new }
|
16
|
+
|
17
|
+
it "decorates the class" do
|
18
|
+
expect(subject).to be_an_instance_of TestClassPresenter
|
19
|
+
end
|
20
|
+
|
21
|
+
it "returns the original object when decorating a presenter" do
|
22
|
+
expect(decorate(subject)).to be_an_instance_of TestClassPresenter
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# context 'decorating a collection of objects' do
|
27
|
+
#
|
28
|
+
# end
|
29
|
+
#
|
30
|
+
# context 'decorating a collection object' do
|
31
|
+
#
|
32
|
+
# end
|
33
|
+
end
|
34
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simpre
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jamie Dyer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-11-
|
11
|
+
date: 2016-11-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '3.4'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rails
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '4.2'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '4.2'
|
55
69
|
description: A super simple presenter implementation for Rails apps
|
56
70
|
email:
|
57
71
|
- jamie@kernowsoul.com
|
@@ -60,6 +74,7 @@ extensions: []
|
|
60
74
|
extra_rdoc_files: []
|
61
75
|
files:
|
62
76
|
- ".gitignore"
|
77
|
+
- ".rubocop.yml"
|
63
78
|
- ".ruby-version"
|
64
79
|
- Gemfile
|
65
80
|
- LICENSE.txt
|
@@ -71,6 +86,8 @@ files:
|
|
71
86
|
- lib/simpre/railtie.rb
|
72
87
|
- lib/simpre/version.rb
|
73
88
|
- simpre.gemspec
|
89
|
+
- spec/helper_spec.rb
|
90
|
+
- spec/spec_helper.rb
|
74
91
|
homepage: https://github.com/kernow/simpre
|
75
92
|
licenses:
|
76
93
|
- MIT
|
@@ -95,4 +112,6 @@ rubygems_version: 2.4.8
|
|
95
112
|
signing_key:
|
96
113
|
specification_version: 4
|
97
114
|
summary: A super simple presenter implementation for Rails apps
|
98
|
-
test_files:
|
115
|
+
test_files:
|
116
|
+
- spec/helper_spec.rb
|
117
|
+
- spec/spec_helper.rb
|