humanize_boolean 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 074ee67d78558c69bda3c9f0f175e3c3aaca2ed3
4
+ data.tar.gz: 5f9002ecaece708ac6bc961bc2ec329d4bc5acd5
5
+ SHA512:
6
+ metadata.gz: 9b0d2596b1e741bb19a1e86cc5095538e4c963812d3cfe6046839d30b406a68f88794ae131882cb60f36af0962bcd544ce3ea43f59bdf5cc4f5e8a6dbca177cb
7
+ data.tar.gz: 9d2a84fc7427cc2f20cbb279af3f8899642f1adc97e3c211e9ac81523b40eca7c0fc85b0a587a1dc3f35e38aa837bf81dc8f628c58ed27f96ed030aacc363624
data/README.md CHANGED
@@ -1,6 +1,9 @@
1
1
  humanize_boolean
2
2
  ===
3
3
 
4
+ [![Gem Version](https://badge.fury.io/rb/humanize_boolean.png)](http://badge.fury.io/rb/humanize_boolean)
5
+ [![Build Status](https://travis-ci.org/parabuzzle/humanize_boolean.png?branch=master)](https://travis-ci.org/parabuzzle/humanize_boolean)
6
+
4
7
  Adds the humanize method for true and false to provide 'Yes' and 'No' respectively.
5
8
 
6
9
  humanize_boolean also natively supports i18n translations too so it can be used in internationalized rails apps.
@@ -27,6 +30,25 @@ Or install it yourself as:
27
30
 
28
31
  false.humanize # => "No"
29
32
 
33
+ ### I18n internationalization support
34
+
35
+ i18n internationalization is out of the scope of this document but... if you want to see it in action you can use the provided pirate locale in the test directory
36
+
37
+ First you add the locale to the i18n load path like so:
38
+
39
+ I18n.load_path << "test/pirate.yml"
40
+
41
+ Then you tell i18n to use the pirate locale like this:
42
+
43
+ I18n.locale = :pirate
44
+
45
+ Now just use humanize and see the translated strings:
46
+
47
+ true.humanize # => "Aye-Aye"
48
+
49
+ false.humanize # => "Argh"
50
+
51
+
30
52
 
31
53
  ## Contributing
32
54
 
data/Rakefile CHANGED
@@ -42,8 +42,7 @@ namespace :gem do
42
42
  end
43
43
 
44
44
  task :push do
45
- sh "cd pkg"
46
- sh "gem push `ls | grep .gem`"
45
+ sh "gem push pkg/`ls pkg | grep .gem`"
47
46
  end
48
47
 
49
48
  end
@@ -22,4 +22,5 @@ Gem::Specification.new do |spec|
22
22
 
23
23
  spec.add_development_dependency "bundler", "~> 1.3"
24
24
  spec.add_development_dependency "rake"
25
+ spec.add_development_dependency "test-unit"
25
26
  end
@@ -24,3 +24,14 @@ class FalseClass
24
24
  I18n.t "boolean.no", :default => "No"
25
25
  end
26
26
  end
27
+
28
+ class NilClass
29
+ # The humanize method to return the
30
+ # string "Nothing" or a translation of that for the key
31
+ # locale.boolean.nil
32
+ #
33
+ # nil.humanize # => "Nothing"
34
+ def humanize
35
+ I18n.t "boolean.nil", :default => "Nothing"
36
+ end
37
+ end
@@ -1,3 +1,3 @@
1
1
  module HumanizeBoolean
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -1,4 +1,5 @@
1
1
  pirate:
2
2
  boolean:
3
3
  "yes": "Aye-Aye"
4
- "no": "Nooo"
4
+ "no": "Argh"
5
+ "nil": "Arrr"
@@ -7,8 +7,9 @@ require "humanize_boolean"
7
7
 
8
8
  # Add pirate translation data
9
9
  I18n.load_path << "#{Dir.pwd}/test/pirate.yml"
10
+ I18n.enforce_available_locales = false
10
11
 
11
12
  # start the tests
12
13
  require 'test/unit'
13
14
  require 'test_human_boolean'
14
- require 'test_translation'
15
+ require 'test_translation'
@@ -1,13 +1,16 @@
1
1
  require 'test_helper'
2
2
 
3
3
  class TestHumanBoolean < Test::Unit::TestCase
4
+
4
5
  def test_human_boolean
5
6
  # Test correct humanization
6
7
  assert_equal(true.humanize, 'Yes')
7
8
  assert_equal(false.humanize, 'No')
9
+ assert_equal(nil.humanize, 'Nothing')
8
10
 
9
11
  # Test incorrect humanization
10
12
  assert_not_equal(true.humanize, 'No')
11
13
  assert_not_equal(false.humanize, 'Yes')
14
+ assert_not_equal(nil.humanize, 'No')
12
15
  end
13
- end
16
+ end
@@ -9,10 +9,12 @@ class TestTranslations < Test::Unit::TestCase
9
9
  def test_human_boolean_in_pirate
10
10
  # Test correct humanization
11
11
  assert_equal(true.humanize, 'Aye-Aye')
12
- assert_equal(false.humanize, 'Nooo')
12
+ assert_equal(false.humanize, 'Argh')
13
+ assert_equal(nil.humanize, 'Arrr')
13
14
 
14
15
  # Test incorrect humanization
15
- assert_not_equal(true.humanize, 'Nooo')
16
+ assert_not_equal(true.humanize, 'Argh')
16
17
  assert_not_equal(false.humanize, 'Aye-Aye')
18
+ assert_not_equal(nil.humanize, 'Nay')
17
19
  end
18
- end
20
+ end
metadata CHANGED
@@ -1,62 +1,69 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: humanize_boolean
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
5
- prerelease:
4
+ version: 0.0.2
6
5
  platform: ruby
7
6
  authors:
8
7
  - Michael Heijmans
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-09-19 00:00:00.000000000 Z
11
+ date: 2015-08-21 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: i18n
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - ">="
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: bundler
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ~>
31
+ - - "~>"
36
32
  - !ruby/object:Gem::Version
37
33
  version: '1.3'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ~>
38
+ - - "~>"
44
39
  - !ruby/object:Gem::Version
45
40
  version: '1.3'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: rake
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - ">="
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: test-unit
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
60
67
  - !ruby/object:Gem::Version
61
68
  version: '0'
62
69
  description: Adds the humanize method for true and false to provide 'Yes' and 'No'
@@ -68,7 +75,7 @@ executables: []
68
75
  extensions: []
69
76
  extra_rdoc_files: []
70
77
  files:
71
- - .gitignore
78
+ - ".gitignore"
72
79
  - Gemfile
73
80
  - LICENSE.txt
74
81
  - README.md
@@ -83,31 +90,29 @@ files:
83
90
  homepage: http://parabuzzle.github.io/humanize_boolean
84
91
  licenses:
85
92
  - MIT
93
+ metadata: {}
86
94
  post_install_message:
87
95
  rdoc_options: []
88
96
  require_paths:
89
97
  - lib
90
98
  required_ruby_version: !ruby/object:Gem::Requirement
91
- none: false
92
99
  requirements:
93
- - - ! '>='
100
+ - - ">="
94
101
  - !ruby/object:Gem::Version
95
102
  version: '0'
96
103
  required_rubygems_version: !ruby/object:Gem::Requirement
97
- none: false
98
104
  requirements:
99
- - - ! '>='
105
+ - - ">="
100
106
  - !ruby/object:Gem::Version
101
107
  version: '0'
102
108
  requirements: []
103
109
  rubyforge_project:
104
- rubygems_version: 1.8.25
110
+ rubygems_version: 2.4.6
105
111
  signing_key:
106
- specification_version: 3
112
+ specification_version: 4
107
113
  summary: Adds humanize method for tre and false to return 'Yes' and 'No' respectively.
108
114
  test_files:
109
115
  - test/pirate.yml
110
116
  - test/test_helper.rb
111
117
  - test/test_human_boolean.rb
112
118
  - test/test_translation.rb
113
- has_rdoc: