padrino-helpers 0.10.6 → 0.10.7
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/padrino-helpers.rb +2 -1
- data/lib/padrino-helpers/form_helpers.rb +4 -4
- data/lib/padrino-helpers/locale/ro.yml +103 -0
- data/lib/padrino-helpers/locale/sv.yml +103 -0
- data/lib/padrino-helpers/output_helpers/slim_handler.rb +2 -2
- data/lib/padrino-helpers/tag_helpers.rb +1 -1
- data/test/fixtures/markup_app/views/capture_concat.slim +5 -5
- data/test/fixtures/markup_app/views/form_for.erb +0 -0
- data/test/fixtures/markup_app/views/form_for.haml +0 -0
- data/test/fixtures/markup_app/views/form_for.slim +0 -0
- data/test/fixtures/markup_app/views/form_tag.erb +0 -0
- data/test/fixtures/markup_app/views/form_tag.haml +0 -0
- data/test/fixtures/markup_app/views/form_tag.slim +0 -0
- data/test/fixtures/markup_app/views/link_to.slim +2 -2
- data/test/test_asset_tag_helpers.rb +6 -0
- data/test/test_form_helpers.rb +6 -0
- data/test/test_output_helpers.rb +1 -2
- metadata +51 -42
data/lib/padrino-helpers.rb
CHANGED
@@ -2,6 +2,7 @@ require 'padrino-core/support_lite' unless defined?(SupportLite)
|
|
2
2
|
require 'cgi'
|
3
3
|
require 'i18n'
|
4
4
|
require 'enumerator'
|
5
|
+
require 'active_support/time_with_zone' # next extension depends on this
|
5
6
|
require 'active_support/core_ext/string/conversions' # to_date
|
6
7
|
require 'active_support/core_ext/float/rounding' # round
|
7
8
|
require 'active_support/option_merger' # with_options
|
@@ -37,7 +38,7 @@ module Padrino
|
|
37
38
|
#
|
38
39
|
# @example Register the helper module
|
39
40
|
# require 'padrino-helpers'
|
40
|
-
# class Padrino::
|
41
|
+
# class Padrino::Application
|
41
42
|
# register Padrino::Helpers
|
42
43
|
# end
|
43
44
|
#
|
@@ -244,11 +244,11 @@ module Padrino
|
|
244
244
|
def error_message_on(object, field, options={})
|
245
245
|
object = object.is_a?(Symbol) ? instance_variable_get("@#{object}") : object
|
246
246
|
error = object.errors[field] rescue nil
|
247
|
-
|
247
|
+
# Array(error).first is necessary because some ORMs give us an array others directly a value
|
248
|
+
if error = Array(error)[0]
|
248
249
|
options.reverse_merge!(:tag => :span, :class => :error)
|
249
250
|
tag = options.delete(:tag)
|
250
|
-
|
251
|
-
error = [options.delete(:prepend), Array(error).first, options.delete(:append)].compact.join(" ")
|
251
|
+
error = [options.delete(:prepend), error, options.delete(:append)].compact.join(" ")
|
252
252
|
content_tag(tag, error, options)
|
253
253
|
else
|
254
254
|
''
|
@@ -703,7 +703,7 @@ module Padrino
|
|
703
703
|
# Returns the options tags for a select based on the given option items
|
704
704
|
#
|
705
705
|
def options_for_select(option_items, selected_value=nil)
|
706
|
-
return
|
706
|
+
return [] if option_items.blank?
|
707
707
|
option_items.map do |caption, value|
|
708
708
|
value ||= caption
|
709
709
|
content_tag(:option, caption, :value => value, :selected => option_is_selected?(value, caption, selected_value))
|
@@ -0,0 +1,103 @@
|
|
1
|
+
ro:
|
2
|
+
number:
|
3
|
+
# Used in number_with_delimiter()
|
4
|
+
# These are also the defaults for 'currency', 'percentage', 'precision', and 'human'
|
5
|
+
format:
|
6
|
+
# Sets the separator between the units, for more precision (e.g. 1.0 / 2.0 == 0.5)
|
7
|
+
separator: ","
|
8
|
+
# Delimets thousands (e.g. 1,000,000 is a million) (always in groups of three)
|
9
|
+
delimiter: "."
|
10
|
+
# Number of decimals, behind the separator (the number 1 with a precision of 2 gives: 1.00)
|
11
|
+
precision: 2
|
12
|
+
|
13
|
+
# Used in number_to_currency()
|
14
|
+
currency:
|
15
|
+
format:
|
16
|
+
# Where is the currency sign? %u is the currency unit, %n the number (default: $5.00)
|
17
|
+
format: "%n %u"
|
18
|
+
unit: "lei"
|
19
|
+
# These three are to override number.format and are optional
|
20
|
+
separator: ","
|
21
|
+
delimiter: "."
|
22
|
+
precision: 2
|
23
|
+
|
24
|
+
# Used in number_to_percentage()
|
25
|
+
percentage:
|
26
|
+
format:
|
27
|
+
# These three are to override number.format and are optional
|
28
|
+
# separator:
|
29
|
+
delimiter: ""
|
30
|
+
# precision:
|
31
|
+
|
32
|
+
# Used in number_to_precision()
|
33
|
+
precision:
|
34
|
+
format:
|
35
|
+
# These three are to override number.format and are optional
|
36
|
+
# separator:
|
37
|
+
delimiter: ""
|
38
|
+
# precision:
|
39
|
+
|
40
|
+
# Used in number_to_human_size()
|
41
|
+
human:
|
42
|
+
format:
|
43
|
+
# These three are to override number.format and are optional
|
44
|
+
# separator:
|
45
|
+
delimiter: ""
|
46
|
+
precision: 1
|
47
|
+
storage_units:
|
48
|
+
# Storage units output formatting.
|
49
|
+
# %u is the storage unit, %n is the number (default: 2 MB)
|
50
|
+
format: "%n %u"
|
51
|
+
units:
|
52
|
+
byte:
|
53
|
+
one: "Byte"
|
54
|
+
other: "Bytes"
|
55
|
+
kb: "KB"
|
56
|
+
mb: "MB"
|
57
|
+
gb: "GB"
|
58
|
+
tb: "TB"
|
59
|
+
|
60
|
+
# Used in distance_of_time_in_words(), distance_of_time_in_words_to_now(), time_ago_in_words()
|
61
|
+
datetime:
|
62
|
+
distance_in_words:
|
63
|
+
half_a_minute: "jumătate de minut"
|
64
|
+
less_than_x_seconds:
|
65
|
+
one: "mai puțin de o secundă"
|
66
|
+
other: "mai puțin de %{count} secunde"
|
67
|
+
x_seconds:
|
68
|
+
one: "o secundă"
|
69
|
+
other: "%{count} secunde"
|
70
|
+
less_than_x_minutes:
|
71
|
+
one: "mai puțin de un minut"
|
72
|
+
other: "mai puțin de %{count} minute"
|
73
|
+
x_minutes:
|
74
|
+
one: "un minut"
|
75
|
+
other: "%{count} minute"
|
76
|
+
about_x_hours:
|
77
|
+
one: "aproximativ o oră"
|
78
|
+
other: "aproximativ %{count} ore"
|
79
|
+
x_days:
|
80
|
+
one: "o zi"
|
81
|
+
other: "%{count} zile"
|
82
|
+
about_x_months:
|
83
|
+
one: "aproximativ o lună"
|
84
|
+
other: "aproximativ %{count} luni"
|
85
|
+
x_months:
|
86
|
+
one: "o lună"
|
87
|
+
other: "%{count} luni"
|
88
|
+
about_x_years:
|
89
|
+
one: "aproximativ un an"
|
90
|
+
other: "aproximativ %{count} ani"
|
91
|
+
over_x_years:
|
92
|
+
one: "peste un an"
|
93
|
+
other: "peste %{count} ani"
|
94
|
+
almost_x_years:
|
95
|
+
one: "aproape un an"
|
96
|
+
other: "aproape %{count} ani"
|
97
|
+
models:
|
98
|
+
errors:
|
99
|
+
template:
|
100
|
+
header:
|
101
|
+
one: "Nu s-a putut salva %{model}, a avut loc o eroare."
|
102
|
+
other: "Nu s-a putut salva %{model}, au avut loc %{count} erori."
|
103
|
+
body: "Există probleme cu următoarele câmpuri:"
|
@@ -0,0 +1,103 @@
|
|
1
|
+
sv:
|
2
|
+
number:
|
3
|
+
# Used in number_with_delimiter()
|
4
|
+
# These are also the defaults for 'currency', 'percentage', 'precision', and 'human'
|
5
|
+
format:
|
6
|
+
# Sets the separator between the units, for more precision (e.g. 1.0 / 2.0 == 0.5)
|
7
|
+
separator: ","
|
8
|
+
# Delimets thousands (e.g. 1,000,000 is a million) (always in groups of three)
|
9
|
+
delimiter: " "
|
10
|
+
# Number of decimals, behind the separator (the number 1 with a precision of 2 gives: 1.00)
|
11
|
+
precision: 2
|
12
|
+
|
13
|
+
# Used in number_to_currency()
|
14
|
+
currency:
|
15
|
+
format:
|
16
|
+
# Where is the currency sign? %u is the currency unit, %n the number (default: $5.00)
|
17
|
+
format: "%n %u"
|
18
|
+
unit: "kr"
|
19
|
+
# These three are to override number.format and are optional
|
20
|
+
separator: ","
|
21
|
+
delimiter: " "
|
22
|
+
precision: 2
|
23
|
+
|
24
|
+
# Used in number_to_percentage()
|
25
|
+
percentage:
|
26
|
+
format:
|
27
|
+
# These three are to override number.format and are optional
|
28
|
+
# separator:
|
29
|
+
delimiter: ""
|
30
|
+
# precision:
|
31
|
+
|
32
|
+
# Used in number_to_precision()
|
33
|
+
precision:
|
34
|
+
format:
|
35
|
+
# These three are to override number.format and are optional
|
36
|
+
# separator:
|
37
|
+
delimiter: ""
|
38
|
+
# precision:
|
39
|
+
|
40
|
+
# Used in number_to_human_size()
|
41
|
+
human:
|
42
|
+
format:
|
43
|
+
# These three are to override number.format and are optional
|
44
|
+
# separator:
|
45
|
+
delimiter: ""
|
46
|
+
precision: 1
|
47
|
+
storage_units:
|
48
|
+
# Storage units output formatting.
|
49
|
+
# %u is the storage unit, %n is the number (default: 2 MB)
|
50
|
+
format: "%n %u"
|
51
|
+
units:
|
52
|
+
byte:
|
53
|
+
one: "Byte"
|
54
|
+
other: "Bytes"
|
55
|
+
kb: "KB"
|
56
|
+
mb: "MB"
|
57
|
+
gb: "GB"
|
58
|
+
tb: "TB"
|
59
|
+
|
60
|
+
# Used in distance_of_time_in_words(), distance_of_time_in_words_to_now(), time_ago_in_words()
|
61
|
+
datetime:
|
62
|
+
distance_in_words:
|
63
|
+
half_a_minute: "en halv minut"
|
64
|
+
less_than_x_seconds:
|
65
|
+
one: "mindre än 1 sekund"
|
66
|
+
other: "mindre än %{count} sekunder"
|
67
|
+
x_seconds:
|
68
|
+
one: "1 sekund"
|
69
|
+
other: "%{count} sekunder"
|
70
|
+
less_than_x_minutes:
|
71
|
+
one: "mindre än en minut"
|
72
|
+
other: "mindre än %{count} minuter"
|
73
|
+
x_minutes:
|
74
|
+
one: "1 minut"
|
75
|
+
other: "%{count} minuter"
|
76
|
+
about_x_hours:
|
77
|
+
one: "cirka 1 timme"
|
78
|
+
other: "cirka %{count} timmar"
|
79
|
+
x_days:
|
80
|
+
one: "1 dag"
|
81
|
+
other: "%{count} dagar"
|
82
|
+
about_x_months:
|
83
|
+
one: "cirka 1 månad"
|
84
|
+
other: "cirka %{count} månader"
|
85
|
+
x_months:
|
86
|
+
one: "1 månad"
|
87
|
+
other: "%{count} månader"
|
88
|
+
about_x_years:
|
89
|
+
one: "cirka 1 år"
|
90
|
+
other: "cirka %{count} år"
|
91
|
+
over_x_years:
|
92
|
+
one: "över 1 år"
|
93
|
+
other: "över %{count} år"
|
94
|
+
almost_x_years:
|
95
|
+
one: "nästan 1 år"
|
96
|
+
other: "nästan %{count} år"
|
97
|
+
models:
|
98
|
+
errors:
|
99
|
+
template:
|
100
|
+
header:
|
101
|
+
one: "1 fel hindrade denna %{model} från att sparas"
|
102
|
+
other: "%{count} fel hindrade denna %{model} från att sparas"
|
103
|
+
body: "Följande fält innehåller fel:"
|
@@ -31,9 +31,9 @@ module Padrino
|
|
31
31
|
# @handler.capture_from_template(&block) => "...html..."
|
32
32
|
#
|
33
33
|
def capture_from_template(*args, &block)
|
34
|
-
self.output_buffer, _buf_was =
|
34
|
+
self.output_buffer, _buf_was = '', self.output_buffer
|
35
35
|
block.call(*args)
|
36
|
-
ret = eval(
|
36
|
+
ret = eval('@_out_buf', block.binding)
|
37
37
|
self.output_buffer = _buf_was
|
38
38
|
ret
|
39
39
|
end
|
@@ -1,13 +1,13 @@
|
|
1
|
-
|
1
|
+
- @content = captured_content do
|
2
2
|
span Captured Line 1
|
3
3
|
span Captured Line 2
|
4
4
|
|
5
|
-
|
5
|
+
== @content
|
6
6
|
|
7
|
-
|
7
|
+
- determine_block_is_template('slim') do
|
8
8
|
span This is slim
|
9
9
|
span This is slim
|
10
10
|
|
11
|
-
==concat_in_p('Concat Line 3')
|
11
|
+
== concat_in_p('Concat Line 3')
|
12
12
|
|
13
|
-
==ruby_not_template_block
|
13
|
+
== ruby_not_template_block
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
== link_to "Test 1 No Block", '/test1', :class => 'test', :id => 'test1'
|
2
2
|
|
3
|
-
|
3
|
+
== link_to("/test2", :class => 'test', :id => 'test2') do
|
4
4
|
span Test 2 With Block
|
@@ -81,6 +81,12 @@ describe "AssetTagHelpers" do
|
|
81
81
|
assert_have_selector :a, :content => "Test 1 No Block", :href => '/test1', :class => 'test', :id => 'test1'
|
82
82
|
assert_have_selector :a, :content => "Test 2 With Block", :href => '/test2', :class => 'test', :id => 'test2'
|
83
83
|
end
|
84
|
+
|
85
|
+
should "display link block element in slim" do
|
86
|
+
visit '/slim/link_to'
|
87
|
+
assert_have_selector :a, :content => "Test 1 No Block", :href => '/test1', :class => 'test', :id => 'test1'
|
88
|
+
assert_have_selector :a, :content => "Test 2 With Block", :href => '/test2', :class => 'test', :id => 'test2'
|
89
|
+
end
|
84
90
|
end
|
85
91
|
|
86
92
|
context 'for #mail_to method' do
|
data/test/test_form_helpers.rb
CHANGED
@@ -177,6 +177,12 @@ describe "FormHelpers" do
|
|
177
177
|
actual_html = error_message_on(:user, :fake, :prepend => "foo", :append => "bar")
|
178
178
|
assert actual_html.blank?
|
179
179
|
end
|
180
|
+
|
181
|
+
should "display no message when error isn't present in an Array" do
|
182
|
+
@user = mock_model("User", :errors => { :a => [], :b => "2" }, :blank? => false)
|
183
|
+
actual_html = error_message_on(:user, :a, :prepend => "foo", :append => "bar")
|
184
|
+
assert actual_html.blank?
|
185
|
+
end
|
180
186
|
end
|
181
187
|
|
182
188
|
context 'for #label_tag method' do
|
data/test/test_output_helpers.rb
CHANGED
@@ -100,8 +100,7 @@ describe "OutputHelpers" do
|
|
100
100
|
should_eventually "work for slim templates" do
|
101
101
|
visit '/slim/capture_concat'
|
102
102
|
assert_have_selector 'p', :content => "The slim block passed in is a template", :class => 'is_template'
|
103
|
-
|
104
|
-
# assert_have_no_selector 'p', :content => "The ruby block passed in is a template", :class => 'is_template'
|
103
|
+
assert_have_no_selector 'p', :content => "The ruby block passed in is a template", :class => 'is_template'
|
105
104
|
end
|
106
105
|
end
|
107
106
|
|
metadata
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: padrino-helpers
|
3
|
-
version: !ruby/object:Gem::Version
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.10.7
|
4
5
|
prerelease:
|
5
|
-
version: 0.10.6
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
7
|
+
authors:
|
8
8
|
- Padrino Team
|
9
9
|
- Nathan Esquenazi
|
10
10
|
- Davide D'Agostino
|
@@ -12,40 +12,48 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
- !ruby/object:Gem::Dependency
|
15
|
+
date: 2012-06-20 00:00:00.000000000 Z
|
16
|
+
dependencies:
|
17
|
+
- !ruby/object:Gem::Dependency
|
19
18
|
name: padrino-core
|
20
|
-
|
21
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
19
|
+
requirement: !ruby/object:Gem::Requirement
|
22
20
|
none: false
|
23
|
-
requirements:
|
24
|
-
- -
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: 0.10.
|
21
|
+
requirements:
|
22
|
+
- - '='
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: 0.10.7
|
27
25
|
type: :runtime
|
28
|
-
version_requirements: *id001
|
29
|
-
- !ruby/object:Gem::Dependency
|
30
|
-
name: i18n
|
31
26
|
prerelease: false
|
32
|
-
|
27
|
+
version_requirements: !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - '='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 0.10.7
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: i18n
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
33
36
|
none: false
|
34
|
-
requirements:
|
37
|
+
requirements:
|
35
38
|
- - ~>
|
36
|
-
- !ruby/object:Gem::Version
|
37
|
-
version:
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.6'
|
38
41
|
type: :runtime
|
39
|
-
|
40
|
-
|
42
|
+
prerelease: false
|
43
|
+
version_requirements: !ruby/object:Gem::Requirement
|
44
|
+
none: false
|
45
|
+
requirements:
|
46
|
+
- - ~>
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0.6'
|
49
|
+
description: Tag helpers, asset helpers, form helpers, form builders and many more
|
50
|
+
helpers for padrino
|
41
51
|
email: padrinorb@gmail.com
|
42
52
|
executables: []
|
43
|
-
|
44
53
|
extensions: []
|
45
|
-
|
46
|
-
extra_rdoc_files:
|
54
|
+
extra_rdoc_files:
|
47
55
|
- README.rdoc
|
48
|
-
files:
|
56
|
+
files:
|
49
57
|
- .document
|
50
58
|
- .gitignore
|
51
59
|
- .yardopts
|
@@ -72,7 +80,9 @@ files:
|
|
72
80
|
- lib/padrino-helpers/locale/no.yml
|
73
81
|
- lib/padrino-helpers/locale/pl.yml
|
74
82
|
- lib/padrino-helpers/locale/pt_br.yml
|
83
|
+
- lib/padrino-helpers/locale/ro.yml
|
75
84
|
- lib/padrino-helpers/locale/ru.yml
|
85
|
+
- lib/padrino-helpers/locale/sv.yml
|
76
86
|
- lib/padrino-helpers/locale/tr.yml
|
77
87
|
- lib/padrino-helpers/locale/uk.yml
|
78
88
|
- lib/padrino-helpers/locale/zh_cn.yml
|
@@ -147,32 +157,30 @@ files:
|
|
147
157
|
- test/test_tag_helpers.rb
|
148
158
|
homepage: http://www.padrinorb.com
|
149
159
|
licenses: []
|
150
|
-
|
151
160
|
post_install_message:
|
152
|
-
rdoc_options:
|
161
|
+
rdoc_options:
|
153
162
|
- --charset=UTF-8
|
154
|
-
require_paths:
|
163
|
+
require_paths:
|
155
164
|
- lib
|
156
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
165
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
157
166
|
none: false
|
158
|
-
requirements:
|
159
|
-
- -
|
160
|
-
- !ruby/object:Gem::Version
|
161
|
-
version:
|
162
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
167
|
+
requirements:
|
168
|
+
- - ! '>='
|
169
|
+
- !ruby/object:Gem::Version
|
170
|
+
version: '0'
|
171
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
163
172
|
none: false
|
164
|
-
requirements:
|
165
|
-
- -
|
166
|
-
- !ruby/object:Gem::Version
|
173
|
+
requirements:
|
174
|
+
- - ! '>='
|
175
|
+
- !ruby/object:Gem::Version
|
167
176
|
version: 1.3.6
|
168
177
|
requirements: []
|
169
|
-
|
170
178
|
rubyforge_project: padrino-helpers
|
171
|
-
rubygems_version: 1.8.
|
179
|
+
rubygems_version: 1.8.21
|
172
180
|
signing_key:
|
173
181
|
specification_version: 3
|
174
182
|
summary: Helpers for padrino
|
175
|
-
test_files:
|
183
|
+
test_files:
|
176
184
|
- test/fixtures/markup_app/app.rb
|
177
185
|
- test/fixtures/markup_app/views/capture_concat.erb
|
178
186
|
- test/fixtures/markup_app/views/capture_concat.haml
|
@@ -231,3 +239,4 @@ test_files:
|
|
231
239
|
- test/test_output_helpers.rb
|
232
240
|
- test/test_render_helpers.rb
|
233
241
|
- test/test_tag_helpers.rb
|
242
|
+
has_rdoc:
|