yesno 1.0.0 → 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.
- data/README.rdoc +36 -20
- data/config/locales/en.yml +32 -11
- data/config/locales/fr.yml +33 -11
- data/config/locales/it.yml +33 -11
- data/lib/yesno/helpers.rb +25 -2
- data/lib/yesno/version.rb +1 -1
- metadata +5 -16
data/README.rdoc
CHANGED
@@ -4,38 +4,54 @@ Yesno is a simple utility for boolean case.
|
|
4
4
|
|
5
5
|
"yesno" is a simple aid for the Boolean case. "yesno" transforms the answers to true / false in various interpretations possible (yes / no, male / female, active / inactive). To use I18n translations and is provided with translations in Italian, English and French.
|
6
6
|
|
7
|
-
|
7
|
+
|
8
|
+
== Install
|
9
|
+
|
10
|
+
gem install yesno
|
11
|
+
rails generate yesno:install
|
12
|
+
|
13
|
+
== Example:
|
8
14
|
|
9
15
|
if @article.active is false
|
10
16
|
|
11
|
-
# yesno(
|
17
|
+
# yesno(@article.active, :type => "atc") -> "inactive"
|
12
18
|
|
13
19
|
if @person.sex is true
|
14
20
|
|
15
|
-
# yesno(
|
21
|
+
# yesno(@person.sex, :type => "mf") -> "male"
|
22
|
+
|
23
|
+
|
24
|
+
the options are
|
25
|
+
:type => "tipology"
|
26
|
+
:female => true/false
|
27
|
+
:pluralize => true/false
|
16
28
|
|
17
29
|
To add new features just edit the file yesno.#{lang}.yml and add new implementations:
|
18
30
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
t: "attivo"
|
35
|
-
f: "disattivo"
|
31
|
+
it:
|
32
|
+
yesno:
|
33
|
+
default:
|
34
|
+
smt: "vero"
|
35
|
+
smf: "falso"
|
36
|
+
sft: "vera"
|
37
|
+
sff: "falsa"
|
38
|
+
pmt: "veri"
|
39
|
+
pmf: "falsi"
|
40
|
+
pft: "vere"
|
41
|
+
pff: "false"
|
42
|
+
yn:
|
43
|
+
smt: "si"
|
44
|
+
smf: "no"
|
45
|
+
ecc.....
|
36
46
|
|
37
47
|
- the type of translation is the third indentation
|
38
48
|
- the translation is the fourth indentation
|
49
|
+
- the name of the traslation (smt, smf, ecc.) is the declination.
|
50
|
+
|
51
|
+
smt single male true
|
52
|
+
smf single male false
|
53
|
+
..
|
54
|
+
pff pural female false
|
39
55
|
|
40
56
|
With this simple rule is possible to implement new uses
|
41
57
|
|
data/config/locales/en.yml
CHANGED
@@ -1,17 +1,38 @@
|
|
1
1
|
en:
|
2
2
|
yesno:
|
3
3
|
default:
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
4
|
+
smt: "true"
|
5
|
+
smf: "false"
|
6
|
+
sft: "true"
|
7
|
+
sff: "false"
|
8
|
+
pmt: "real"
|
9
|
+
pmf: "false"
|
10
|
+
pft: "true"
|
11
|
+
pff: "false"
|
9
12
|
yn:
|
10
|
-
|
11
|
-
|
13
|
+
smt: "yes"
|
14
|
+
smf: "no"
|
15
|
+
sft: "yes"
|
16
|
+
sff: "no"
|
17
|
+
pmt: "yes"
|
18
|
+
pmf: "no"
|
19
|
+
pft: "yes"
|
20
|
+
pff: "no"
|
12
21
|
mf:
|
13
|
-
|
14
|
-
|
22
|
+
smt: "male"
|
23
|
+
smf: "female"
|
24
|
+
sft: "male"
|
25
|
+
sff: "female"
|
26
|
+
pmt: "mes"
|
27
|
+
pmf: "females"
|
28
|
+
pft: "mes"
|
29
|
+
pff: "females"
|
15
30
|
act:
|
16
|
-
|
17
|
-
|
31
|
+
smt: "active"
|
32
|
+
smf: "inactive"
|
33
|
+
sft: "active"
|
34
|
+
sff: "inactive"
|
35
|
+
pmt: "actives"
|
36
|
+
pmf: "inactives"
|
37
|
+
pft: "actives"
|
38
|
+
pff: "inactives"
|
data/config/locales/fr.yml
CHANGED
@@ -1,18 +1,40 @@
|
|
1
1
|
fr:
|
2
2
|
yesno:
|
3
3
|
default:
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
4
|
+
smt: "vero"
|
5
|
+
smf: "falso"
|
6
|
+
sft: "vera"
|
7
|
+
sff: "falsa"
|
8
|
+
pmt: "veri"
|
9
|
+
pmf: "falsi"
|
10
|
+
pft: "vere"
|
11
|
+
pff: "false"
|
9
12
|
yn:
|
10
|
-
|
11
|
-
|
13
|
+
smt: "si"
|
14
|
+
smf: "no"
|
15
|
+
sft: "si"
|
16
|
+
sff: "no"
|
17
|
+
pmt: "si"
|
18
|
+
pmf: "no"
|
19
|
+
pft: "si"
|
20
|
+
pff: "no"
|
12
21
|
mf:
|
13
|
-
|
14
|
-
|
22
|
+
smt: "maschio"
|
23
|
+
smf: "femmina"
|
24
|
+
sft: "maschio"
|
25
|
+
sff: "femmina"
|
26
|
+
pmt: "maschi"
|
27
|
+
pmf: "femmine"
|
28
|
+
pft: "maschi"
|
29
|
+
pff: "femmine"
|
15
30
|
act:
|
16
|
-
|
17
|
-
|
31
|
+
smt: "attivo"
|
32
|
+
smf: "inattivo"
|
33
|
+
sft: "attiva"
|
34
|
+
sff: "inattiva"
|
35
|
+
pmt: "attivi"
|
36
|
+
pmf: "inattivi"
|
37
|
+
pft: "attive"
|
38
|
+
pff: "inattive"
|
39
|
+
|
18
40
|
|
data/config/locales/it.yml
CHANGED
@@ -1,18 +1,40 @@
|
|
1
1
|
it:
|
2
2
|
yesno:
|
3
3
|
default:
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
4
|
+
smt: "vero"
|
5
|
+
smf: "falso"
|
6
|
+
sft: "vera"
|
7
|
+
sff: "falsa"
|
8
|
+
pmt: "veri"
|
9
|
+
pmf: "falsi"
|
10
|
+
pft: "vere"
|
11
|
+
pff: "false"
|
9
12
|
yn:
|
10
|
-
|
11
|
-
|
13
|
+
smt: "si"
|
14
|
+
smf: "no"
|
15
|
+
sft: "si"
|
16
|
+
sff: "no"
|
17
|
+
pmt: "si"
|
18
|
+
pmf: "no"
|
19
|
+
pft: "si"
|
20
|
+
pff: "no"
|
12
21
|
mf:
|
13
|
-
|
14
|
-
|
22
|
+
smt: "maschio"
|
23
|
+
smf: "femmina"
|
24
|
+
sft: "maschio"
|
25
|
+
sff: "femmina"
|
26
|
+
pmt: "maschi"
|
27
|
+
pmf: "femmine"
|
28
|
+
pft: "maschi"
|
29
|
+
pff: "femmine"
|
15
30
|
act:
|
16
|
-
|
17
|
-
|
31
|
+
smt: "attivo"
|
32
|
+
smf: "inattivo"
|
33
|
+
sft: "attiva"
|
34
|
+
sff: "inattiva"
|
35
|
+
pmt: "attivi"
|
36
|
+
pmf: "inattivi"
|
37
|
+
pft: "attive"
|
38
|
+
pff: "inattive"
|
39
|
+
|
18
40
|
|
data/lib/yesno/helpers.rb
CHANGED
@@ -1,3 +1,26 @@
|
|
1
|
-
def
|
2
|
-
|
1
|
+
def yesno(to_validate, options = {})
|
2
|
+
defaults = {
|
3
|
+
:type => "default",
|
4
|
+
:pluralize => false,
|
5
|
+
:female => false
|
6
|
+
}
|
7
|
+
options = defaults.merge(options)
|
8
|
+
if options[:pluralize] == false
|
9
|
+
if options[:female] == false
|
10
|
+
return to_validate ? I18n.t("yesno.#{options[:type]}.smt") : I18n.t("yesno.#{options[:type]}.smf")
|
11
|
+
else
|
12
|
+
return to_validate ? I18n.t("yesno.#{options[:type]}.sft") : I18n.t("yesno.#{options[:type]}.sff")
|
13
|
+
end
|
14
|
+
else
|
15
|
+
if options[:female] == false
|
16
|
+
return to_validate ? I18n.t("yesno.#{options[:type]}.pmt") : I18n.t("yesno.#{options[:type]}.pmf")
|
17
|
+
else
|
18
|
+
return to_validate ? I18n.t("yesno.#{options[:type]}.pft") : I18n.t("yesno.#{options[:type]}.pff")
|
19
|
+
end
|
20
|
+
end
|
3
21
|
end
|
22
|
+
|
23
|
+
def fyesno(to_validate, type = "default", options = "sm")
|
24
|
+
return to_validate ? I18n.t("yesno.#{type}.#{options}t") : I18n.t("yesno.#{type}.#{options}f")
|
25
|
+
end
|
26
|
+
|
data/lib/yesno/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yesno
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,30 +9,19 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-01-
|
12
|
+
date: 2012-01-27 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
16
|
-
requirement: &
|
16
|
+
requirement: &7568840 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 3.
|
21
|
+
version: 3.0.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
25
|
-
- !ruby/object:Gem::Dependency
|
26
|
-
name: sqlite3
|
27
|
-
requirement: &6030980 !ruby/object:Gem::Requirement
|
28
|
-
none: false
|
29
|
-
requirements:
|
30
|
-
- - ! '>='
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version: '0'
|
33
|
-
type: :development
|
34
|
-
prerelease: false
|
35
|
-
version_requirements: *6030980
|
24
|
+
version_requirements: *7568840
|
36
25
|
description: Boolean helper fot rails
|
37
26
|
email:
|
38
27
|
- andrea.ranaldi@gmail.com
|