iuliia 1.0.0 → 1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b104da0c637eac076457e888d30e52f977f2871b80f54cd82f995237ff343338
4
- data.tar.gz: edba6708b1590c7016749bd65c89f0f01d1514653c620064620fba8749061cd4
3
+ metadata.gz: 687b0bb708b6eb6c64d055562c7e6be0b61a901c466b1bced4d7e0b4201cff1f
4
+ data.tar.gz: 9d45eb3171cbb1e21f43bc56dd6aa286f3425d884088a5f41ec51debaaa38e1e
5
5
  SHA512:
6
- metadata.gz: b67688c64d902c5507826a3b9da892675bff114450e7cc9039248819a9d95c3904c7851d6698ec2b0e311d2e46ea6740484c163caaed2a2311e1db7138ec0800
7
- data.tar.gz: b32700393e2f5c510402e9ac22e782d2bc7396e805dcad60e8fec65ac5a7fa5fb83b9364da690eccbb776d408f3e427e3002234afe73d555c4320c3d4fd98212
6
+ metadata.gz: d35bd6868e309f3887fc61d1e8c4944523dd0f5560dfe0763c56171045ff99c8f93c57ce3142c4d769aa0fa6cd52b71c244f02c26579b66a7389c2621d3324cf
7
+ data.tar.gz: f167b6d8d86029dd462724d75483ba6d281e1e478491fb20dbd1e0e2eccc6690db33cc4658b996a57e0bdda9d33da4939cc368c477221338448580c94e24ddf4
@@ -17,9 +17,7 @@ on:
17
17
 
18
18
  jobs:
19
19
  test:
20
-
21
20
  runs-on: ubuntu-latest
22
-
23
21
  steps:
24
22
  - uses: actions/checkout@v2
25
23
  with:
@@ -31,4 +29,4 @@ jobs:
31
29
  - name: Install dependencies
32
30
  run: bundle install
33
31
  - name: Run tests
34
- run: bundle exec rake
32
+ run: bundle exec rspec
@@ -11,10 +11,10 @@
11
11
  # Include: **/*.gemspec
12
12
  Gemspec/RequiredRubyVersion:
13
13
  Exclude:
14
- - 'iiulia-rb.gemspec'
14
+ - 'iiulia.gemspec'
15
15
 
16
16
  # Offense count: 1
17
17
  # Configuration parameters: MinBodyLength.
18
18
  Style/GuardClause:
19
19
  Exclude:
20
- - 'iiulia-rb.gemspec'
20
+ - 'iiulia.gemspec'
@@ -4,9 +4,19 @@ All notable changes to this project will be documented in this file.
4
4
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
5
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## [1.0.1] - 2020-09-25
8
+ #### Deprecations
9
+ Method `translit` now deprecated, use `translate` instead. Will be removed completely in the future releases.
10
+ #### Improvements
11
+ Now call for translate with wrong (non-existent) schema will throw more human-friendly exception.
12
+
7
13
  ## [1.0.0] - 2020-09-14
8
14
  This is the new initial version for gem `iuliia` after renaming it from `iuliia-rb`
9
15
 
16
+ ## [0.2.1] - 2020-09-14
17
+ Changes:
18
+ * Gem has been renamed to `iuliia`. This is the last version of `iuliia-rb`. Please, use `iuliia` instead.
19
+
10
20
  ## [0.2.0] - 2020-09-14
11
21
  Changes:
12
22
  * Moved `lib/schemas` to the git submodule `github.com/nalgeon/iuliia`
data/Gemfile CHANGED
@@ -4,5 +4,5 @@ source 'https://rubygems.org'
4
4
 
5
5
  git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
6
6
 
7
- # Specify your gem's dependencies in iiulia-rb.gemspec
7
+ # Specify your gem's dependencies in iiulia.gemspec
8
8
  gemspec
data/README.md CHANGED
@@ -6,6 +6,8 @@ Small gem to properly transliterate cyrillic to latin. Use https://github.com/na
6
6
 
7
7
  ## Installation
8
8
 
9
+ #### Gem has been renamed to `iuliia`. This is the last version of `iuliia-rb`. Please, use `iuliia` instead.
10
+
9
11
  Add this line to your application's Gemfile:
10
12
 
11
13
  ```ruby
@@ -60,7 +62,7 @@ Iuliia::Schema.available_schemas
60
62
  Pick one and transliterate
61
63
 
62
64
  ```ruby
63
- Iuliia.translit('Юлия, съешь ещё этих мягких французских булок из Йошкар-Олы, да выпей алтайского чаю', schema: 'mvd_782')
65
+ Iuliia.translate('Юлия, съешь ещё этих мягких французских булок из Йошкар-Олы, да выпей алтайского чаю', schema: 'mvd_782')
64
66
 
65
67
  "Yuliya, syesh' eshche etikh myagkikh frantsuzskikh bulok iz Yoshkar-Oly, da vypey altayskogo chayu"
66
68
  ```
@@ -73,10 +75,47 @@ Iuliia.translit('Юлия, съешь ещё этих мягких францу
73
75
 
74
76
  ## Development
75
77
 
76
- 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.
78
+ Check out repo:
79
+
80
+ ```
81
+ git clone git@github.com:adnikiforov/iuliia-rb.git
82
+ ```
83
+
84
+ Check out submodule with schemas:
85
+
86
+ ```
87
+ git submodule update --init
88
+ ```
89
+
90
+ Setup dependencies:
91
+
92
+ ```
93
+ bin/setup
94
+ ```
95
+
96
+ Run specs:
97
+
98
+ ```
99
+ bundle exec rspec
100
+ ```
101
+
102
+ Or open console to try it:
103
+
104
+ ```
105
+ bin/console
106
+ ```
77
107
 
78
108
  To install this gem onto your local machine, run `bundle exec rake install`.
79
109
 
110
+ ## Support
111
+
112
+ <p>
113
+ <a href="https://evrone.com/?utm_source=github&utm_campaign=iuliia-rb">
114
+ <img src="https://raw.githubusercontent.com/adnikiforov/iuliia-rb/master/priv/evrone-sponsored-logo.png"
115
+ alt="Sponsored by Evrone" width="210">
116
+ </a>
117
+ </p>
118
+
80
119
  ## License
81
120
 
82
121
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -27,7 +27,7 @@ Gem::Specification.new do |spec|
27
27
  # Specify which files should be added to the gem when it is released.
28
28
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
29
29
  spec.files = Dir.chdir(File.expand_path(__dir__)) do
30
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
30
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features|priv)/}) }
31
31
  end
32
32
  spec.bindir = 'exe'
33
33
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
@@ -6,3 +6,4 @@ require 'iuliia/version'
6
6
  require 'iuliia/translit'
7
7
  require 'iuliia/schema'
8
8
  require 'iuliia/iuliia'
9
+ require 'iuliia/exceptions'
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Iuliia
4
+ module Exceptions
5
+ class NonExistentSchemaException < StandardError
6
+ def initialize(msg = 'Specified schema does not exist')
7
+ super
8
+ end
9
+ end
10
+ end
11
+ end
@@ -2,13 +2,17 @@
2
2
 
3
3
  module Iuliia
4
4
  class << self
5
-
6
- # Translit cyrillic string to latin representation
5
+ # Translate cyrillic string to latin representation
7
6
  # @param string [String]
8
7
  # @param schema [Iuliia::Schema]
9
8
  # @return [String]
10
- def translit(string, schema:)
9
+ def translate(string, schema:)
11
10
  Iuliia::Translit.new(string, schema).translit
12
11
  end
12
+
13
+ def translit(string, schema:)
14
+ warn 'translit is deprecated, use .translate instead'
15
+ translate(string, schema: schema)
16
+ end
13
17
  end
14
18
  end
@@ -3,7 +3,6 @@
3
3
  module Iuliia
4
4
  module Schema
5
5
  class << self
6
-
7
6
  # Fetch schema by schema name
8
7
  # @param schema_name [String]
9
8
  # @return [Iuliia::Schema]
@@ -11,10 +10,11 @@ module Iuliia
11
10
  schemas[schema_name]
12
11
  end
13
12
 
13
+ # @deprecated
14
14
  alias schema []
15
15
 
16
16
  # Return list of available schemas
17
- # @return [Array<Iuliia::Schema]>]
17
+ # @return [Array]
18
18
  def available_schemas
19
19
  load_schemas.transform_values(&:description).to_a
20
20
  end
@@ -26,7 +26,10 @@ module Iuliia
26
26
  end
27
27
 
28
28
  def load_schema(name)
29
- JSON.parse(File.read("lib/schemas/#{name}.json"), object_class: OpenStruct, symbolize_names: true)
29
+ filename = "lib/schemas/#{name}.json"
30
+ raise Exceptions::NonExistentSchemaException unless File.exist?(filename)
31
+
32
+ JSON.parse(File.read(filename), object_class: OpenStruct, symbolize_names: true)
30
33
  end
31
34
 
32
35
  def load_schemas
@@ -3,6 +3,7 @@
3
3
  module Iuliia
4
4
  class Translit
5
5
  ENDING_LENGTH = 2
6
+ private_constant :ENDING_LENGTH
6
7
 
7
8
  # Initialize transliterator engine with string and schema
8
9
  # @param string [String]
@@ -10,12 +11,14 @@ module Iuliia
10
11
  # @return [Iuliia::Translit]
11
12
  def initialize(string, schema)
12
13
  @string = string
13
- @schema = Iuliia::Schema.schema(schema)
14
+ @schema = Iuliia::Schema[schema]
14
15
  end
15
16
 
16
17
  # Translit cyrillic string to latin representation
17
18
  # @return [String]
18
19
  def translit
20
+ return unless schema
21
+
19
22
  string.split(/\b/).map { |chunk| translit_chunk(chunk) }.join
20
23
  end
21
24
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Iuliia
4
- VERSION = '1.0.0'
4
+ VERSION = '1.0.1'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iuliia
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrey Nikiforov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-09-14 00:00:00.000000000 Z
11
+ date: 2020-09-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -101,8 +101,9 @@ files:
101
101
  - Rakefile
102
102
  - bin/console
103
103
  - bin/setup
104
- - iiulia-rb.gemspec
104
+ - iiulia.gemspec
105
105
  - lib/iuliia.rb
106
+ - lib/iuliia/exceptions.rb
106
107
  - lib/iuliia/iuliia.rb
107
108
  - lib/iuliia/schema.rb
108
109
  - lib/iuliia/translit.rb