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 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
- example:
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("act", @article.active) -> "inactive"
17
+ # yesno(@article.active, :type => "atc") -> "inactive"
12
18
 
13
19
  if @person.sex is true
14
20
 
15
- # yesno("mf", @person.sex) -> "male"
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
- it:
20
- yesno:
21
- default:
22
- t: "vero"
23
- f: "falso"
24
- tf:
25
- t: "vero"
26
- f: "falso"
27
- yn:
28
- t: "si"
29
- f: "no"
30
- mf:
31
- t: "maschio"
32
- f: "femmina"
33
- act:
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
 
@@ -1,17 +1,38 @@
1
1
  en:
2
2
  yesno:
3
3
  default:
4
- t: "true"
5
- f: "false"
6
- tf:
7
- t: "true"
8
- f: "false"
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
- t: "yes"
11
- f: "no"
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
- t: "male"
14
- f: "female"
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
- t: "active"
17
- f: "inactive"
31
+ smt: "active"
32
+ smf: "inactive"
33
+ sft: "active"
34
+ sff: "inactive"
35
+ pmt: "actives"
36
+ pmf: "inactives"
37
+ pft: "actives"
38
+ pff: "inactives"
@@ -1,18 +1,40 @@
1
1
  fr:
2
2
  yesno:
3
3
  default:
4
- t: "vrai"
5
- f: "false"
6
- tf:
7
- t: "vrai"
8
- f: "false"
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
- t: "oui"
11
- f: "pas"
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
- t: "masculins"
14
- f: "féminine"
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
- t: "actifs"
17
- f: "inactives"
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
 
@@ -1,18 +1,40 @@
1
1
  it:
2
2
  yesno:
3
3
  default:
4
- t: "vero"
5
- f: "falso"
6
- tf:
7
- t: "vero"
8
- f: "falso"
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
- t: "si"
11
- f: "no"
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
- t: "maschio"
14
- f: "femmina"
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
- t: "attivo"
17
- f: "disattivo"
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 yes_no(type, to_validate)
2
- return to_validate ? I18n.t("yesno.#{type}.t") : I18n.t("yesno.#{type}.f")
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
@@ -1,3 +1,3 @@
1
1
  module Yesno
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
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.0.0
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-23 00:00:00.000000000Z
12
+ date: 2012-01-27 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
16
- requirement: &6031420 !ruby/object:Gem::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.1.3
21
+ version: 3.0.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *6031420
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