rails_script 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -4
- data/lib/generators/rails_script/controller/controller_generator.rb +2 -16
- data/lib/generators/rails_script/controller/templates/javascript.js.coffee +1 -1
- data/lib/generators/rails_script/install/install_generator.rb +0 -4
- data/lib/rails_script/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a45c4e0cfcd3d7119e7bbfdd5faced86fff4fdf6
|
4
|
+
data.tar.gz: a2eea95db0864953d79755ba049ee60439950360
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ca7226ed715dc5e8132763055c0034433928e4b46954bfce6e89b0e322ca1a924553df64c2b771350e26b28515447bc2c09e82fa33b2110a5551af5677d6679
|
7
|
+
data.tar.gz: 324e36c76dee1acfe112fe9afb781101005c303895d68f59b723efb3687e9201eda8572a12a4384a392b9a92c5a9f87bffd042c2b5258115a156850f23574ca7
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
#
|
1
|
+
# RailsScript
|
2
2
|
|
3
|
-
|
3
|
+
RailsScript is a Rails-centric, object oriented, featherweight framework for writting CoffeeScript. It is optomized for the [Rails Asset Pipeline](http://guides.rubyonrails.org/asset_pipeline.html) and is compatible with [TurboLinks](https://github.com/rails/turbolinks). Using Rails controller names and actions to call JavaScript, it has never been easier to write clean, concise, and maintanable page specific JavaScript.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -16,7 +16,7 @@ After bundling you need to run the initial installation generator:
|
|
16
16
|
|
17
17
|
$ rails g rails_script:install
|
18
18
|
|
19
|
-
After the generator finishes, you will be prompted to add helper call to your application layout. The generated code is responsible for initializing and
|
19
|
+
After the generator finishes, you will be prompted to add helper call to your application layout. The generated code is responsible for initializing and calling the action specific JavaScript. This helper shouyld be called before the closing body tag.
|
20
20
|
|
21
21
|
```
|
22
22
|
<%= include_rails_script %>
|
@@ -107,7 +107,7 @@ In this example we extracted the rollover action into a new function. Doing so
|
|
107
107
|
|
108
108
|
### Generating New Controllers
|
109
109
|
|
110
|
-
When a new controller is generated, the JavaScript asset file will be generated with
|
110
|
+
When a new controller is generated, the JavaScript asset file will be generated with RailsScript. However, if you need to manually generate a RailsScript controller you can use:
|
111
111
|
|
112
112
|
$ rails g rails_script:controller Some::NewController
|
113
113
|
|
@@ -2,24 +2,10 @@ module RailsScript
|
|
2
2
|
module Generators
|
3
3
|
class ControllerGenerator < ::Rails::Generators::Base
|
4
4
|
source_root File.expand_path("../templates", __FILE__)
|
5
|
-
argument :
|
6
|
-
hook_for :controller
|
5
|
+
argument :controller, type: :string
|
7
6
|
|
8
7
|
def generate_file
|
9
|
-
|
10
|
-
Rails.application.eager_load!
|
11
|
-
controllers = ApplicationController.descendants.map(&:to_s)
|
12
|
-
controllers.each{ |c| c.gsub!('Controller', '') }
|
13
|
-
else
|
14
|
-
controllers = [controller_name]
|
15
|
-
end
|
16
|
-
|
17
|
-
controllers.each do |controller|
|
18
|
-
if !File.exist?("app/assets/javascripts/#{controller.underscore}.js.coffee")
|
19
|
-
template 'javascript.js.coffee', "app/assets/javascripts/#{controller.underscore}.js.coffee"
|
20
|
-
gsub_file "app/assets/javascripts/#{controller.underscore}.js.coffee", 'Example', controller.gsub('::', '')
|
21
|
-
end
|
22
|
-
end
|
8
|
+
template 'javascript.js.coffee', "app/assets/javascripts/#{controller.underscore}.js.coffee"
|
23
9
|
end
|
24
10
|
|
25
11
|
end
|
@@ -16,10 +16,6 @@ module RailsScript
|
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
-
def create_controllers
|
20
|
-
generate 'rails_script:controller'
|
21
|
-
end
|
22
|
-
|
23
19
|
def insert_layout_javascript
|
24
20
|
say <<-RUBY
|
25
21
|
In order to complete installation, you must include the following helper BEFORE the closing body tag in the application layout:
|
data/lib/rails_script/version.rb
CHANGED