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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e973c05de9a7b234530590b64bd75f0ebe74e0b3
4
- data.tar.gz: 53e23e0516eead3ac4abf9efdec426eb75d6b11a
3
+ metadata.gz: 7b6c9f637c65670750169022f2aebb2db40a0c76
4
+ data.tar.gz: 4e41f5bdc80a39a058980f48e83a8a3b68e8e9e3
5
5
  SHA512:
6
- metadata.gz: aebd00253858fee75c270a2b30c3aac34d5f5d90859f2005eb177af4bdfec47edc94dadffdf9b1140e765489bed2938d21fbc7d82870b9f5521d325bcbec92ff
7
- data.tar.gz: 4ebefd5f0ba4b552d443cd89797ffe90d2919bac30d3850d0e25a9c104f29b2241e5add0a2a5c6b9042ea9832bc02d0c011d86bdc9349196c14b7cb3c2e07234
6
+ metadata.gz: 8ae92a31777a940108788e30a2f19ad13e10904551307c80c928166053c3b8a2dc933bb0cc2dc69aa84973cc57115a58b59df630a141aaf84439b600a971042e
7
+ data.tar.gz: 54894be55b507d5dfda3ede69ccb970d9f378cc9346506584c9f50e8ef180ff6a18bb04a03a8193131132d6fc2df33a0ac4c67216669b65fa1ff8d19c7dba6f3
@@ -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
@@ -1,4 +1,4 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in simpre.gemspec
4
4
  gemspec
data/Rakefile CHANGED
@@ -1,2 +1 @@
1
1
  require "bundler/gem_tasks"
2
-
@@ -1,8 +1,8 @@
1
- require 'simpre/helper'
2
- require 'simpre/presenter'
3
- require 'simpre/version'
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 'simpre/railtie' if defined?(Rails) && Rails::VERSION::MAJOR >= 3
8
+ require "simpre/railtie" if defined?(Rails) && Rails::VERSION::MAJOR >= 3
@@ -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
- is_a?(ApplicationController) ? view_context : self
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
@@ -1,4 +1,4 @@
1
- require 'delegate'
1
+ require "delegate"
2
2
 
3
3
  module Simpre
4
4
  class Presenter < SimpleDelegator
@@ -1,3 +1,3 @@
1
1
  module Simpre
2
- VERSION = '0.4.1'.freeze
2
+ VERSION = "0.4.3".freeze
3
3
  end
@@ -1,7 +1,7 @@
1
1
  # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
2
+ lib = File.expand_path("../lib", __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'simpre/version'
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
@@ -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
@@ -0,0 +1,8 @@
1
+ $LOAD_PATH.unshift File.dirname(__FILE__)
2
+
3
+ require "rspec"
4
+ require "simpre"
5
+
6
+ RSpec.configure do |config|
7
+ config.order = "random"
8
+ end
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.1
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-22 00:00:00.000000000 Z
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