chanko 2.2.1 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/master_and_pr.yml +40 -0
- data/.gitignore +1 -1
- data/CHANGELOG.md +15 -1
- data/README.md +3 -43
- data/bin/setup +8 -0
- data/bin/test +7 -0
- data/chanko.gemspec +6 -5
- data/gemfiles/Gemfile_rails_6.1.rb +6 -0
- data/gemfiles/Gemfile_rails_7.0.rb +6 -0
- data/gemfiles/Gemfile_rails_7.1.rb +6 -0
- data/lib/chanko/config.rb +18 -4
- data/lib/chanko/function.rb +4 -13
- data/lib/chanko/loader.rb +124 -48
- data/lib/chanko/railtie.rb +9 -19
- data/lib/chanko/resolver/no_cache_file_system_resolver.rb +13 -0
- data/lib/chanko/test.rb +4 -0
- data/lib/chanko/unit/extender/extension.rb +0 -2
- data/lib/chanko/unit/extender.rb +0 -1
- data/lib/chanko/unit.rb +0 -12
- data/lib/chanko/version.rb +1 -1
- data/lib/generators/chanko/unit/templates/unit.rb.erb +3 -28
- data/lib/generators/chanko/unit/unit_generator.rb +22 -13
- data/spec/chanko/function_spec.rb +6 -30
- data/spec/chanko/invoker_spec.rb +2 -10
- data/spec/chanko/loader_spec.rb +14 -12
- data/spec/chanko/test_spec.rb +2 -5
- data/spec/chanko/unit_spec.rb +0 -63
- data/spec/controllers/application_controller_spec.rb +1 -1
- data/spec/dummy/app/assets/config/manifest.js +3 -0
- data/spec/dummy/app/units/entry_deletion/entry_deletion.rb +0 -16
- data/spec/dummy/app/views/units/example_unit +1 -0
- data/spec/dummy/config/application.rb +9 -1
- data/spec/dummy/config/boot.rb +4 -5
- data/spec/dummy/config/environment.rb +1 -1
- data/spec/dummy/config/environments/test.rb +8 -1
- data/spec/dummy/config/initializers/chanko_initializer.rb +0 -0
- data/spec/dummy/config/storage.yml +1 -0
- data/spec/fixtures/units/example_unit/example_unit.rb +2 -2
- data/spec/spec_helper.rb +19 -5
- metadata +54 -14
- data/.travis.yml +0 -8
- data/Gemfile +0 -11
- data/lib/chanko/unit/extender/active_record_class_methods.rb +0 -57
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 72b1ce54ea0cf5bbf3d56237723d00c9383213d67534c21531ed568465d95435
|
4
|
+
data.tar.gz: 74c763b3087ac11d7ddaa4700995240681ceafd6fcfa1dcf26785d547a20e934
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ec921fb9b47ca4f5878f902a01de61a8e5c96d4f671a1a3f991c3d047f2102c24245697a27e05e0af928acaa7b5345bf8cd79465082a3aabffaf2e66f26a7d68
|
7
|
+
data.tar.gz: a6f855b9f756b034f9098718bc1ad2c0e112f5ad0a616ac2a9023767ba92228c4f41a6cb0e1a21bf53910140dc2a8bf1480180a6aec0b1cbe8b75dd829be7d47
|
@@ -0,0 +1,40 @@
|
|
1
|
+
name: master & PR
|
2
|
+
on:
|
3
|
+
pull_request:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- master
|
7
|
+
jobs:
|
8
|
+
spec:
|
9
|
+
runs-on: ubuntu-latest
|
10
|
+
strategy:
|
11
|
+
matrix:
|
12
|
+
rails_version:
|
13
|
+
- "6.1"
|
14
|
+
- "7.0"
|
15
|
+
- "7.1"
|
16
|
+
ruby_version:
|
17
|
+
- "3.1"
|
18
|
+
- "3.2"
|
19
|
+
- "3.3"
|
20
|
+
eager_load:
|
21
|
+
- "true"
|
22
|
+
- "false"
|
23
|
+
name: Test on Rails ${{ matrix.rails_version }} & Ruby ${{ matrix.ruby_version }} & EagerLoad ${{ matrix.eager_load }}
|
24
|
+
env:
|
25
|
+
BUNDLE_GEMFILE: gemfiles/Gemfile_rails_${{ matrix.rails_version }}.rb
|
26
|
+
CI: true
|
27
|
+
EAGER_LOAD: ${{ matrix.eager_load }}
|
28
|
+
steps:
|
29
|
+
- uses: actions/checkout@v3
|
30
|
+
- uses: ruby/setup-ruby@v1
|
31
|
+
with:
|
32
|
+
ruby-version: ${{ matrix.ruby_version }}
|
33
|
+
bundler-cache: true
|
34
|
+
- name: rspec
|
35
|
+
run: bundle exec rspec
|
36
|
+
- name: Coveralls
|
37
|
+
if: matrix.rails_version == '7.1' && matrix.ruby_version == '3.3'
|
38
|
+
uses: coverallsapp/github-action@master
|
39
|
+
with:
|
40
|
+
github-token: ${{ secrets.GITHUB_TOKEN }}
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,18 @@
|
|
1
|
-
##
|
1
|
+
## 3.0.0
|
2
|
+
* Support Rails 6,1. 7.0, 7.1.
|
3
|
+
* Support Ruby >= 3.0.
|
4
|
+
* Drop support for Rails <= 6.0.
|
5
|
+
* Drop support for Ruby 2.
|
6
|
+
* Drop support for classic loader.
|
7
|
+
* The functionality to extend the view_paths has been discontinued.
|
8
|
+
* The functionality to extend the models has been discontinued.
|
9
|
+
|
10
|
+
## 2.3.0
|
11
|
+
* Support Rails 5.0, 5.1, 5,2, 6.0, 6,1.
|
12
|
+
* Drop support of Rails 4.x.
|
13
|
+
* Rails7 not supported yet.
|
14
|
+
* Chanko::Config.eager_load has been replaced by a direct reference to Rails.configuration.eager_load.
|
15
|
+
* Fix cache resolver error on Rails 6.
|
2
16
|
|
3
17
|
## 2.2.1
|
4
18
|
* Support Rails 7.0.
|
data/README.md
CHANGED
@@ -10,11 +10,9 @@ With Chanko, you can release many features concurrently and manage target users
|
|
10
10
|
When any errors are raised from chanko's features,
|
11
11
|
it will be automatically hidden and fallback to its normal behavior.
|
12
12
|
|
13
|
-
|
14
13
|
## Requirements
|
15
|
-
* Ruby >=
|
16
|
-
* Rails >=
|
17
|
-
|
14
|
+
* Ruby >= 3.0.0
|
15
|
+
* Rails >= 6.1.0
|
18
16
|
|
19
17
|
## Usage
|
20
18
|
Add to your Gemfile.
|
@@ -63,11 +61,6 @@ end
|
|
63
61
|
= invoke(:example_unit, :render_example)
|
64
62
|
```
|
65
63
|
|
66
|
-
```
|
67
|
-
-# app/units/example_unit/views/_example.html.slim
|
68
|
-
= foo
|
69
|
-
```
|
70
|
-
|
71
64
|
## Unit
|
72
65
|
You can see [the real example of an unit module file](https://github.com/cookpad/chanko/blob/master/spec/dummy/app/units/entry_deletion/entry_deletion.rb).
|
73
66
|
|
@@ -120,39 +113,7 @@ end
|
|
120
113
|
```
|
121
114
|
|
122
115
|
### render
|
123
|
-
|
124
|
-
So you can render app/units/example_unit/views/_example.html.slim in invoking.
|
125
|
-
|
126
|
-
```ruby
|
127
|
-
scope(:view) do
|
128
|
-
function(:render_example) do
|
129
|
-
render "/example", :foo => hello("world")
|
130
|
-
end
|
131
|
-
end
|
132
|
-
```
|
133
|
-
|
134
|
-
### models
|
135
|
-
In models block, you can expand model features by `expand` method.
|
136
|
-
The expanded methods are available via unit proxy like `User.unit.active`,
|
137
|
-
`User.find(params[:id]).unit.active?` or `User.unit.gc_all_soft_deleted_users`.
|
138
|
-
|
139
|
-
```ruby
|
140
|
-
models do
|
141
|
-
expand(:User) do
|
142
|
-
scope :active, lambda { where(:deleted_at => nil) }
|
143
|
-
|
144
|
-
def active?
|
145
|
-
deleted_at.nil?
|
146
|
-
end
|
147
|
-
|
148
|
-
class_methods do
|
149
|
-
def gc_all_soft_deleted_users
|
150
|
-
where.not(deleted_at: nil).delete_all
|
151
|
-
end
|
152
|
-
end
|
153
|
-
end
|
154
|
-
end
|
155
|
-
```
|
116
|
+
In version 2 and earlier, Chanko extended Rails' search path to include the views path of the unit. This functionality has been discontinued. To maintain the views path under the unit, you will need to manually create a symbolic link in app/views/units to access it.
|
156
117
|
|
157
118
|
### shared
|
158
119
|
You can call methods defined by `shared` in invoking.
|
@@ -174,7 +135,6 @@ helpers do
|
|
174
135
|
end
|
175
136
|
```
|
176
137
|
|
177
|
-
|
178
138
|
## Example
|
179
139
|
https://github.com/cookpad/chanko/tree/master/spec/dummy
|
180
140
|
Chanko provides an example rails application in spec/dummy directory.
|
data/bin/setup
ADDED
data/bin/test
ADDED
data/chanko.gemspec
CHANGED
@@ -12,21 +12,22 @@ Gem::Specification.new do |gem|
|
|
12
12
|
gem.homepage = "https://github.com/cookpad/chanko"
|
13
13
|
|
14
14
|
gem.files = `git ls-files`.split($/)
|
15
|
-
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
16
15
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
17
16
|
gem.require_paths = ["lib"]
|
18
|
-
gem.required_ruby_version = '>=
|
17
|
+
gem.required_ruby_version = '>= 3.0.0'
|
19
18
|
|
20
|
-
gem.add_dependency "rails", ">=
|
19
|
+
gem.add_dependency "rails", ">= 6.1.0"
|
20
|
+
gem.add_development_dependency "byebug"
|
21
21
|
gem.add_development_dependency "coffee-rails", ">= 3.0.10"
|
22
|
-
gem.add_development_dependency "coveralls"
|
23
22
|
gem.add_development_dependency "jquery-rails"
|
24
23
|
gem.add_development_dependency "pry"
|
24
|
+
gem.add_development_dependency "pry-rails"
|
25
25
|
gem.add_development_dependency "rspec-rails", ">= 3.0.0"
|
26
26
|
gem.add_development_dependency "sass-rails", ">= 3.0.10"
|
27
27
|
gem.add_development_dependency "simplecov"
|
28
|
+
gem.add_development_dependency 'simplecov-lcov'
|
28
29
|
gem.add_development_dependency "slim"
|
29
|
-
gem.add_development_dependency "sqlite3"
|
30
|
+
gem.add_development_dependency "sqlite3", ">= 1.4"
|
30
31
|
gem.add_development_dependency "thin"
|
31
32
|
gem.add_development_dependency "uglifier"
|
32
33
|
end
|
data/lib/chanko/config.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'chanko/resolver/no_cache_file_system_resolver'
|
2
|
+
|
1
3
|
module Chanko
|
2
4
|
module Config
|
3
5
|
class << self
|
@@ -6,13 +8,11 @@ module Chanko
|
|
6
8
|
:backtrace_limit,
|
7
9
|
:cache_units,
|
8
10
|
:compatible_css_class,
|
9
|
-
:eager_load,
|
10
11
|
:enable_logger,
|
11
12
|
:propagated_errors,
|
12
13
|
:proxy_method_name,
|
13
14
|
:raise_error,
|
14
15
|
:resolver,
|
15
|
-
:units_directory_path
|
16
16
|
)
|
17
17
|
|
18
18
|
def reset
|
@@ -20,13 +20,27 @@ module Chanko
|
|
20
20
|
self.backtrace_limit = 10
|
21
21
|
self.compatible_css_class = false
|
22
22
|
self.enable_logger = true
|
23
|
-
self.eager_load = Rails.env.production?
|
24
23
|
self.propagated_errors = []
|
25
24
|
self.proxy_method_name = :unit
|
26
25
|
self.raise_error = Rails.env.development?
|
27
|
-
self.resolver
|
26
|
+
self.resolver = resolver_for_using_rails_and_env
|
28
27
|
self.units_directory_path = "app/units"
|
29
28
|
end
|
29
|
+
|
30
|
+
def units_directory_path=(path)
|
31
|
+
@units_directory_path = path
|
32
|
+
end
|
33
|
+
|
34
|
+
def units_directory_path
|
35
|
+
@resolved_units_directory_path ||= Rails.root.join(@units_directory_path).to_s
|
36
|
+
end
|
37
|
+
|
38
|
+
def resolver_for_using_rails_and_env
|
39
|
+
return ActionView::FileSystemResolver if Rails::VERSION::MAJOR >= 7
|
40
|
+
return Chanko::Resolver::NoCacheFileSystemResolver if Rails.env.development?
|
41
|
+
return ActionView::OptimizedFileSystemResolver
|
42
|
+
end
|
43
|
+
private :resolver_for_using_rails_and_env
|
30
44
|
end
|
31
45
|
|
32
46
|
reset
|
data/lib/chanko/function.rb
CHANGED
@@ -22,12 +22,10 @@ module Chanko
|
|
22
22
|
|
23
23
|
def invoke(context, options = {})
|
24
24
|
with_unit_stack(context) do
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
result
|
30
|
-
end
|
25
|
+
capture_exception(context) do
|
26
|
+
result = context.instance_eval(&block)
|
27
|
+
result = decorate(result, context, options[:type]) if context.view? && result.present?
|
28
|
+
result
|
31
29
|
end
|
32
30
|
end
|
33
31
|
end
|
@@ -59,13 +57,6 @@ module Chanko
|
|
59
57
|
context.units.pop
|
60
58
|
end
|
61
59
|
|
62
|
-
def with_unit_view_path(context)
|
63
|
-
context.view_paths.unshift unit.resolver if context.respond_to?(:view_paths)
|
64
|
-
yield
|
65
|
-
ensure
|
66
|
-
context.view_paths.paths.shift if context.respond_to?(:view_paths)
|
67
|
-
end
|
68
|
-
|
69
60
|
def capture_exception(context)
|
70
61
|
yield
|
71
62
|
rescue Exception => exception
|
data/lib/chanko/loader.rb
CHANGED
@@ -1,73 +1,149 @@
|
|
1
1
|
require "pathname"
|
2
|
-
|
3
2
|
module Chanko
|
4
|
-
|
3
|
+
module Loader
|
4
|
+
class MissingEagarLoadSettingError < StandardError; end
|
5
|
+
|
5
6
|
class << self
|
6
|
-
|
7
|
-
|
7
|
+
delegate :load, :cache, :eager_load_units!, to: "loader"
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.loader
|
11
|
+
zeitwerk? ? ZeitwerkLoader : ClassicLoader
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.zeitwerk?
|
15
|
+
Rails.respond_to?(:autoloaders) && Rails.autoloaders.zeitwerk_enabled?
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.classic?
|
19
|
+
!zeitwerk?
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.prepare_eager_load(mode: )
|
23
|
+
if mode == :zeitwerk && zeitwerk?
|
24
|
+
self.loader.prepare_eager_load
|
25
|
+
elsif mode == :classic && classic?
|
26
|
+
self.loader.prepare_eager_load
|
8
27
|
end
|
28
|
+
end
|
9
29
|
|
10
|
-
|
11
|
-
|
30
|
+
class ZeitwerkLoader
|
31
|
+
def self.load(name)
|
32
|
+
self.new(name).load
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.cache
|
36
|
+
# backward compatibility
|
37
|
+
{ }
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.eager_load_units!
|
41
|
+
# Zeitwerk load chanko units as default
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.prepare_eager_load
|
45
|
+
add_unit_directory_to_eager_load_paths
|
46
|
+
Rails.autoloaders.main.collapse(Chanko::Config.units_directory_path + '/*')
|
47
|
+
Rails.autoloaders.main.ignore(Chanko::Config.units_directory_path + '/*/spec*')
|
12
48
|
end
|
13
49
|
|
14
|
-
def
|
15
|
-
|
16
|
-
|
50
|
+
def self.add_unit_directory_to_eager_load_paths
|
51
|
+
path = Chanko::Config.units_directory_path
|
52
|
+
|
53
|
+
unless Rails.configuration.eager_load_paths.include?(path)
|
54
|
+
Rails.configuration.eager_load_paths << path
|
17
55
|
end
|
18
56
|
end
|
19
|
-
end
|
20
57
|
|
21
|
-
|
22
|
-
|
23
|
-
|
58
|
+
def initialize(name)
|
59
|
+
@name = name
|
60
|
+
end
|
24
61
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
62
|
+
def load
|
63
|
+
constantize
|
64
|
+
rescue NameError
|
65
|
+
# Chanko never raise error even if the constant fails to reference
|
66
|
+
false
|
30
67
|
end
|
31
|
-
end
|
32
68
|
|
33
|
-
|
34
|
-
|
69
|
+
def constantize
|
70
|
+
@name.to_s.camelize.constantize
|
71
|
+
end
|
35
72
|
end
|
36
73
|
|
37
|
-
|
38
|
-
cache
|
39
|
-
|
74
|
+
class ClassicLoader
|
75
|
+
def self.cache
|
76
|
+
@cache ||= {}
|
77
|
+
end
|
40
78
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
cache[@name] = false
|
47
|
-
nil
|
48
|
-
end
|
79
|
+
def self.eager_load_units!
|
80
|
+
Pathname.glob("#{Chanko::Config.units_directory_path}/*").select(&:directory?).each do |path|
|
81
|
+
Chanko::Loader::ClassicLoader.load(path.basename.to_s.to_sym)
|
82
|
+
end
|
83
|
+
end
|
49
84
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
85
|
+
def self.prepare_eager_load
|
86
|
+
raise MissingEagarLoadSettingError if Rails.configuration.eager_load.nil?
|
87
|
+
|
88
|
+
if Rails.configuration.eager_load
|
89
|
+
ruleout_unit_files_from_rails_eager_loading
|
90
|
+
end
|
54
91
|
end
|
55
|
-
end
|
56
92
|
|
57
|
-
|
58
|
-
|
59
|
-
|
93
|
+
def self.ruleout_unit_files_from_rails_eager_loading
|
94
|
+
Rails.configuration.eager_load_paths.delete(Chanko::Config.units_directory_path)
|
95
|
+
end
|
60
96
|
|
61
|
-
|
62
|
-
|
63
|
-
|
97
|
+
def self.load(name)
|
98
|
+
self.new(name).load
|
99
|
+
end
|
64
100
|
|
65
|
-
|
66
|
-
|
67
|
-
|
101
|
+
def self.load_from_cache(name)
|
102
|
+
self.cache[name]
|
103
|
+
end
|
104
|
+
|
105
|
+
def self.save_to_cache(name, unit)
|
106
|
+
self.cache[name] = unit
|
107
|
+
end
|
108
|
+
|
109
|
+
def initialize(name)
|
110
|
+
@name = name
|
111
|
+
end
|
68
112
|
|
69
|
-
|
70
|
-
|
113
|
+
def load
|
114
|
+
load_from_cache.then do |unit|
|
115
|
+
next unit unless unit.nil?
|
116
|
+
load_from_file_and_store_to_cache
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
def load_from_file_and_store_to_cache
|
121
|
+
add_autoload_path
|
122
|
+
constantize.tap do |unit|
|
123
|
+
self.class.save_to_cache(@name, unit)
|
124
|
+
end
|
125
|
+
rescue Exception => exception
|
126
|
+
ExceptionHandler.handle(exception)
|
127
|
+
self.class.save_to_cache(@name, false)
|
128
|
+
false
|
129
|
+
end
|
130
|
+
|
131
|
+
def load_from_cache
|
132
|
+
self.class.load_from_cache(@name)
|
133
|
+
end
|
134
|
+
|
135
|
+
def add_autoload_path
|
136
|
+
ActiveSupport::Dependencies.autoload_paths << autoload_path
|
137
|
+
ActiveSupport::Dependencies.autoload_paths.uniq!
|
138
|
+
end
|
139
|
+
|
140
|
+
def autoload_path
|
141
|
+
"#{Config.units_directory_path }/#{@name}"
|
142
|
+
end
|
143
|
+
|
144
|
+
def constantize
|
145
|
+
@name.to_s.camelize.constantize
|
146
|
+
end
|
71
147
|
end
|
72
148
|
end
|
73
149
|
end
|
data/lib/chanko/railtie.rb
CHANGED
@@ -1,35 +1,25 @@
|
|
1
1
|
module Chanko
|
2
2
|
class Railtie < Rails::Railtie
|
3
|
-
initializer "chanko" do |app|
|
3
|
+
initializer "chanko.include", before: :eager_load! do |app|
|
4
4
|
ActiveSupport.on_load :action_view do
|
5
5
|
::ActionView::Base.send(:include, Helper, Invoker, UnitProxyProvider)
|
6
6
|
end
|
7
7
|
ActiveSupport.on_load :action_controller do
|
8
8
|
::ActionController::Base.send(:include, Controller, Invoker, UnitProxyProvider)
|
9
9
|
end
|
10
|
-
ActiveSupport.on_load :active_record do
|
11
|
-
::ActiveRecord::Base.send(:include, UnitProxyProvider)
|
12
|
-
::ActiveRecord::Relation.send(:include, UnitProxyProvider)
|
13
|
-
::ActiveRecord::Associations::CollectionAssociation.send(:include, UnitProxyProvider)
|
14
|
-
end
|
15
10
|
end
|
16
11
|
|
17
|
-
initializer("chanko.support_zeitwerk") do |app|
|
18
|
-
if Rails.respond_to?(:autoloaders) && Rails.autoloaders.zeitwerk_enabled?
|
19
|
-
Rails.autoloaders.main.collapse(Rails.root.join(Chanko::Config.units_directory_path, '*'))
|
20
|
-
end
|
21
|
-
end
|
22
12
|
|
23
|
-
initializer("chanko.
|
24
|
-
|
25
|
-
|
26
|
-
|
13
|
+
initializer("chanko.zeitwerk.prepare_eager_load", before: :set_autoload_paths) do |app|
|
14
|
+
# zeitwerk freezes autoload_paths after :set_autoload_paths.
|
15
|
+
# So we need to prepare before set_autoload_paths
|
16
|
+
Chanko::Loader.prepare_eager_load(mode: :zeitwerk)
|
27
17
|
end
|
28
18
|
|
29
|
-
initializer("chanko.eager_load_units") do |app|
|
30
|
-
|
31
|
-
|
32
|
-
|
19
|
+
initializer("chanko.eager_load_units", before: :eager_load!) do |app|
|
20
|
+
# This is why we need handmade eager-loading
|
21
|
+
# https://github.com/cookpad/chanko/pull/38
|
22
|
+
Chanko::Loader.eager_load_units!
|
33
23
|
end
|
34
24
|
end
|
35
25
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
unless defined?(ActionView::FileSystemResolver)
|
2
|
+
require 'action_view/template/resolver'
|
3
|
+
end
|
4
|
+
|
5
|
+
module Chanko
|
6
|
+
module Resolver
|
7
|
+
class NoCacheFileSystemResolver < ActionView::FileSystemResolver
|
8
|
+
def query(path, details, formats, locals, cache:)
|
9
|
+
super(path, details, formats, locals, cache: false)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/lib/chanko/test.rb
CHANGED
data/lib/chanko/unit/extender.rb
CHANGED
data/lib/chanko/unit.rb
CHANGED
@@ -33,10 +33,6 @@ module Chanko
|
|
33
33
|
Helper.define(unit_name, &block)
|
34
34
|
end
|
35
35
|
|
36
|
-
def models(&block)
|
37
|
-
extender.instance_eval(&block)
|
38
|
-
end
|
39
|
-
|
40
36
|
def active_if(*conditions, &block)
|
41
37
|
@active_if = ActiveIf.new(*conditions, &block)
|
42
38
|
end
|
@@ -70,10 +66,6 @@ module Chanko
|
|
70
66
|
UnitProxy.generate_prefix(unit_name)
|
71
67
|
end
|
72
68
|
|
73
|
-
def view_path
|
74
|
-
Rails.root.join("#{Config.units_directory_path}/#{unit_name}/views").to_s
|
75
|
-
end
|
76
|
-
|
77
69
|
def find_function(identifier, label)
|
78
70
|
scope = ScopeFinder.find(identifier)
|
79
71
|
target = scope.ancestors.find {|klass| scopes[klass] }
|
@@ -93,10 +85,6 @@ module Chanko
|
|
93
85
|
@shared_methods ||= {}
|
94
86
|
end
|
95
87
|
|
96
|
-
def resolver
|
97
|
-
@resolver ||= Config.resolver.new(view_path)
|
98
|
-
end
|
99
|
-
|
100
88
|
def extender
|
101
89
|
@extender ||= Extender.new(to_prefix)
|
102
90
|
end
|
data/lib/chanko/version.rb
CHANGED