the_oxford_comma 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,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1f5aa05f3587b38f7954de2ccf1f0d3bcd1fa10e
4
+ data.tar.gz: f396356fe4e70e435357f3bd6f228a5166dc5514
5
+ SHA512:
6
+ metadata.gz: acd0995a1e7a091415d5c1aebf75250b935be9e5096fea9b92dc210a1396cd73b45ea640892434daf6350f685644c702f1ec5cc22829710f69f3d477b5ba9ac0
7
+ data.tar.gz: 4a1ef8354690a9cda9b27e871b8189429db0a081f78a44dbffc4f33cfbd3dd8db349e0958180d2ecbbceb9536b61a3e9f150d2254c806eb34d2ad6215bf617fa
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in the_oxford_comma.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Dave Kinkead
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.
Binary file
@@ -0,0 +1,45 @@
1
+ # The Oxford Comma
2
+
3
+ ![Punctuation is important](OxfordComma.jpg)
4
+
5
+ Punctuation is important. There is a subtle difference between inviting the strippers, JFK, & Stalin; and inviting the stippers, JKF & Stalin.
6
+
7
+ Capitalisation is also important. There's a subtle difference between helping my Uncle Jack off a horse; and helping my uncle ...
8
+
9
+
10
+ ## Installation
11
+
12
+ Reduce the ambiguity of your project by adding this line to your application's Gemfile:
13
+
14
+ ```ruby
15
+ gem 'the_oxford_comma'
16
+ ```
17
+
18
+ And then execute:
19
+
20
+ $ bundle
21
+
22
+ Or install it yourself as:
23
+
24
+ $ gem install the_oxford_comma
25
+
26
+
27
+ ## Usage
28
+
29
+ Just require the gem and you'll make any sane grammatist happy.
30
+
31
+
32
+ ["the strippers", "Kennedy", "Stalin"].and
33
+ # => "the stripers, Kennedy, and Stalin"
34
+
35
+ ["the strippers", "Kennedy", "Stalin"].or
36
+ # => "the stripers, Kennedy, or Stalin"
37
+
38
+
39
+ ## Why
40
+
41
+ Why not. Punctuation is important.
42
+
43
+ > "By train, plane and sedan chair, Peter Ustinov retraces a journey made by Mark Twain a century ago. The highlights of his global tour include encounters with Nelson Mandela, an 800-year-old demigod and a dildo collector."
44
+
45
+ > "Top stories today: World leaders attend Mandella tribute, Obama and Castro meet and same-sex marriage date set."
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ task :test do
4
+ $LOAD_PATH.unshift 'lib', 'test'
5
+ Dir.glob('test/**/*_spec.rb').each { |spec| require_relative spec }
6
+ end
@@ -0,0 +1,21 @@
1
+ require "the_oxford_comma/version"
2
+
3
+ class Array
4
+ def and
5
+ case size
6
+ when 0 then ""
7
+ when 1 then first
8
+ when 2 then "#{first} and #{last}"
9
+ else self[0..-2].join(", ") << ", and #{last}"
10
+ end
11
+ end
12
+
13
+ def or
14
+ case size
15
+ when 0 then ""
16
+ when 1 then first
17
+ when 2 then "#{first} or #{last}"
18
+ else self[0..-2].join(", ") << ", or #{last}"
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,3 @@
1
+ module TheOxfordComma
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,40 @@
1
+ require 'minitest/autorun'
2
+ require 'the_oxford_comma'
3
+
4
+ describe Array do
5
+ describe "#and" do
6
+ it "reduces conjunctive ambiguity" do
7
+ ["the strippers", "Kennedy", "Stalin"].and.must_equal "the strippers, Kennedy, and Stalin"
8
+ end
9
+
10
+ it "conjoins pairs without commas" do
11
+ ["bacon", "eggs"].and.must_equal "bacon and eggs"
12
+ end
13
+
14
+ it "dosn't spit the dummy with single arrays" do
15
+ ["single"].and.must_equal "single"
16
+ end
17
+
18
+ it "fails silently with empty arrays" do
19
+ [].and.must_equal ""
20
+ end
21
+ end
22
+
23
+ describe "#or" do
24
+ it "reduces disjuntive ambiguity" do
25
+ ["the strippers", "Kennedy", "Stalin"].or.must_equal "the strippers, Kennedy, or Stalin"
26
+ end
27
+
28
+ it "disjoins pairs without commas" do
29
+ ["dead", "alive"].or.must_equal "dead or alive"
30
+ end
31
+
32
+ it "dosn't spit the dummy with single arrays" do
33
+ ["single"].or.must_equal "single"
34
+ end
35
+
36
+ it "fails silently with empty arrays" do
37
+ [].or.must_equal ""
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'the_oxford_comma/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "the_oxford_comma"
8
+ spec.version = TheOxfordComma::VERSION
9
+ spec.authors = ["Dave Kinkead"]
10
+ spec.email = ["dave@kinkead.com.au"]
11
+ spec.summary = %q{Punctuation is important.}
12
+ spec.description = %q{Punctuation is important.}
13
+ spec.homepage = "https://github.com/davekinkead/the-oxford-comma"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
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_development_dependency "bundler", "~> 1.7"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ end
metadata ADDED
@@ -0,0 +1,83 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: the_oxford_comma
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Dave Kinkead
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-10-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description: Punctuation is important.
42
+ email:
43
+ - dave@kinkead.com.au
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - Gemfile
50
+ - LICENSE.txt
51
+ - OxfordComma.jpg
52
+ - README.md
53
+ - Rakefile
54
+ - lib/the_oxford_comma.rb
55
+ - lib/the_oxford_comma/version.rb
56
+ - test/oxford_spec.rb
57
+ - the_oxford_comma.gemspec
58
+ homepage: https://github.com/davekinkead/the-oxford-comma
59
+ licenses:
60
+ - MIT
61
+ metadata: {}
62
+ post_install_message:
63
+ rdoc_options: []
64
+ require_paths:
65
+ - lib
66
+ required_ruby_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ requirements: []
77
+ rubyforge_project:
78
+ rubygems_version: 2.2.2
79
+ signing_key:
80
+ specification_version: 4
81
+ summary: Punctuation is important.
82
+ test_files:
83
+ - test/oxford_spec.rb