contexts 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: 769797619302adbd6183a7498199810826cb6a37
4
- data.tar.gz: 015c8f23bf692fab0904b72f4e6c9530bf4ac6b7
3
+ metadata.gz: 152d6f29d9baeeed0af51ba46574a3f96d37ec7d
4
+ data.tar.gz: 2138c23ac0adb9f181f82dd7db13499f8ab3c21e
5
5
  SHA512:
6
- metadata.gz: fd913b15066d17f2e1f7e1253daa729f543b41716f3d91c63c05c38b1114f3080efc3c05d2d59f94420fdfa865e11b6e1b5089cf6de4ad1afa9ffc3a9d88d33f
7
- data.tar.gz: dc46451e7a778b23fed0589ef360dd1ede8461f41ccbf7ee9ad880c86df98548d316b78b3b3e86854c970c280bae67a24b7968043f98da4ddbf4a4e34c214f3e
6
+ metadata.gz: 6be9641c3cf6731b5f564c83c87f47ec74e9bdd327369a657f3f91eb474b09a70e77691e2c10a0c3773ad7a51f5a8434d381b706b76eff8b65db5a7375a7487f
7
+ data.tar.gz: d882b04c68bd96ce2a029bea9ddfbca66a4656e0a028dae2a669406e508ac161805bca7a311c92e14b123cae9ff6761518f53fa95ea83b9c5d517d18275234ce
data/.travis.yml ADDED
@@ -0,0 +1,10 @@
1
+ language: ruby
2
+
3
+ rvm:
4
+ - 1.9.3
5
+ - 2.0.0
6
+ - 2.1.0
7
+
8
+ addons:
9
+ code_climate:
10
+ repo_token: 5054ad323c8adaa7271febec2c4364ec7eb0a81e10f6fc551799c2797ada8149
data/README.md CHANGED
@@ -1,3 +1,9 @@
1
+ [![Gem Version](https://badge.fury.io/rb/contexts.svg)](http://badge.fury.io/rb/contexts)
2
+ [![Build Status](https://travis-ci.org/kolesnikovde/contexts.svg)](https://travis-ci.org/kolesnikovde/contexts)
3
+ [![Code Climate](https://codeclimate.com/github/kolesnikovde/contexts/badges/gpa.svg)](https://codeclimate.com/github/kolesnikovde/contexts)
4
+ [![Test Coverage](https://codeclimate.com/github/kolesnikovde/contexts/badges/coverage.svg)](https://codeclimate.com/github/kolesnikovde/contexts)
5
+
6
+
1
7
  # Contexts
2
8
 
3
9
  This gem provides simple way to reuse routes logic in rails apps.
@@ -1,3 +1,3 @@
1
1
  module Contexts
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
data/lib/mapper.rb CHANGED
@@ -14,7 +14,7 @@ module ActionDispatch::Routing
14
14
  name = "#{name}_context".classify.constantize unless name.is_a?(Class)
15
15
  ctx = name.new
16
16
  path = ":#{ctx.key}"
17
- path = "(#{path})" if ctx.required?
17
+ path = "(#{path})" unless ctx.required?
18
18
 
19
19
  constraints = lambda do |req|
20
20
  (req.env['contexts'] ||= {})[ctx.key] = ctx
@@ -51,6 +51,8 @@ shared_examples 'context controller' do
51
51
 
52
52
  context 'when context is required' do
53
53
  it 'requires value' do
54
+ allow_any_instance_of(LanguageContext).to receive(:required?).and_return(true)
55
+
54
56
  expect(get: '/').not_to be_routable
55
57
  expect(get: '/en/').to route_to('application#index', lang: 'en')
56
58
  end
@@ -3,6 +3,10 @@ class LanguageContext < Contexts::Base
3
3
  :lang
4
4
  end
5
5
 
6
+ def required?
7
+ false
8
+ end
9
+
6
10
  def constraints
7
11
  /ru|en/
8
12
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: contexts
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
  - Kolesnikov Danil
@@ -104,6 +104,7 @@ files:
104
104
  - ".editorconfig"
105
105
  - ".gitignore"
106
106
  - ".rspec"
107
+ - ".travis.yml"
107
108
  - Gemfile
108
109
  - README.md
109
110
  - Rakefile