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.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/master_and_pr.yml +40 -0
  3. data/.gitignore +1 -1
  4. data/CHANGELOG.md +15 -1
  5. data/README.md +3 -43
  6. data/bin/setup +8 -0
  7. data/bin/test +7 -0
  8. data/chanko.gemspec +6 -5
  9. data/gemfiles/Gemfile_rails_6.1.rb +6 -0
  10. data/gemfiles/Gemfile_rails_7.0.rb +6 -0
  11. data/gemfiles/Gemfile_rails_7.1.rb +6 -0
  12. data/lib/chanko/config.rb +18 -4
  13. data/lib/chanko/function.rb +4 -13
  14. data/lib/chanko/loader.rb +124 -48
  15. data/lib/chanko/railtie.rb +9 -19
  16. data/lib/chanko/resolver/no_cache_file_system_resolver.rb +13 -0
  17. data/lib/chanko/test.rb +4 -0
  18. data/lib/chanko/unit/extender/extension.rb +0 -2
  19. data/lib/chanko/unit/extender.rb +0 -1
  20. data/lib/chanko/unit.rb +0 -12
  21. data/lib/chanko/version.rb +1 -1
  22. data/lib/generators/chanko/unit/templates/unit.rb.erb +3 -28
  23. data/lib/generators/chanko/unit/unit_generator.rb +22 -13
  24. data/spec/chanko/function_spec.rb +6 -30
  25. data/spec/chanko/invoker_spec.rb +2 -10
  26. data/spec/chanko/loader_spec.rb +14 -12
  27. data/spec/chanko/test_spec.rb +2 -5
  28. data/spec/chanko/unit_spec.rb +0 -63
  29. data/spec/controllers/application_controller_spec.rb +1 -1
  30. data/spec/dummy/app/assets/config/manifest.js +3 -0
  31. data/spec/dummy/app/units/entry_deletion/entry_deletion.rb +0 -16
  32. data/spec/dummy/app/views/units/example_unit +1 -0
  33. data/spec/dummy/config/application.rb +9 -1
  34. data/spec/dummy/config/boot.rb +4 -5
  35. data/spec/dummy/config/environment.rb +1 -1
  36. data/spec/dummy/config/environments/test.rb +8 -1
  37. data/spec/dummy/config/initializers/chanko_initializer.rb +0 -0
  38. data/spec/dummy/config/storage.yml +1 -0
  39. data/spec/fixtures/units/example_unit/example_unit.rb +2 -2
  40. data/spec/spec_helper.rb +19 -5
  41. metadata +54 -14
  42. data/.travis.yml +0 -8
  43. data/Gemfile +0 -11
  44. 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: 12298afeff1eced18d28a06531c8a34469c97da44a93f988a6caa7835fca337b
4
- data.tar.gz: 3eb396ab691ec4d7c84fa58bdb23d43c017f6ca1eb2da29902ee2ed9adc5e542
3
+ metadata.gz: 72b1ce54ea0cf5bbf3d56237723d00c9383213d67534c21531ed568465d95435
4
+ data.tar.gz: 74c763b3087ac11d7ddaa4700995240681ceafd6fcfa1dcf26785d547a20e934
5
5
  SHA512:
6
- metadata.gz: ddd983d0d75d909378694f3d752d8f2b07fc8166c018de5ba1667f7309e94da09d98fdf186f746c96fc74bd1f45180b017341f999d6cb717ef18bb97269dff06
7
- data.tar.gz: b92cac319cbb13c2c381c40159a784550fec5714e9b83ea867cc59605e70929c601c247d8f003d39b2f58935caeafb9d96d3e8e65b82784e1cd13abf1c22c93e
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
@@ -8,7 +8,7 @@ spec/dummy/.sass-cache
8
8
  .bundle
9
9
  .config
10
10
  .yardoc
11
- Gemfile.lock
11
+ gemfiles/Gemfile_rails_*.rb.lock
12
12
  InstalledFiles
13
13
  _yardoc
14
14
  coverage
data/CHANGELOG.md CHANGED
@@ -1,4 +1,18 @@
1
- ## Unreleased
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 >= 2.1.0
16
- * Rails >= 4.0.0
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
- The view path app/units/example_unit/views is added into view_paths in invoking.
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
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ for path in gemfiles/Gemfile_*.rb; do
7
+ BUNDLE_GEMFILE="${path}" bundle install
8
+ done
data/bin/test ADDED
@@ -0,0 +1,7 @@
1
+ set -euo pipefail
2
+ IFS=$'\n\t'
3
+ set -vx
4
+
5
+ for path in gemfiles/Gemfile_*.rb; do
6
+ BUNDLE_GEMFILE="${path}" bundle exec rspec
7
+ done
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 = '>= 2.6.0'
17
+ gem.required_ruby_version = '>= 3.0.0'
19
18
 
20
- gem.add_dependency "rails", ">= 4.0.0"
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
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec path: '..'
4
+
5
+ gem 'rails', '~> 6.1.0'
6
+ gem 'sqlite3', '~> 1.4'
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec path: '..'
4
+
5
+ gem 'rails', '~> 7.0.0'
6
+ gem 'sqlite3', '~> 1.4'
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec path: '..'
4
+
5
+ gem 'rails', '~> 7.1.0'
6
+ gem 'sqlite3', '~> 1.4'
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 = Gem::Version.new(Rails::VERSION::STRING) >= Gem::Version.new('7') ? ActionView::FileSystemResolver : ActionView::OptimizedFileSystemResolver
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
@@ -22,12 +22,10 @@ module Chanko
22
22
 
23
23
  def invoke(context, options = {})
24
24
  with_unit_stack(context) do
25
- with_unit_view_path(context) do
26
- capture_exception(context) do
27
- result = context.instance_eval(&block)
28
- result = decorate(result, context, options[:type]) if context.view? && result.present?
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
- class Loader
3
+ module Loader
4
+ class MissingEagarLoadSettingError < StandardError; end
5
+
5
6
  class << self
6
- def load(unit_name)
7
- new(unit_name).load
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
- def cache
11
- @cache ||= {}
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 eager_load_units!
15
- Pathname.glob("#{Rails.root}/#{Config.units_directory_path}/*").select(&:directory?).each do |path|
16
- load(path.to_s.split("/").last.to_sym) rescue nil
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
- def initialize(name)
22
- @name = name
23
- end
58
+ def initialize(name)
59
+ @name = name
60
+ end
24
61
 
25
- def load
26
- if loaded?
27
- load_from_cache
28
- else
29
- load_from_file
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
- def loaded?
34
- cache[@name] != nil
69
+ def constantize
70
+ @name.to_s.camelize.constantize
71
+ end
35
72
  end
36
73
 
37
- def load_from_cache
38
- cache[@name]
39
- end
74
+ class ClassicLoader
75
+ def self.cache
76
+ @cache ||= {}
77
+ end
40
78
 
41
- def load_from_file
42
- add_autoload_path
43
- cache[@name] = constantize
44
- rescue Exception => exception
45
- ExceptionHandler.handle(exception)
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
- def add_autoload_path
51
- unless Rails.respond_to?(:autoloaders) && Rails.autoloaders.zeitwerk_enabled?
52
- ActiveSupport::Dependencies.autoload_paths << autoload_path
53
- ActiveSupport::Dependencies.autoload_paths.uniq!
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
- def autoload_path
58
- Rails.root.join("#{directory_path}/#@name").to_s
59
- end
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
- def directory_path
62
- Config.units_directory_path
63
- end
97
+ def self.load(name)
98
+ self.new(name).load
99
+ end
64
100
 
65
- def constantize
66
- @name.to_s.camelize.constantize
67
- end
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
- def cache
70
- self.class.cache
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
@@ -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.prevent_units_directory_from_eager_loading", before: :set_autoload_paths) do |app|
24
- if Chanko::Config.eager_load
25
- Rails.configuration.eager_load_paths.delete(Rails.root.join(Chanko::Config.units_directory_path).to_s)
26
- end
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
- if Chanko::Config.eager_load
31
- Chanko::Loader.eager_load_units!
32
- end
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
@@ -8,6 +8,10 @@ module Chanko
8
8
  def included(base)
9
9
  base.send :include, UnitProxyProvider
10
10
  end
11
+
12
+ def logger
13
+ @logger = ::Logger.new(STDOUT)
14
+ end
11
15
  end
12
16
 
13
17
  def enable_unit(unit_name)
@@ -2,8 +2,6 @@ module Chanko
2
2
  module Unit
3
3
  class Extender
4
4
  class Extension < Module
5
- include ActiveRecordClassMethods
6
-
7
5
  def initialize(mod, prefix = nil, &block)
8
6
  @mod = mod
9
7
  @prefix = prefix
@@ -1,4 +1,3 @@
1
- require "chanko/unit/extender/active_record_class_methods"
2
1
  require "chanko/unit/extender/extension"
3
2
 
4
3
  module Chanko
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
@@ -1,3 +1,3 @@
1
1
  module Chanko
2
- VERSION = "2.2.1"
2
+ VERSION = "3.0.0"
3
3
  end