indefinite_article 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
@@ -0,0 +1,21 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## PROJECT::SPECIFIC
data/LICENSE ADDED
@@ -0,0 +1,20 @@
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.
@@ -0,0 +1,18 @@
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.
@@ -0,0 +1,52 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "indefinite_article"
8
+ gem.summary = %Q{Indefinite articles for stringlike classes in Ruby}
9
+ gem.description = %Q{Adds indefinite article ('a' vs. 'an') methods to String and Symbol}
10
+ gem.email = "andy@rossmeissl.net"
11
+ gem.homepage = "http://github.com/rossmeissl/indefinite_article"
12
+ gem.authors = ["Andy Rossmeissl"]
13
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
14
+ end
15
+ Jeweler::GemcutterTasks.new
16
+ rescue LoadError
17
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
18
+ end
19
+
20
+ require 'rake/testtask'
21
+ Rake::TestTask.new(:test) do |test|
22
+ test.libs << 'lib' << 'test'
23
+ test.pattern = 'test/**/test_*.rb'
24
+ test.verbose = true
25
+ end
26
+
27
+ begin
28
+ require 'rcov/rcovtask'
29
+ Rcov::RcovTask.new do |test|
30
+ test.libs << 'test'
31
+ test.pattern = 'test/**/test_*.rb'
32
+ test.verbose = true
33
+ end
34
+ rescue LoadError
35
+ task :rcov do
36
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
37
+ end
38
+ end
39
+
40
+ task :test => :check_dependencies
41
+
42
+ task :default => :test
43
+
44
+ require 'rake/rdoctask'
45
+ Rake::RDocTask.new do |rdoc|
46
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
47
+
48
+ rdoc.rdoc_dir = 'rdoc'
49
+ rdoc.title = "indefinite_article #{version}"
50
+ rdoc.rdoc_files.include('README*')
51
+ rdoc.rdoc_files.include('lib/**/*.rb')
52
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,8 @@
1
+ require 'indefinite_article/articulated'
2
+ require 'activesupport'
3
+
4
+ module IndefiniteArticle
5
+ WORDS_WITH_INITIAL_VOWELS_THAT_ACT_LIKE_WORDS_WITH_INITIAL_CONSONANTS = %w(one united)
6
+ INDEFINITE_ARTICLES = { :vowel => 'an', :consonant => 'a'}
7
+ VOWELS = %w(a e i o u)
8
+ end
@@ -0,0 +1,33 @@
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? 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
@@ -0,0 +1,9 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+
4
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
5
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
+ require 'indefinite_article'
7
+
8
+ class Test::Unit::TestCase
9
+ end
@@ -0,0 +1,23 @@
1
+ require 'helper'
2
+
3
+ class TestIndefiniteArticle < Test::Unit::TestCase
4
+ def setup
5
+ end
6
+
7
+ def test_indefinite_article_selection
8
+ assert_equal 'a', 'banana'.indefinite_article
9
+ assert_equal 'an', 'apple'.indefinite_article
10
+ end
11
+
12
+ def test_unusual_article_selection
13
+ assert_equal 'a', 'one'.indefinite_article
14
+ end
15
+
16
+ def test_functionality_on_symbol
17
+ assert_equal 'a', :banana.indefinite_article
18
+ end
19
+
20
+ def test_indefinite_article_prefix
21
+ assert_equal 'a banana', 'banana'.with_indefinite_article
22
+ end
23
+ end
metadata ADDED
@@ -0,0 +1,66 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: indefinite_article
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Andy Rossmeissl
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2010-03-05 00:00:00 -05:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: Adds indefinite article ('a' vs. 'an') methods to String and Symbol
17
+ email: andy@rossmeissl.net
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - LICENSE
24
+ - README.rdoc
25
+ files:
26
+ - .document
27
+ - .gitignore
28
+ - LICENSE
29
+ - README.rdoc
30
+ - Rakefile
31
+ - VERSION
32
+ - lib/indefinite_article.rb
33
+ - lib/indefinite_article/articulated.rb
34
+ - test/helper.rb
35
+ - test/test_indefinite_article.rb
36
+ has_rdoc: true
37
+ homepage: http://github.com/rossmeissl/indefinite_article
38
+ licenses: []
39
+
40
+ post_install_message:
41
+ rdoc_options:
42
+ - --charset=UTF-8
43
+ require_paths:
44
+ - lib
45
+ required_ruby_version: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: "0"
50
+ version:
51
+ required_rubygems_version: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: "0"
56
+ version:
57
+ requirements: []
58
+
59
+ rubyforge_project:
60
+ rubygems_version: 1.3.5
61
+ signing_key:
62
+ specification_version: 3
63
+ summary: Indefinite articles for stringlike classes in Ruby
64
+ test_files:
65
+ - test/helper.rb
66
+ - test/test_indefinite_article.rb