gematria 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ .rvmrc
7
+ Gemfile.lock
8
+ InstalledFiles
9
+ _yardoc
10
+ coverage
11
+ doc/
12
+ lib/bundler/man
13
+ pkg
14
+ rdoc
15
+ spec/reports
16
+ test/tmp
17
+ test/version_tmp
18
+ tmp
data/CHANGELOG.md ADDED
@@ -0,0 +1,3 @@
1
+ ## v0.0.1
2
+
3
+ * initial release
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in gematria.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Adam Zaninovich
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.
data/README.md ADDED
@@ -0,0 +1,72 @@
1
+ # Gematria
2
+
3
+ A Ruby gem that calculates Gematria. This version supports English text and uses a mispar hechrachi style correspondence table, but in future versions there may be support for more languages as well as user configurable correspondence tables. The gem supports raw conversion to number (by simple summation), mapping (breakdown of individual numbers), and reduction to a single digit (mispar katan mispari).
4
+
5
+ The current correspondence table is as follows:
6
+
7
+ a:1 b:2 c:3 d:4 e:5 f:6 g:7 h:8 i:9
8
+ j:10 k:20 l:30 m:40 n:50 o:60 p:70 q:80 r:90
9
+ s:100 t:200 u:300 v:400 w:500 x:600 y:700 z:800
10
+
11
+ ## Installation
12
+
13
+ Add this line to your application's Gemfile:
14
+
15
+ gem 'gematria'
16
+
17
+ And then execute:
18
+
19
+ $ bundle
20
+
21
+ Or install it yourself as:
22
+
23
+ $ gem install gematria
24
+
25
+ ## Usage
26
+
27
+ name = Gematria::English.new("Adam")
28
+ name.converted # => 46
29
+ name.mapped.join(" + ") # => "1 + 4 + 1 + 40"
30
+ name.reduced # => 1
31
+
32
+ gematria = Gematria::English.new("Gematria is fun!")
33
+ gematria.converted # => 818
34
+ gematria.mapped # => [7, 5, 40, 1, 200, 90, 9, 1, 0, 9, 100, 0, 6, 300, 50, 0]
35
+
36
+ alphabet = Gematria::English.new("abcdefghijklmnopqrstuvwxyz")
37
+ alphabet.converted == 4095 # => true
38
+
39
+ ## Contributing
40
+
41
+ Please submit specs with your feature!
42
+
43
+ 1. Fork it
44
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
45
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
46
+ 4. Push to the branch (`git push origin my-new-feature`)
47
+ 5. Create new Pull Request
48
+
49
+ ## License
50
+
51
+ Copyright (c) 2013 Adam Zaninovich
52
+
53
+ MIT License
54
+
55
+ Permission is hereby granted, free of charge, to any person obtaining
56
+ a copy of this software and associated documentation files (the
57
+ "Software"), to deal in the Software without restriction, including
58
+ without limitation the rights to use, copy, modify, merge, publish,
59
+ distribute, sublicense, and/or sell copies of the Software, and to
60
+ permit persons to whom the Software is furnished to do so, subject to
61
+ the following conditions:
62
+
63
+ The above copyright notice and this permission notice shall be
64
+ included in all copies or substantial portions of the Software.
65
+
66
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
67
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
68
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
69
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
70
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
71
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
72
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/gematria.gemspec ADDED
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'gematria/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "gematria"
8
+ gem.version = Gematria::VERSION
9
+ gem.authors = ["Adam Zaninovich"]
10
+ gem.email = ["adam.zaninovich@gmail.com"]
11
+ gem.description = %q{A Ruby gem that calculates Gematria. This version supports English text and uses a mispar hechrachi style correspondence table, but in future versions there may be support for more languages as well as user configurable correspondence tables. The gem supports raw conversion to number (by simple summation), mapping (breakdown of individual numbers), and reduction to a single digit (mispar katan mispari).}
12
+ gem.summary = %q{A Ruby gem that calculates Gematria}
13
+ gem.homepage = "http://github.com/adamzaninovich/gematria"
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+
20
+ gem.add_development_dependency 'rspec', '~> 2.13.0'
21
+ end
data/lib/gematria.rb ADDED
@@ -0,0 +1,5 @@
1
+ require "gematria/version"
2
+ require "gematria/english"
3
+
4
+ module Gematria
5
+ end
@@ -0,0 +1,35 @@
1
+ module Gematria
2
+ class English < Struct.new(:text)
3
+ CORRESPONDENCE_TABLE = { # applies `mispar hechrachi` method to English alphabet (http://www.inner.org/gematria/fourways.php)
4
+ a: 1, b: 2, c: 3, d: 4, e: 5, f: 6, g: 7, h: 8, i: 9,
5
+ j: 10, k: 20, l: 30, m: 40, n: 50, o: 60, p: 70, q: 80, r: 90,
6
+ s: 100, t: 200, u: 300, v: 400, w: 500, x: 600, y: 700, z: 800
7
+ }
8
+
9
+ def mapped
10
+ text.each_char.map { |c| lookup_char c }
11
+ end
12
+
13
+ def converted
14
+ mapped.inject(:+)
15
+ end
16
+
17
+ def reduced
18
+ do_reduction_on converted
19
+ end
20
+
21
+ private
22
+ def lookup_char(char)
23
+ CORRESPONDENCE_TABLE.fetch(char.downcase.to_sym, 0)
24
+ end
25
+
26
+ def do_reduction_on(number)
27
+ if number < 10
28
+ number
29
+ else
30
+ do_reduction_on number.to_s.each_char.map(&:to_i).inject(:+)
31
+ end
32
+ end
33
+
34
+ end
35
+ end
@@ -0,0 +1,3 @@
1
+ module Gematria
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,37 @@
1
+ require 'spec_helper'
2
+
3
+ describe Gematria::English do
4
+ it "is instantiated with text and provides access to that text" do
5
+ gematria = Gematria::English.new('mytext')
6
+ expect(gematria.text).to eq 'mytext'
7
+ end
8
+
9
+ describe "#mapped" do
10
+ it "returns an array of values for each character in text" do
11
+ gematria = Gematria::English.new('abc')
12
+ expect(gematria.mapped).to eq [1,2,3]
13
+ end
14
+ end
15
+
16
+ describe "#converted" do
17
+ it "returns the sum of the letter values" do
18
+ gematria = Gematria::English.new('abc')
19
+ expect(gematria.converted).to eq 6
20
+ end
21
+ end
22
+
23
+ describe "#reduced" do
24
+ context "when converted value is a single digit" do
25
+ it "returns a single digit" do
26
+ gematria = Gematria::English.new('abc')
27
+ expect(gematria.reduced).to eq 6
28
+ end
29
+ end
30
+ context "when converted value is more than one digit" do
31
+ it "returns a single digit" do
32
+ gematria = Gematria::English.new('abcdefghijklmnopqrstuvwxyz')
33
+ expect(gematria.reduced).to eq 9 # 4095 -> 18 -> 9
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,2 @@
1
+ require 'rspec'
2
+ require 'gematria'
metadata ADDED
@@ -0,0 +1,79 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gematria
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Adam Zaninovich
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-02-26 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rspec
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 2.13.0
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 2.13.0
30
+ description: A Ruby gem that calculates Gematria. This version supports English text
31
+ and uses a mispar hechrachi style correspondence table, but in future versions there
32
+ may be support for more languages as well as user configurable correspondence tables.
33
+ The gem supports raw conversion to number (by simple summation), mapping (breakdown
34
+ of individual numbers), and reduction to a single digit (mispar katan mispari).
35
+ email:
36
+ - adam.zaninovich@gmail.com
37
+ executables: []
38
+ extensions: []
39
+ extra_rdoc_files: []
40
+ files:
41
+ - .gitignore
42
+ - CHANGELOG.md
43
+ - Gemfile
44
+ - LICENSE.txt
45
+ - README.md
46
+ - Rakefile
47
+ - gematria.gemspec
48
+ - lib/gematria.rb
49
+ - lib/gematria/english.rb
50
+ - lib/gematria/version.rb
51
+ - spec/gematria/english_spec.rb
52
+ - spec/spec_helper.rb
53
+ homepage: http://github.com/adamzaninovich/gematria
54
+ licenses: []
55
+ post_install_message:
56
+ rdoc_options: []
57
+ require_paths:
58
+ - lib
59
+ required_ruby_version: !ruby/object:Gem::Requirement
60
+ none: false
61
+ requirements:
62
+ - - ! '>='
63
+ - !ruby/object:Gem::Version
64
+ version: '0'
65
+ required_rubygems_version: !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ! '>='
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ requirements: []
72
+ rubyforge_project:
73
+ rubygems_version: 1.8.24
74
+ signing_key:
75
+ specification_version: 3
76
+ summary: A Ruby gem that calculates Gematria
77
+ test_files:
78
+ - spec/gematria/english_spec.rb
79
+ - spec/spec_helper.rb