greek_abc 0.1.0

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
+ SHA256:
3
+ metadata.gz: 59838b01626c03233f7226ebcc2554c7fd68343dd92958aef213a11a48a2dcc8
4
+ data.tar.gz: 636caa18a07327f8cd186c60e2fddd4afad5db7ecb28cd82ee5278297dd544b9
5
+ SHA512:
6
+ metadata.gz: a780712314cd93a1deb3d6c2f1fc38984fc468069ba630f85520d174f1e7bd7611df0fee2d41fc3a68ef0dade30dcc77ffa1cfe6e386a899763a519d8ae099c3
7
+ data.tar.gz: 32c5a5bbe0ee1c00514dce2f0b54a4c790da8731f6f3dc33896a478b27942f4a0135bc9eb4360aa0a9116339f74054bac8421cf99d82b78412bc7d5460ffd750
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.6.2
7
+ before_install: gem install bundler -v 2.0.1
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in greek_abc.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,35 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ greek_abc (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ diff-lcs (1.3)
10
+ rake (10.5.0)
11
+ rspec (3.8.0)
12
+ rspec-core (~> 3.8.0)
13
+ rspec-expectations (~> 3.8.0)
14
+ rspec-mocks (~> 3.8.0)
15
+ rspec-core (3.8.0)
16
+ rspec-support (~> 3.8.0)
17
+ rspec-expectations (3.8.3)
18
+ diff-lcs (>= 1.2.0, < 2.0)
19
+ rspec-support (~> 3.8.0)
20
+ rspec-mocks (3.8.0)
21
+ diff-lcs (>= 1.2.0, < 2.0)
22
+ rspec-support (~> 3.8.0)
23
+ rspec-support (3.8.0)
24
+
25
+ PLATFORMS
26
+ ruby
27
+
28
+ DEPENDENCIES
29
+ bundler (~> 2.0)
30
+ greek_abc!
31
+ rake (~> 10.0)
32
+ rspec (~> 3.0)
33
+
34
+ BUNDLED WITH
35
+ 2.0.1
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 Vladislav Andreev
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,36 @@
1
+ # GreekABC
2
+
3
+ Gem for Greek alphabet manipulations
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'greek_abc'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install greek_abc
20
+
21
+ ## Usage
22
+
23
+
24
+ ## Development
25
+
26
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
27
+
28
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
29
+
30
+ ## Contributing
31
+
32
+ Bug reports and pull requests are welcome on GitHub at https://github.com/vladyio/greek_abc.
33
+
34
+ ## License
35
+
36
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "greek_abc"
5
+
6
+ require "irb"
7
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
data/greek_abc.gemspec ADDED
@@ -0,0 +1,41 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "greek_abc/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "greek_abc"
8
+ spec.version = GreekABC::VERSION
9
+ spec.authors = ["Vladislav Andreev"]
10
+ spec.email = ["me@vld.by"]
11
+
12
+ spec.summary = %q{Greek alphabet manipulation gem}
13
+ spec.homepage = "https://github.com/vladyio/greek_abc"
14
+ spec.license = "MIT"
15
+
16
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
17
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
18
+ if spec.respond_to?(:metadata)
19
+ spec.metadata["allowed_push_host"] = "https://rubygems.org/"
20
+
21
+ spec.metadata["homepage_uri"] = spec.homepage
22
+ spec.metadata["source_code_uri"] = "https://github.com/vladyio/greek_abc"
23
+ spec.metadata["changelog_uri"] = "https://github.com/vladyio/greek_abc/CHANGELOG.md"
24
+ else
25
+ raise "RubyGems 2.0 or newer is required to protect against " \
26
+ "public gem pushes."
27
+ end
28
+
29
+ # Specify which files should be added to the gem when it is released.
30
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
31
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
32
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
33
+ end
34
+ spec.bindir = "exe"
35
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
36
+ spec.require_paths = ["lib"]
37
+
38
+ spec.add_development_dependency "bundler", "~> 2.0"
39
+ spec.add_development_dependency "rake", "~> 10.0"
40
+ spec.add_development_dependency "rspec", "~> 3.0"
41
+ end
@@ -0,0 +1,52 @@
1
+ module GreekABC
2
+ class Alphabet
3
+ attr_accessor :letters
4
+
5
+ def initialize
6
+ @letters = ALPHABET.map.with_index(1) do |(name, letter), index|
7
+ Letter.new(position: index, name: name, lower: letter,
8
+ upper: letter.upcase)
9
+ end
10
+ end
11
+
12
+ def find_letter_by(**lookup)
13
+ parameter = lookup.keys.first
14
+ value = lookup.values.first
15
+
16
+ unless letter_parameter?(parameter)
17
+ raise LetterLookupError, "Letter does not have parameter `#{parameter}`"
18
+ end
19
+
20
+ result = @letters.select do |letter|
21
+ letter if letter.send(parameter.to_sym) == value
22
+ end
23
+
24
+ if result.empty?
25
+ raise LetterNotFoundError, "Letter with `#{parameter}: #{value}` not found"
26
+ else
27
+ result.first
28
+ end
29
+ end
30
+
31
+ def to_h
32
+ @letters.each_with_object({}) do |letter, hash|
33
+ hash[letter.name.to_s] = {
34
+ position: letter.position,
35
+ lower: letter.lower,
36
+ upper: letter.upper
37
+ }
38
+ end
39
+ end
40
+
41
+ def to_s
42
+ @letters
43
+ end
44
+
45
+ private
46
+
47
+ def letter_parameter?(parameter)
48
+ parameters = %i[name position lower upper]
49
+ parameters.include?(parameter)
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,16 @@
1
+ module GreekABC
2
+ class Letter
3
+ attr_reader :position, :name, :lower, :upper
4
+
5
+ def initialize(position:, name:, lower:, upper:)
6
+ @position = position
7
+ @name = name
8
+ @lower = lower
9
+ @upper = upper
10
+ end
11
+
12
+ def to_s
13
+ "Letter ##{@position} '#{@name}', lowercase '#{@lower}', uppercase '#{@upper}'"
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,3 @@
1
+ module GreekABC
2
+ VERSION = "0.1.0"
3
+ end
data/lib/greek_abc.rb ADDED
@@ -0,0 +1,36 @@
1
+ require 'greek_abc/version'
2
+ require 'greek_abc/letter'
3
+ require 'greek_abc/alphabet'
4
+
5
+ module GreekABC
6
+ class GreekABCError < StandardError; end
7
+ class LetterLookupError < GreekABCError; end
8
+ class LetterNotFoundError < GreekABCError; end
9
+
10
+ ALPHABET = {
11
+ 'Alpha' => 'α',
12
+ 'Beta' => 'β',
13
+ 'Gamma' => 'γ',
14
+ 'Delta' => 'δ',
15
+ 'Epsilon' => 'ε',
16
+ 'Zeta' => 'ζ',
17
+ 'Eta' => 'η',
18
+ 'Theta' => 'θ',
19
+ 'Iota' => 'ι',
20
+ 'Kappa' => 'κ',
21
+ 'Lambda' => 'λ',
22
+ 'Mu' => 'μ',
23
+ 'Nu' => 'ν',
24
+ 'Xi' => 'ξ',
25
+ 'Omicron' => 'ο',
26
+ 'Pi' => 'π',
27
+ 'Rho' => 'ρ',
28
+ 'Sigma' => 'σ',
29
+ 'Tau' => 'τ',
30
+ 'Upsilon' => 'υ',
31
+ 'Phi' => 'φ',
32
+ 'Chi' => 'χ',
33
+ 'Psi' => 'ψ',
34
+ 'Omega' => 'ω'
35
+ }.freeze
36
+ end
metadata ADDED
@@ -0,0 +1,104 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: greek_abc
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Vladislav Andreev
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-04-27 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: '2.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
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
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ description:
56
+ email:
57
+ - me@vld.by
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - ".rspec"
64
+ - ".travis.yml"
65
+ - Gemfile
66
+ - Gemfile.lock
67
+ - LICENSE.txt
68
+ - README.md
69
+ - Rakefile
70
+ - bin/console
71
+ - bin/setup
72
+ - greek_abc.gemspec
73
+ - lib/greek_abc.rb
74
+ - lib/greek_abc/alphabet.rb
75
+ - lib/greek_abc/letter.rb
76
+ - lib/greek_abc/version.rb
77
+ homepage: https://github.com/vladyio/greek_abc
78
+ licenses:
79
+ - MIT
80
+ metadata:
81
+ allowed_push_host: https://rubygems.org/
82
+ homepage_uri: https://github.com/vladyio/greek_abc
83
+ source_code_uri: https://github.com/vladyio/greek_abc
84
+ changelog_uri: https://github.com/vladyio/greek_abc/CHANGELOG.md
85
+ post_install_message:
86
+ rdoc_options: []
87
+ require_paths:
88
+ - lib
89
+ required_ruby_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ required_rubygems_version: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ requirements: []
100
+ rubygems_version: 3.0.3
101
+ signing_key:
102
+ specification_version: 4
103
+ summary: Greek alphabet manipulation gem
104
+ test_files: []