sections_rails 0.7.2 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +4 -6
- data/lib/sections_rails/section_asset_rendering.rb +50 -29
- data/lib/sections_rails/version.rb +1 -1
- data/spec/controllers/image_assets_controller_spec.rb +2 -2
- data/spec/controllers/script_assets_controller_spec.rb +1 -1
- data/spec/controllers/style_assets_controller_spec.rb +1 -1
- data/spec/dummy/config/application.rb +15 -5
- data/spec/dummy/config/environments/development.rb +9 -12
- data/spec/dummy/config/environments/test.rb +15 -12
- data/spec/dummy/config/initializers/secret_token.rb +1 -0
- data/spec/dummy/config/routes.rb +1 -1
- data/spec/dummy/log/development.log +2517 -0
- data/spec/dummy/tmp/cache/assets/development/sass/6895cbbabdbdd68bfd5eaeb8a7205320b5ae8570/sass.sassc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/8498f83ad93e5e5008158dd5f1a619c70444d1b9/css_scss.css.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/af6c5e5e0472cd741dba44cad548e8bee004b57f/css_sass.css.sassc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/c4f2628633a30efcaac4adae6d64dc98a3dc5098/scss.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/07debd2f5bdd0945f151e2b19446f044 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/08f27e536dfd0bf16e287507b2acf9cd +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/0fca8ebe3afdfe78547af6286f823282 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/1b3072864335229a30962921e232e038 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/1e3b95f4fb7349356a18d5d6c25a03c5 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/1ef0ad5f3bf9347ff721cc9adb7ac475 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/22ca9b4c7a72cecb6e5bd86aeb2cbe1a +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/23a710a5152e77b9f6093d0ff6132cbb +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/2760c50c86bfb006436f3b08f7f86d50 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/27cd0623d0c7bf548c06891f9ff3a7fe +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/2883d6642cddc16b7cbec8a10d604e1f +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/43f23e226a6cf9111462a1de5a4141c9 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/4469f565cbeb63b8a9dd57c772a0063f +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/4bfa702f177bb40d4add4fa2cdc56290 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/620334e6045e81791d00cfc3d5880e99 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/778cbfb3c3494e0a1bff25acec1acb41 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/88172c7017f9d54036e04229e5aeb7a9 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/a1675ac0cfcd39baa9de6cd3800ed7d8 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/a5d83488b94f2eb72952aead38dff3e3 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/a6fce1b02a415f12102f90ede73a4466 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/ab9a16c02e5840aa2caa410053c6d992 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/ad63aa5b66774feeab4dc6bcf5cd62ba +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/b4e4bd3378cc31d280c2f1e817d7e563 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/b55f94acb73aef21cd0314d38e7154d1 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/bb6a12b80c6bb08c7943f43676e3c85b +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/c427bfd8150de82240a0e21a09f2555b +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/c6e5bc7bd239a1911ec2e68129e3de64 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/dca0e46db52c9d8f506520eb6da852d5 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/e96fdb62e07b19eed5b0da3f39778ad8 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/ea32dd93eace3bc52cef33158a05dff0 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/ee731240c77f9d385c44692245a14659 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/f05f533e9d84fde309ea83909d9ce528 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/f4e42345683e627f5c3ddbed7b0f3003 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/f5d263c951494ab0fb39fe65f211ea9d +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/fb9a65051eb9d735f3634545d153a9eb +0 -0
- data/spec/spec_helper.rb +4 -2
- metadata +141 -33
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: eeeef33448cd6b0e68ef9770dd85824fe160db3a
|
4
|
+
data.tar.gz: ee80965c2a0212282b1247cf8c4138b7c39690bb
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5251a0e3f15cc42a908f08b2be7f7747fb97f02dd290eb6331e9d67861f49cb1a69bfcc45778e936e0c30e4321db70b5a96c8308ebac202c92af15caeeca16b7
|
7
|
+
data.tar.gz: ec87d416e8e1e0c2d5296df248a1ccd83eae55b92ac1e93d2383bce2acc8869ad94be5909c6cbbb3fb1fa1cc1d2e9e69614ea38dc8ba612f929ca51698bf6ea3
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Sections for Rails [![Build Status](https://travis-ci.org/kevgo/sections_rails.png?branch=master)](https://travis-ci.org/kevgo/sections_rails) [![Code Climate](https://codeclimate.com/github/kevgo/sections_rails.png)](https://codeclimate.com/github/kevgo/sections_rails) [![Coverage Status](https://coveralls.io/repos/kevgo/sections_rails/badge.png?branch=master)](https://coveralls.io/r/kevgo/sections_rails)
|
1
|
+
# Sections for Rails [![Build Status](https://travis-ci.org/kevgo/sections_rails.png?branch=master)](https://travis-ci.org/kevgo/sections_rails) [![Code Climate](https://codeclimate.com/github/kevgo/sections_rails.png)](https://codeclimate.com/github/kevgo/sections_rails) [![Coverage Status](https://coveralls.io/repos/kevgo/sections_rails/badge.png?branch=master)](https://coveralls.io/r/kevgo/sections_rails) [![Dependency Status](https://gemnasium.com/kevgo/sections_rails.png)](https://gemnasium.com/kevgo/sections_rails)
|
2
2
|
|
3
3
|
_A component-oriented infrastructure for the view layer of Ruby on Rails applications._
|
4
4
|
|
@@ -60,11 +60,11 @@ The generator
|
|
60
60
|
|
61
61
|
* creates a new folder __/app/sections__, in which you put the source code for the different sections.
|
62
62
|
|
63
|
-
* adds the folder
|
63
|
+
* adds the folder /app/sections to the asset pipeline by inserting this line into your _application.rb_ file:
|
64
64
|
|
65
65
|
config.assets.paths << 'app/sections'
|
66
66
|
|
67
|
-
* optionally creates a demo section called
|
67
|
+
* optionally creates a demo section called __hello_world__ that you can try out as described below.
|
68
68
|
|
69
69
|
|
70
70
|
The current implementation requires two empty asset container files: __application_sections.js__ and __application_sections.css__.
|
@@ -158,9 +158,7 @@ To run your section tests using [Konacha](https://github.com/jfirebaugh/konacha)
|
|
158
158
|
Feel free to send unit-tested pull requests! The unit tests of this project are run using `rake`.
|
159
159
|
|
160
160
|
|
161
|
-
###
|
162
|
-
|
163
|
-
_Sections_rails_ is far from complete. Some missing things are:
|
161
|
+
### Roadmap
|
164
162
|
|
165
163
|
* Support for multiple application assets, for example page-specific compiled asset files instead of one global one.
|
166
164
|
* Support for serverside controller logic for sections, for example by integrating with https://github.com/apotonick/cells.
|
@@ -51,42 +51,63 @@ module SectionsRails
|
|
51
51
|
end
|
52
52
|
|
53
53
|
|
54
|
-
# Renders the assets of this section into the given
|
55
|
-
def render_assets
|
56
|
-
render_js_assets
|
57
|
-
render_css_assets
|
54
|
+
# Renders the assets of this section into the given out.
|
55
|
+
def render_assets out
|
56
|
+
render_js_assets out
|
57
|
+
render_css_assets out
|
58
58
|
end
|
59
59
|
|
60
60
|
# Renders the CSS for this section.
|
61
|
-
def render_css_assets
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
# No option for :css given --> include the default stylesheet.
|
71
|
-
css_includepath = find_css_includepath
|
72
|
-
result << @view.stylesheet_link_tag(css_includepath) if css_includepath
|
73
|
-
end
|
61
|
+
def render_css_assets out
|
62
|
+
|
63
|
+
# Handle default case if no options given.
|
64
|
+
return render_default_css_asset(out) unless @options.has_key? :css
|
65
|
+
|
66
|
+
# Do nothing if 'css: nil' given.
|
67
|
+
return unless @options[:css]
|
68
|
+
|
69
|
+
render_custom_css_asset @options[:css], out
|
74
70
|
end
|
75
71
|
|
72
|
+
|
73
|
+
# Renders the CSS asset with the given filename.
|
74
|
+
def render_custom_css_asset filename, out
|
75
|
+
out << @view.stylesheet_link_tag(File.join(folder_includepath, @options[:css]))
|
76
|
+
end
|
77
|
+
|
78
|
+
|
79
|
+
# Renders the default CSS asset.
|
80
|
+
def render_default_css_asset out
|
81
|
+
css_includepath = find_css_includepath
|
82
|
+
out << @view.stylesheet_link_tag(css_includepath) if css_includepath
|
83
|
+
end
|
84
|
+
|
85
|
+
|
76
86
|
# Renders the JS for this section.
|
77
|
-
def render_js_assets
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
js_includepath = find_js_includepath
|
87
|
-
result << @view.javascript_include_tag(js_includepath) if js_includepath
|
88
|
-
end
|
87
|
+
def render_js_assets out
|
88
|
+
|
89
|
+
# Render default asset if no option given.
|
90
|
+
return render_default_js_asset(out) unless @options.has_key? :js
|
91
|
+
|
92
|
+
# Do nothing if 'js: nil' given.
|
93
|
+
return unless @options[:js]
|
94
|
+
|
95
|
+
render_custom_js_asset @options[:js], out
|
89
96
|
end
|
97
|
+
|
98
|
+
|
99
|
+
# Renders the default JS asset.
|
100
|
+
def render_default_js_asset out
|
101
|
+
js_includepath = find_js_includepath
|
102
|
+
out << @view.javascript_include_tag(js_includepath) if js_includepath
|
103
|
+
end
|
104
|
+
|
105
|
+
|
106
|
+
# Renders the JS asset with the given filename.
|
107
|
+
def render_custom_js_asset filename, out
|
108
|
+
out << @view.javascript_include_tag(File.join(folder_includepath, filename))
|
109
|
+
end
|
110
|
+
|
90
111
|
end
|
91
112
|
end
|
92
113
|
end
|
@@ -4,9 +4,9 @@ describe ImageAssetsController do
|
|
4
4
|
render_views
|
5
5
|
|
6
6
|
before :each do
|
7
|
-
RSpec::Matchers.define :have_image_tag do |
|
7
|
+
RSpec::Matchers.define :have_image_tag do |image_path|
|
8
8
|
match do |body|
|
9
|
-
body =~ Regexp.new("<img.*src=\"#{
|
9
|
+
body =~ Regexp.new("<img.*src=\"#{image_path}\"")
|
10
10
|
end
|
11
11
|
end
|
12
12
|
end
|
@@ -6,14 +6,24 @@ require "sprockets/railtie"
|
|
6
6
|
# require 'rails/all'
|
7
7
|
require 'haml'
|
8
8
|
|
9
|
-
Bundler.require(
|
10
|
-
|
9
|
+
Bundler.require(:default, Rails.env)
|
10
|
+
require 'sections_rails'
|
11
11
|
|
12
12
|
module Dummy
|
13
13
|
class Application < Rails::Application
|
14
|
-
config
|
15
|
-
|
16
|
-
|
14
|
+
# Settings in config/environments/* take precedence over those specified here.
|
15
|
+
# Application configuration should go into files in config/initializers
|
16
|
+
# -- all .rb files in that directory are automatically loaded.
|
17
|
+
|
18
|
+
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
19
|
+
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
20
|
+
# config.time_zone = 'Central Time (US & Canada)'
|
21
|
+
|
22
|
+
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
23
|
+
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
24
|
+
# config.i18n.default_locale = :de
|
25
|
+
|
26
|
+
config.assets.paths += %w(../../app/sections)
|
17
27
|
end
|
18
28
|
end
|
19
29
|
|
@@ -1,27 +1,24 @@
|
|
1
1
|
Dummy::Application.configure do
|
2
|
-
# Settings specified here will take precedence over those in config/application.rb
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb.
|
3
3
|
|
4
4
|
# In the development environment your application's code is reloaded on
|
5
5
|
# every request. This slows down response time but is perfect for development
|
6
6
|
# since you don't have to restart the web server when you make code changes.
|
7
7
|
config.cache_classes = false
|
8
8
|
|
9
|
-
#
|
10
|
-
config.
|
9
|
+
# Do not eager load code on boot.
|
10
|
+
config.eager_load = false
|
11
11
|
|
12
|
-
# Show full error reports and disable caching
|
12
|
+
# Show full error reports and disable caching.
|
13
13
|
config.consider_all_requests_local = true
|
14
14
|
config.action_controller.perform_caching = false
|
15
15
|
|
16
|
-
# Print deprecation notices to the Rails logger
|
16
|
+
# Print deprecation notices to the Rails logger.
|
17
17
|
config.active_support.deprecation = :log
|
18
18
|
|
19
|
-
#
|
20
|
-
|
21
|
-
|
22
|
-
# Do not compress assets
|
23
|
-
config.assets.compress = false
|
24
|
-
|
25
|
-
# Expands the lines which load the assets
|
19
|
+
# Debug mode disables concatenation and preprocessing of assets.
|
20
|
+
# This option may cause significant delays in view rendering with a large
|
21
|
+
# number of complex assets.
|
26
22
|
config.assets.debug = true
|
27
23
|
end
|
24
|
+
|
@@ -1,5 +1,5 @@
|
|
1
1
|
Dummy::Application.configure do
|
2
|
-
# Settings specified here will take precedence over those in config/application.rb
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb.
|
3
3
|
|
4
4
|
# The test environment is used exclusively to run your application's
|
5
5
|
# test suite. You never need to work with it otherwise. Remember that
|
@@ -7,28 +7,31 @@ Dummy::Application.configure do
|
|
7
7
|
# and recreated between test runs. Don't rely on the data there!
|
8
8
|
config.cache_classes = true
|
9
9
|
|
10
|
-
#
|
11
|
-
|
12
|
-
|
10
|
+
# Do not eager load code on boot. This avoids loading your whole application
|
11
|
+
# just for the purpose of running a single test. If you are using a tool that
|
12
|
+
# preloads Rails for running tests, you may have to set it to true.
|
13
|
+
config.eager_load = false
|
13
14
|
|
14
|
-
#
|
15
|
-
config.
|
15
|
+
# Configure static asset server for tests with Cache-Control for performance.
|
16
|
+
config.serve_static_assets = true
|
17
|
+
config.static_cache_control = "public, max-age=3600"
|
16
18
|
|
17
|
-
# Show full error reports and disable caching
|
19
|
+
# Show full error reports and disable caching.
|
18
20
|
config.consider_all_requests_local = true
|
19
21
|
config.action_controller.perform_caching = false
|
20
22
|
|
21
|
-
# Raise exceptions instead of rendering exception templates
|
23
|
+
# Raise exceptions instead of rendering exception templates.
|
22
24
|
config.action_dispatch.show_exceptions = false
|
23
25
|
|
24
|
-
# Disable request forgery protection in test environment
|
25
|
-
config.action_controller.allow_forgery_protection
|
26
|
+
# Disable request forgery protection in test environment.
|
27
|
+
config.action_controller.allow_forgery_protection = false
|
26
28
|
|
27
29
|
# Tell Action Mailer not to deliver emails to the real world.
|
28
30
|
# The :test delivery method accumulates sent emails in the
|
29
31
|
# ActionMailer::Base.deliveries array.
|
30
|
-
#config.action_mailer.delivery_method = :test
|
32
|
+
# config.action_mailer.delivery_method = :test
|
31
33
|
|
32
|
-
# Print deprecation notices to the stderr
|
34
|
+
# Print deprecation notices to the stderr.
|
33
35
|
config.active_support.deprecation = :stderr
|
34
36
|
end
|
37
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
Dummy::Application.config.secret_key_base = 'eea8321616a4ab02c44c134c98059ad070bee6c215649081958cf30b9b96e5e740b0ac696426d61cdd68a31e00909feac9369a627c1f618bb7274de785ca58a0'
|
data/spec/dummy/config/routes.rb
CHANGED