indefinite_article 0.1.2 → 0.2.5

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 1f5faf302e7c83820b0e3b7ac410c53c1630659e92cecd3940db64fe1eb3a96e
4
+ data.tar.gz: d16f0405b26aabc3050dca91ea8b2007da8c7d13e8dd259dd51226191c95bc98
5
+ SHA512:
6
+ metadata.gz: 80fa09844e8d2f243b673f8f700ecc14138d568bc2e5c0016d1ae5266e7f0a7327804889c9787b57acb2125145d4bd1d906d502fc12ac913e605c80cb5e4f8d3
7
+ data.tar.gz: e91d67fc16f4f75db4403322e672238d262750b3839744f64bf3763f7e02deec46df320d8a7d8c42f8ffb8e300959b9a69958353e1b4ecd9b0fb026290a2e372
@@ -0,0 +1,29 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "indefinite_article/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "indefinite_article"
7
+ s.version = IndefiniteArticle::VERSION
8
+ s.licenses = ['MIT']
9
+ s.authors = ["Andrew Rossmeissl", 'Shane Brinkman-Davis']
10
+ s.email = ["andy@rossmeissl.net"]
11
+ s.homepage = "http://github.com/rossmeissl/indefinite_article"
12
+ s.summary = %q{Adds indefinite article methods to String and Symbol}
13
+ s.description = %q{Adds indefinite article methods to String and Symbol}
14
+
15
+ s.files = [
16
+ 'indefinite_article.gemspec',
17
+ 'lib/indefinite_article.rb',
18
+ 'lib/indefinite_article/version.rb'
19
+ ]
20
+ s.test_files = [
21
+ 'test/test_indefinite_article.rb'
22
+ ]
23
+
24
+ s.require_paths = ["lib"]
25
+ s.add_dependency 'activesupport'
26
+ s.add_development_dependency 'minitest', '~> 5.1'
27
+ s.add_development_dependency 'i18n'
28
+ s.add_development_dependency 'rake'
29
+ end
@@ -1,3 +1,3 @@
1
1
  module IndefiniteArticle
2
- VERSION = "0.1.2"
2
+ VERSION = "0.2.5"
3
3
  end
@@ -1,9 +1,33 @@
1
- require 'indefinite_article/articulated'
2
1
  require 'active_support'
3
2
  require 'active_support/core_ext/string'
4
3
 
5
4
  module IndefiniteArticle
6
- WORDS_WITH_INITIAL_VOWELS_THAT_ACT_LIKE_WORDS_WITH_INITIAL_CONSONANTS = %w(one united)
7
- INDEFINITE_ARTICLES = { :vowel => 'an', :consonant => 'a'}
8
- VOWELS = %w(a e i o u)
5
+
6
+ A_REQUIRING_PATTERNS = /^(([bcdgjkpqtuvwyz]|onc?e|onearmed|onetime|ouija)$|e[uw]|uk|ubi|ubo|oaxaca|ufo|ur[aeiou]|use|ut([^t])|unani|uni(l[^l]|[a-ko-z]))/i
7
+ AN_REQUIRING_PATTERNS = /^([aefhilmnorsx]$|hono|honest|hour|heir|[aeiou]|8|11)/i
8
+ UPCASE_A_REQUIRING_PATTERNS = /^(UN$)/
9
+ UPCASE_AN_REQUIRING_PATTERNS = /^(NDA)$/ #need if we decide to support acronyms like "XL" (extra-large)
10
+
11
+ def indefinite_article
12
+ first_word = to_s.split(/[- ]/).first
13
+ if (first_word[AN_REQUIRING_PATTERNS] || first_word[UPCASE_AN_REQUIRING_PATTERNS]) &&
14
+ !(first_word[A_REQUIRING_PATTERNS] || first_word[UPCASE_A_REQUIRING_PATTERNS])
15
+ 'an'
16
+ else
17
+ 'a'
18
+ end unless first_word.nil?
19
+ end
20
+
21
+ def with_indefinite_article(upcase = false)
22
+ "#{upcase ? indefinite_article.humanize : indefinite_article}#{ ' ' unless self.blank? }#{self}"
23
+ end
24
+ alias :indefinitize :with_indefinite_article
25
+ end
26
+
27
+ class String
28
+ include ::IndefiniteArticle
29
+ end
30
+
31
+ class Symbol
32
+ include ::IndefiniteArticle
9
33
  end
@@ -1,18 +1,92 @@
1
1
  require File.expand_path('../helper', __FILE__)
2
2
 
3
- class TestIndefiniteArticle < Test::Unit::TestCase
3
+ class TestIndefiniteArticle < Minitest::Test
4
+ AN_WORDS = %w{
5
+ apple
6
+ unassailable
7
+ ubuntu
8
+ ubersexual
9
+ ungrammatical
10
+ unanswered
11
+ unilluminated
12
+ unintentional
13
+ unlikely
14
+ honor
15
+ honorable
16
+ onerous
17
+ hour
18
+ honest
19
+ heir
20
+ NDA
21
+ utter
22
+ urgent
23
+ a e f h i l m n o r s x
24
+ 8 11
25
+ }
26
+
27
+ A_WORDS = %w{
28
+ ukulele
29
+ UN
30
+ uk
31
+ oaxaca
32
+ ufo
33
+ unanimous
34
+ one
35
+ onearmed
36
+ once
37
+ onetime
38
+ ouija
39
+ european
40
+ ewe
41
+ ubiquity
42
+ uboat
43
+ unicorn
44
+ unilateral
45
+ banana
46
+ user
47
+ useful
48
+ urinologist
49
+ urea
50
+ b c d g j k p q t u v w y z
51
+ 1 2 3 4 5 6 7 9 10 12 13 14 15 16 17 18 19 20
52
+ }
53
+
4
54
  def setup
5
55
  end
56
+
6
57
  def test_active_support
7
58
  assert_equal 'banana'.first, 'b'
8
59
  end
9
- def test_indefinite_article_selection
10
- assert_equal 'a', 'banana'.indefinite_article
11
- assert_equal 'an', 'apple'.indefinite_article
60
+
61
+ def test_indefinite_article_selection_for_an
62
+ AN_WORDS.each do |word|
63
+ assert_equal "an", word.indefinite_article, "word: #{word}"
64
+ assert_equal "an", word.upcase.indefinite_article, "word: #{word.upcase}"
65
+ end
66
+ end
67
+
68
+ def test_indefinite_article_selection_for_a
69
+ A_WORDS.each do |word|
70
+ assert_equal "a", word.indefinite_article, "word: #{word}"
71
+ assert_equal "a", word.upcase.indefinite_article, "word: #{word.upcase}"
72
+ end
73
+ end
74
+
75
+ def test_indefinite_article_selection_case_insensitvity
76
+ assert_equal "a", "bananna".indefinite_article
77
+ assert_equal "a", "Bananna".indefinite_article
78
+ assert_equal "an", "apple".indefinite_article
79
+ assert_equal "an", "Apple".indefinite_article
80
+ end
81
+
82
+ def test_phrases
83
+ assert_equal 'a', 'banana of yummieness'.indefinite_article
84
+ assert_equal 'an', 'honor-seeking person'.indefinite_article
12
85
  end
13
86
 
14
- def test_unusual_article_selection
15
- assert_equal 'a', 'one'.indefinite_article
87
+ def test_indefinitize
88
+ assert_equal 'a banana', 'banana'.indefinitize
89
+ assert_equal 'an apple', 'apple'.indefinitize
16
90
  end
17
91
 
18
92
  def test_functionality_on_symbol
@@ -22,4 +96,8 @@ class TestIndefiniteArticle < Test::Unit::TestCase
22
96
  def test_indefinite_article_prefix
23
97
  assert_equal 'a banana', 'banana'.with_indefinite_article
24
98
  end
99
+
100
+ def test_empty_string
101
+ assert_equal '', ''.indefinitize
102
+ end
25
103
  end
metadata CHANGED
@@ -1,153 +1,105 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: indefinite_article
3
- version: !ruby/object:Gem::Version
4
- hash: 31
5
- prerelease:
6
- segments:
7
- - 0
8
- - 1
9
- - 2
10
- version: 0.1.2
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.5
11
5
  platform: ruby
12
- authors:
13
- - Kevin English
6
+ authors:
7
+ - Andrew Rossmeissl
8
+ - Shane Brinkman-Davis
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2012-10-04 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
12
+ date: 2022-04-18 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
21
15
  name: activesupport
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
24
- none: false
25
- requirements:
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
26
18
  - - ">="
27
- - !ruby/object:Gem::Version
28
- hash: 7
29
- segments:
30
- - 3
31
- - 0
32
- - 0
33
- version: 3.0.0
34
- - - <
35
- - !ruby/object:Gem::Version
36
- hash: 11
37
- segments:
38
- - 3
39
- - 3
40
- - 0
41
- version: 3.3.0
19
+ - !ruby/object:Gem::Version
20
+ version: '0'
42
21
  type: :runtime
43
- version_requirements: *id001
44
- - !ruby/object:Gem::Dependency
45
- name: i18n
46
22
  prerelease: false
47
- requirement: &id002 !ruby/object:Gem::Requirement
48
- none: false
49
- requirements:
50
- - - ~>
51
- - !ruby/object:Gem::Version
52
- hash: 7
53
- segments:
54
- - 0
55
- - 6
56
- - 0
57
- version: 0.6.0
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ version: '0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: minitest
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '5.1'
58
35
  type: :development
59
- version_requirements: *id002
60
- - !ruby/object:Gem::Dependency
61
- name: activesupport
62
36
  prerelease: false
63
- requirement: &id003 !ruby/object:Gem::Requirement
64
- none: false
65
- requirements:
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '5.1'
42
+ - !ruby/object:Gem::Dependency
43
+ name: i18n
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
66
46
  - - ">="
67
- - !ruby/object:Gem::Version
68
- hash: 7
69
- segments:
70
- - 3
71
- - 0
72
- - 0
73
- version: 3.0.0
74
- - - <
75
- - !ruby/object:Gem::Version
76
- hash: 11
77
- segments:
78
- - 3
79
- - 3
80
- - 0
81
- version: 3.3.0
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
82
49
  type: :development
83
- version_requirements: *id003
84
- - !ruby/object:Gem::Dependency
85
- name: i18n
86
50
  prerelease: false
87
- requirement: &id004 !ruby/object:Gem::Requirement
88
- none: false
89
- requirements:
90
- - - ~>
91
- - !ruby/object:Gem::Version
92
- hash: 7
93
- segments:
94
- - 0
95
- - 6
96
- - 0
97
- version: 0.6.0
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: rake
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
98
63
  type: :development
99
- version_requirements: *id004
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
100
70
  description: Adds indefinite article methods to String and Symbol
101
- email:
102
- - kenglish@gmail.com
71
+ email:
72
+ - andy@rossmeissl.net
103
73
  executables: []
104
-
105
74
  extensions: []
106
-
107
75
  extra_rdoc_files: []
108
-
109
- files:
110
- - Gemfile
111
- - LICENSE
112
- - README.rdoc
113
- - Rakefile
114
- - lib/indefinite_article/articulated.rb
115
- - lib/indefinite_article/version.rb
76
+ files:
77
+ - indefinite_article.gemspec
116
78
  - lib/indefinite_article.rb
79
+ - lib/indefinite_article/version.rb
117
80
  - test/test_indefinite_article.rb
118
- homepage: ""
119
- licenses: []
120
-
81
+ homepage: http://github.com/rossmeissl/indefinite_article
82
+ licenses:
83
+ - MIT
84
+ metadata: {}
121
85
  post_install_message:
122
86
  rdoc_options: []
123
-
124
- require_paths:
87
+ require_paths:
125
88
  - lib
126
- required_ruby_version: !ruby/object:Gem::Requirement
127
- none: false
128
- requirements:
89
+ required_ruby_version: !ruby/object:Gem::Requirement
90
+ requirements:
129
91
  - - ">="
130
- - !ruby/object:Gem::Version
131
- hash: 3
132
- segments:
133
- - 0
134
- version: "0"
135
- required_rubygems_version: !ruby/object:Gem::Requirement
136
- none: false
137
- requirements:
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ required_rubygems_version: !ruby/object:Gem::Requirement
95
+ requirements:
138
96
  - - ">="
139
- - !ruby/object:Gem::Version
140
- hash: 3
141
- segments:
142
- - 0
143
- version: "0"
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
144
99
  requirements: []
145
-
146
- rubyforge_project: indefinite_article
147
- rubygems_version: 1.8.8
100
+ rubygems_version: 3.1.2
148
101
  signing_key:
149
- specification_version: 3
102
+ specification_version: 4
150
103
  summary: Adds indefinite article methods to String and Symbol
151
- test_files:
104
+ test_files:
152
105
  - test/test_indefinite_article.rb
153
- has_rdoc:
data/Gemfile DELETED
@@ -1,4 +0,0 @@
1
- source "http://rubygems.org"
2
-
3
- # Specify your gem's dependencies in indefinite_article.gemspec
4
- gemspec
data/LICENSE DELETED
@@ -1,20 +0,0 @@
1
- Copyright (c) 2009 Andy Rossmeissl
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 DELETED
@@ -1,18 +0,0 @@
1
- = indefinite_article
2
-
3
- Adds indefinite article methods to String and Symbol so that you can do:
4
-
5
- >> 'apple'.indefinite_article
6
- => 'an'
7
- >> 'banana'.with_indefinite_article
8
- => 'a banana'
9
-
10
- == Installation
11
-
12
- The gem is hosted at http://gemcutter.org/gems/indefinite_article
13
-
14
- gem install indefinite_article
15
-
16
- == Copyright
17
-
18
- Copyright (c) 2010 Andy Rossmeissl. See LICENSE for details.
data/Rakefile DELETED
@@ -1 +0,0 @@
1
- require 'bundler/gem_tasks'
@@ -1,33 +0,0 @@
1
- module IndefiniteArticle
2
- module Articulated
3
- def indefinite_article
4
- if ::IndefiniteArticle::WORDS_WITH_INITIAL_VOWELS_THAT_ACT_LIKE_WORDS_WITH_INITIAL_CONSONANTS.include? to_s._first_word_for_indefinite_article._first_term_for_indefinite_article.downcase
5
- ::IndefiniteArticle::INDEFINITE_ARTICLES[:consonant]
6
- elsif VOWELS.include? self.to_s.first.downcase
7
- ::IndefiniteArticle::INDEFINITE_ARTICLES[:vowel]
8
- else
9
- ::IndefiniteArticle::INDEFINITE_ARTICLES[:consonant]
10
- end
11
- end
12
-
13
- def with_indefinite_article(upcase = false)
14
- "#{upcase ? indefinite_article.humanize : indefinite_article}#{ ' ' unless self.blank? }#{self}"
15
- end
16
-
17
- def _first_word_for_indefinite_article
18
- split(' ').first
19
- end
20
-
21
- def _first_term_for_indefinite_article
22
- split('-').first
23
- end
24
- end
25
- end
26
-
27
- class String
28
- include ::IndefiniteArticle::Articulated
29
- end
30
-
31
- class Symbol
32
- include ::IndefiniteArticle::Articulated
33
- end