rfc5646 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +1 -1
- data/CHANGELOG.md +4 -0
- data/README.md +5 -3
- data/{config → lib/data}/locales/locales.en.yml +0 -0
- data/lib/rfc5646.rb +4 -0
- data/lib/rfc5646/locale.rb +2 -5
- data/lib/rfc5646/version.rb +1 -1
- metadata +4 -4
- data/lib/rfc5646/engine.rb +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6864463ae74c628f96e944fdd49fd428899d5c85
|
4
|
+
data.tar.gz: 980e25fd41dfda98acafef65bbdb539187752e9c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f4957a4bf34ab5202e6ac8a33d73c16d20bda210a02877f9949be32099b384e7ae2ecaf2cd1f718ed6cd46c279fea8b743ec37503ff5501c2d2083aab5a72520
|
7
|
+
data.tar.gz: 357b11719ef66de7cfcb43cae76d7b84be858e58f81a2151f0ba21a92d73e819b79b143de0dc5f9b01bb79fab6b03ea0316fd94c278e8ada60dc98b1efbfa6ea
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/CHANGELOG.md
ADDED
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
|
-
|
1
|
+
[![Build Status](https://travis-ci.org/SPBTV/rfc5646.svg)](https://travis-ci.org/SPBTV/rfc5646)
|
2
|
+
[![Gem Version](https://badge.fury.io/rb/rfc5646.svg)](https://badge.fury.io/rb/rfc5646)
|
2
3
|
|
4
|
+
# Rfc5646
|
3
5
|
|
4
6
|
Parse [RFC 5646](http://tools.ietf.org/html/rfc5646) locales.
|
5
7
|
This code extracted from [shuttle](https://github.com/square/shuttle) codebase.
|
@@ -21,7 +23,7 @@ Or install it yourself as:
|
|
21
23
|
## Usage
|
22
24
|
|
23
25
|
```ruby
|
24
|
-
locale
|
26
|
+
locale = Rfc5646::Locale.from_rfc5646(params[:locale])
|
25
27
|
```
|
26
28
|
|
27
29
|
The ISO 639 code for the base language (e.g., "de" for German).
|
@@ -75,7 +77,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
75
77
|
|
76
78
|
## Contributing
|
77
79
|
|
78
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/SPBTV/rfc5646. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
|
80
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/SPBTV/rfc5646. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org/) code of conduct.
|
79
81
|
|
80
82
|
|
81
83
|
## License
|
File without changes
|
data/lib/rfc5646.rb
CHANGED
data/lib/rfc5646/locale.rb
CHANGED
@@ -2,8 +2,6 @@ require 'active_support/core_ext/object/try'
|
|
2
2
|
require 'active_support/core_ext/object/blank'
|
3
3
|
require 'i18n'
|
4
4
|
|
5
|
-
I18n.backend.load_translations('config/locales/locales.en.yml')
|
6
|
-
|
7
5
|
module Rfc5646
|
8
6
|
# Represents a locale that can be localized to. Locales are identified by
|
9
7
|
# their RFC 5646 code, which can be as simple as just a language (e.g., "en" for
|
@@ -64,11 +62,10 @@ module Rfc5646
|
|
64
62
|
class << self
|
65
63
|
# Generates a new instance from an RFC 5646 code.
|
66
64
|
#
|
67
|
-
# @param [String] ident The RFC 5646 code for the locale.
|
65
|
+
# @param [String, nil] ident The RFC 5646 code for the locale.
|
68
66
|
# @return [Locale] The instance representing that locale.
|
69
|
-
|
70
67
|
def from_rfc5646(ident)
|
71
|
-
ident = ident.tr('_', '-')
|
68
|
+
ident = String(ident).tr('_', '-')
|
72
69
|
return nil unless (matches = RFC5646_FORMAT.match(ident))
|
73
70
|
attrs = RFC5646_FORMAT.named_captures.each_with_object({}) do |(name, offsets), hsh|
|
74
71
|
hsh[name] = offsets.map { |offset| matches[offset] }.compact
|
data/lib/rfc5646/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rfc5646
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Artyom Bolshakov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -105,6 +105,7 @@ files:
|
|
105
105
|
- ".rspec"
|
106
106
|
- ".rubocop.yml"
|
107
107
|
- ".travis.yml"
|
108
|
+
- CHANGELOG.md
|
108
109
|
- CODE_OF_CONDUCT.md
|
109
110
|
- Gemfile
|
110
111
|
- LICENSE.txt
|
@@ -112,9 +113,8 @@ files:
|
|
112
113
|
- Rakefile
|
113
114
|
- bin/console
|
114
115
|
- bin/setup
|
115
|
-
-
|
116
|
+
- lib/data/locales/locales.en.yml
|
116
117
|
- lib/rfc5646.rb
|
117
|
-
- lib/rfc5646/engine.rb
|
118
118
|
- lib/rfc5646/locale.rb
|
119
119
|
- lib/rfc5646/version.rb
|
120
120
|
- rfc5646.gemspec
|
data/lib/rfc5646/engine.rb
DELETED