kj 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8bd1f8584fa28f64cab1304e9d2436fea7870355
4
+ data.tar.gz: a6c661c7f1eadf045bc5d07d1a79d1b7a49ed80d
5
+ SHA512:
6
+ metadata.gz: 69bc011cdf510ef479cc2e1245073eddbffa8449230c6fe73009a136f46ba97e4de6541da8d0426b7b7b80f849d0911a28cd46d108f6e76fec7549de7761eb43
7
+ data.tar.gz: 66ae9aa135ab987675cd3e692df80e5a8abeba90c669a79af185b2dfd63556fcbfe5be4e35800ac0518b65219820942a07cb221209ca821b928a3602b0161f32
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.idea/kj.iml ADDED
@@ -0,0 +1,58 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="RUBY_MODULE" version="4">
3
+ <component name="FacetManager">
4
+ <facet type="gem" name="Ruby Gem">
5
+ <configuration>
6
+ <option name="GEM_APP_ROOT_PATH" value="$MODULE_DIR$" />
7
+ <option name="GEM_APP_TEST_PATH" value="$MODULE_DIR$/test" />
8
+ <option name="GEM_APP_LIB_PATH" value="$MODULE_DIR$/lib" />
9
+ </configuration>
10
+ </facet>
11
+ </component>
12
+ <component name="NewModuleRootManager">
13
+ <content url="file://$MODULE_DIR$">
14
+ <sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
15
+ </content>
16
+ <orderEntry type="inheritedJdk" />
17
+ <orderEntry type="sourceFolder" forTests="false" />
18
+ <orderEntry type="library" scope="PROVIDED" name="activesupport (v4.2.2, RVM: ruby-2.1.4) [gem]" level="application" />
19
+ <orderEntry type="library" scope="PROVIDED" name="addressable (v2.3.8, RVM: ruby-2.1.4) [gem]" level="application" />
20
+ <orderEntry type="library" scope="PROVIDED" name="builder (v3.2.2, RVM: ruby-2.1.4) [gem]" level="application" />
21
+ <orderEntry type="library" scope="PROVIDED" name="bundler (v1.7.6, RVM: ruby-2.1.4) [gem]" level="application" />
22
+ <orderEntry type="library" scope="PROVIDED" name="descendants_tracker (v0.0.4, RVM: ruby-2.1.4) [gem]" level="application" />
23
+ <orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.2.5, RVM: ruby-2.1.4) [gem]" level="application" />
24
+ <orderEntry type="library" scope="PROVIDED" name="docile (v1.1.5, RVM: ruby-2.1.4) [gem]" level="application" />
25
+ <orderEntry type="library" scope="PROVIDED" name="faraday (v0.9.1, RVM: ruby-2.1.4) [gem]" level="application" />
26
+ <orderEntry type="library" scope="PROVIDED" name="git (v1.2.9.1, RVM: ruby-2.1.4) [gem]" level="application" />
27
+ <orderEntry type="library" scope="PROVIDED" name="github_api (v0.12.3, RVM: ruby-2.1.4) [gem]" level="application" />
28
+ <orderEntry type="library" scope="PROVIDED" name="hashie (v3.4.2, RVM: ruby-2.1.4) [gem]" level="application" />
29
+ <orderEntry type="library" scope="PROVIDED" name="highline (v1.7.2, RVM: ruby-2.1.4) [gem]" level="application" />
30
+ <orderEntry type="library" scope="PROVIDED" name="i18n (v0.7.0, RVM: ruby-2.1.4) [gem]" level="application" />
31
+ <orderEntry type="library" scope="PROVIDED" name="jeweler (v2.0.1, RVM: ruby-2.1.4) [gem]" level="application" />
32
+ <orderEntry type="library" scope="PROVIDED" name="json (v1.8.3, RVM: ruby-2.1.4) [gem]" level="application" />
33
+ <orderEntry type="library" scope="PROVIDED" name="jwt (v1.5.0, RVM: ruby-2.1.4) [gem]" level="application" />
34
+ <orderEntry type="library" scope="PROVIDED" name="mini_portile (v0.6.2, RVM: ruby-2.1.4) [gem]" level="application" />
35
+ <orderEntry type="library" scope="PROVIDED" name="minitest (v5.7.0, RVM: ruby-2.1.4) [gem]" level="application" />
36
+ <orderEntry type="library" scope="PROVIDED" name="multi_json (v1.11.1, RVM: ruby-2.1.4) [gem]" level="application" />
37
+ <orderEntry type="library" scope="PROVIDED" name="multi_xml (v0.5.5, RVM: ruby-2.1.4) [gem]" level="application" />
38
+ <orderEntry type="library" scope="PROVIDED" name="multipart-post (v2.0.0, RVM: ruby-2.1.4) [gem]" level="application" />
39
+ <orderEntry type="library" scope="PROVIDED" name="nokogiri (v1.6.6.2, RVM: ruby-2.1.4) [gem]" level="application" />
40
+ <orderEntry type="library" scope="PROVIDED" name="oauth2 (v1.0.0, RVM: ruby-2.1.4) [gem]" level="application" />
41
+ <orderEntry type="library" scope="PROVIDED" name="rack (v1.6.4, RVM: ruby-2.1.4) [gem]" level="application" />
42
+ <orderEntry type="library" scope="PROVIDED" name="rake (v10.4.2, RVM: ruby-2.1.4) [gem]" level="application" />
43
+ <orderEntry type="library" scope="PROVIDED" name="rdoc (v3.12.2, RVM: ruby-2.1.4) [gem]" level="application" />
44
+ <orderEntry type="library" scope="PROVIDED" name="rspec (v3.0.0, RVM: ruby-2.1.4) [gem]" level="application" />
45
+ <orderEntry type="library" scope="PROVIDED" name="rspec-core (v3.0.4, RVM: ruby-2.1.4) [gem]" level="application" />
46
+ <orderEntry type="library" scope="PROVIDED" name="rspec-expectations (v3.0.4, RVM: ruby-2.1.4) [gem]" level="application" />
47
+ <orderEntry type="library" scope="PROVIDED" name="rspec-mocks (v3.0.4, RVM: ruby-2.1.4) [gem]" level="application" />
48
+ <orderEntry type="library" scope="PROVIDED" name="rspec-support (v3.0.4, RVM: ruby-2.1.4) [gem]" level="application" />
49
+ <orderEntry type="library" scope="PROVIDED" name="shoulda (v3.5.0, RVM: ruby-2.1.4) [gem]" level="application" />
50
+ <orderEntry type="library" scope="PROVIDED" name="shoulda-context (v1.2.1, RVM: ruby-2.1.4) [gem]" level="application" />
51
+ <orderEntry type="library" scope="PROVIDED" name="shoulda-matchers (v2.8.0, RVM: ruby-2.1.4) [gem]" level="application" />
52
+ <orderEntry type="library" scope="PROVIDED" name="simplecov (v0.10.0, RVM: ruby-2.1.4) [gem]" level="application" />
53
+ <orderEntry type="library" scope="PROVIDED" name="simplecov-html (v0.10.0, RVM: ruby-2.1.4) [gem]" level="application" />
54
+ <orderEntry type="library" scope="PROVIDED" name="sqlite3 (v1.3.10, RVM: ruby-2.1.4) [gem]" level="application" />
55
+ <orderEntry type="library" scope="PROVIDED" name="thread_safe (v0.3.5, RVM: ruby-2.1.4) [gem]" level="application" />
56
+ <orderEntry type="library" scope="PROVIDED" name="tzinfo (v1.2.2, RVM: ruby-2.1.4) [gem]" level="application" />
57
+ </component>
58
+ </module>
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ --warnings
3
+ --require spec_helper
data/Gemfile ADDED
@@ -0,0 +1,14 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ # Add dependencies to develop your gem here.
7
+ # Include everything needed to run rake, tests, features, etc.
8
+ group :development do
9
+ gem "bundler", "~> 1.0"
10
+ gem "jeweler", "~> 2.0.1"
11
+ gem "rspec"
12
+ end
13
+
14
+ gem 'sqlite3'
data/Gemfile.lock ADDED
@@ -0,0 +1,71 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ addressable (2.3.8)
5
+ builder (3.2.2)
6
+ descendants_tracker (0.0.4)
7
+ thread_safe (~> 0.3, >= 0.3.1)
8
+ diff-lcs (1.2.5)
9
+ faraday (0.9.1)
10
+ multipart-post (>= 1.2, < 3)
11
+ git (1.2.9.1)
12
+ github_api (0.12.3)
13
+ addressable (~> 2.3)
14
+ descendants_tracker (~> 0.0.4)
15
+ faraday (~> 0.8, < 0.10)
16
+ hashie (>= 3.3)
17
+ multi_json (>= 1.7.5, < 2.0)
18
+ nokogiri (~> 1.6.3)
19
+ oauth2
20
+ hashie (3.4.2)
21
+ highline (1.7.2)
22
+ jeweler (2.0.1)
23
+ builder
24
+ bundler (>= 1.0)
25
+ git (>= 1.2.5)
26
+ github_api
27
+ highline (>= 1.6.15)
28
+ nokogiri (>= 1.5.10)
29
+ rake
30
+ rdoc
31
+ json (1.8.3)
32
+ jwt (1.5.0)
33
+ mini_portile (0.6.2)
34
+ multi_json (1.11.1)
35
+ multi_xml (0.5.5)
36
+ multipart-post (2.0.0)
37
+ nokogiri (1.6.6.2)
38
+ mini_portile (~> 0.6.0)
39
+ oauth2 (1.0.0)
40
+ faraday (>= 0.8, < 0.10)
41
+ jwt (~> 1.0)
42
+ multi_json (~> 1.3)
43
+ multi_xml (~> 0.5)
44
+ rack (~> 1.2)
45
+ rack (1.6.4)
46
+ rake (10.4.2)
47
+ rdoc (3.12.2)
48
+ json (~> 1.4)
49
+ rspec (3.0.0)
50
+ rspec-core (~> 3.0.0)
51
+ rspec-expectations (~> 3.0.0)
52
+ rspec-mocks (~> 3.0.0)
53
+ rspec-core (3.0.4)
54
+ rspec-support (~> 3.0.0)
55
+ rspec-expectations (3.0.4)
56
+ diff-lcs (>= 1.2.0, < 2.0)
57
+ rspec-support (~> 3.0.0)
58
+ rspec-mocks (3.0.4)
59
+ rspec-support (~> 3.0.0)
60
+ rspec-support (3.0.4)
61
+ sqlite3 (1.3.10)
62
+ thread_safe (0.3.5)
63
+
64
+ PLATFORMS
65
+ ruby
66
+
67
+ DEPENDENCIES
68
+ bundler (~> 1.0)
69
+ jeweler (~> 2.0.1)
70
+ rspec
71
+ sqlite3
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2015 David John
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.md ADDED
@@ -0,0 +1,88 @@
1
+ # kj
2
+ kj is a simple rubygem for accessing the King James Bible. It uses an embedded sqlite data store.
3
+
4
+ ___
5
+ ##Usage
6
+ ###Create
7
+ ```ruby
8
+ require 'kj'
9
+ bible = Kj::Bible.new
10
+ ```
11
+ ###Books
12
+ All return an array of Book objects.
13
+ ```ruby
14
+ genesis = bible.books
15
+ genesis = bible.books(1)
16
+ genesis = bible.books(:genesis)
17
+ genesis = bible.books('Gen')
18
+ genesis = bible.books(:genesis, 2, 'Levit')
19
+ ```
20
+ ###Book
21
+ ```ruby
22
+ romans = bible.book(45)
23
+ romans = bible.book(:romans)
24
+ romans = bible.book('Rom')
25
+ puts romans.name
26
+ => "Romans"
27
+ ```
28
+ ###Chapters
29
+ All return an array of Chapter objects for the book.
30
+ ```ruby
31
+ genesis = bible.book(:genesis)
32
+ chapters = genesis.chapters
33
+ chapters = genesis.chapters(1, 2, (3..10).to_a)
34
+ ```
35
+ ###Chapter
36
+ ```ruby
37
+ genesis = bible.book(:genesis)
38
+ chapter = genesis.chapter(1)
39
+ puts chapter.book_name
40
+ => "Genesis"
41
+ puts chapter.number
42
+ => 1
43
+ puts chapter.title
44
+ => "Genesis 1"
45
+ ```
46
+ ###Verses
47
+ All return an array of Verse objects.
48
+ ```ruby
49
+ genesis = bible.book(:genesis)
50
+ verses = genesis.chapter(1).verses
51
+ verse = genesis.chapter(1).verses(1, 2, (3..10).to_a)
52
+ ```
53
+ ###Verse
54
+ ```ruby
55
+ genesis = bible.book(:genesis)
56
+ verse = genesis.chapter(1).verse(1)
57
+ puts verse.title
58
+ => "Genesis 1:1"
59
+ puts verse.text
60
+ => "In the beginning God..."
61
+ ```
62
+ ###Exceptions
63
+ Kj will raise a Kj::Iniquity when it can't find what you're looking for.
64
+ ```
65
+ bible.book(:tobit)
66
+ # Kj::Iniquity: Not found
67
+ ```
68
+ As you can see, kj is a protestant gem.
69
+ ###FAQ
70
+ Q. Why only King James? Are you one of those 'King James only' nuts?
71
+
72
+ A. Yes
73
+
74
+ ### Contributing to kj
75
+
76
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
77
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
78
+ * Fork the project.
79
+ * Start a feature/bugfix branch.
80
+ * Commit and push until you are happy with your contribution.
81
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
82
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
83
+
84
+ ### Copyright
85
+
86
+ Copyright (c) 2015 David John. See LICENSE.txt for
87
+ further details.
88
+
data/Rakefile ADDED
@@ -0,0 +1,49 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://guides.rubygems.org/specification-reference/ for more options
17
+ gem.name = "kj"
18
+ gem.homepage = "http://github.com/billguy/kj"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{kj is a simple rubygem for accessing the King James Bible}
21
+ gem.description = %Q{kj is a simple rubygem for accessing the King James Bible. It uses an embedded sqlite data store.}
22
+ gem.email = "djohn@arch-no.org"
23
+ gem.authors = ["David John"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rspec/core'
29
+ require 'rspec/core/rake_task'
30
+ RSpec::Core::RakeTask.new(:spec) do |spec|
31
+ spec.pattern = FileList['spec/**/*_spec.rb']
32
+ end
33
+
34
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
35
+ spec.pattern = 'spec/**/*_spec.rb'
36
+ spec.rcov = true
37
+ end
38
+
39
+ task :default => :spec
40
+
41
+ require 'rdoc/task'
42
+ Rake::RDocTask.new do |rdoc|
43
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
44
+
45
+ rdoc.rdoc_dir = 'rdoc'
46
+ rdoc.title = "kj #{version}"
47
+ rdoc.rdoc_files.include('README*')
48
+ rdoc.rdoc_files.include('lib/**/*.rb')
49
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
data/db/kjb.db ADDED
Binary file
data/kj.gemspec ADDED
@@ -0,0 +1,75 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+ # stub: kj 0.0.1 ruby lib
6
+
7
+ Gem::Specification.new do |s|
8
+ s.name = "kj"
9
+ s.version = "0.0.1"
10
+
11
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
+ s.require_paths = ["lib"]
13
+ s.authors = ["David John"]
14
+ s.date = "2015-07-12"
15
+ s.description = "kj is a simple rubygem for accessing the King James Bible. It uses an embedded sqlite data store."
16
+ s.email = "djohn@arch-no.org"
17
+ s.extra_rdoc_files = [
18
+ "LICENSE.txt",
19
+ "README.md"
20
+ ]
21
+ s.files = [
22
+ ".document",
23
+ ".idea/kj.iml",
24
+ ".rspec",
25
+ "Gemfile",
26
+ "Gemfile.lock",
27
+ "LICENSE.txt",
28
+ "README.md",
29
+ "Rakefile",
30
+ "VERSION",
31
+ "db/kjb.db",
32
+ "kj.gemspec",
33
+ "lib/kj.rb",
34
+ "lib/kj/book.rb",
35
+ "lib/kj/chapter.rb",
36
+ "lib/kj/db.rb",
37
+ "lib/kj/exceptions.rb",
38
+ "lib/kj/verse.rb",
39
+ "spec/book_spec.rb",
40
+ "spec/chapter_spec.rb",
41
+ "spec/kj_spec.rb",
42
+ "spec/spec_helper.rb",
43
+ "spec/verse_spec.rb",
44
+ "vendor/README.md",
45
+ "vendor/books.csv",
46
+ "vendor/import.rb",
47
+ "vendor/kjb.txt"
48
+ ]
49
+ s.homepage = "http://github.com/billguy/kj"
50
+ s.licenses = ["MIT"]
51
+ s.rubygems_version = "2.4.8"
52
+ s.summary = "kj is a simple rubygem for accessing the King James Bible"
53
+
54
+ if s.respond_to? :specification_version then
55
+ s.specification_version = 4
56
+
57
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
58
+ s.add_runtime_dependency(%q<sqlite3>, [">= 0"])
59
+ s.add_development_dependency(%q<bundler>, ["~> 1.0"])
60
+ s.add_development_dependency(%q<jeweler>, ["~> 2.0.1"])
61
+ s.add_development_dependency(%q<rspec>, [">= 0"])
62
+ else
63
+ s.add_dependency(%q<sqlite3>, [">= 0"])
64
+ s.add_dependency(%q<bundler>, ["~> 1.0"])
65
+ s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
66
+ s.add_dependency(%q<rspec>, [">= 0"])
67
+ end
68
+ else
69
+ s.add_dependency(%q<sqlite3>, [">= 0"])
70
+ s.add_dependency(%q<bundler>, ["~> 1.0"])
71
+ s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
72
+ s.add_dependency(%q<rspec>, [">= 0"])
73
+ end
74
+ end
75
+
data/lib/kj.rb ADDED
@@ -0,0 +1,37 @@
1
+ require "sqlite3"
2
+ require_relative 'kj/db'
3
+ require_relative 'kj/book'
4
+
5
+ module Kj
6
+
7
+ class Bible
8
+
9
+ def book(name_or_number)
10
+ if name_or_number.is_a?(Integer)
11
+ book = Db.query("SELECT id, name FROM books WHERE id = ?", [name_or_number], true)
12
+ else
13
+ book = Db.query("SELECT id, name FROM books WHERE name = ? OR abbreviations LIKE ?", [name_or_number.to_s.downcase, "%#{name_or_number.to_s}%"], true)
14
+ end
15
+ Book.new(id: book['id'], name: book['name'])
16
+ end
17
+
18
+ def books(*names_or_numbers)
19
+ if names_or_numbers.empty?
20
+ @books = begin
21
+ results = Db.query("SELECT id, name FROM books")
22
+ results.map{ |book| Book.new(id: book['id'], name: book['name']) }
23
+ end
24
+ else
25
+ names_or_numbers.flatten!
26
+ numbers = names_or_numbers.uniq.select{|n| n.is_a?(Integer)}
27
+ names = (names_or_numbers - numbers).uniq.map{|name| name.to_s.downcase}
28
+ results = []
29
+ results << Db.query("SELECT id, name FROM books WHERE id IN (#{numbers.join(',')})") if numbers.any?
30
+ names.each{ |name| results << Db.query("SELECT id, name FROM books WHERE abbreviations LIKE ?", ["%#{name.to_s}%"]) }
31
+ results.flatten.map!{|book| Book.new(id: book['id'], name: book['name'])}.uniq.sort!{ |a,b| a.id <=> b.id }
32
+ end
33
+ end
34
+
35
+ end
36
+
37
+ end