yesno 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2012 Andrea Ranaldi
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,44 @@
1
+ = Yesno
2
+
3
+ Yesno is a simple utility for boolean case.
4
+
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
+
7
+ example:
8
+
9
+ if @article.active is false
10
+
11
+ # yesno("act", @article.active) -> "inactive"
12
+
13
+ if @person.sex is true
14
+
15
+ # yesno("mf", @person.sex) -> "male"
16
+
17
+ To add new features just edit the file yesno.#{lang}.yml and add new implementations:
18
+
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"
36
+
37
+ - the type of translation is the third indentation
38
+ - the translation is the fourth indentation
39
+
40
+ With this simple rule is possible to implement new uses
41
+
42
+ This project rocks and uses MIT-LICENSE.
43
+
44
+ email me if you have new implementations or translations
data/Rakefile ADDED
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env rake
2
+ begin
3
+ require 'bundler/setup'
4
+ rescue LoadError
5
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
+ end
7
+ begin
8
+ require 'rdoc/task'
9
+ rescue LoadError
10
+ require 'rdoc/rdoc'
11
+ require 'rake/rdoctask'
12
+ RDoc::Task = Rake::RDocTask
13
+ end
14
+
15
+ RDoc::Task.new(:rdoc) do |rdoc|
16
+ rdoc.rdoc_dir = 'rdoc'
17
+ rdoc.title = 'Yesno'
18
+ rdoc.options << '--line-numbers'
19
+ rdoc.rdoc_files.include('README.rdoc')
20
+ rdoc.rdoc_files.include('lib/**/*.rb')
21
+ end
22
+
23
+
24
+
25
+ Bundler::GemHelper.install_tasks
26
+
@@ -0,0 +1,17 @@
1
+ en:
2
+ yesno:
3
+ default:
4
+ t: "true"
5
+ f: "false"
6
+ tf:
7
+ t: "true"
8
+ f: "false"
9
+ yn:
10
+ t: "yes"
11
+ f: "no"
12
+ mf:
13
+ t: "male"
14
+ f: "female"
15
+ act:
16
+ t: "active"
17
+ f: "inactive"
@@ -0,0 +1,18 @@
1
+ fr:
2
+ yesno:
3
+ default:
4
+ t: "vrai"
5
+ f: "false"
6
+ tf:
7
+ t: "vrai"
8
+ f: "false"
9
+ yn:
10
+ t: "oui"
11
+ f: "pas"
12
+ mf:
13
+ t: "masculins"
14
+ f: "féminine"
15
+ act:
16
+ t: "actifs"
17
+ f: "inactives"
18
+
@@ -0,0 +1,18 @@
1
+ it:
2
+ yesno:
3
+ default:
4
+ t: "vero"
5
+ f: "falso"
6
+ tf:
7
+ t: "vero"
8
+ f: "falso"
9
+ yn:
10
+ t: "si"
11
+ f: "no"
12
+ mf:
13
+ t: "maschio"
14
+ f: "femmina"
15
+ act:
16
+ t: "attivo"
17
+ f: "disattivo"
18
+
@@ -0,0 +1,13 @@
1
+ module Yesno
2
+ module Generators
3
+ class InstallGenerator < Rails::Generators::Base
4
+ source_root File.expand_path('../templates', __FILE__)
5
+ desc "Copy locale files to your application."
6
+ def install
7
+ copy_file "../../../../config/locales/it.yml", "config/locales/yesno.it.yml"
8
+ copy_file "../../../../config/locales/en.yml", "config/locales/yesno.en.yml"
9
+ copy_file "../../../../config/locales/fr.yml", "config/locales/yesno.fr.yml"
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :yesno do
3
+ # # Task goes here
4
+ # end
@@ -0,0 +1,3 @@
1
+ def yes_no(type, to_validate)
2
+ return to_validate ? I18n.t("yesno.#{type}.t") : I18n.t("yesno.#{type}.f")
3
+ end
@@ -0,0 +1,3 @@
1
+ module Yesno
2
+ VERSION = "1.0.0"
3
+ end
data/lib/yesno.rb ADDED
@@ -0,0 +1,3 @@
1
+ module Yesno
2
+ require "yesno/helpers"
3
+ end
metadata ADDED
@@ -0,0 +1,78 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: yesno
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Andrea Ranaldi
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-01-23 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rails
16
+ requirement: &6031420 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 3.1.3
22
+ type: :runtime
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
36
+ description: Boolean helper fot rails
37
+ email:
38
+ - andrea.ranaldi@gmail.com
39
+ executables: []
40
+ extensions: []
41
+ extra_rdoc_files: []
42
+ files:
43
+ - config/locales/en.yml
44
+ - config/locales/it.yml
45
+ - config/locales/fr.yml
46
+ - lib/yesno.rb
47
+ - lib/tasks/yesno_tasks.rake
48
+ - lib/yesno/version.rb
49
+ - lib/yesno/helpers.rb
50
+ - lib/generators/yesno/install_generator.rb
51
+ - MIT-LICENSE
52
+ - Rakefile
53
+ - README.rdoc
54
+ homepage: https://github.com/MdreW/yesno
55
+ licenses: []
56
+ post_install_message:
57
+ rdoc_options: []
58
+ require_paths:
59
+ - lib
60
+ required_ruby_version: !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ required_rubygems_version: !ruby/object:Gem::Requirement
67
+ none: false
68
+ requirements:
69
+ - - ! '>='
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ requirements: []
73
+ rubyforge_project:
74
+ rubygems_version: 1.8.10
75
+ signing_key:
76
+ specification_version: 3
77
+ summary: Boolean helper for rails
78
+ test_files: []