iuliia-rb 0.1.0 → 0.2.0

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.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/spec.yml +34 -0
  3. data/.gitmodules +3 -0
  4. data/.rubocop.yml +8 -0
  5. data/.rubocop_todo.yml +20 -0
  6. data/CHANGELOG.md +5 -0
  7. data/README.md +5 -3
  8. data/Rakefile +2 -0
  9. data/iiulia-rb.gemspec +4 -5
  10. data/lib/iuliia/iuliia.rb +8 -3
  11. data/lib/iuliia/schema.rb +27 -40
  12. data/lib/iuliia/translit.rb +6 -0
  13. data/lib/iuliia/version.rb +1 -1
  14. metadata +29 -43
  15. data/.idea/iiulia-rb.iml +0 -19
  16. data/.idea/misc.xml +0 -7
  17. data/.idea/modules.xml +0 -8
  18. data/.idea/workspace.xml +0 -4
  19. data/CODE_OF_CONDUCT.md +0 -74
  20. data/Gemfile.lock +0 -37
  21. data/lib/schemas/LICENSE +0 -21
  22. data/lib/schemas/README.md +0 -20
  23. data/lib/schemas/ala_lc.json +0 -49
  24. data/lib/schemas/ala_lc_alt.json +0 -49
  25. data/lib/schemas/bgn_pcgn.json +0 -147
  26. data/lib/schemas/bgn_pcgn_alt.json +0 -106
  27. data/lib/schemas/bs_2979.json +0 -55
  28. data/lib/schemas/bs_2979_alt.json +0 -49
  29. data/lib/schemas/gost_16876.json +0 -49
  30. data/lib/schemas/gost_16876_alt.json +0 -49
  31. data/lib/schemas/gost_52290.json +0 -92
  32. data/lib/schemas/gost_52535.json +0 -50
  33. data/lib/schemas/gost_7034.json +0 -62
  34. data/lib/schemas/gost_779.json +0 -50
  35. data/lib/schemas/gost_779_alt.json +0 -54
  36. data/lib/schemas/icao_doc_9303.json +0 -57
  37. data/lib/schemas/iso_9_1954.json +0 -49
  38. data/lib/schemas/iso_9_1968.json +0 -49
  39. data/lib/schemas/iso_9_1968_alt.json +0 -49
  40. data/lib/schemas/mosmetro.json +0 -102
  41. data/lib/schemas/mvd_310.json +0 -52
  42. data/lib/schemas/mvd_310_fr.json +0 -66
  43. data/lib/schemas/mvd_782.json +0 -96
  44. data/lib/schemas/scientific.json +0 -49
  45. data/lib/schemas/telegram.json +0 -49
  46. data/lib/schemas/ungegn_1987.json +0 -53
  47. data/lib/schemas/wikipedia.json +0 -95
  48. data/lib/schemas/yandex_maps.json +0 -58
  49. data/lib/schemas/yandex_money.json +0 -52
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 876f5a93f34261da9f5f94131bafdc301976e627d9f2016671a512b2ddd4c872
4
- data.tar.gz: fbec866a5c2a808ebcaa04c3d0e9ad2449e676c8e071e4fcdb9960aec35f7219
3
+ metadata.gz: cf7054429bbf45777a898982dbbf5efa5a1690d3656b5486d04adb80a27a6a77
4
+ data.tar.gz: ce0d3f3f87719303dfcfbdf3599feb89991f8d9eac115be2575d73f8ee1fe2e1
5
5
  SHA512:
6
- metadata.gz: fc513edc37525c16bbfa7c5873f8c4b6d4680e0f94393feecb58467ea0bbc818b865d03a13526fff6180a03060c1dcdcca25a7198681b7939a1ac7f22f2f0678
7
- data.tar.gz: bf8b4ccbd91d0c8204e64f05365e7c7bd40a8f24d44dcf78f81be6669acc97d3fb58deed9ce6eb2a181eb36833e958477cddb16e37c23c828002f4c057f23dae
6
+ metadata.gz: 3b0934133b04fbe07076949c02d89475e69faee3b009de8a597feb62af38dbb769e991356047ab618b1759737e663d876126ad07e695e320a671f0cd3612a222
7
+ data.tar.gz: 6832a81554d55ee79415a0780485b3a7cb0f52de638f7086e45e454187cddc6dd33f9ac51a88d7210ef7255d4fce336663fa2ddd981afeea6ad9360eb92dec17
@@ -0,0 +1,34 @@
1
+ # This workflow uses actions that are not certified by GitHub.
2
+ # They are provided by a third-party and are governed by
3
+ # separate terms of service, privacy policy, and support
4
+ # documentation.
5
+ # This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
6
+ # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
7
+
8
+ name: Ruby
9
+
10
+ on:
11
+ push:
12
+ branches:
13
+ - master
14
+ - release-*
15
+ pull_request:
16
+ branches: [ master ]
17
+
18
+ jobs:
19
+ test:
20
+
21
+ runs-on: ubuntu-latest
22
+
23
+ steps:
24
+ - uses: actions/checkout@v2
25
+ with:
26
+ submodules: 'true'
27
+ - name: Set up Ruby
28
+ uses: ruby/setup-ruby@v1
29
+ with:
30
+ ruby-version: 2.6
31
+ - name: Install dependencies
32
+ run: bundle install
33
+ - name: Run tests
34
+ run: bundle exec rake
@@ -0,0 +1,3 @@
1
+ [submodule "lib/schemas"]
2
+ path = lib/schemas
3
+ url = https://github.com/nalgeon/iuliia
@@ -0,0 +1,8 @@
1
+ inherit_from: .rubocop_todo.yml
2
+
3
+ AllCops:
4
+ DisplayCopNames: true
5
+ NewCops: enable
6
+
7
+ Style/Documentation:
8
+ Enabled: false
@@ -0,0 +1,20 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config --exclude-limit 1000`
3
+ # on 2020-09-14 09:10:34 UTC using RuboCop version 0.90.0.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 1
10
+ # Configuration parameters: Include.
11
+ # Include: **/*.gemspec
12
+ Gemspec/RequiredRubyVersion:
13
+ Exclude:
14
+ - 'iiulia-rb.gemspec'
15
+
16
+ # Offense count: 1
17
+ # Configuration parameters: MinBodyLength.
18
+ Style/GuardClause:
19
+ Exclude:
20
+ - 'iiulia-rb.gemspec'
@@ -4,5 +4,10 @@ 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
+ ## [0.2.0] - 2020-09-14
8
+ Changes:
9
+ * Moved `lib/schemas` to the git submodule `github.com/nalgeon/iuliia`
10
+ * Lazy loading for schemas
11
+
7
12
  ## [0.1.0] - 2020-04-30
8
13
  ### Initial release
data/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  Small gem to properly transliterate cyrillic to latin. Use https://github.com/nalgeon/iuliia for transliteration schemas.
4
4
 
5
+ ![Ruby](https://github.com/adnikiforov/iuliia-rb/workflows/Ruby/badge.svg)
6
+
5
7
  ## Installation
6
8
 
7
9
  Add this line to your application's Gemfile:
@@ -65,9 +67,9 @@ Iuliia.translit('Юлия, съешь ещё этих мягких францу
65
67
 
66
68
  ## TODO
67
69
 
68
- * Add documentation
70
+ * ~~Add documentation~~
69
71
  * Maybe some more specs
70
- * Implement reverse translit (not available for all schemas though)
72
+ * Implement reverse translit (not available for all schemas though): https://github.com/adnikiforov/iuliia-rb/issues/3
71
73
 
72
74
  ## Development
73
75
 
@@ -77,4 +79,4 @@ To install this gem onto your local machine, run `bundle exec rake install`.
77
79
 
78
80
  ## License
79
81
 
80
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
82
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'bundler/gem_tasks'
2
4
  require 'rspec/core/rake_task'
3
5
 
@@ -17,11 +17,9 @@ Gem::Specification.new do |spec|
17
17
  # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
18
  # to allow pushing to a single host or delete this section to allow pushing to any host.
19
19
  if spec.respond_to?(:metadata)
20
- # spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
21
-
22
- # spec.metadata['homepage_uri'] = spec.homepage
23
- # spec.metadata['source_code_uri'] = "TODO: Put your gem's public repo URL here."
24
- # spec.metadata['changelog_uri'] = "TODO: Put your gem's CHANGELOG.md URL here."
20
+ spec.metadata['homepage_uri'] = spec.homepage
21
+ spec.metadata['source_code_uri'] = 'https://github.com/adnikiforov/iuliia-rb'
22
+ spec.metadata['changelog_uri'] = 'https://github.com/adnikiforov/iuliia-rb/blob/master/CHANGELOG.md'
25
23
  else
26
24
  raise 'RubyGems 2.0 or newer is required to protect against public gem pushes.'
27
25
  end
@@ -38,6 +36,7 @@ Gem::Specification.new do |spec|
38
36
  spec.add_development_dependency 'bundler'
39
37
  spec.add_development_dependency 'rake'
40
38
  spec.add_development_dependency 'rspec'
39
+ spec.add_development_dependency 'rubocop'
41
40
 
42
41
  spec.add_dependency 'json'
43
42
  end
@@ -1,9 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Iuliia
4
- module_function
4
+ class << self
5
5
 
6
- def translit(string, schema:)
7
- Iuliia::Translit.new(string, schema).translit
6
+ # Translit cyrillic string to latin representation
7
+ # @param string [String]
8
+ # @param schema [Iuliia::Schema]
9
+ # @return [String]
10
+ def translit(string, schema:)
11
+ Iuliia::Translit.new(string, schema).translit
12
+ end
8
13
  end
9
14
  end
@@ -2,52 +2,39 @@
2
2
 
3
3
  module Iuliia
4
4
  module Schema
5
- extend self
6
-
7
- SCHEMA = Struct.new(
8
- :description,
9
- :url,
10
- :mapping,
11
- :prev_mapping,
12
- :next_mapping,
13
- :ending_mapping
14
- )
15
-
16
- def schema(schema_name)
17
- schemas[schema_name]
18
- end
5
+ class << self
19
6
 
20
- def available_schemas
21
- schemas.map do |schema_name, schema|
22
- [schema_name, schema.description]
7
+ # Fetch schema by schema name
8
+ # @param schema_name [String]
9
+ # @return [Iuliia::Schema]
10
+ def [](schema_name)
11
+ schemas[schema_name]
23
12
  end
24
- end
25
13
 
26
- private
14
+ alias schema []
27
15
 
28
- def schemas
29
- @schemas ||= load_schemas
30
- end
16
+ # Return list of available schemas
17
+ # @return [Array<Iuliia::Schema]>]
18
+ def available_schemas
19
+ load_schemas.transform_values(&:description).to_a
20
+ end
31
21
 
32
- def load_schemas
33
- Dir['lib/schemas/*.json'].map do |schema_file|
34
- file = File.read(schema_file)
35
- parse_and_create_schema(file)
36
- end.reduce({}, :update)
37
- end
22
+ private
38
23
 
39
- def parse_and_create_schema(file)
40
- parsed_data = JSON.parse(file)
41
- schema = SCHEMA.new(
42
- parsed_data['description'],
43
- parsed_data['url'],
44
- parsed_data['mapping'],
45
- parsed_data['prev_mapping'],
46
- parsed_data['next_mapping'],
47
- parsed_data['ending_mapping']
48
- )
49
-
50
- { parsed_data['name'] => schema }
24
+ def schemas
25
+ @schemas ||= Hash.new { |h, k| h[k] = load_schema(k) }
26
+ end
27
+
28
+ def load_schema(name)
29
+ JSON.parse(File.read("lib/schemas/#{name}.json"), object_class: OpenStruct, symbolize_names: true)
30
+ end
31
+
32
+ def load_schemas
33
+ Dir['lib/schemas/*.json'].map do |file|
34
+ schema = load_schema(File.basename(file, '.json'))
35
+ [schema.name, schema]
36
+ end.to_h
37
+ end
51
38
  end
52
39
  end
53
40
  end
@@ -4,11 +4,17 @@ module Iuliia
4
4
  class Translit
5
5
  ENDING_LENGTH = 2
6
6
 
7
+ # Initialize transliterator engine with string and schema
8
+ # @param string [String]
9
+ # @param schema [Iuliia::Schema]
10
+ # @return [Iuliia::Translit]
7
11
  def initialize(string, schema)
8
12
  @string = string
9
13
  @schema = Iuliia::Schema.schema(schema)
10
14
  end
11
15
 
16
+ # Translit cyrillic string to latin representation
17
+ # @return [String]
12
18
  def translit
13
19
  string.split(/\b/).map { |chunk| translit_chunk(chunk) }.join
14
20
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Iuliia
4
- VERSION = '0.1.0'.freeze
4
+ VERSION = '0.2.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iuliia-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrey Nikiforov
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-04-30 00:00:00.000000000 Z
11
+ date: 2020-09-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubocop
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: json
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -66,24 +80,22 @@ dependencies:
66
80
  - - ">="
67
81
  - !ruby/object:Gem::Version
68
82
  version: '0'
69
- description:
83
+ description:
70
84
  email:
71
85
  - a.d.nikiforov@gmail.com
72
86
  executables: []
73
87
  extensions: []
74
88
  extra_rdoc_files: []
75
89
  files:
90
+ - ".github/workflows/spec.yml"
76
91
  - ".gitignore"
77
- - ".idea/iiulia-rb.iml"
78
- - ".idea/misc.xml"
79
- - ".idea/modules.xml"
80
- - ".idea/workspace.xml"
92
+ - ".gitmodules"
81
93
  - ".rspec"
94
+ - ".rubocop.yml"
95
+ - ".rubocop_todo.yml"
82
96
  - ".travis.yml"
83
97
  - CHANGELOG.md
84
- - CODE_OF_CONDUCT.md
85
98
  - Gemfile
86
- - Gemfile.lock
87
99
  - LICENSE.txt
88
100
  - README.md
89
101
  - Rakefile
@@ -95,40 +107,14 @@ files:
95
107
  - lib/iuliia/schema.rb
96
108
  - lib/iuliia/translit.rb
97
109
  - lib/iuliia/version.rb
98
- - lib/schemas/LICENSE
99
- - lib/schemas/README.md
100
- - lib/schemas/ala_lc.json
101
- - lib/schemas/ala_lc_alt.json
102
- - lib/schemas/bgn_pcgn.json
103
- - lib/schemas/bgn_pcgn_alt.json
104
- - lib/schemas/bs_2979.json
105
- - lib/schemas/bs_2979_alt.json
106
- - lib/schemas/gost_16876.json
107
- - lib/schemas/gost_16876_alt.json
108
- - lib/schemas/gost_52290.json
109
- - lib/schemas/gost_52535.json
110
- - lib/schemas/gost_7034.json
111
- - lib/schemas/gost_779.json
112
- - lib/schemas/gost_779_alt.json
113
- - lib/schemas/icao_doc_9303.json
114
- - lib/schemas/iso_9_1954.json
115
- - lib/schemas/iso_9_1968.json
116
- - lib/schemas/iso_9_1968_alt.json
117
- - lib/schemas/mosmetro.json
118
- - lib/schemas/mvd_310.json
119
- - lib/schemas/mvd_310_fr.json
120
- - lib/schemas/mvd_782.json
121
- - lib/schemas/scientific.json
122
- - lib/schemas/telegram.json
123
- - lib/schemas/ungegn_1987.json
124
- - lib/schemas/wikipedia.json
125
- - lib/schemas/yandex_maps.json
126
- - lib/schemas/yandex_money.json
127
110
  homepage: https://github.com/adnikiforov/iuliia-rb
128
111
  licenses:
129
112
  - MIT
130
- metadata: {}
131
- post_install_message:
113
+ metadata:
114
+ homepage_uri: https://github.com/adnikiforov/iuliia-rb
115
+ source_code_uri: https://github.com/adnikiforov/iuliia-rb
116
+ changelog_uri: https://github.com/adnikiforov/iuliia-rb/blob/master/CHANGELOG.md
117
+ post_install_message:
132
118
  rdoc_options: []
133
119
  require_paths:
134
120
  - lib
@@ -143,8 +129,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
143
129
  - !ruby/object:Gem::Version
144
130
  version: '0'
145
131
  requirements: []
146
- rubygems_version: 3.1.2
147
- signing_key:
132
+ rubygems_version: 3.1.4
133
+ signing_key:
148
134
  specification_version: 4
149
135
  summary: Russian transliteration using nalgeon/iuliia schemas
150
136
  test_files: []
@@ -1,19 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <module type="RUBY_MODULE" version="4">
3
- <component name="ModuleRunConfigurationManager">
4
- <shared />
5
- </component>
6
- <component name="NewModuleRootManager">
7
- <content url="file://$MODULE_DIR$" />
8
- <orderEntry type="jdk" jdkName="RVM: ruby-2.6.6" jdkType="RUBY_SDK" />
9
- <orderEntry type="sourceFolder" forTests="false" />
10
- <orderEntry type="library" scope="PROVIDED" name="bundler (v1.17.3, RVM: ruby-2.6.6) [gem]" level="application" />
11
- <orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.3, RVM: ruby-2.6.6) [gem]" level="application" />
12
- <orderEntry type="library" scope="PROVIDED" name="json (v2.3.0, RVM: ruby-2.6.6) [gem]" level="application" />
13
- <orderEntry type="library" scope="PROVIDED" name="rake (v12.3.3, RVM: ruby-2.6.6) [gem]" level="application" />
14
- <orderEntry type="library" scope="PROVIDED" name="rspec-core (v3.9.1, RVM: ruby-2.6.6) [gem]" level="application" />
15
- <orderEntry type="library" scope="PROVIDED" name="rspec-expectations (v3.9.1, RVM: ruby-2.6.6) [gem]" level="application" />
16
- <orderEntry type="library" scope="PROVIDED" name="rspec-mocks (v3.9.1, RVM: ruby-2.6.6) [gem]" level="application" />
17
- <orderEntry type="library" scope="PROVIDED" name="rspec-support (v3.9.2, RVM: ruby-2.6.6) [gem]" level="application" />
18
- </component>
19
- </module>
@@ -1,7 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="JavaScriptSettings">
4
- <option name="languageLevel" value="ES6" />
5
- </component>
6
- <component name="ProjectRootManager" version="2" project-jdk-name="RVM: ruby-2.4.5 [global]" project-jdk-type="RUBY_SDK" />
7
- </project>
@@ -1,8 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="ProjectModuleManager">
4
- <modules>
5
- <module fileurl="file://$PROJECT_DIR$/.idea/iiulia-rb.iml" filepath="$PROJECT_DIR$/.idea/iiulia-rb.iml" />
6
- </modules>
7
- </component>
8
- </project>
@@ -1,4 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="ProjectId" id="1bEGnmEDYzBnl6qIoQ8XtjqEJc9" />
4
- </project>