cookpad / chanko Goto Github PK
View Code? Open in Web Editor NEWRapidly and safely prototyping your rails application
Home Page: https://cookpad.github.io/chanko/
License: MIT License
Rapidly and safely prototyping your rails application
Home Page: https://cookpad.github.io/chanko/
License: MIT License
Recently I started to play and adopt Chanko into our project. It works nicely and really changes the way we work.
However, I found that in Chanko 2.0, the unit generator no longer creates spec files for units, and since there's no need to run install generator in 2.0, the app/units
folder is also not symlinked to /spec
.
What is the suggested way to test against Chanko 2.0?
cookpad_all では Rails 6.0 で zeitwerk を使っている状況で Chanko を使っています。
また Chanko::Config
の設定については config/initializers
以下に Chanko 用のファイルを用意してそこで各種値を設定しており、そこで unit を置くディレクトリを Chanko::Config.units_directory_path = "app/extensions"
で変更しています。
上で設定した units_directory_path
が反映されず、デフォルトである app/units
で固定されてしまいます。
Chanko::Config
は一度 units_directory_path
を読み出そうとしたタイミングで現在の @units_directory_path
の値をキャッシュしています。
Lines 34 to 36 in f6fdda4
また、zeitwerk 環境下では以下のコードにより before: :set_autoload_paths
のタイミングで Chanko::Loader.prepare_eager_load
が呼び出されます。これは initializers
以下のコードが実行されるよりも前のタイミングです。
Lines 18 to 22 in f6fdda4
この prepare_eager_load
の中で Chanko::Config::units_directory_path
が読み出されているんですが、その時点ではまだ units_directory_path
がデフォルト値なのでそちらの値でパスが固定されます。
Line 46 in f6fdda4
@resolved_units_directory_path
に一度値が入ってしまった場合、 @units_directory_path
にいくら値を入れても Chanko で利用するパスは変更できないので、units_directory_path=(path)
で @resolved_units_directory_path
が nil でないときに例外を吐くなどをしたい。Rails6 + development + zeitwerk及びclassicのview拡張
scope(:view) do
function(:hello) do
render '/hello'
end
end
上記をviewファイルから呼び出した状態で、viewファイル「のみ」を保存しリロードすると、下記のエラーが発生する。
[Chanko] ActionView::Template::Error - undefined method `_app_units_hello_world_views__hello_html_erb__3197552978688360732_19600' for #<ActionView::Base:0x00000000009ad8>
Rails6ではViewファイルを保存するたびにActionView::Baseを作り直すようで、Unitで事後に定義したviewファイルの追加設定が反映されない。
Rails6
1. Viewクラスのインスタンス(viewでのself.__id__)
- リロード => 不変
- Viewファイル書き換え => 変更
- Modelファイル書き換え => 変更
2. Model/Unit
- リロード => 不変
- Viewファイル書き換え => 不変
- Modelファイル書き換え => 変更
Rails5
1. Viewクラスのインスタンス(viewでのself.__id__)
- リロード => 不変
- Viewファイル書き換え => 不変
- Modelファイル書き換え => 変更
3. Model/Unit
- リロード => 不変
- Viewファイル書き換え => 不変
- Modelファイル書き換え => 変更
Hi there
I might be missing something but am wondering what the best practice would be when prototyping a feature that requires "new" routes and controllers. The readme covers scenarios where the feature is implemented as an extension to existing controllers, models and views but I don't see a story for units that include new routes and controllers. I guess what I was expecting to see for this was some kind of :routes scope?
Is this something that you've considered and if so can you provide some guidance?
Thanks
Richie
v2.0.8 on Sep 15, 2015
is too old 😭
This line not work in rails 6.1.0.
https://github.com/cookpad/chanko/blob/master/lib/chanko/loader.rb#L51
def add_autoload_path
ActiveSupport::Dependencies.autoload_paths << autoload_path
ActiveSupport::Dependencies.autoload_paths.uniq!
end
Because ActiveSupport::Dependencies.autoload_paths
is frozen.
https://guides.rubyonrails.org/autoloading_and_reloading_constants.html#autoload-paths
Hi, this is not an issue, but a simple question whether it works with rails 3.2.x versions?
See this failing spec I added to the chanko_sample app:
robbevan/chanko_sample@6179ebe
The spec will pass if 'include Chanko::Invoker' is removed/commented out in ApplicationHelper.
Commenting out the two alias_method_chain statements on lines #20 and #43 in invoker.rb will fix this, but that's as far as I've got in trying to work out what's going on ;-)
This can be avoided by letting zeitwerk do the work instead of using Chanko :: Loader.
So in my project I added the following code in config/application.rb
config.before_configuration do
Chanko::Config.eager_load = false
end
Is it possible to add a decision process to determine if zeitwerk is used in the next part, like #57?
https://github.com/cookpad/chanko/blob/master/lib/chanko/railtie.rb#L24
https://github.com/cookpad/chanko/blob/master/lib/chanko/railtie.rb#L30
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.