rfc5646 0.1.0 → 0.1.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
  SHA1:
3
- metadata.gz: 5c9bbddf7f5096f5e98ffcc4b999c3abe580fd80
4
- data.tar.gz: 868ddc35a4dc5528fdf15ab9f696b7e69e2455c8
3
+ metadata.gz: 6864463ae74c628f96e944fdd49fd428899d5c85
4
+ data.tar.gz: 980e25fd41dfda98acafef65bbdb539187752e9c
5
5
  SHA512:
6
- metadata.gz: ebde845ba1a46ed1469b113f002f649833da81163a6e1aa45b0d6eefccf15f2a2115a11e2fb935729989db88b1c110edf8ef81d63f74303d0c4c1f70e472d1dc
7
- data.tar.gz: 5a1698cf6cb22b2f7a7391aa759cb631d0a6108f0eafc7d5856bd1f928172c804ee0997c1086cb31bafdc31e82153e1581d6fb8c1209b00493328d69346e3be9
6
+ metadata.gz: f4957a4bf34ab5202e6ac8a33d73c16d20bda210a02877f9949be32099b384e7ae2ecaf2cd1f718ed6cd46c279fea8b743ec37503ff5501c2d2083aab5a72520
7
+ data.tar.gz: 357b11719ef66de7cfcb43cae76d7b84be858e58f81a2151f0ba21a92d73e819b79b143de0dc5f9b01bb79fab6b03ea0316fd94c278e8ada60dc98b1efbfa6ea
data/.gitignore CHANGED
@@ -7,3 +7,4 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
+ /spec/examples.txt
@@ -10,4 +10,4 @@ matrix:
10
10
  before_install: gem install bundler -v 1.10.6
11
11
  script:
12
12
  - bundle exec rake spec
13
- - bundle exec rubocop
13
+ - bundle exec rubocop --fail-level C
@@ -0,0 +1,4 @@
1
+ 0.1.1
2
+
3
+ * **Fix** localization loading
4
+ * Allow to pass nil into Locale.from_rfc5646 methodq
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
- # Rfc5646
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 == Rfc5646::Locale.from_rfc5646(params[: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
@@ -1,4 +1,8 @@
1
1
  module Rfc5646
2
2
  require 'rfc5646/version'
3
3
  require 'rfc5646/locale'
4
+ require 'i18n'
5
+
6
+ locales = Pathname.new(__FILE__).dirname.join('data', 'locales', 'locales.en.yml').to_s
7
+ I18n.backend.load_translations(locales)
4
8
  end
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Rfc5646
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
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.0
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-14 00:00:00.000000000 Z
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
- - config/locales/locales.en.yml
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
@@ -1,4 +0,0 @@
1
- module Rfc5646
2
- class Engine
3
- end
4
- end