codus 0.0.1.6.1 → 0.0.1.7
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/codus/version.rb +1 -1
- data/lib/codus/view_helpers.rb +18 -1
- data/spec/codus/view_helpers_spec.rb +15 -1
- metadata +2 -2
data/lib/codus/version.rb
CHANGED
data/lib/codus/view_helpers.rb
CHANGED
|
@@ -3,10 +3,27 @@ require "codus/view_helpers/yojs_helper"
|
|
|
3
3
|
module Codus
|
|
4
4
|
module ViewHelpers
|
|
5
5
|
include Codus::ViewHelpers::YojsHelper
|
|
6
|
-
|
|
6
|
+
|
|
7
7
|
def javascript_ready(&block)
|
|
8
8
|
javascript_tag("$(function(){\n" + capture(&block) + "});").html_safe
|
|
9
9
|
end
|
|
10
10
|
|
|
11
|
+
def current_layout
|
|
12
|
+
layout = controller.send(:_layout)
|
|
13
|
+
|
|
14
|
+
if layout.instance_of? String
|
|
15
|
+
layout.split('/').last
|
|
16
|
+
else
|
|
17
|
+
File.basename(layout.identifier).split('.').first
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def classes_for_scoped_css
|
|
22
|
+
classes = []
|
|
23
|
+
classes << "#{current_layout}-layout"
|
|
24
|
+
classes << "#{params[:controller].parameterize('-')}-controller"
|
|
25
|
+
classes << "#{params[:action].parameterize('-')}-action"
|
|
26
|
+
classes.join(" ")
|
|
27
|
+
end
|
|
11
28
|
end
|
|
12
29
|
end
|
|
@@ -7,7 +7,7 @@ describe Codus::ViewHelpers do
|
|
|
7
7
|
end.new
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
describe "javascript_ready" do
|
|
10
|
+
describe "javascript_ready" do
|
|
11
11
|
specify do
|
|
12
12
|
helper.javascript_ready do
|
|
13
13
|
"CONTEUDO JAVASCRIPT"
|
|
@@ -15,4 +15,18 @@ describe Codus::ViewHelpers do
|
|
|
15
15
|
end
|
|
16
16
|
end
|
|
17
17
|
|
|
18
|
+
describe 'classes_for_scoped_css' do
|
|
19
|
+
specify do
|
|
20
|
+
helper.stub(:params).and_return({controller: 'controllername', action: 'actionname'})
|
|
21
|
+
helper.should_receive(:current_layout).and_return('layoutname')
|
|
22
|
+
helper.classes_for_scoped_css.should == "layoutname-layout controllername-controller actionname-action"
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
describe 'current_layout' do
|
|
27
|
+
specify do
|
|
28
|
+
helper.stub_chain(:controller, :send).and_return("layoutname")
|
|
29
|
+
helper.current_layout.should == "layoutname"
|
|
30
|
+
end
|
|
31
|
+
end
|
|
18
32
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: codus
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.1.
|
|
4
|
+
version: 0.0.1.7
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2013-
|
|
12
|
+
date: 2013-11-21 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: bundler
|