dekiru 0.0.12 → 0.0.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +8 -0
- data/dekiru.gemspec +2 -0
- data/lib/dekiru.rb +1 -1
- data/lib/dekiru/helper.rb +7 -6
- data/lib/dekiru/version.rb +1 -1
- data/spec/dekiru/helper_spec.rb +49 -0
- data/spec/spec_helper.rb +22 -0
- metadata +42 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cd5a7fc14faa2c42c45038e12d68c4788ceba430
|
4
|
+
data.tar.gz: c2102fa4f4ba153dec9bd3a668bdf80ce1e45f7c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f8c7da994f0703d883a79f0c57886ea9aae63e856211b21af7697c44a505ffd35a20151b0378d3b36a42d7415b08c5b08bbfb92ed4fccb9b9e3a6afab97c782d
|
7
|
+
data.tar.gz: 5364ca6d5908249904699c8d67f3efeb8231eb46162c9a71d6a17963815a293e69e664737eb6b63bf2b9fbaf4976a58e5eea39d13cc3820c34894c76caf3d5fd
|
data/Rakefile
CHANGED
data/dekiru.gemspec
CHANGED
data/lib/dekiru.rb
CHANGED
data/lib/dekiru/helper.rb
CHANGED
@@ -1,15 +1,16 @@
|
|
1
1
|
module Dekiru
|
2
2
|
module Helper
|
3
|
-
def menu_link_to(
|
4
|
-
|
3
|
+
def menu_link_to(name = nil, options = nil, html_options = nil, &block)
|
4
|
+
args = [name, options, html_options]
|
5
|
+
html_options, options, name = options, name, block if block_given?
|
5
6
|
|
6
|
-
classes = []
|
7
|
-
classes << "active" if current_page?(
|
7
|
+
classes = html_options.try(:delete, :li_class).try(:split, ' ') || []
|
8
|
+
classes << "active" if current_page?(options)
|
8
9
|
|
9
|
-
obj = [
|
10
|
+
obj = [options].flatten.last
|
10
11
|
if obj.is_a?(ActiveRecord::Base)
|
11
12
|
content_tag_for(:li, obj, :class => classes.join(' ')) do
|
12
|
-
link_to
|
13
|
+
link_to name, options, html_options, &block
|
13
14
|
end
|
14
15
|
else
|
15
16
|
content_tag(:li, :class => classes.join(' ')) do
|
data/lib/dekiru/version.rb
CHANGED
@@ -0,0 +1,49 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Dekiru::Helper do
|
4
|
+
let(:helper) do
|
5
|
+
class AClass
|
6
|
+
include Dekiru::Helper
|
7
|
+
include ActionView::Helpers::TagHelper
|
8
|
+
include ActionView::Context
|
9
|
+
include ActionView::Helpers::UrlHelper
|
10
|
+
end
|
11
|
+
a = AClass.new
|
12
|
+
end
|
13
|
+
describe "#menu_link_to" do
|
14
|
+
before do
|
15
|
+
helper.stub(:current_page?).and_return(true)
|
16
|
+
end
|
17
|
+
context "一番シンプルな呼び出し" do
|
18
|
+
it "動くこと" do
|
19
|
+
expect(helper.menu_link_to("テキスト", "/some_path")).to eq("<li class=\"active\"><a href=\"/some_path\">テキスト</a></li>")
|
20
|
+
end
|
21
|
+
end
|
22
|
+
context "blockなし" do
|
23
|
+
it "動くこと" do
|
24
|
+
expect(helper.menu_link_to("テキスト", "/some_path", class: "some_class")).to eq("<li class=\"active\"><a class=\"some_class\" href=\"/some_path\">テキスト</a></li>")
|
25
|
+
end
|
26
|
+
end
|
27
|
+
context "blockあり" do
|
28
|
+
it "動くこと" do
|
29
|
+
html = helper.menu_link_to("/some_path", class: "some_class") do
|
30
|
+
"テキスト"
|
31
|
+
end
|
32
|
+
expect(html).to eq("<li class=\"active\"><a class=\"some_class\" href=\"/some_path\">テキスト</a></li>")
|
33
|
+
end
|
34
|
+
end
|
35
|
+
context "今のページじゃない" do
|
36
|
+
before do
|
37
|
+
helper.stub(:current_page?).and_return(false)
|
38
|
+
end
|
39
|
+
it "動くこと" do
|
40
|
+
expect(helper.menu_link_to("テキスト", "/some_path", class: "some_class")).to eq("<li class=\"\"><a class=\"some_class\" href=\"/some_path\">テキスト</a></li>")
|
41
|
+
end
|
42
|
+
end
|
43
|
+
context "li_class指定あり" do
|
44
|
+
it "動くこと" do
|
45
|
+
expect(helper.menu_link_to("テキスト", "/some_path", class: "some_class", li_class: "li_class")).to eq("<li class=\"li_class active\"><a class=\"some_class\" href=\"/some_path\">テキスト</a></li>")
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rspec'
|
3
|
+
|
4
|
+
# For rails app
|
5
|
+
require "active_support"
|
6
|
+
require 'active_support/core_ext/object'
|
7
|
+
require "active_record"
|
8
|
+
require "action_view"
|
9
|
+
require "action_view/helpers"
|
10
|
+
|
11
|
+
PROJECT_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
12
|
+
|
13
|
+
$LOAD_PATH << File.join(PROJECT_ROOT, 'lib')
|
14
|
+
|
15
|
+
require 'dekiru'
|
16
|
+
|
17
|
+
Dir.glob(File.join(PROJECT_ROOT, 'spec', 'support', '**', '*.rb')).each do |file|
|
18
|
+
require(file)
|
19
|
+
end
|
20
|
+
|
21
|
+
RSpec.configure do |config|
|
22
|
+
end
|
metadata
CHANGED
@@ -1,41 +1,69 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dekiru
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Akihiro Matsumura
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-12-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: http_accept_language
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 2.0.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 2.0.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rails
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: rake
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
30
44
|
requirements:
|
31
|
-
- -
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
32
60
|
- !ruby/object:Gem::Version
|
33
61
|
version: '0'
|
34
62
|
type: :development
|
35
63
|
prerelease: false
|
36
64
|
version_requirements: !ruby/object:Gem::Requirement
|
37
65
|
requirements:
|
38
|
-
- -
|
66
|
+
- - ">="
|
39
67
|
- !ruby/object:Gem::Version
|
40
68
|
version: '0'
|
41
69
|
description: Usefull helper methods for Ruby on Rails
|
@@ -45,7 +73,7 @@ executables: []
|
|
45
73
|
extensions: []
|
46
74
|
extra_rdoc_files: []
|
47
75
|
files:
|
48
|
-
- .gitignore
|
76
|
+
- ".gitignore"
|
49
77
|
- Gemfile
|
50
78
|
- LICENSE
|
51
79
|
- README.md
|
@@ -56,6 +84,8 @@ files:
|
|
56
84
|
- lib/dekiru/helper.rb
|
57
85
|
- lib/dekiru/railtie.rb
|
58
86
|
- lib/dekiru/version.rb
|
87
|
+
- spec/dekiru/helper_spec.rb
|
88
|
+
- spec/spec_helper.rb
|
59
89
|
homepage: ''
|
60
90
|
licenses: []
|
61
91
|
metadata: {}
|
@@ -65,12 +95,12 @@ require_paths:
|
|
65
95
|
- lib
|
66
96
|
required_ruby_version: !ruby/object:Gem::Requirement
|
67
97
|
requirements:
|
68
|
-
- -
|
98
|
+
- - ">="
|
69
99
|
- !ruby/object:Gem::Version
|
70
100
|
version: '0'
|
71
101
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
102
|
requirements:
|
73
|
-
- -
|
103
|
+
- - ">="
|
74
104
|
- !ruby/object:Gem::Version
|
75
105
|
version: '0'
|
76
106
|
requirements: []
|
@@ -79,4 +109,6 @@ rubygems_version: 2.2.2
|
|
79
109
|
signing_key:
|
80
110
|
specification_version: 4
|
81
111
|
summary: Usefull helper methods for Ruby on Rails
|
82
|
-
test_files:
|
112
|
+
test_files:
|
113
|
+
- spec/dekiru/helper_spec.rb
|
114
|
+
- spec/spec_helper.rb
|