unicode_range 1.0.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 5f447b852ac6d4823b5ba19dde7eb4df84b782942f40553287da349fd016632a
4
+ data.tar.gz: 6af4f94af8b34bf4b2311417f93c3aff45b5cf080b015e53fdf370017a3cd84c
5
+ SHA512:
6
+ metadata.gz: dfb6f36021d1176deb7d8eac64b1895d1652af3254d830203e682723e0b6d15d8f9beed722265137e367d37841dc338ed66a965b372dcd1f5e2171ddad37197d
7
+ data.tar.gz: 145503e6ccf15cc53d7ec8fefe4a7ebdc5e8023a227bb355d35128d9fc0a8b418160ec0d3f26c7465dca821128cf23cbae1f1088466103f1d60834c3480de6ce
@@ -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
@@ -0,0 +1,4 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.5.1
@@ -0,0 +1,5 @@
1
+ # Changelog
2
+
3
+ ## 1.0.0
4
+
5
+ 2018.06.17
data/Gemfile ADDED
@@ -0,0 +1,13 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in unicode_range.gemspec
6
+ gemspec
7
+
8
+ group :development do
9
+ gem "pry"
10
+ gem "bundler"
11
+ gem "rake"
12
+ gem "rspec", "~> 3.7"
13
+ end
@@ -0,0 +1,41 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ unicode_range (1.0.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ coderay (1.1.2)
10
+ diff-lcs (1.3)
11
+ method_source (0.9.0)
12
+ pry (0.11.3)
13
+ coderay (~> 1.1.0)
14
+ method_source (~> 0.9.0)
15
+ rake (10.5.0)
16
+ rspec (3.7.0)
17
+ rspec-core (~> 3.7.0)
18
+ rspec-expectations (~> 3.7.0)
19
+ rspec-mocks (~> 3.7.0)
20
+ rspec-core (3.7.1)
21
+ rspec-support (~> 3.7.0)
22
+ rspec-expectations (3.7.0)
23
+ diff-lcs (>= 1.2.0, < 2.0)
24
+ rspec-support (~> 3.7.0)
25
+ rspec-mocks (3.7.0)
26
+ diff-lcs (>= 1.2.0, < 2.0)
27
+ rspec-support (~> 3.7.0)
28
+ rspec-support (3.7.1)
29
+
30
+ PLATFORMS
31
+ ruby
32
+
33
+ DEPENDENCIES
34
+ bundler
35
+ pry
36
+ rake
37
+ rspec (~> 3.7)
38
+ unicode_range!
39
+
40
+ BUNDLED WITH
41
+ 1.16.2
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Juanito Fatas
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.
@@ -0,0 +1,48 @@
1
+ # UnicodeRange
2
+
3
+ Get unicodes by range and exclude reserved words.
4
+
5
+ ```ruby
6
+ unicode_range = UnicodeRange.new(from: "FF10", to: "FF19")
7
+
8
+ unicode_range.expand
9
+ => [65296, 65297, 65298, 65299, 65300, 65301, 65302, 65303, 65304, 65305]
10
+
11
+ unicode_range.expand.to_s
12
+ => "0123456789"
13
+
14
+ reserved_words = %w(FF3B FF3C FF3D FF3E FF3F FF40)
15
+ UnicodeRange.new(from: "FF21", to: "FF5A").expand(except: reserved_words).to_s
16
+ => "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
17
+ ```
18
+
19
+ ## Installation
20
+
21
+ Add this line to your application's Gemfile:
22
+
23
+ ```ruby
24
+ gem "unicode_range"
25
+ ```
26
+
27
+ And then execute:
28
+
29
+ $ bundle
30
+
31
+ Or install it yourself as:
32
+
33
+ $ gem install unicode_range
34
+
35
+
36
+ ## Development
37
+
38
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/hack` for an interactive prompt that will allow you to experiment.
39
+
40
+ 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).
41
+
42
+ ## Contributing
43
+
44
+ Bug reports and pull requests are welcome on GitHub at https://github.com/JuanitoFatas/unicode_range.
45
+
46
+ ## License
47
+
48
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -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
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "unicode_range"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ require "pry"
10
+ Pry.start
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$"\n\t"
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,31 @@
1
+ require "unicode_range/version"
2
+ require "unicode_range/collection"
3
+
4
+ class UnicodeRange
5
+ def initialize(from:, to:)
6
+ @from = from.to_i(16)
7
+ @to = to.to_i(16)
8
+ end
9
+
10
+ def expand(except: [])
11
+ Collection.new codepoints(except)
12
+ end
13
+
14
+ private
15
+
16
+ attr_reader :from, :to
17
+
18
+ def codepoints(except)
19
+ [*from..to].select do |codepoint|
20
+ not except.any? { |exclude| casecmp(to_hex(codepoint), exclude) }
21
+ end
22
+ end
23
+
24
+ def to_hex(int)
25
+ int.to_s(16)
26
+ end
27
+
28
+ def casecmp(x, y)
29
+ x.casecmp(y) == 0
30
+ end
31
+ end
@@ -0,0 +1,23 @@
1
+ class UnicodeRange
2
+ class Collection
3
+ def initialize(decimals)
4
+ @decimals = decimals
5
+ end
6
+
7
+ def to_a
8
+ decimals
9
+ end
10
+
11
+ def to_s
12
+ decimals.pack("U*")
13
+ end
14
+
15
+ def inspect
16
+ decimals
17
+ end
18
+
19
+ private
20
+
21
+ attr_reader :decimals
22
+ end
23
+ end
@@ -0,0 +1,3 @@
1
+ class UnicodeRange
2
+ VERSION = "1.0.0"
3
+ end
@@ -0,0 +1,25 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "unicode_range/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "unicode_range"
8
+ spec.version = UnicodeRange::VERSION
9
+ spec.authors = ["Juanito Fatas"]
10
+ spec.email = ["juanito.fatas@shopify.com"]
11
+
12
+ spec.summary = %q{Get unicodes given range}
13
+ spec.description = spec.summary
14
+ spec.homepage = "https://github.com/juanitofatas/unicode_range"
15
+ spec.license = "MIT"
16
+
17
+ # Specify which files should be added to the gem when it is released.
18
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
19
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
20
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
21
+ end
22
+ spec.bindir = "exe"
23
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
+ spec.require_paths = ["lib"]
25
+ end
metadata ADDED
@@ -0,0 +1,59 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: unicode_range
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Juanito Fatas
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-06-17 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Get unicodes given range
14
+ email:
15
+ - juanito.fatas@shopify.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - ".gitignore"
21
+ - ".rspec"
22
+ - ".travis.yml"
23
+ - CHANGELOG.md
24
+ - Gemfile
25
+ - Gemfile.lock
26
+ - LICENSE.txt
27
+ - README.md
28
+ - Rakefile
29
+ - bin/hack
30
+ - bin/setup
31
+ - lib/unicode_range.rb
32
+ - lib/unicode_range/collection.rb
33
+ - lib/unicode_range/version.rb
34
+ - unicode_range.gemspec
35
+ homepage: https://github.com/juanitofatas/unicode_range
36
+ licenses:
37
+ - MIT
38
+ metadata: {}
39
+ post_install_message:
40
+ rdoc_options: []
41
+ require_paths:
42
+ - lib
43
+ required_ruby_version: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ required_rubygems_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ requirements: []
54
+ rubyforge_project:
55
+ rubygems_version: 2.7.3
56
+ signing_key:
57
+ specification_version: 4
58
+ summary: Get unicodes given range
59
+ test_files: []