sections_rails 0.6.7 → 0.6.8
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.
- data/lib/generators/section_generator.rb +11 -26
- data/lib/sections_rails/helpers.rb +0 -15
- data/lib/sections_rails/section.rb +88 -43
- data/lib/sections_rails/version.rb +1 -1
- data/lib/tasks/sections_rails_tasks.rake +5 -5
- data/spec/sections_rails/helpers_spec.rb +0 -50
- data/spec/sections_rails/section_spec.rb +82 -16
- metadata +12 -12
@@ -4,41 +4,26 @@ class SectionGenerator < Rails::Generators::Base
|
|
4
4
|
|
5
5
|
argument :name, :type => :string
|
6
6
|
|
7
|
+
def parse_arguments
|
8
|
+
@section = SectionsRails::Section.new name
|
9
|
+
end
|
10
|
+
|
7
11
|
def create_folder
|
8
|
-
empty_directory
|
12
|
+
empty_directory @section.folder_filepath
|
9
13
|
end
|
10
14
|
|
11
15
|
def create_partial
|
12
|
-
|
13
|
-
|
14
|
-
".#{filename}\n -# DOM content goes here.\n"
|
16
|
+
create_file "#{@section.partial_filepath}.html.haml",
|
17
|
+
".#{@section.filename}\n -# DOM content goes here.\n"
|
15
18
|
end
|
16
19
|
|
17
20
|
def create_coffee_file
|
18
|
-
|
19
|
-
|
20
|
-
"class #{filename}\n # Your CoffeeScript code goes here.\n"
|
21
|
+
create_file "#{@section.asset_filepath}.coffee",
|
22
|
+
"class #{@section.filename}\n # Your CoffeeScript code goes here.\n"
|
21
23
|
end
|
22
24
|
|
23
25
|
def create_sass_file
|
24
|
-
|
25
|
-
|
26
|
-
".#{filename}\n /* Your SASS goes here. */\n"
|
27
|
-
end
|
28
|
-
|
29
|
-
private
|
30
|
-
|
31
|
-
# Returns the path for the directory of the section.
|
32
|
-
def directory_path
|
33
|
-
@directory_path ||= begin
|
34
|
-
directory, filename = split_path(name)
|
35
|
-
File.join 'app/sections', directory, filename
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
# Returns the base path of the file, i.e. '/app/sections/admin/foo/foo'.
|
40
|
-
def asset_base_path file_prefix = nil
|
41
|
-
filename = File.basename(name)
|
42
|
-
"#{directory_path}/#{file_prefix}#{filename}"
|
26
|
+
create_file "#{@section.asset_filepath}.sass",
|
27
|
+
".#{@section.filename}\n /* Your SASS goes here. */\n"
|
43
28
|
end
|
44
29
|
end
|
@@ -1,21 +1,6 @@
|
|
1
1
|
module SectionsRails
|
2
2
|
module Helpers
|
3
3
|
|
4
|
-
# Returns a list of all section names in the given text.
|
5
|
-
#
|
6
|
-
# @param [ String ] text
|
7
|
-
# @return [ Array<String> ]
|
8
|
-
def find_sections text
|
9
|
-
|
10
|
-
# Find sections in ERB templates.
|
11
|
-
result = text.scan(/<%=\s*section\s+['":]([^'",\s]+)/).flatten.sort.uniq
|
12
|
-
|
13
|
-
# Find sections in HAML templates.
|
14
|
-
result.concat text.scan(/^\s*\=\s*section\s+['":]([^'",\s]+)/).flatten.sort.uniq
|
15
|
-
|
16
|
-
result
|
17
|
-
end
|
18
|
-
|
19
4
|
# Returns directory and filename portion of the given path.
|
20
5
|
#
|
21
6
|
# @param [ String ] paths
|
@@ -2,63 +2,107 @@ module SectionsRails
|
|
2
2
|
require "sections_rails/config"
|
3
3
|
|
4
4
|
class Section
|
5
|
-
attr_reader :asset_path, :css, :directory_name, :filename, :absolute_asset_path, :js, :locals, :partial, :partial_path
|
6
5
|
|
7
6
|
def initialize section_name, view = nil, options = {}
|
8
|
-
section_name = section_name.to_s
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
@directory_name = File.dirname(section_name).gsub(/^\.$/, '')
|
13
|
-
@asset_path = File.join(@directory_name, @filename, @filename).gsub(/^\//, '')
|
14
|
-
@absolute_asset_path = File.join SectionsRails.config.path, @asset_path
|
15
|
-
@partial_path = File.join(@directory_name, @filename, "_#{@filename}").gsub(/^\//, '')
|
16
|
-
|
17
|
-
# Options.
|
18
|
-
@js = options[:js]
|
19
|
-
@css = options[:css]
|
20
|
-
@partial = options[:partial]
|
21
|
-
@locals = options[:locals]
|
22
|
-
|
23
|
-
# For running view helper methods.
|
7
|
+
@section_name = section_name.to_s
|
8
|
+
@options = options
|
9
|
+
|
10
|
+
# This is necessary for running view helper methods.
|
24
11
|
@view = view
|
25
12
|
end
|
26
13
|
|
27
|
-
# Returns the
|
14
|
+
# Returns the names of any subdirectories that the section is in.
|
15
|
+
# Example: the section named 'folder1/folder2/section' has the directory_name 'folder1/folder2'.
|
16
|
+
def directory_name
|
17
|
+
@directory_name ||= File.dirname(@section_name).gsub(/^\.$/, '')
|
18
|
+
end
|
19
|
+
|
20
|
+
# Returns the file name of the section.
|
21
|
+
# Example 'section'
|
22
|
+
def filename
|
23
|
+
@filename ||= File.basename @section_name, '.*'
|
24
|
+
end
|
25
|
+
|
26
|
+
# Path of the folder on the file system.
|
27
|
+
# Example: 'app/sections/folder/section'
|
28
|
+
def folder_filepath
|
29
|
+
@folder_filepath ||= File.join SectionsRails.config.path, directory_name, filename
|
30
|
+
end
|
31
|
+
|
32
|
+
# Path to access assets on the file system.
|
33
|
+
# Includes only the base name of assets, without extensions.
|
34
|
+
# Example: 'app/sections/folder/section/section'
|
35
|
+
def asset_filepath
|
36
|
+
@asset_filepath ||= File.join SectionsRails.config.path, asset_includepath
|
37
|
+
end
|
38
|
+
|
39
|
+
# Path for including assets into the web page.
|
40
|
+
#
|
41
|
+
def asset_includepath
|
42
|
+
@asset_includepath ||= File.join(directory_name, filename, filename).gsub(/^\//, '')
|
43
|
+
end
|
44
|
+
|
45
|
+
# The path for accessing the partial on the filesystem.
|
46
|
+
# Example: '
|
47
|
+
def partial_filepath
|
48
|
+
@partial_filepath ||= File.join(SectionsRails.config.path, directory_name,filename, "_#{filename}").gsub(/^\//, '')
|
49
|
+
end
|
50
|
+
|
51
|
+
# For including the partial into views.
|
52
|
+
def partial_includepath
|
53
|
+
@partial_includepath ||= File.join(directory_name, filename, "#{filename}").gsub(/^\//, '')
|
54
|
+
end
|
55
|
+
|
56
|
+
# Returns the asset path of asset with the given extensions.
|
28
57
|
# Helper method.
|
29
|
-
def
|
58
|
+
def find_asset_includepath asset_option, extensions
|
30
59
|
return nil if asset_option == false
|
31
60
|
return asset_option if asset_option
|
32
61
|
extensions.each do |ext|
|
33
|
-
file_path = "#{
|
34
|
-
return
|
62
|
+
file_path = "#{asset_filepath}.#{ext}"
|
63
|
+
return asset_includepath if File.exists? file_path
|
35
64
|
end
|
36
65
|
nil
|
37
66
|
end
|
38
67
|
|
39
68
|
# Returns the path to the JS asset of this section, or nil if the section doesn't have one.
|
40
|
-
def
|
41
|
-
|
69
|
+
def find_css_includepath
|
70
|
+
@find_css_includepath ||= find_asset_includepath @options[:css], SectionsRails.config.css_extensions
|
42
71
|
end
|
43
72
|
|
44
73
|
# Returns the path to the JS asset of this section, or nil if the section doesn't have one.
|
45
|
-
def
|
46
|
-
|
74
|
+
def find_js_includepath
|
75
|
+
@find_js_includepath ||= find_asset_includepath @options[:js], SectionsRails.config.js_extensions
|
47
76
|
end
|
48
77
|
|
49
78
|
# Returns the filename of the partial of this section, or nil if this section has no partial.
|
50
|
-
def
|
79
|
+
def find_partial_filepath
|
51
80
|
SectionsRails.config.partial_extensions.each do |ext|
|
52
|
-
path =
|
81
|
+
path = "#{partial_filepath}.#{ext}"
|
53
82
|
return path if File.exists? path
|
54
83
|
end
|
55
84
|
nil
|
56
85
|
end
|
57
86
|
|
87
|
+
# Returns a list of all section names in the given text.
|
88
|
+
#
|
89
|
+
# @param [ String ] text
|
90
|
+
# @return [ Array<String> ]
|
91
|
+
def self.find_sections text
|
92
|
+
|
93
|
+
# Find sections in ERB templates.
|
94
|
+
result = text.scan(/<%=\s*section\s+['":]([^'",\s]+)/).flatten.sort.uniq
|
95
|
+
|
96
|
+
# Find sections in HAML templates.
|
97
|
+
result.concat text.scan(/^\s*\=\s*section\s+['":]([^'",\s]+)/).flatten.sort.uniq
|
98
|
+
|
99
|
+
result
|
100
|
+
end
|
101
|
+
|
58
102
|
# TODO: replace this with find_asset.
|
59
103
|
def has_asset? *extensions
|
60
104
|
extensions.flatten.each do |ext|
|
61
|
-
return true if File.exists?("#{
|
105
|
+
return true if File.exists?("#{asset_filepath}.#{ext}")
|
62
106
|
end
|
63
107
|
false
|
64
108
|
end
|
@@ -76,7 +120,7 @@ module SectionsRails
|
|
76
120
|
# Returns whether this section has a template.
|
77
121
|
# Deprecated.
|
78
122
|
def has_partial?
|
79
|
-
@view.lookup_context.template_exists?
|
123
|
+
@view.lookup_context.template_exists? partial_includepath
|
80
124
|
end
|
81
125
|
|
82
126
|
# TODO(SZ): missing specs.
|
@@ -87,26 +131,28 @@ module SectionsRails
|
|
87
131
|
if Rails.env != 'production'
|
88
132
|
|
89
133
|
# Include JS assets.
|
90
|
-
if js
|
134
|
+
if @options[:js]
|
91
135
|
result << @view.javascript_include_tag(File.join(path, js))
|
92
|
-
elsif js == false
|
136
|
+
elsif @options[:js] == false
|
93
137
|
# ":js => false" given --> don't include any JS.
|
94
|
-
|
95
|
-
|
138
|
+
else
|
139
|
+
js_includepath = find_js_includepath
|
140
|
+
result << @view.javascript_include_tag(js_includepath) if js_includepath
|
96
141
|
end
|
97
142
|
|
98
143
|
# Include CSS assets.
|
99
|
-
if css
|
144
|
+
if @options[:css]
|
100
145
|
result << @view.stylesheet_link_tag(File.join(path, css))
|
101
|
-
elsif css == false
|
146
|
+
elsif @options[:css] == false
|
102
147
|
# ":css => false" given --> don't include any CSS.
|
103
|
-
|
104
|
-
|
148
|
+
else
|
149
|
+
css_includepath = find_css_includepath
|
150
|
+
result << @view.stylesheet_link_tag(css_includepath) if css_includepath
|
105
151
|
end
|
106
152
|
end
|
107
153
|
|
108
154
|
# Render the section partial into the view.
|
109
|
-
case partial
|
155
|
+
case @options[:partial]
|
110
156
|
when :tag
|
111
157
|
result << @view.content_tag(:div, '', :class => filename)
|
112
158
|
|
@@ -115,17 +161,16 @@ module SectionsRails
|
|
115
161
|
|
116
162
|
when nil
|
117
163
|
# partial: nil given --> render default partial
|
118
|
-
|
119
|
-
if
|
120
|
-
result << @view.render(:partial =>
|
164
|
+
partial_filepath = find_partial_filepath
|
165
|
+
if partial_filepath
|
166
|
+
result << @view.render(:partial => partial_includepath, :locals => @options[:locals])
|
121
167
|
else
|
122
168
|
result << @view.content_tag(:div, '', :class => filename)
|
123
169
|
end
|
124
170
|
|
125
171
|
else
|
126
172
|
# partial: custom path given --> render custom partial
|
127
|
-
|
128
|
-
result << @view.render("#{path}/#{partial}", locals)
|
173
|
+
result << @view.render("#{path}/#{partial}", @options[:locals])
|
129
174
|
end
|
130
175
|
|
131
176
|
result.join("\n").html_safe
|
@@ -7,7 +7,7 @@ namespace :sections do
|
|
7
7
|
|
8
8
|
# Find all sections used in the views.
|
9
9
|
sections = find_all_views('app/views').map do |view|
|
10
|
-
find_sections IO.read "app/views/#{view}"
|
10
|
+
SectionsRails::Section.find_sections IO.read "app/views/#{view}"
|
11
11
|
end.flatten.sort.uniq
|
12
12
|
|
13
13
|
# Find all sections within the already known sections.
|
@@ -26,7 +26,7 @@ namespace :sections do
|
|
26
26
|
File.open "app/assets/javascripts/application_sections.js", 'w' do |file|
|
27
27
|
sections.each do |section_name|
|
28
28
|
section = SectionsRails::Section.new section_name
|
29
|
-
js_asset = section.
|
29
|
+
js_asset = section.find_js_includepath
|
30
30
|
file.write "//= require #{js_asset}\n" if js_asset
|
31
31
|
end
|
32
32
|
end
|
@@ -36,7 +36,7 @@ namespace :sections do
|
|
36
36
|
file.write "/*\n"
|
37
37
|
sections.each do |section_name|
|
38
38
|
section = SectionsRails::Section.new section_name
|
39
|
-
js_asset = section.
|
39
|
+
js_asset = section.find_css_includepath
|
40
40
|
file.write "*= require #{js_asset}\n" if js_asset
|
41
41
|
end
|
42
42
|
file.write " */"
|
@@ -121,9 +121,9 @@ namespace :sections do
|
|
121
121
|
|
122
122
|
def find_sections_in_section section_name
|
123
123
|
section = SectionsRails::Section.new section_name
|
124
|
-
partial_path = section.
|
124
|
+
partial_path = section.find_partial_filepath
|
125
125
|
if partial_path
|
126
|
-
find_sections IO.read partial_path
|
126
|
+
SectionsRails::Section.find_sections IO.read partial_path
|
127
127
|
else
|
128
128
|
[]
|
129
129
|
end
|
@@ -3,56 +3,6 @@ include SectionsRails::Helpers
|
|
3
3
|
|
4
4
|
describe SectionsRails::Helpers do
|
5
5
|
|
6
|
-
describe '#find_sections' do
|
7
|
-
it 'finds ERB sections with symbols' do
|
8
|
-
find_sections("one <%= section :alpha %> two").should == ['alpha']
|
9
|
-
end
|
10
|
-
|
11
|
-
it 'finds ERB sections with single quotes' do
|
12
|
-
find_sections("one <%= section 'alpha' %> two").should == ['alpha']
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'finds ERB sections with double quotes' do
|
16
|
-
find_sections('one <%= section "alpha" %> two').should == ['alpha']
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'finds ERB sections with parameters' do
|
20
|
-
find_sections('one <%= section "alpha", css: false %> two').should == ['alpha']
|
21
|
-
end
|
22
|
-
|
23
|
-
it 'finds HAML sections with symbols' do
|
24
|
-
find_sections("= section :alpha").should == ['alpha']
|
25
|
-
end
|
26
|
-
|
27
|
-
it 'finds HAML sections with single quotes' do
|
28
|
-
find_sections("= section 'alpha'").should == ['alpha']
|
29
|
-
end
|
30
|
-
|
31
|
-
it 'finds HAML sections with double quotes' do
|
32
|
-
find_sections('= section "alpha"').should == ['alpha']
|
33
|
-
end
|
34
|
-
|
35
|
-
it 'finds indented HAML sections' do
|
36
|
-
find_sections(' = section "alpha"').should == ['alpha']
|
37
|
-
end
|
38
|
-
|
39
|
-
it 'finds HAML sections with parameters' do
|
40
|
-
find_sections('= section "alpha", css: false').should == ['alpha']
|
41
|
-
end
|
42
|
-
|
43
|
-
it 'finds all results in the text' do
|
44
|
-
find_sections("one <%= section 'alpha' \ntwo <%= section 'beta'").should == ['alpha', 'beta']
|
45
|
-
end
|
46
|
-
|
47
|
-
it 'sorts the results' do
|
48
|
-
find_sections("one <%= section 'beta' \ntwo <%= section 'alpha'").should == ['alpha', 'beta']
|
49
|
-
end
|
50
|
-
|
51
|
-
it 'removes duplicates' do
|
52
|
-
find_sections("one <%= section 'alpha' \ntwo <%= section 'alpha'").should == ['alpha']
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
6
|
describe '#split_path' do
|
57
7
|
it 'returns the directory and filename of the given path' do
|
58
8
|
directory, filename = split_path '/one/two/three.js'
|
@@ -10,71 +10,137 @@ describe SectionsRails::Section do
|
|
10
10
|
context 'with section in folder' do
|
11
11
|
its(:filename) { should == 'section' }
|
12
12
|
its(:directory_name) { should == 'folder' }
|
13
|
-
its(:asset_path) { should == 'folder/section/section' }
|
14
|
-
its(:absolute_asset_path) { should == 'app/sections/folder/section/section' }
|
15
|
-
its(:partial_path) { should == 'folder/section/_section' }
|
16
13
|
end
|
17
14
|
|
18
15
|
context 'without folder' do
|
19
16
|
subject { SectionsRails::Section.new 'section', nil }
|
20
17
|
its(:filename) { should == 'section' }
|
21
18
|
its(:directory_name) { should == '' }
|
22
|
-
its(:asset_path) { should == 'section/section' }
|
23
|
-
its(:absolute_asset_path) { should == 'app/sections/section/section' }
|
24
|
-
its(:partial_path) { should == 'section/_section' }
|
25
19
|
end
|
26
20
|
end
|
27
21
|
|
28
|
-
describe '
|
22
|
+
describe 'path helper methods' do
|
23
|
+
|
24
|
+
context 'section in a folder' do
|
25
|
+
its(:folder_filepath) { should == 'app/sections/folder/section' }
|
26
|
+
its(:asset_filepath) { should == 'app/sections/folder/section/section' }
|
27
|
+
its(:asset_includepath) { should == 'folder/section/section' }
|
28
|
+
its(:partial_filepath) { should == 'app/sections/folder/section/_section' }
|
29
|
+
its(:partial_includepath) { should == 'folder/section/section' }
|
30
|
+
end
|
31
|
+
|
32
|
+
context 'section in root sections directory' do
|
33
|
+
subject { SectionsRails::Section.new 'section' }
|
34
|
+
its(:folder_filepath) { should == 'app/sections/section' }
|
35
|
+
its(:asset_filepath) { should == 'app/sections/section/section' }
|
36
|
+
its(:asset_includepath) { should == 'section/section' }
|
37
|
+
its(:partial_filepath) { should == 'app/sections/section/_section' }
|
38
|
+
its(:partial_includepath) { should == 'section/section' }
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe 'find_js_includepath' do
|
43
|
+
|
29
44
|
it 'tries all different JS asset file types for sections' do
|
30
45
|
SectionsRails.config.js_extensions.each do |ext|
|
31
46
|
File.should_receive(:exists?).with("app/sections/folder/section/section.#{ext}").and_return(false)
|
32
47
|
end
|
33
|
-
subject.
|
48
|
+
subject.find_js_includepath
|
34
49
|
end
|
35
50
|
|
36
51
|
it 'returns nil if there is no known JS asset file' do
|
37
52
|
SectionsRails.config.js_extensions.each do |ext|
|
38
53
|
File.should_receive(:exists?).with("app/sections/folder/section/section.#{ext}").and_return(false)
|
39
54
|
end
|
40
|
-
subject.
|
55
|
+
subject.find_js_includepath.should be_nil
|
41
56
|
end
|
42
57
|
|
43
58
|
it 'returns the asset path of the JS asset' do
|
44
59
|
File.stub(:exists?).and_return(true)
|
45
|
-
subject.
|
60
|
+
subject.find_js_includepath.should == 'folder/section/section'
|
46
61
|
end
|
47
62
|
|
48
63
|
it 'returns nil if the file exists but the section has JS assets disabled' do
|
49
64
|
File.stub(:exists?).and_return(true)
|
50
65
|
section = SectionsRails::Section.new 'folder/section', nil, js: false
|
51
|
-
section.
|
66
|
+
section.find_js_includepath.should be_nil
|
52
67
|
end
|
53
68
|
|
54
69
|
it 'returns the custom JS asset path if one is set' do
|
55
70
|
section = SectionsRails::Section.new 'folder/section', nil, js: 'custom'
|
56
|
-
section.
|
71
|
+
section.find_js_includepath.should == 'custom'
|
57
72
|
end
|
58
73
|
end
|
59
74
|
|
60
75
|
|
61
|
-
describe '
|
76
|
+
describe 'find_partial_filepath' do
|
62
77
|
|
63
78
|
it 'looks for all known types of partials' do
|
64
79
|
File.should_receive(:exists?).with("app/sections/folder/section/_section.html.erb").and_return(false)
|
65
80
|
File.should_receive(:exists?).with("app/sections/folder/section/_section.html.haml").and_return(false)
|
66
|
-
subject.
|
81
|
+
subject.find_partial_filepath
|
67
82
|
end
|
68
83
|
|
69
84
|
it "returns nil if it doesn't find any assets" do
|
70
85
|
File.should_receive(:exists?).with("app/sections/folder/section/_section.html.erb").and_return(false)
|
71
86
|
File.should_receive(:exists?).with("app/sections/folder/section/_section.html.haml").and_return(false)
|
72
|
-
subject.
|
87
|
+
subject.find_partial_filepath.should be_false
|
73
88
|
end
|
74
89
|
|
75
90
|
it "returns the absolute path to the asset if it finds one" do
|
76
91
|
File.stub(:exists?).and_return(true)
|
77
|
-
subject.
|
92
|
+
subject.find_partial_filepath.should == 'app/sections/folder/section/_section.html.erb'
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
|
97
|
+
describe '#find_sections' do
|
98
|
+
it 'finds ERB sections with symbols' do
|
99
|
+
SectionsRails::Section.find_sections("one <%= section :alpha %> two").should == ['alpha']
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'finds ERB sections with single quotes' do
|
103
|
+
SectionsRails::Section.find_sections("one <%= section 'alpha' %> two").should == ['alpha']
|
104
|
+
end
|
105
|
+
|
106
|
+
it 'finds ERB sections with double quotes' do
|
107
|
+
SectionsRails::Section.find_sections('one <%= section "alpha" %> two').should == ['alpha']
|
108
|
+
end
|
109
|
+
|
110
|
+
it 'finds ERB sections with parameters' do
|
111
|
+
SectionsRails::Section.find_sections('one <%= section "alpha", css: false %> two').should == ['alpha']
|
112
|
+
end
|
113
|
+
|
114
|
+
it 'finds HAML sections with symbols' do
|
115
|
+
SectionsRails::Section.find_sections("= section :alpha").should == ['alpha']
|
116
|
+
end
|
117
|
+
|
118
|
+
it 'finds HAML sections with single quotes' do
|
119
|
+
SectionsRails::Section.find_sections("= section 'alpha'").should == ['alpha']
|
120
|
+
end
|
121
|
+
|
122
|
+
it 'finds HAML sections with double quotes' do
|
123
|
+
SectionsRails::Section.find_sections('= section "alpha"').should == ['alpha']
|
124
|
+
end
|
125
|
+
|
126
|
+
it 'finds indented HAML sections' do
|
127
|
+
SectionsRails::Section.find_sections(' = section "alpha"').should == ['alpha']
|
128
|
+
end
|
129
|
+
|
130
|
+
it 'finds HAML sections with parameters' do
|
131
|
+
SectionsRails::Section.find_sections('= section "alpha", css: false').should == ['alpha']
|
132
|
+
end
|
133
|
+
|
134
|
+
it 'finds all results in the text' do
|
135
|
+
SectionsRails::Section.find_sections("one <%= section 'alpha' \ntwo <%= section 'beta'").should == ['alpha', 'beta']
|
136
|
+
end
|
137
|
+
|
138
|
+
it 'sorts the results' do
|
139
|
+
SectionsRails::Section.find_sections("one <%= section 'beta' \ntwo <%= section 'alpha'").should == ['alpha', 'beta']
|
140
|
+
end
|
141
|
+
|
142
|
+
it 'removes duplicates' do
|
143
|
+
SectionsRails::Section.find_sections("one <%= section 'alpha' \ntwo <%= section 'alpha'").should == ['alpha']
|
78
144
|
end
|
79
145
|
end
|
80
146
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sections_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-06-
|
12
|
+
date: 2012-06-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
16
|
-
requirement: &
|
16
|
+
requirement: &70203401926000 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '3.1'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70203401926000
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rspec
|
27
|
-
requirement: &
|
27
|
+
requirement: &70203401925460 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70203401925460
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: sqlite3
|
38
|
-
requirement: &
|
38
|
+
requirement: &70203401924800 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70203401924800
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: guard-rspec
|
49
|
-
requirement: &
|
49
|
+
requirement: &70203401924300 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70203401924300
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: rb-fsevent
|
60
|
-
requirement: &
|
60
|
+
requirement: &70203401918100 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,7 +65,7 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70203401918100
|
69
69
|
description: Sections_rails adds infrastructure to the view layer of Ruby on Rails.
|
70
70
|
It allows to define and use the HTML, CSS, and JavaScript code of dedicated sections
|
71
71
|
of pages together in one place.
|