unicode-version 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 776e55f85f2be081d35917ed4d35e5c273a51bab40c7bf57002cf62f830f4b93
4
+ data.tar.gz: bff45459eaaab89965ed235ee54903c7b52acd193e5e7115ab348a6e2a161817
5
+ SHA512:
6
+ metadata.gz: 67a6dd320cfb2c5deb90baa6dedb7eb24daad2a3200e4309c2d91040254758e775e868b408bf2cba24d1274242f09039861527d2b23280a9e82caebebe44128f
7
+ data.tar.gz: '086d8c0586215382dc57f51f6801df0509dc761dfc48866912d51a21fe7f6f8aebc390a96869ac7e5d2db8640104c5f70fbc24e601a4fc164bf16d3452a01dd5'
@@ -0,0 +1,2 @@
1
+ Gemfile.lock
2
+ /pkg
@@ -0,0 +1,21 @@
1
+ sudo: false
2
+ language: ruby
3
+
4
+ rvm:
5
+ - 2.7
6
+ - 2.6
7
+ - 2.5
8
+ - 2.4
9
+ - 2.3
10
+ - 2.2
11
+ - 2.1
12
+ - 2.0
13
+ - ruby-head
14
+ - jruby-9.2.9.0
15
+ - truffleruby
16
+
17
+ matrix:
18
+ allow_failures:
19
+ - rvm: jruby-2.9.2.0
20
+ - rvm: truffleruby
21
+ # fast_finish: true
@@ -0,0 +1,6 @@
1
+ ## CHANGELOG
2
+
3
+ ### 1.0.0
4
+
5
+ * Initial release
6
+
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at opensource@janlelis.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ gem "minitest"
6
+ gem "rake"
7
+ gem "irb"
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2020 Jan Lelis, hi@ruby.consulting
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,39 @@
1
+ # unicode-version [![[version]](https://badge.fury.io/rb/unicode-version.svg)](https://badge.fury.io/rb/unicode-version) [![[travis]](https://travis-ci.org/janlelis/unicode-version.svg)](https://travis-ci.org/janlelis/unicode-version)
2
+
3
+ Makes it easy to check for Unicode and Emoji support of your current Ruby (and older Rubies)
4
+
5
+ ## Setup
6
+
7
+ Add to your `Gemfile`:
8
+
9
+ ```ruby
10
+ gem "unicode-version"
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ```ruby
16
+ # Returns current Unicode version (example with Ruby 2.7.0)
17
+ Unicode::Version.unicode_version # => 12.1
18
+
19
+ # Returns Unicode version of older Rubies
20
+ Unicode::Version.unicode_version "2.6.2" # => 12.0.0
21
+ Unicode::Version.unicode_version 1.9 # => 5.2.0
22
+
23
+ # Returns nil when Ruby version too old (before 1.9)
24
+ Unicode::Version.unicode_version 1.8 # => nil
25
+
26
+ # Returns current Emoji version (example with Ruby 2.7.0)
27
+ Unicode::Version.emoji_version # => 12.1
28
+
29
+ # Returns Emoji version of older Rubies
30
+ Unicode::Version.emoji_version "2.6.2" # => 12.0
31
+ Unicode::Version.emoji_version 2.5 # => 5.0
32
+
33
+ # Returns nil when Ruby version too old (before 2.5)
34
+ Unicode::Version.emoji_version 2.4 # => nil
35
+ ```
36
+
37
+ ## MIT License
38
+
39
+ Copyright (C) 2020 Jan Lelis <https://janlelis.com>. Released under the MIT license.
@@ -0,0 +1,38 @@
1
+ # # #
2
+ # Get gemspec info
3
+
4
+ gemspec_file = Dir["*.gemspec"].first
5
+ gemspec = eval File.read(gemspec_file), binding, gemspec_file
6
+ info = "#{gemspec.name} | #{gemspec.version} | " \
7
+ "#{gemspec.runtime_dependencies.size} dependencies | " \
8
+ "#{gemspec.files.size} files"
9
+
10
+ # # #
11
+ # Gem build and install task
12
+
13
+ desc info
14
+ task :gem do
15
+ puts info + "\n\n"
16
+ print " "; sh "gem build #{gemspec_file}"
17
+ FileUtils.mkdir_p "pkg"
18
+ FileUtils.mv "#{gemspec.name}-#{gemspec.version}.gem", "pkg"
19
+ puts; sh %{gem install --no-document pkg/#{gemspec.name}-#{gemspec.version}.gem}
20
+ end
21
+
22
+ # # #
23
+ # Start an IRB session with the gem loaded
24
+
25
+ desc "#{gemspec.name} | IRB"
26
+ task :irb do
27
+ sh "irb -I ./lib -r #{gemspec.name.gsub '-','/'}"
28
+ end
29
+
30
+ # # #
31
+ # Run specs
32
+
33
+ desc "#{gemspec.name} | Spec"
34
+ task :spec do
35
+ sh "for file in spec/*_spec.rb; do ruby $file; done"
36
+ end
37
+ task default: :spec
38
+
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "version/version"
4
+
5
+ module Unicode
6
+ module Version
7
+ RB_CONFIG_UNICODE_AVAILABLE = "2.4.0"
8
+ RB_CONFIG_EMOJI_AVAILABLE = "2.6.0"
9
+
10
+ RUBY_UNICODE_VERSIONS = {
11
+ 2.7 => "12.1.0",
12
+ 2.6 => "12.1.0",
13
+ "2.6.2" => "12.0.0",
14
+ "2.6.1" => "11.0.0",
15
+ "2.6.0" => "11.0.0",
16
+ 2.5 => "10.0.0",
17
+ 2.4 => "9.0.0",
18
+ 2.3 => "8.0.0",
19
+ 2.2 => "7.0.0",
20
+ 2.1 => "6.1.0",
21
+ 2.0 => "6.1.0",
22
+ 1.9 => "5.2.0",
23
+ }.freeze
24
+
25
+ RUBY_EMOJI_VERSIONS = {
26
+ 2.7 => "12.1",
27
+ 2.6 => "12.0",
28
+ "2.6.1" => "11.0",
29
+ "2.6.0" => "11.0",
30
+ 2.5 => "5.0",
31
+ }.freeze
32
+
33
+ def self.unicode_version(ruby_version = RUBY_VERSION)
34
+ if ruby_version == RUBY_VERSION && ruby_version >= RB_CONFIG_UNICODE_AVAILABLE
35
+ RbConfig::CONFIG["UNICODE_VERSION"]
36
+ else
37
+ RUBY_UNICODE_VERSIONS[ruby_version] || RUBY_UNICODE_VERSIONS[ruby_version.to_f]
38
+ end
39
+ end
40
+
41
+ def self.emoji_version(ruby_version = RUBY_VERSION)
42
+ if ruby_version == RUBY_VERSION && ruby_version >= RB_CONFIG_EMOJI_AVAILABLE
43
+ RbConfig::CONFIG["UNICODE_EMOJI_VERSION"]
44
+ else
45
+ RUBY_EMOJI_VERSIONS[ruby_version] || RUBY_EMOJI_VERSIONS[ruby_version.to_f]
46
+ end
47
+ end
48
+ end
49
+ end
50
+
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Unicode
4
+ module Version
5
+ VERSION = "1.0.0"
6
+ end
7
+ end
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../lib/unicode/version"
4
+ require "minitest/autorun"
5
+
6
+ describe Unicode::Version do
7
+ describe ".unicode_version" do
8
+ it "returns current Ruby's Unicode version when no Ruby version given" do
9
+ RUBY_VERSION, original_ruby_version = "2.0.0", RUBY_VERSION
10
+
11
+ assert_equal "6.1.0", Unicode::Version.unicode_version
12
+
13
+ RUBY_VERSION = original_ruby_version
14
+ end
15
+
16
+ it "returns Unicode version of given Ruby" do
17
+ assert_equal "12.0.0", Unicode::Version.unicode_version("2.6.2")
18
+ assert_equal "5.2.0", Unicode::Version.unicode_version(1.9)
19
+ end
20
+
21
+ it "returns nil when Ruby version too old" do
22
+ assert_equal nil, Unicode::Version.unicode_version(1.8)
23
+ end
24
+ end
25
+
26
+ describe ".emoji_version" do
27
+ it "returns current Ruby's Emoji version when no Ruby version given" do
28
+ RUBY_VERSION, original_ruby_version = "2.7.0", RUBY_VERSION
29
+
30
+ assert_equal "12.1", Unicode::Version.emoji_version
31
+
32
+ RUBY_VERSION = original_ruby_version
33
+ end
34
+
35
+ it "returns Emoji version of given Ruby" do
36
+ assert_equal "12.0", Unicode::Version.emoji_version("2.6.2")
37
+ assert_equal "5.0", Unicode::Version.emoji_version(2.5)
38
+ end
39
+
40
+ it "returns nil when Ruby version too old" do
41
+ assert_equal nil, Unicode::Version.emoji_version(2.4)
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require File.dirname(__FILE__) + "/lib/unicode/version/version"
4
+
5
+ Gem::Specification.new do |gem|
6
+ gem.name = "unicode-version"
7
+ gem.version = Unicode::Version::VERSION
8
+ gem.summary = "Ruby / Unicode / Emoji versions mapping"
9
+ gem.description = "Returns Unicode / Emoji versions of current and previous Rubies"
10
+ gem.authors = ["Jan Lelis"]
11
+ gem.email = ["hi@ruby.consulting"]
12
+ gem.homepage = "https://github.com/janlelis/unicode-version"
13
+ gem.license = "MIT"
14
+
15
+ gem.files = Dir["{**/}{.*,*}"].select{ |path| File.file?(path) && path !~ /^pkg/ }
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.required_ruby_version = ">= 2.0"
21
+ end
metadata ADDED
@@ -0,0 +1,57 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: unicode-version
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Jan Lelis
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-02-02 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Returns Unicode / Emoji versions of current and previous Rubies
14
+ email:
15
+ - hi@ruby.consulting
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - ".gitignore"
21
+ - ".travis.yml"
22
+ - CHANGELOG.md
23
+ - CODE_OF_CONDUCT.md
24
+ - Gemfile
25
+ - Gemfile.lock
26
+ - MIT-LICENSE.txt
27
+ - README.md
28
+ - Rakefile
29
+ - lib/unicode/version.rb
30
+ - lib/unicode/version/version.rb
31
+ - spec/unicode_version_spec.rb
32
+ - unicode-version.gemspec
33
+ homepage: https://github.com/janlelis/unicode-version
34
+ licenses:
35
+ - MIT
36
+ metadata: {}
37
+ post_install_message:
38
+ rdoc_options: []
39
+ require_paths:
40
+ - lib
41
+ required_ruby_version: !ruby/object:Gem::Requirement
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: '2.0'
46
+ required_rubygems_version: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: '0'
51
+ requirements: []
52
+ rubygems_version: 3.1.2
53
+ signing_key:
54
+ specification_version: 4
55
+ summary: Ruby / Unicode / Emoji versions mapping
56
+ test_files:
57
+ - spec/unicode_version_spec.rb