humanize_boolean 0.0.1

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.
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ .idea
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in humanize_boolean.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Michael Heijmans
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,37 @@
1
+ humanize_boolean
2
+ ===
3
+
4
+ Adds the humanize method for true and false to provide 'Yes' and 'No' respectively.
5
+
6
+ humanize_boolean also natively supports i18n translations too so it can be used in internationalized rails apps.
7
+
8
+ i18n keys are locale.boolean.yes and locale.boolean.no
9
+
10
+ ## Installation
11
+
12
+ Add this line to your application's Gemfile:
13
+
14
+ gem 'humanize_boolean'
15
+
16
+ And then execute:
17
+
18
+ $ bundle
19
+
20
+ Or install it yourself as:
21
+
22
+ $ gem install humanize_boolean
23
+
24
+ ## Usage
25
+
26
+ true.humanize # => "Yes"
27
+
28
+ false.humanize # => "No"
29
+
30
+
31
+ ## Contributing
32
+
33
+ 1. Fork it
34
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
35
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
36
+ 4. Push to the branch (`git push origin my-new-feature`)
37
+ 5. Create new Pull Request
@@ -0,0 +1,49 @@
1
+ require "bundler/gem_tasks"
2
+ # humanize_boolean
3
+ # - adds humanize method to boolean objects
4
+ #
5
+ # originated by Mike Heijmans
6
+
7
+ require 'rake'
8
+
9
+ # Run the tests and build a test package by default
10
+ task :default => [:build]
11
+
12
+ # map test_and_build task to proper tasks
13
+ task :test_and_build => [:test, 'gem:clean', 'gem:build']
14
+
15
+ # map install
16
+ task :install => ['gem:install']
17
+
18
+ task :clean => ['gem:clean']
19
+
20
+ task :build => [:test_and_build]
21
+
22
+ task :test do
23
+ # define the tests
24
+ ruby "test/test_helper.rb"
25
+ end
26
+
27
+ namespace :gem do
28
+
29
+ task :clean do
30
+ begin
31
+ sh "rm ./pkg/humanize_boolean-*"
32
+ rescue
33
+ end
34
+ end
35
+
36
+ task :build do
37
+ sh "gem build ./humanize_boolean.gemspec"
38
+ end
39
+
40
+ task :install do
41
+ sh "gem install ./pkg/humanize_boolean"
42
+ end
43
+
44
+ task :push do
45
+ sh "cd pkg"
46
+ sh "gem push `ls | grep .gem`"
47
+ end
48
+
49
+ end
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'humanize_boolean/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "humanize_boolean"
8
+ spec.version = HumanizeBoolean::VERSION
9
+ spec.authors = ["Michael Heijmans"]
10
+ spec.email = ["parabuzzle@gmail.com"]
11
+ spec.description = "Adds the humanize method for true and false to provide 'Yes' and 'No' respectively. humanize supports i18n translations too so it can be used in internationalized rails apps."
12
+ spec.summary = "Adds humanize method for tre and false to return 'Yes' and 'No' respectively."
13
+ spec.homepage = "http://parabuzzle.github.io/humanize_boolean"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "i18n"
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.3"
24
+ spec.add_development_dependency "rake"
25
+ end
@@ -0,0 +1,26 @@
1
+ # encoding: utf-8
2
+
3
+ require 'i18n'
4
+ require "humanize_boolean/version"
5
+
6
+ class TrueClass
7
+ # The humanize method to return the
8
+ # string "Yes" or a translation of that for the key
9
+ # locale.boolean.yes
10
+ #
11
+ # true.humanize # => "Yes"
12
+ def humanize
13
+ I18n.t "boolean.yes", :default => "Yes"
14
+ end
15
+ end
16
+
17
+ class FalseClass
18
+ # The humanize method to return the
19
+ # string "No" or a translation of that for the key
20
+ # locale.boolean.no
21
+ #
22
+ # true.humanize # => "No"
23
+ def humanize
24
+ I18n.t "boolean.no", :default => "No"
25
+ end
26
+ end
@@ -0,0 +1,3 @@
1
+ module HumanizeBoolean
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,4 @@
1
+ pirate:
2
+ boolean:
3
+ "yes": "Aye-Aye"
4
+ "no": "Nooo"
@@ -0,0 +1,14 @@
1
+ # Setup load paths
2
+ rootdir = File.dirname(File.dirname(__FILE__))
3
+ $LOAD_PATH.unshift "#{rootdir}/lib", "#{rootdir}/test"
4
+
5
+ # Require the gem
6
+ require "humanize_boolean"
7
+
8
+ # Add pirate translation data
9
+ I18n.load_path << "#{Dir.pwd}/test/pirate.yml"
10
+
11
+ # start the tests
12
+ require 'test/unit'
13
+ require 'test_human_boolean'
14
+ require 'test_translation'
@@ -0,0 +1,13 @@
1
+ require 'test_helper'
2
+
3
+ class TestHumanBoolean < Test::Unit::TestCase
4
+ def test_human_boolean
5
+ # Test correct humanization
6
+ assert_equal(true.humanize, 'Yes')
7
+ assert_equal(false.humanize, 'No')
8
+
9
+ # Test incorrect humanization
10
+ assert_not_equal(true.humanize, 'No')
11
+ assert_not_equal(false.humanize, 'Yes')
12
+ end
13
+ end
@@ -0,0 +1,18 @@
1
+ require 'test_helper'
2
+
3
+ class TestTranslations < Test::Unit::TestCase
4
+ def setup
5
+ # Use the pirate locale :P
6
+ I18n.locale = :pirate
7
+ end
8
+
9
+ def test_human_boolean_in_pirate
10
+ # Test correct humanization
11
+ assert_equal(true.humanize, 'Aye-Aye')
12
+ assert_equal(false.humanize, 'Nooo')
13
+
14
+ # Test incorrect humanization
15
+ assert_not_equal(true.humanize, 'Nooo')
16
+ assert_not_equal(false.humanize, 'Aye-Aye')
17
+ end
18
+ end
metadata ADDED
@@ -0,0 +1,113 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: humanize_boolean
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Michael Heijmans
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-09-19 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: i18n
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: bundler
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: '1.3'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '1.3'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rake
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ description: Adds the humanize method for true and false to provide 'Yes' and 'No'
63
+ respectively. humanize supports i18n translations too so it can be used in internationalized
64
+ rails apps.
65
+ email:
66
+ - parabuzzle@gmail.com
67
+ executables: []
68
+ extensions: []
69
+ extra_rdoc_files: []
70
+ files:
71
+ - .gitignore
72
+ - Gemfile
73
+ - LICENSE.txt
74
+ - README.md
75
+ - Rakefile
76
+ - humanize_boolean.gemspec
77
+ - lib/humanize_boolean.rb
78
+ - lib/humanize_boolean/version.rb
79
+ - test/pirate.yml
80
+ - test/test_helper.rb
81
+ - test/test_human_boolean.rb
82
+ - test/test_translation.rb
83
+ homepage: http://parabuzzle.github.io/humanize_boolean
84
+ licenses:
85
+ - MIT
86
+ post_install_message:
87
+ rdoc_options: []
88
+ require_paths:
89
+ - lib
90
+ required_ruby_version: !ruby/object:Gem::Requirement
91
+ none: false
92
+ requirements:
93
+ - - ! '>='
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ required_rubygems_version: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ requirements: []
103
+ rubyforge_project:
104
+ rubygems_version: 1.8.25
105
+ signing_key:
106
+ specification_version: 3
107
+ summary: Adds humanize method for tre and false to return 'Yes' and 'No' respectively.
108
+ test_files:
109
+ - test/pirate.yml
110
+ - test/test_helper.rb
111
+ - test/test_human_boolean.rb
112
+ - test/test_translation.rb
113
+ has_rdoc: