action_context 0.1.2
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.
- data/MIT-LICENSE +20 -0
- data/README +13 -0
- data/Rakefile +34 -0
- data/VERSION +1 -0
- data/action_context.gemspec +51 -0
- data/init.rb +2 -0
- data/install.rb +1 -0
- data/lib/action_context.rb +28 -0
- data/pkg/action_context-0.1.2.gem +0 -0
- data/rails/init.rb +1 -0
- data/test/action_context_test.rb +20 -0
- data/test/helper.rb +5 -0
- data/uninstall.rb +1 -0
- metadata +77 -0
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 [name of plugin creator]
|
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.
|
data/README
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/testtask'
|
3
|
+
require 'rake/rdoctask'
|
4
|
+
|
5
|
+
desc 'Default: run unit tests.'
|
6
|
+
task :default => :test
|
7
|
+
|
8
|
+
desc 'Test the action_context plugin.'
|
9
|
+
Rake::TestTask.new(:test) do |t|
|
10
|
+
t.libs << 'lib'
|
11
|
+
t.libs << 'test'
|
12
|
+
t.pattern = 'test/**/*_test.rb'
|
13
|
+
t.verbose = true
|
14
|
+
end
|
15
|
+
|
16
|
+
desc 'Generate documentation for the action_context plugin.'
|
17
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
18
|
+
rdoc.rdoc_dir = 'rdoc'
|
19
|
+
rdoc.title = 'ActionContext'
|
20
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
21
|
+
rdoc.rdoc_files.include('README')
|
22
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
23
|
+
end
|
24
|
+
|
25
|
+
require 'jeweler'
|
26
|
+
Jeweler::Tasks.new do |gem|
|
27
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
28
|
+
gem.name = "action_context"
|
29
|
+
gem.summary = "Context awareness for Rails 3"
|
30
|
+
gem.email = "mdaubert@gmail.com"
|
31
|
+
gem.homepage = "http://github.com/MDaubs/action_context"
|
32
|
+
gem.authors = ["Matthew Daubert"]
|
33
|
+
end
|
34
|
+
Jeweler::GemcutterTasks.new
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.2
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{action_context}
|
8
|
+
s.version = "0.1.2"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Matthew Daubert"]
|
12
|
+
s.date = %q{2011-01-30}
|
13
|
+
s.email = %q{mdaubert@gmail.com}
|
14
|
+
s.extra_rdoc_files = [
|
15
|
+
"README"
|
16
|
+
]
|
17
|
+
s.files = [
|
18
|
+
"MIT-LICENSE",
|
19
|
+
"README",
|
20
|
+
"Rakefile",
|
21
|
+
"VERSION",
|
22
|
+
"action_context.gemspec",
|
23
|
+
"init.rb",
|
24
|
+
"install.rb",
|
25
|
+
"lib/action_context.rb",
|
26
|
+
"pkg/action_context-0.1.2.gem",
|
27
|
+
"rails/init.rb",
|
28
|
+
"test/action_context_test.rb",
|
29
|
+
"test/helper.rb",
|
30
|
+
"uninstall.rb"
|
31
|
+
]
|
32
|
+
s.homepage = %q{http://github.com/MDaubs/action_context}
|
33
|
+
s.require_paths = ["lib"]
|
34
|
+
s.rubygems_version = %q{1.3.7}
|
35
|
+
s.summary = %q{Context awareness for Rails 3}
|
36
|
+
s.test_files = [
|
37
|
+
"test/action_context_test.rb",
|
38
|
+
"test/helper.rb"
|
39
|
+
]
|
40
|
+
|
41
|
+
if s.respond_to? :specification_version then
|
42
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
43
|
+
s.specification_version = 3
|
44
|
+
|
45
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
46
|
+
else
|
47
|
+
end
|
48
|
+
else
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
data/init.rb
ADDED
data/install.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# Install hook code here
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'active_support/core_ext'
|
2
|
+
|
3
|
+
module ActionContext
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
module ClassMethods
|
7
|
+
end
|
8
|
+
|
9
|
+
module InstanceMethods
|
10
|
+
|
11
|
+
# Establish a connection between the current action and where we are in the current navigation context.
|
12
|
+
# Accepts a context symbol (e.g. :primary) and a Regex matcher (e.g. /^\/users/).
|
13
|
+
def set_context(context, matcher)
|
14
|
+
@contexts ||= {}
|
15
|
+
@contexts[context] = matcher
|
16
|
+
end
|
17
|
+
|
18
|
+
# Checks the given path to see if it represents the specified context
|
19
|
+
def match_context(context, path)
|
20
|
+
@contexts ||= {}
|
21
|
+
return false unless @contexts[context].present?
|
22
|
+
return true if path =~ @contexts[context]
|
23
|
+
false
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
Binary file
|
data/rails/init.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'action_context'
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'helper'
|
2
|
+
require 'action_context'
|
3
|
+
|
4
|
+
class ActionContextTest < Test::Unit::TestCase
|
5
|
+
|
6
|
+
class TestController
|
7
|
+
include ActionContext
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_set_and_match_context_methods
|
11
|
+
tc = TestController.new
|
12
|
+
tc.set_context(:primary, /^\/users/)
|
13
|
+
tc.set_context(:secondary, /^\/pages/)
|
14
|
+
assert tc.match_context(:primary, "/users")
|
15
|
+
assert tc.match_context(:secondary, "/pages/123/edit")
|
16
|
+
assert !tc.match_context(:secondary, "/users")
|
17
|
+
assert !tc.match_context(:doesntexist, "/qwerty")
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
data/test/helper.rb
ADDED
data/uninstall.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# Uninstall hook code here
|
metadata
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: action_context
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 1
|
8
|
+
- 2
|
9
|
+
version: 0.1.2
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Matthew Daubert
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2011-01-30 00:00:00 -05:00
|
18
|
+
default_executable:
|
19
|
+
dependencies: []
|
20
|
+
|
21
|
+
description:
|
22
|
+
email: mdaubert@gmail.com
|
23
|
+
executables: []
|
24
|
+
|
25
|
+
extensions: []
|
26
|
+
|
27
|
+
extra_rdoc_files:
|
28
|
+
- README
|
29
|
+
files:
|
30
|
+
- MIT-LICENSE
|
31
|
+
- README
|
32
|
+
- Rakefile
|
33
|
+
- VERSION
|
34
|
+
- action_context.gemspec
|
35
|
+
- init.rb
|
36
|
+
- install.rb
|
37
|
+
- lib/action_context.rb
|
38
|
+
- pkg/action_context-0.1.2.gem
|
39
|
+
- rails/init.rb
|
40
|
+
- test/action_context_test.rb
|
41
|
+
- test/helper.rb
|
42
|
+
- uninstall.rb
|
43
|
+
has_rdoc: true
|
44
|
+
homepage: http://github.com/MDaubs/action_context
|
45
|
+
licenses: []
|
46
|
+
|
47
|
+
post_install_message:
|
48
|
+
rdoc_options: []
|
49
|
+
|
50
|
+
require_paths:
|
51
|
+
- lib
|
52
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
segments:
|
58
|
+
- 0
|
59
|
+
version: "0"
|
60
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ">="
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
segments:
|
66
|
+
- 0
|
67
|
+
version: "0"
|
68
|
+
requirements: []
|
69
|
+
|
70
|
+
rubyforge_project:
|
71
|
+
rubygems_version: 1.3.7
|
72
|
+
signing_key:
|
73
|
+
specification_version: 3
|
74
|
+
summary: Context awareness for Rails 3
|
75
|
+
test_files:
|
76
|
+
- test/action_context_test.rb
|
77
|
+
- test/helper.rb
|