attribute_pair_generator 1.0.1 → 1.1.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bac8f3031dcc068e105bf8f30c4cdc0e2008cf98
4
- data.tar.gz: 2420640934192d3de205e99924aaab25eaab4286
3
+ metadata.gz: 68896e9f3169aff1522ee7d91eeacf04cbcfbdbd
4
+ data.tar.gz: f783d871f9a034ce982485127240cfd0cdac2364
5
5
  SHA512:
6
- metadata.gz: 2b3faef7021f6a4bf7d1ff40fe4762a53d9d9c5bb0145fa1ed964205576344faeecb4b209392dbc8ce6c6e685b198c541faf3bcdaec5c509de2bfb2c56a555e9
7
- data.tar.gz: 6c46c0d9b9fa7af72f6494257031911b0e50c6439e181201430d4a2ab1c18c834d9c82477f0270d23a471a4eaf120c813cfb458769fb3d5ea042b3a2cedca341
6
+ metadata.gz: bc4683ab50dc1896419caf6d3b9fd7d27a11b6133c0a54a93c71b34be97a9e21764e42382f40b063c32165feab8c635e8285dc5656ddbef346feb73ab6a68b18
7
+ data.tar.gz: cb8bafef60a172cbcf42d35e809b19e41511cf6fe0d1283408571953a0fdc245b7f7b250fb89d836b92d462c1d9277e3dc6d6cff8020b7ec710c85d4248cf3bc
data/README.md CHANGED
@@ -18,17 +18,23 @@ generates...
18
18
 
19
19
  <form accept-charset="UTF-8" action="/foo" method="post">
20
20
  <dl>
21
- <dt>title</dt>
21
+ <dt>
22
+ <label for"title">title</label>
23
+ </dt>
22
24
  <dd>
23
25
  <input id="title" name="title" type="text" value="bar">
24
26
  <span class="help-inline">the title of your foo</span>
25
27
  </dd>
26
- <dt>starts at</dt>
28
+ <dt>
29
+ <label for"starts_at">starts at</label>
30
+ </dt>
27
31
  <dd>
28
32
  <input class="datepicker" id="starts_at" name="starts_at" type="text" value="2013-10-30 05:00:00 +0000">
29
33
  <span class="help-inline"></span>
30
34
  </dd>
31
- <dt>status</dt>
35
+ <dt>
36
+ <label for"status">status</label>
37
+ </dt>
32
38
  <dd>
33
39
  approved
34
40
  <span class="help-inline"></span>
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |gem|
6
6
  gem.name = "attribute_pair_generator"
7
- gem.version = "1.0.1"
7
+ gem.version = "1.1.0"
8
8
  gem.authors = ["Andrew Thal", "Jeff Whitmire"]
9
9
  gem.email = "andrew.thal@livingsocial.com"
10
10
  gem.description = %q{Easily generate form fields and object information fields with labels.}
@@ -76,7 +76,7 @@ class AttributePairGenerator
76
76
  end
77
77
 
78
78
  def render(content, options)
79
- dt_content = options[:label] ? options[:label].to_s : options[:attr].to_s.humanize.downcase
79
+ dt_content = label(options)
80
80
  dd_content = content.to_s
81
81
  dd_content += content_tag(:span, class: "help-inline") { options[:help].to_s } if options[:help]
82
82
  content_tag(:dt) { dt_content } +
@@ -106,4 +106,9 @@ class AttributePairGenerator
106
106
  options[:attr]
107
107
  end
108
108
  end
109
+
110
+ def label(options)
111
+ label_tag(attribute(options),
112
+ options[:label] ? options[:label].to_s : options[:attr].to_s.humanize.downcase)
113
+ end
109
114
  end
@@ -7,6 +7,7 @@ describe AttributePairGenerator do
7
7
 
8
8
  shared_examples 'a generated pair structure' do
9
9
  it { generated.css('dt').should be_present }
10
+ it { generated.css('dt').children.first.name.should == 'label' }
10
11
  it { generated.css('dd').should be_present }
11
12
  end
12
13
 
@@ -62,9 +63,13 @@ describe AttributePairGenerator do
62
63
  generated.css('dd').children.last['name'].should == "#{generator_arguments[:prefix]}[#{generator_arguments[:attr]}]"
63
64
  end
64
65
 
65
- it 'does not use the prefix in the label' do
66
+ it 'does not use the prefix in the label text' do
66
67
  generated.css("dt").text.should eq(generator_arguments[:attr].to_s.humanize.downcase)
67
68
  end
69
+
70
+ it "uses the prefix in the label tag 'for'" do
71
+ generated.css('dt').children.last['for'].should == "#{generator_arguments[:prefix]}_#{generator_arguments[:attr]}"
72
+ end
68
73
  end
69
74
 
70
75
  context 'if not given a prefix option' do
@@ -79,6 +84,10 @@ describe AttributePairGenerator do
79
84
  it 'uses the attribute as the name' do
80
85
  generated.css('dd').children.last['id'].should == generator_arguments[:attr].to_s
81
86
  end
87
+
88
+ it "uses the attribute in the label tag 'for'" do
89
+ generated.css('dt').children.last['for'].should == generator_arguments[:attr].to_s
90
+ end
82
91
  end
83
92
  end
84
93
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: attribute_pair_generator
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Thal
@@ -9,76 +9,76 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-11-27 00:00:00.000000000 Z
12
+ date: 2014-07-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - '>='
18
+ - - ">="
19
19
  - !ruby/object:Gem::Version
20
20
  version: '0'
21
21
  type: :development
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - '>='
25
+ - - ">="
26
26
  - !ruby/object:Gem::Version
27
27
  version: '0'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: faker
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - '>='
32
+ - - ">="
33
33
  - !ruby/object:Gem::Version
34
34
  version: '0'
35
35
  type: :development
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - '>='
39
+ - - ">="
40
40
  - !ruby/object:Gem::Version
41
41
  version: '0'
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: rspec
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
- - - ~>
46
+ - - "~>"
47
47
  - !ruby/object:Gem::Version
48
48
  version: '2.0'
49
49
  type: :development
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
- - - ~>
53
+ - - "~>"
54
54
  - !ruby/object:Gem::Version
55
55
  version: '2.0'
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: nokogiri
58
58
  requirement: !ruby/object:Gem::Requirement
59
59
  requirements:
60
- - - ~>
60
+ - - "~>"
61
61
  - !ruby/object:Gem::Version
62
62
  version: '1.6'
63
63
  type: :development
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
- - - ~>
67
+ - - "~>"
68
68
  - !ruby/object:Gem::Version
69
69
  version: '1.6'
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: actionpack
72
72
  requirement: !ruby/object:Gem::Requirement
73
73
  requirements:
74
- - - '>='
74
+ - - ">="
75
75
  - !ruby/object:Gem::Version
76
76
  version: 3.0.0
77
77
  type: :runtime
78
78
  prerelease: false
79
79
  version_requirements: !ruby/object:Gem::Requirement
80
80
  requirements:
81
- - - '>='
81
+ - - ">="
82
82
  - !ruby/object:Gem::Version
83
83
  version: 3.0.0
84
84
  description: Easily generate form fields and object information fields with labels.
@@ -87,7 +87,7 @@ executables: []
87
87
  extensions: []
88
88
  extra_rdoc_files: []
89
89
  files:
90
- - .gitignore
90
+ - ".gitignore"
91
91
  - Gemfile
92
92
  - MIT-LICENSE
93
93
  - README.md
@@ -106,17 +106,17 @@ require_paths:
106
106
  - lib
107
107
  required_ruby_version: !ruby/object:Gem::Requirement
108
108
  requirements:
109
- - - '>='
109
+ - - ">="
110
110
  - !ruby/object:Gem::Version
111
111
  version: '0'
112
112
  required_rubygems_version: !ruby/object:Gem::Requirement
113
113
  requirements:
114
- - - '>='
114
+ - - ">="
115
115
  - !ruby/object:Gem::Version
116
116
  version: '0'
117
117
  requirements: []
118
118
  rubyforge_project:
119
- rubygems_version: 2.0.3
119
+ rubygems_version: 2.2.2
120
120
  signing_key:
121
121
  specification_version: 4
122
122
  summary: Easily generate form fields and object information fields with labels.