roda-i18n 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 61da5676e50ba7ef694e025bfd717c279c0dfe01
4
- data.tar.gz: 57e1b41f3d7856e464e51542fa9c6172f6fe93bc
3
+ metadata.gz: 7c49e1ba809caf572d5d75f55cbe48bedf855f80
4
+ data.tar.gz: eb86ad5e8c25b9c152ae1a4c56d7cbcfac084f46
5
5
  SHA512:
6
- metadata.gz: 741426239b80ef746c01ba0e3551855af218b12412147d8117da8a2524eba80502b7c934bca41ae1ad6cbbeaa2f1375581c08f639fe233776dbf69a397227437
7
- data.tar.gz: 931482a0bbd46455887a2f67affc4a93c13329db1acf73c723e386f3cdf29aaecbe4f340cbcabee2ea4f2bdd8f83fc3f22243714eb4734966d602067befe3f17
6
+ metadata.gz: 5d31eee8bb80bc0e147e8b94901c1be53b32c6684eb9471156e4841e3f6cbeff8234e3258f569093e26fa3276606d4d99eecbfd7d3656f7f91fa45c75ea20038
7
+ data.tar.gz: d9351ab146c07cd61a0c29f5b234966f5b18deeaf55aecafe7d1018e53f503a6efe54f3b002e2af74a3c24442e5f4affef48015c68b6f9d5986924a179951878
data/.gitignore CHANGED
@@ -1,4 +1,9 @@
1
- tmp
2
- Gemfile.lock
3
- coverage
4
- pkg
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
@@ -0,0 +1,11 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.2
4
+ - 2.3.0
5
+ # - jruby
6
+ # - rbx-2
7
+ before_install:
8
+ - gem install bundler -v 1.12.5
9
+
10
+ # uncomment and edit the following line if your project needs to run something other than `rake`:
11
+ # script: bundle exec rspec spec
@@ -0,0 +1,25 @@
1
+ # CHANGELOG
2
+
3
+
4
+ ## 0.3.0 (2016-08-11)
5
+
6
+ * Merged PR #3 by @jonduarte - Making routes behind #locale block work
7
+
8
+ * Added Travis CI support (all builds passing)
9
+
10
+ * Change r18n-core gem to version 2.1.4
11
+
12
+ * Add alias for rake test
13
+
14
+
15
+ ## 0.2.0 (2015-11-24)
16
+
17
+ * Mainly internal build and setup improvements
18
+
19
+
20
+ ## 0.1.0 (2015-09-13)
21
+
22
+ * Initial public release
23
+
24
+ * Big Thank You to @jeremyevans for his assistance in creating this initial version.
25
+
data/Gemfile CHANGED
@@ -1,19 +1,4 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- # Specify your gem's dependencies in roda-tags.gemspec
3
+ # Specify your gem's dependencies in roda-i18n.gemspec
4
4
  gemspec
5
-
6
- # gem 'roda', '~> 2.5.1'
7
- # gem 'r18n-core'
8
- #
9
- # group :test do
10
- # gem 'minitest'
11
- # gem 'minitest-hooks'
12
- # gem "rack-test"
13
- #
14
- # gem 'tilt'
15
- # gem 'erubis'
16
- # gem 'kramdown'
17
- #
18
- # gem 'simplecov', :require => false
19
- # end
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Roda-i18n
2
2
 
3
+ [![Build Status](https://travis-ci.org/kematzy/roda-i18n.svg?branch=master)](https://travis-ci.org/kematzy/roda-i18n)
4
+
3
5
  Add Internationalisation (i18n) and localisation support to your [Roda](http://roda.jeremyevans.net/)
4
6
  apps, based upon the [R18n](https://github.com/ai/r18n) gem.
5
7
 
@@ -180,7 +182,7 @@ end
180
182
  <br>
181
183
 
182
184
 
183
- ### ``#i18n_set_locale_from(type)` - (request method)
185
+ ### `#i18n_set_locale_from(type)` - (request method)
184
186
 
185
187
  Obtains the locale from either ENV, HTTP (browser), Params or Session values.
186
188
 
@@ -331,6 +333,10 @@ Som form of built-in support for storing / loading translations from a Sequel ba
331
333
 
332
334
  * Inspiration and assistance by [Jeremy Evans](github.com/jeremyevans). Many thanks Jeremy!!
333
335
 
336
+ * Code fixes and improvements by:
337
+
338
+ * [Jonathan Duarte](github.com/jonduarte). Many thanks Jonathan
339
+
334
340
 
335
341
  ## Licence
336
342
 
data/Rakefile CHANGED
@@ -1,21 +1,29 @@
1
- require "bundler/gem_tasks"
2
- require "rake/testtask"
1
+ require 'bundler/gem_tasks'
2
+ require 'rake/testtask'
3
3
 
4
4
  Rake::TestTask.new(:spec) do |t|
5
- t.libs << "spec"
6
- t.libs << "lib"
5
+ t.libs << 'spec'
6
+ t.libs << 'lib'
7
7
  t.test_files = FileList['spec/**/*_spec.rb']
8
8
  end
9
9
 
10
10
  task :default => :spec
11
+ task :test => :spec
11
12
 
12
- desc "Run specs with coverage"
13
+ desc 'Run specs with coverage'
13
14
  task :coverage do
14
15
  ENV['COVERAGE'] = '1'
15
16
  Rake::Task['spec'].invoke
17
+ # `open coverage/index.html` # if OSX
16
18
  end
17
19
 
18
- desc "Run Rubocop report"
20
+ desc 'Run Rubocop report'
19
21
  task :rubocop do
20
- `rubocop -f html -o ./Rubocop-report.html lib/`
22
+ res = `which rubocop`
23
+ if res != ""
24
+ `rubocop -f html -o ./rubocop/report.html lib/`
25
+ # `open rubocop/report.html` # if OSX
26
+ else
27
+ puts "\nERROR: 'rubocop' gem is not installed or available. Please install with 'gem install rubocop'."
28
+ end
21
29
  end
@@ -1,7 +1,7 @@
1
1
  class Roda
2
2
 
3
3
  module I18n
4
- VERSION = '0.2.0'
4
+ VERSION = '0.3.0'
5
5
  end
6
6
 
7
7
  end
@@ -266,6 +266,20 @@ class Roda
266
266
  # return # NB!! needed to enable routes below to work
267
267
  end
268
268
 
269
+ # Match only paths that contain one available locale from the ::R18n.available_locales
270
+ # list, otherwise skip it.
271
+ #
272
+ # This custom matcher allows us to have other routes below the r.locale .. declaration
273
+ def _match_available_locales_only
274
+ lambda do
275
+ locale = remaining_path.split("/").reject(&:empty?).first
276
+ if ::R18n.available_locales.map(&:code).map(&:downcase).include?(locale.downcase)
277
+ @captures.push(locale)
278
+ @remaining_path = remaining_path.sub("/#{locale}", "")
279
+ end
280
+ end
281
+ end
282
+
269
283
  # Sets the locale based upon <tt>:locale</tt> prefixed routes
270
284
  #
271
285
  # route do |r|
@@ -280,8 +294,8 @@ class Roda
280
294
  # end
281
295
  #
282
296
  def locale(opts = {}, &blk)
283
- on(':locale', opts) do |l|
284
- loc = l || self.class.opts[:locale]
297
+ on(_match_available_locales_only, opts) do |l|
298
+ loc = l || Roda.opts[:locale]
285
299
  session[:locale] = loc unless session[:locale]
286
300
  ::R18n.set(loc)
287
301
  yield if block_given?
@@ -6,13 +6,13 @@ require 'roda/i18n/version'
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = 'roda-i18n'
8
8
  spec.version = ::Roda::I18n::VERSION
9
- spec.authors = ["Kematzy"]
10
- spec.email = ["kematzy@gmail.com"]
9
+ spec.authors = ['Kematzy']
10
+ spec.email = ['kematzy@gmail.com']
11
11
 
12
- spec.summary = "Roda Internationalisation plugin"
12
+ spec.summary = 'Roda Internationalisation plugin'
13
13
  spec.description = "The Roda-i18n plugin enables easy addition of internationalisation (i18n) and localisation support in Roda apps"
14
- spec.homepage = "http://github.com/kematzy/roda-i18n"
15
- spec.license = "MIT"
14
+ spec.homepage = 'http://github.com/kematzy/roda-i18n'
15
+ spec.license = 'MIT'
16
16
 
17
17
  # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
18
18
  # delete this section to allow pushing this gem to any host.
@@ -29,21 +29,22 @@ Gem::Specification.new do |spec|
29
29
 
30
30
  spec.platform = Gem::Platform::RUBY
31
31
  spec.has_rdoc = true
32
- spec.extra_rdoc_files = ["README.md", "MIT-LICENSE"]
33
- spec.rdoc_options += ["--quiet", "--line-numbers", "--inline-source", '--title', 'Roda-i18n: internationalisation plugin', '--main', 'README.md']
32
+ spec.extra_rdoc_files = ['README.md', "MIT-LICENSE"]
33
+ spec.rdoc_options += ['--quiet', '--line-numbers', '--inline-source', '--title', 'Roda-i18n: internationalisation plugin', '--main', 'README.md']
34
34
 
35
35
  spec.add_runtime_dependency 'roda', '~> 2.5', '>= 2.5.0'
36
36
  spec.add_runtime_dependency 'tilt'
37
- spec.add_runtime_dependency "r18n-core", '~> 2.0', '>= 2.0.3'
37
+ spec.add_runtime_dependency 'r18n-core', '~> 2.0', '>= 2.1.4'
38
38
 
39
39
  spec.add_development_dependency 'bundler', "~> 1.10"
40
40
  spec.add_development_dependency 'rake', "~> 10.0"
41
41
  spec.add_development_dependency 'erubis'
42
42
  spec.add_development_dependency 'kramdown'
43
- spec.add_development_dependency "minitest", '~> 5.7', '>= 5.7.0'
44
- spec.add_development_dependency "minitest-hooks", '~> 1.1', '>= 1.1.0'
43
+ spec.add_development_dependency 'minitest', '~> 5.7', '>= 5.7.0'
44
+ spec.add_development_dependency 'minitest-assert_errors'
45
+ spec.add_development_dependency 'minitest-hooks', '~> 1.1', '>= 1.1.0'
45
46
  spec.add_development_dependency 'minitest-rg'
46
- spec.add_development_dependency "rack-test", '~> 0.6.3'
47
+ spec.add_development_dependency 'rack-test', '~> 0.6.3'
47
48
  spec.add_development_dependency 'nokogiri'
48
49
  spec.add_development_dependency 'simplecov'
49
50
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: roda-i18n
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kematzy
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-11-24 00:00:00.000000000 Z
11
+ date: 2016-08-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: roda
@@ -53,7 +53,7 @@ dependencies:
53
53
  version: '2.0'
54
54
  - - ">="
55
55
  - !ruby/object:Gem::Version
56
- version: 2.0.3
56
+ version: 2.1.4
57
57
  type: :runtime
58
58
  prerelease: false
59
59
  version_requirements: !ruby/object:Gem::Requirement
@@ -63,7 +63,7 @@ dependencies:
63
63
  version: '2.0'
64
64
  - - ">="
65
65
  - !ruby/object:Gem::Version
66
- version: 2.0.3
66
+ version: 2.1.4
67
67
  - !ruby/object:Gem::Dependency
68
68
  name: bundler
69
69
  requirement: !ruby/object:Gem::Requirement
@@ -140,6 +140,20 @@ dependencies:
140
140
  - - ">="
141
141
  - !ruby/object:Gem::Version
142
142
  version: 5.7.0
143
+ - !ruby/object:Gem::Dependency
144
+ name: minitest-assert_errors
145
+ requirement: !ruby/object:Gem::Requirement
146
+ requirements:
147
+ - - ">="
148
+ - !ruby/object:Gem::Version
149
+ version: '0'
150
+ type: :development
151
+ prerelease: false
152
+ version_requirements: !ruby/object:Gem::Requirement
153
+ requirements:
154
+ - - ">="
155
+ - !ruby/object:Gem::Version
156
+ version: '0'
143
157
  - !ruby/object:Gem::Dependency
144
158
  name: minitest-hooks
145
159
  requirement: !ruby/object:Gem::Requirement
@@ -227,6 +241,8 @@ extra_rdoc_files:
227
241
  - MIT-LICENSE
228
242
  files:
229
243
  - ".gitignore"
244
+ - ".travis.yml"
245
+ - CHANGELOG.md
230
246
  - Gemfile
231
247
  - MIT-LICENSE
232
248
  - README.md
@@ -262,7 +278,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
262
278
  version: '0'
263
279
  requirements: []
264
280
  rubyforge_project:
265
- rubygems_version: 2.4.5
281
+ rubygems_version: 2.5.1
266
282
  signing_key:
267
283
  specification_version: 4
268
284
  summary: Roda Internationalisation plugin