activeadmin-poro-decorator 0.0.9 → 0.1.0

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: 2221401621c7c777cc695cc28ae8f8b17deb5b1e
4
- data.tar.gz: 10aadefde8b7cd4d13efdc9268632b1d76258bc5
3
+ metadata.gz: 88f812d5409d60050f58427243a77a0cf1d2f97e
4
+ data.tar.gz: d2ada57dc5c19e865bcc03c7a01fdfbb0f8bc9dd
5
5
  SHA512:
6
- metadata.gz: cd92720f35479a79e5eebb9ab107d5c06372def7d12e6bbff2f8d30216aaaa1c806e95f51c772af78073630d1dac3ed520b1b8075a020a665f3c3e12b2824fe3
7
- data.tar.gz: 911bf92bd5bbf9b8bf1975afb164ac25b54f81677cc77b37d7eaabefc7bf979b9ba7bc974ded87f9ec13a0b60926f706c7abd56fb9070246d4228d4fea130d73
6
+ metadata.gz: f0f6d2b39020694f7404e66e50f6a9874cb8fabc8924e1ea0a0dfaa1b8e30a14ec877ddadd6a94a566e4987d93c374a9931663d8d499596a2f08605a6c0365d8
7
+ data.tar.gz: db7dc203bba84a74b2c63fc1e3586e8badcbf28ede96ae7d791f9656b63da162e5c8a91db20c1cbe25e2876e4363341a6030c1c58482402a86c585daeda07059
data/.gitignore CHANGED
@@ -1,2 +1,3 @@
1
1
  pkg
2
+ log
2
3
  .idea
data/Gemfile.lock CHANGED
@@ -1,12 +1,70 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- activeadmin-poro-decorator (0.0.3)
4
+ activeadmin-poro-decorator (0.1.0)
5
+ rails (>= 4.0.0)
5
6
 
6
7
  GEM
7
8
  remote: https://rubygems.org/
8
9
  specs:
10
+ actionmailer (4.0.12)
11
+ actionpack (= 4.0.12)
12
+ mail (~> 2.5, >= 2.5.4)
13
+ actionpack (4.0.12)
14
+ activesupport (= 4.0.12)
15
+ builder (~> 3.1.0)
16
+ erubis (~> 2.7.0)
17
+ rack (~> 1.5.2)
18
+ rack-test (~> 0.6.2)
19
+ activemodel (4.0.12)
20
+ activesupport (= 4.0.12)
21
+ builder (~> 3.1.0)
22
+ activerecord (4.0.12)
23
+ activemodel (= 4.0.12)
24
+ activerecord-deprecated_finders (~> 1.0.2)
25
+ activesupport (= 4.0.12)
26
+ arel (~> 4.0.0)
27
+ activerecord-deprecated_finders (1.0.3)
28
+ activesupport (4.0.12)
29
+ i18n (~> 0.6, >= 0.6.9)
30
+ minitest (~> 4.2)
31
+ multi_json (~> 1.3)
32
+ thread_safe (~> 0.1)
33
+ tzinfo (~> 0.3.37)
34
+ arel (4.0.2)
35
+ builder (3.1.4)
36
+ coderay (1.1.0)
37
+ database_cleaner (0.9.1)
9
38
  diff-lcs (1.2.5)
39
+ erubis (2.7.0)
40
+ hike (1.2.3)
41
+ i18n (0.7.0)
42
+ mail (2.6.3)
43
+ mime-types (>= 1.16, < 3)
44
+ method_source (0.8.2)
45
+ mime-types (2.4.3)
46
+ minitest (4.7.5)
47
+ multi_json (1.10.1)
48
+ pry (0.10.1)
49
+ coderay (~> 1.1.0)
50
+ method_source (~> 0.8.1)
51
+ slop (~> 3.4)
52
+ rack (1.5.2)
53
+ rack-test (0.6.2)
54
+ rack (>= 1.0)
55
+ rails (4.0.12)
56
+ actionmailer (= 4.0.12)
57
+ actionpack (= 4.0.12)
58
+ activerecord (= 4.0.12)
59
+ activesupport (= 4.0.12)
60
+ bundler (>= 1.3.0, < 2.0)
61
+ railties (= 4.0.12)
62
+ sprockets-rails (~> 2.0)
63
+ railties (4.0.12)
64
+ actionpack (= 4.0.12)
65
+ activesupport (= 4.0.12)
66
+ rake (>= 0.8.7)
67
+ thor (>= 0.18.1, < 2.0)
10
68
  rake (10.3.2)
11
69
  rspec (3.1.0)
12
70
  rspec-core (~> 3.1.0)
@@ -20,6 +78,21 @@ GEM
20
78
  rspec-mocks (3.1.3)
21
79
  rspec-support (~> 3.1.0)
22
80
  rspec-support (3.1.2)
81
+ slop (3.6.0)
82
+ sprockets (2.12.3)
83
+ hike (~> 1.2)
84
+ multi_json (~> 1.0)
85
+ rack (~> 1.0)
86
+ tilt (~> 1.1, != 1.3.0)
87
+ sprockets-rails (2.2.2)
88
+ actionpack (>= 3.0)
89
+ activesupport (>= 3.0)
90
+ sprockets (>= 2.8, < 4.0)
91
+ sqlite3 (1.3.10)
92
+ thor (0.19.1)
93
+ thread_safe (0.3.4)
94
+ tilt (1.4.1)
95
+ tzinfo (0.3.42)
23
96
 
24
97
  PLATFORMS
25
98
  ruby
@@ -27,5 +100,8 @@ PLATFORMS
27
100
  DEPENDENCIES
28
101
  activeadmin-poro-decorator!
29
102
  bundler (~> 1.7)
103
+ database_cleaner
104
+ pry
30
105
  rake (~> 10.0)
31
106
  rspec
107
+ sqlite3
data/README.md CHANGED
@@ -69,6 +69,8 @@ class PostDecorator < DelegateClass(Post)
69
69
  end
70
70
  ```
71
71
 
72
+ For more examples have a look to [sample app](https://github.com/kiote/aa_plus_poro)
73
+
72
74
  ## Contributing
73
75
 
74
76
  1. Fork it ( https://github.com/[my-github-username]/activeadmin-poro-decorator/fork )
@@ -21,4 +21,12 @@ 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'
24
+ spec.add_development_dependency 'database_cleaner'
25
+ spec.add_development_dependency 'pry'
26
+ spec.add_development_dependency 'sqlite3'
27
+
28
+ # spec.add_dependency 'activeadmin'
29
+ spec.add_dependency 'rails', '>= 4.0.0'
30
+
31
+ spec.required_ruby_version = '~> 2.0'
24
32
  end
@@ -0,0 +1,9 @@
1
+ module ActiveAdmin
2
+ class Comment < ActiveRecord::Base
3
+ # @returns [String] The name of the record to use for the polymorphic relationship
4
+ def self.resource_type(resource)
5
+ return resource.type if resource.respond_to?(:type)
6
+ ResourceController::Decorators.undecorate(resource).class.name.to_s
7
+ end
8
+ end
9
+ end
@@ -1,3 +1,3 @@
1
1
  module ActiveadminPoroDecorator
2
- VERSION = "0.0.9"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -0,0 +1,9 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Decorate' do
4
+ let(:article) { double('article') }
5
+ it 'decorates properly' do
6
+ allow(article).to receive(:title).and_return('Aslak')
7
+ expect(ArticlePresenter.new(article).hello).to eq 'Hello, Aslak'
8
+ end
9
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,8 +1,23 @@
1
+ ENV["RAILS_ENV"] = "test"
2
+
1
3
  require 'bundler/setup'
4
+ require 'active_record'
5
+ require 'pry'
6
+ require 'delegate'
2
7
  require 'activeadmin-poro-decorator'
8
+ require 'database_cleaner'
9
+
10
+ require File.expand_path("../support/dummy/config/environment", __FILE__)
3
11
 
4
12
  RSpec.configure do |config|
5
- config.treat_symbols_as_metadata_keys_with_true_values = true
6
13
  config.expect_with(:rspec) {|c| c.syntax = :expect}
7
14
  config.order = :random
15
+
16
+ DatabaseCleaner.strategy = :transaction
17
+
18
+ config.around(:each, db: true) do |example|
19
+ DatabaseCleaner.start
20
+ example.run
21
+ DatabaseCleaner.clean
22
+ end
8
23
  end
@@ -0,0 +1,6 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require File.expand_path('../config/application', __FILE__)
5
+
6
+ Rails.application.load_tasks
@@ -0,0 +1,2 @@
1
+ class Article < ActiveRecord::Base
2
+ end
@@ -0,0 +1,25 @@
1
+ # inspired by https://github.com/activeadmin/activeadmin/blob/a180c76f17480715948bff2ead827f338d95a835/spec/support/templates/post_decorator.rb
2
+ class ArticlePresenter < DelegateClass(Article)
3
+ include ActiveadminPoroDecorator
4
+
5
+ class << self
6
+ delegate :all, :arel_table, :find_by_sql, :columns, :connection,\
7
+ :unscoped, :table_name, :primary_key, to: Article
8
+
9
+ def model_name
10
+ ActiveModel::Name.new Article
11
+ end
12
+
13
+ def build_default_scope
14
+ Article.send(:build_default_scope)
15
+ end
16
+ end
17
+
18
+ def hello
19
+ "Hello, #{title}"
20
+ end
21
+
22
+ def link_title
23
+ helpers.link_to(id, url_helpers.admin_article_path(self))
24
+ end
25
+ end
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3
+ load Gem.bin_path('bundler', 'bundle')
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
3
+ require_relative '../config/boot'
4
+ require 'rails/commands'
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative '../config/boot'
3
+ require 'rake'
4
+ Rake.application.run
@@ -0,0 +1,4 @@
1
+ # This file is used by Rack-based servers to start the application.
2
+
3
+ require ::File.expand_path('../config/environment', __FILE__)
4
+ run Rails.application
@@ -0,0 +1,11 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ # Pick the frameworks you want:
4
+ require 'active_record/railtie'
5
+
6
+ Bundler.require(*Rails.groups)
7
+
8
+ module Dummy
9
+ class Application < Rails::Application
10
+ end
11
+ end
@@ -0,0 +1,5 @@
1
+ # Set up gems listed in the Gemfile.
2
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../../../Gemfile", __FILE__)
3
+
4
+ require "bundler/setup" if File.exist?(ENV["BUNDLE_GEMFILE"])
5
+ $LOAD_PATH.unshift File.expand_path("../../../../lib", __FILE__)
@@ -0,0 +1,9 @@
1
+ development: &default
2
+ adapter: sqlite3
3
+ database: dummy_development
4
+ encoding: unicode
5
+ pool: 5
6
+
7
+ test:
8
+ <<: *default
9
+ database: dummy_test
@@ -0,0 +1,5 @@
1
+ # Load the Rails application.
2
+ require File.expand_path("../application", __FILE__)
3
+
4
+ # Initialize the Rails application.
5
+ Rails.application.initialize!
@@ -0,0 +1,6 @@
1
+ Rails.application.configure do
2
+ config.cache_classes = false
3
+
4
+ # Do not eager load code on boot.
5
+ config.eager_load = false
6
+ end
@@ -0,0 +1,5 @@
1
+ Dummy::Application.configure do
2
+ config.cache_classes = true
3
+ config.eager_load = false
4
+ config.active_support.deprecation = :stderr
5
+ end
File without changes
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activeadmin-poro-decorator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Krivich Ekaterina
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-12 00:00:00.000000000 Z
11
+ date: 2015-01-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,6 +52,62 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: database_cleaner
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: sqlite3
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: rails
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: 4.0.0
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: 4.0.0
55
111
  description: Inspired by http://thepugautomatic.com/2014/03/draper/ to not use draper
56
112
  while decorating th
57
113
  email:
@@ -69,11 +125,27 @@ files:
69
125
  - activeadmin-poro-decorator.gemspec
70
126
  - activeadmin-poro-decorator.yml.example
71
127
  - lib/activeadmin-poro-decorator.rb
128
+ - lib/activeadmin-poro-decorator/activeadmin_comment.rb
72
129
  - lib/activeadmin-poro-decorator/config.rb
73
130
  - lib/activeadmin-poro-decorator/railtie.rb
74
131
  - lib/activeadmin-poro-decorator/version.rb
75
132
  - lib/tasks/copy_config.rake
133
+ - spec/integration/decorate_spec.rb
76
134
  - spec/spec_helper.rb
135
+ - spec/support/dummy/Rakefile
136
+ - spec/support/dummy/app/models/article.rb
137
+ - spec/support/dummy/app/presenters/article_presenter.rb
138
+ - spec/support/dummy/bin/bundle
139
+ - spec/support/dummy/bin/rails
140
+ - spec/support/dummy/bin/rake
141
+ - spec/support/dummy/config.ru
142
+ - spec/support/dummy/config/application.rb
143
+ - spec/support/dummy/config/boot.rb
144
+ - spec/support/dummy/config/database.yml
145
+ - spec/support/dummy/config/environment.rb
146
+ - spec/support/dummy/config/environments/development.rb
147
+ - spec/support/dummy/config/environments/test.rb
148
+ - spec/support/dummy/db/migrate/.keep
77
149
  homepage: https://github.com/kiote/activeadmin-poro-decorator
78
150
  licenses:
79
151
  - MIT
@@ -84,9 +156,9 @@ require_paths:
84
156
  - lib
85
157
  required_ruby_version: !ruby/object:Gem::Requirement
86
158
  requirements:
87
- - - ">="
159
+ - - "~>"
88
160
  - !ruby/object:Gem::Version
89
- version: '0'
161
+ version: '2.0'
90
162
  required_rubygems_version: !ruby/object:Gem::Requirement
91
163
  requirements:
92
164
  - - ">="
@@ -99,4 +171,19 @@ signing_key:
99
171
  specification_version: 4
100
172
  summary: Plain Old Ruby Objects as Decorators for Active Admin
101
173
  test_files:
174
+ - spec/integration/decorate_spec.rb
102
175
  - spec/spec_helper.rb
176
+ - spec/support/dummy/Rakefile
177
+ - spec/support/dummy/app/models/article.rb
178
+ - spec/support/dummy/app/presenters/article_presenter.rb
179
+ - spec/support/dummy/bin/bundle
180
+ - spec/support/dummy/bin/rails
181
+ - spec/support/dummy/bin/rake
182
+ - spec/support/dummy/config.ru
183
+ - spec/support/dummy/config/application.rb
184
+ - spec/support/dummy/config/boot.rb
185
+ - spec/support/dummy/config/database.yml
186
+ - spec/support/dummy/config/environment.rb
187
+ - spec/support/dummy/config/environments/development.rb
188
+ - spec/support/dummy/config/environments/test.rb
189
+ - spec/support/dummy/db/migrate/.keep