cells-rails 0.0.6 → 0.1.1

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
- SHA1:
3
- metadata.gz: 40821ac015d8c060bd0a7256a50df3e1cd2bfbc4
4
- data.tar.gz: c1b0af24dfd1e96b8ce41a4edfe5ed1706745628
2
+ SHA256:
3
+ metadata.gz: a7b0dcf280b05760c17e077945620957e91f6ca8cf9384379d8d6e982efe06ae
4
+ data.tar.gz: ec0289e903975584640a1aeaf8c9417514a775d2b106c5f8d1d993894c27d51d
5
5
  SHA512:
6
- metadata.gz: f0f8edd58721c1bfa8c151dc410d20d6a4ad6841e0484f75bffddb49eaa85bde373d75de2fd735b6134b530ea0f38fbe24535f25c49dc7a37886204c6378f4a8
7
- data.tar.gz: 928d93f1c90cc4676b701b6070569a6535390509f1e8595b2f4454d8b81040ca70362253009bba7608c41364b6626700edaecdb16a3e3d2192a62b3498c0cf81
6
+ metadata.gz: 3fa9e93d578670b6a9f13cc7008c2a05e581c2b0fc42579a91af913cc3c9f207f7426e5a6662488c2254f29ad29404b255289bb3eaa4b0575b9101bd08a41987
7
+ data.tar.gz: 1162939f99fc4e9f4989f46624f93ed5c148e5a3be1cece4e3a5ae86669509a09f5406542ff4e489b68b2d8424b43c8040ea05ee296ab3950cf034c8dad45c1a
data/.gitignore CHANGED
@@ -1,4 +1,4 @@
1
- /.bundle/
1
+ .bundle/
2
2
  /.yardoc
3
3
  /Gemfile.lock
4
4
  /_yardoc/
@@ -6,4 +6,9 @@
6
6
  /doc/
7
7
  /pkg/
8
8
  /spec/reports/
9
- /tmp/
9
+ /log
10
+ tmp
11
+ .DS_Store
12
+ log/
13
+ *.iml
14
+ .idea
@@ -1,13 +1,19 @@
1
1
  language: ruby
2
2
  rvm:
3
- - ruby-head
4
- - 2.2
5
- - 2.1
6
- - 2.0.0
7
- - 1.9.3
8
- - jruby-19mode
9
- gemfile:
10
- - gemfiles/rails4.2.gemfile
11
- - gemfiles/rails4.1.gemfile
12
- - gemfiles/rails4.0.gemfile
13
- - gemfiles/rails3.2.gemfile
3
+ - 2.4.7
4
+ - 2.5.6
5
+ - 2.6.4
6
+ env:
7
+ - "RAILS_VERSION=5.0"
8
+ - "RAILS_VERSION=5.1"
9
+ - "RAILS_VERSION=5.2"
10
+ - "RAILS_VERSION=6.0"
11
+ matrix:
12
+ fast_finish: true
13
+ exclude:
14
+ - rvm: 2.3.8
15
+ env: RAILS_VERSION=6.0
16
+ - rvm: 2.4.7
17
+ env: RAILS_VERSION=6.0
18
+
19
+ cache: bundler
data/CHANGES.md CHANGED
@@ -1,3 +1,25 @@
1
+ ## 0.1.1
2
+
3
+ * The `Cell.view_paths` are now set automatically for `Trailblazer::Cell`s, too, if the gem is present. This allows starting Rails in daemon mode `rails s -d` and cells finding its views.
4
+
5
+ ## 0.1.0
6
+
7
+ * Support for Rails 6.0 Thank to @Szeliga
8
+
9
+ ## 0.0.9
10
+
11
+ * Prevent Forwardable from printing warnings in Ruby 2.4+
12
+
13
+ ## 0.0.8
14
+
15
+ * Fix testing for `rspec-cells` in combination with Rails 5.1. Thanks @tiagoamaro.
16
+
17
+ ## 0.0.7
18
+
19
+ * Add `config.cells.include_template_engine = false` to turn off automatic
20
+ inclusion of, e.g., `Cell::Slim`.
21
+ * Require Cells >= 4.1.6.
22
+
1
23
  ## 0.0.6
2
24
 
3
25
  * `Testing` fixed with Rails 5.
data/Gemfile CHANGED
@@ -5,9 +5,15 @@ gemspec
5
5
 
6
6
  # gem "my_engine", path: "engines/my_engine"
7
7
 
8
- # gem 'sass-rails', "~> 4.0.3"#, " ~> 3.1.0"
8
+ gem 'sass-rails', "~> 6.0.0"
9
9
  # gem "sprockets", "~> 2.12.3"
10
10
 
11
+ rails_version = ENV.fetch('RAILS_VERSION','5.0')
12
+ gem "railties", "~> #{rails_version}"
13
+ gem "activerecord", "~> #{rails_version}"
14
+
15
+ gem "my_engine", path: "test/rails#{rails_version}/engines/my_engine"
16
+
11
17
  group :development, :test do
12
18
  gem "minitest-spec-rails"
13
19
  gem "capybara_minitest_spec"
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Nick Sutterer
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md CHANGED
@@ -1,4 +1,5 @@
1
1
  # Cells::Rails
2
+ [![Build Status](https://travis-ci.org/trailblazer/cells-rails.svg?branch=master)](https://travis-ci.org/trailblazer/cells-rails)
2
3
 
3
4
  [Cells](https://github.com/apotonick/cells) is a generic view model implementation for Ruby. Cells-rails brings Rails-specific bindings.
4
5
 
@@ -18,3 +19,7 @@ Add this line to your application's Gemfile and keep it real:
18
19
  ```ruby
19
20
  gem 'cells-rails'
20
21
  ```
22
+
23
+ ## License
24
+
25
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile CHANGED
@@ -1,10 +1,12 @@
1
1
  require "bundler/gem_tasks"
2
2
  require "rake/testtask"
3
3
 
4
+ RAILS_VERSION = ENV.fetch('RAILS_VERSION','5.0')
5
+
4
6
  Rake::TestTask.new(:test) do |t|
5
7
  t.libs << "test"
6
8
  t.libs << "lib"
7
- t.test_files = FileList['test/**/*_test.rb']
9
+ t.test_files = FileList["test/rails#{RAILS_VERSION}/**/*_test.rb"]
8
10
  end
9
11
 
10
12
  task :default => :test
@@ -7,6 +7,7 @@ Gem::Specification.new do |spec|
7
7
  spec.version = Cells::Rails::VERSION
8
8
  spec.authors = ["Nick Sutterer"]
9
9
  spec.email = ["apotonick@gmail.com"]
10
+ spec.license = "MIT"
10
11
 
11
12
  spec.summary = %q{Convenient Rails support for Cells.}
12
13
  spec.homepage = "http://trailblazer.to"
@@ -16,13 +17,14 @@ Gem::Specification.new do |spec|
16
17
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
17
18
  spec.require_paths = ["lib"]
18
19
 
19
- spec.add_dependency "cells", ">= 4.1"
20
- spec.add_dependency "actionpack", ">= 3.0"
20
+ spec.add_dependency "cells", ">= 4.1.6", "< 5.0.0"
21
+ spec.add_dependency "actionpack", ">= 5.0"
21
22
 
22
23
 
23
- spec.add_development_dependency "bundler", "~> 1.10"
24
- spec.add_development_dependency "rake", "~> 10.0"
24
+ spec.add_development_dependency "bundler"
25
+ spec.add_development_dependency "rake"
25
26
  spec.add_development_dependency "minitest"
26
27
  spec.add_development_dependency "rails"
27
28
  spec.add_development_dependency "cells-erb"
29
+ spec.add_development_dependency "sass-rails"
28
30
  end
@@ -15,11 +15,13 @@ module Cell
15
15
  asset_path
16
16
  asset_url
17
17
  image_tag
18
+ video_tag
18
19
  audio_path
19
20
  audio_url
20
21
  compute_asset_extname
21
22
  compute_asset_host
22
23
  compute_asset_path
24
+ favicon_link_tag
23
25
  font_path
24
26
  font_url
25
27
  image_path
@@ -1,3 +1,4 @@
1
+ require 'active_support/concern'
1
2
  module Cell
2
3
  def self.rails_version
3
4
  Gem::Version.new(ActionPack::VERSION::STRING)
@@ -45,9 +46,9 @@ module Cell
45
46
  # include ActionController::RequestForgeryProtection
46
47
  included do
47
48
  extend Uber::Delegates
48
- delegates :parent_controller, :session, :params, :request, :config, :env, :url_options
49
+ delegates :parent_controller, :session, :params, :request, :config, :env, :url_options, :default_url_options
49
50
  # forgery protection.
50
- delegates :parent_controller, :protect_against_forgery?, :form_authenticity_token, :request_forgery_protection_token
51
+ delegates :parent_controller, :request_forgery_protection_token
51
52
  end
52
53
 
53
54
  def call(*)
@@ -67,6 +68,20 @@ module Cell
67
68
  ::ActionController::Base.cache_store
68
69
  end
69
70
 
71
+ # In Ruby 2.4.0+, Forwardable prints a warning when you delegate
72
+ # to a private or protected method - so `delegates :protect_against_forgery?`
73
+ # or `delegates :form_authenticity_token` will print warnings all
74
+ # over the place
75
+ #
76
+ # This workaround prevents warnings being printed
77
+ def protect_against_forgery?
78
+ controller.send(:protect_against_forgery?)
79
+ end
80
+
81
+ def form_authenticity_token(*args)
82
+ controller.send(:form_authenticity_token, *args)
83
+ end
84
+
70
85
  module ClassMethods
71
86
  def expand_cache_key(key)
72
87
  ::ActiveSupport::Cache.expand_cache_key(key, :cells)
@@ -2,17 +2,25 @@ module Cell
2
2
  module RailsExtensions
3
3
  # This modules overrides Cell::Testing#controller_for and provides Rails-specific logic.
4
4
  module Testing
5
+ RAILS_7_0 = Gem::Version.new("7.0.0")
6
+ RAILS_5_1 = Gem::Version.new("5.1.0")
7
+ RAILS_5_0 = Gem::Version.new("5.0.0")
8
+
5
9
  def controller_for(controller_class)
6
10
  return unless controller_class
7
11
 
8
12
  controller_class.new.tap do |ctl|
9
- ctl.request = action_controller_test_request
13
+ ctl.request = action_controller_test_request(controller_class)
10
14
  ctl.instance_variable_set :@routes, ::Rails.application.routes.url_helpers
11
15
  end
12
16
  end
13
17
 
14
- def action_controller_test_request
15
- if ::Rails.version.start_with?('5')
18
+ def action_controller_test_request(controller_class)
19
+ version = ::Rails.gem_version
20
+
21
+ if version >= RAILS_5_1 && version < RAILS_7_0
22
+ ::ActionController::TestRequest.create(controller_class)
23
+ elsif version >= RAILS_5_0 && version < RAILS_5_1
16
24
  ::ActionController::TestRequest.create
17
25
  else
18
26
  ::ActionController::TestRequest.new
@@ -14,6 +14,9 @@ module Cell
14
14
 
15
15
  # ruthlessly stolen from the zurb-foundation gem.
16
16
  initializer "cells.update_asset_paths" do |app|
17
+ # Add Rails.root to view_paths
18
+ Cell::ViewModel.view_paths = [Rails.root.join("app", "cells")]
19
+
17
20
  Array(app.config.cells.with_assets).each do |cell_class|
18
21
  # puts "@@@@@ #{cell_class.camelize.constantize.prefixes}"
19
22
  app.config.assets.paths += cell_class.camelize.constantize.prefixes # Song::Cell.prefixes
@@ -54,15 +57,17 @@ module Cell
54
57
  end
55
58
  end
56
59
 
57
- # TODO: allow to turn off this.
58
- initializer "cells.include_template_module", after: "cells.include_default_helpers" do
60
+ IncludeTemplateModules = ->(app) do
61
+ return if app.config.cells.include_template_engine == false
62
+
59
63
  # yepp, this is happening. saves me a lot of coding in each extension.
60
- ViewModel.send(:include, Cell::Erb) if Cell.const_defined?(:Erb, false)
61
- ViewModel.send(:include, Cell::Haml) if Cell.const_defined?(:Haml, false)
64
+ ViewModel.send(:include, Cell::Erb) if Cell.const_defined?(:Erb, false)
65
+ ViewModel.send(:include, Cell::Haml) if Cell.const_defined?(:Haml, false)
62
66
  ViewModel.send(:include, Cell::Hamlit) if Cell.const_defined?(:Hamlit, false)
63
- ViewModel.send(:include, Cell::Slim) if Cell.const_defined?(:Slim, false)
67
+ ViewModel.send(:include, Cell::Slim) if Cell.const_defined?(:Slim, false)
64
68
  end
65
- # ViewModel.template_engine = app.config.app_generators.rails.fetch(:template_engine, "erb").to_s
69
+
70
+ initializer( "cells.include_template_module", after: "cells.include_default_helpers", &IncludeTemplateModules)
66
71
 
67
72
  initializer("cells.development") do |app|
68
73
  if Rails.env == "development"
@@ -71,6 +76,12 @@ module Cell
71
76
  end
72
77
  end
73
78
 
79
+ initializer "trailblazer.cells.update_view_paths" do |app|
80
+ return unless Object.const_defined?(:Trailblazer) && Trailblazer.const_defined?(:Cell)
81
+ # Add Rails.root to view_paths
82
+ Trailblazer::Cell.view_paths = [Rails.root.join("app", "concepts")]
83
+ end
84
+
74
85
  rake_tasks do
75
86
  load "tasks/cells.rake"
76
87
  end
@@ -1 +1,2 @@
1
+ require "cells/rails/version"
1
2
  require "cells/rails"
@@ -1,9 +1,6 @@
1
- require "cells/rails/version"
2
1
  require "cells"
3
-
4
- require "cell/caching/notification"
5
- require "cell/rails"
6
2
  require "cell/railtie"
3
+ require "cell/caching/notification"
7
4
  require "cell/rails/testing"
8
5
 
9
6
  module Cell
@@ -1,5 +1,5 @@
1
1
  module Cells
2
2
  module Rails
3
- VERSION = "0.0.6"
3
+ VERSION = "0.1.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cells-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Sutterer
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-07-03 00:00:00.000000000 Z
11
+ date: 2020-07-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cells
@@ -16,56 +16,62 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '4.1'
19
+ version: 4.1.6
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: 5.0.0
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
27
  - - ">="
25
28
  - !ruby/object:Gem::Version
26
- version: '4.1'
29
+ version: 4.1.6
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: 5.0.0
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: actionpack
29
35
  requirement: !ruby/object:Gem::Requirement
30
36
  requirements:
31
37
  - - ">="
32
38
  - !ruby/object:Gem::Version
33
- version: '3.0'
39
+ version: '5.0'
34
40
  type: :runtime
35
41
  prerelease: false
36
42
  version_requirements: !ruby/object:Gem::Requirement
37
43
  requirements:
38
44
  - - ">="
39
45
  - !ruby/object:Gem::Version
40
- version: '3.0'
46
+ version: '5.0'
41
47
  - !ruby/object:Gem::Dependency
42
48
  name: bundler
43
49
  requirement: !ruby/object:Gem::Requirement
44
50
  requirements:
45
- - - "~>"
51
+ - - ">="
46
52
  - !ruby/object:Gem::Version
47
- version: '1.10'
53
+ version: '0'
48
54
  type: :development
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
51
57
  requirements:
52
- - - "~>"
58
+ - - ">="
53
59
  - !ruby/object:Gem::Version
54
- version: '1.10'
60
+ version: '0'
55
61
  - !ruby/object:Gem::Dependency
56
62
  name: rake
57
63
  requirement: !ruby/object:Gem::Requirement
58
64
  requirements:
59
- - - "~>"
65
+ - - ">="
60
66
  - !ruby/object:Gem::Version
61
- version: '10.0'
67
+ version: '0'
62
68
  type: :development
63
69
  prerelease: false
64
70
  version_requirements: !ruby/object:Gem::Requirement
65
71
  requirements:
66
- - - "~>"
72
+ - - ">="
67
73
  - !ruby/object:Gem::Version
68
- version: '10.0'
74
+ version: '0'
69
75
  - !ruby/object:Gem::Dependency
70
76
  name: minitest
71
77
  requirement: !ruby/object:Gem::Requirement
@@ -108,6 +114,20 @@ dependencies:
108
114
  - - ">="
109
115
  - !ruby/object:Gem::Version
110
116
  version: '0'
117
+ - !ruby/object:Gem::Dependency
118
+ name: sass-rails
119
+ requirement: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ type: :development
125
+ prerelease: false
126
+ version_requirements: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
111
131
  description:
112
132
  email:
113
133
  - apotonick@gmail.com
@@ -119,6 +139,7 @@ files:
119
139
  - ".travis.yml"
120
140
  - CHANGES.md
121
141
  - Gemfile
142
+ - LICENSE.txt
122
143
  - README.md
123
144
  - Rakefile
124
145
  - cells-rails.gemspec
@@ -149,7 +170,8 @@ files:
149
170
  - lib/rails/generators/test_unit/concept/concept_generator.rb
150
171
  - lib/rails/generators/test_unit/concept/templates/unit_test.rb.erb
151
172
  homepage: http://trailblazer.to
152
- licenses: []
173
+ licenses:
174
+ - MIT
153
175
  metadata: {}
154
176
  post_install_message:
155
177
  rdoc_options: []
@@ -167,7 +189,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
167
189
  version: '0'
168
190
  requirements: []
169
191
  rubyforge_project:
170
- rubygems_version: 2.5.1
192
+ rubygems_version: 2.7.6
171
193
  signing_key:
172
194
  specification_version: 4
173
195
  summary: Convenient Rails support for Cells.