super_finder 0.0.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.
- data/.gitignore +1 -0
- data/MIT-LICENSE +20 -0
- data/README.textile +211 -0
- data/Rakefile +46 -0
- data/VERSION +1 -0
- data/assets/images/boxy-ne.png +0 -0
- data/assets/images/boxy-nw.png +0 -0
- data/assets/images/boxy-se.png +0 -0
- data/assets/images/boxy-sw.png +0 -0
- data/assets/images/close.png +0 -0
- data/assets/images/magnify.png +0 -0
- data/assets/javascripts/boxy.js +570 -0
- data/assets/javascripts/super_finder.js +193 -0
- data/assets/stylesheets/boxy.css +49 -0
- data/assets/stylesheets/super_finder.css +60 -0
- data/init.rb +2 -0
- data/install.rb +18 -0
- data/lib/super_finder.rb +17 -0
- data/lib/super_finder/cache_manager.rb +38 -0
- data/lib/super_finder/cache_sweeper.rb +41 -0
- data/lib/super_finder/config.rb +45 -0
- data/lib/super_finder/filters.rb +33 -0
- data/lib/super_finder/generator_controller.rb +94 -0
- data/lib/super_finder/helper.rb +18 -0
- data/lib/super_finder/initializer.rb +31 -0
- data/lib/super_finder/routes.rb +10 -0
- data/spec/assets/locales/en.yml +4 -0
- data/spec/functional/cache_spec.rb +45 -0
- data/spec/functional/controller_spec.rb +61 -0
- data/spec/functional/functional_spec_helper.rb +82 -0
- data/spec/functional/routes_spec.rb +29 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +37 -0
- data/spec/unit/cache_manager_spec.rb +41 -0
- data/spec/unit/config_spec.rb +24 -0
- data/spec/unit/controller_spec.rb +76 -0
- data/spec/unit/initializer_spec.rb +44 -0
- data/spec/unit/unit_spec_helper.rb +1 -0
- data/super_finder.gemspec +92 -0
- data/tasks/super_finder_tasks.rake +4 -0
- data/uninstall.rb +1 -0
- metadata +124 -0
@@ -0,0 +1,41 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/unit_spec_helper')
|
2
|
+
|
3
|
+
describe SuperFinder::CacheManager do
|
4
|
+
|
5
|
+
before(:each) do
|
6
|
+
class Project; end
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'should generate a key' do
|
10
|
+
key = SuperFinder::CacheManager.instance.key(Project)
|
11
|
+
key.should match /superfinder_all_projects_[0-9]*/
|
12
|
+
|
13
|
+
SuperFinder::CacheManager.instance.key(Project).should == key
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should generate a key depending on a scoper' do
|
17
|
+
@instance = Object.new
|
18
|
+
@instance.stubs(:id).returns(42)
|
19
|
+
|
20
|
+
key = SuperFinder::CacheManager.instance.key(Project, @instance)
|
21
|
+
key.should match /superfinder_42_projects_[0-9]*/
|
22
|
+
|
23
|
+
SuperFinder::CacheManager.instance.key(Project, @instance).should == key
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'should generate a key depending on a scoper by passing its id' do
|
27
|
+
key = SuperFinder::CacheManager.instance.key(Project, 7)
|
28
|
+
key.should match /superfinder_7_projects_[0-9]*/
|
29
|
+
|
30
|
+
SuperFinder::CacheManager.instance.key(Project, 7).should == key
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'should refresh a key' do
|
34
|
+
key = SuperFinder::CacheManager.instance.key(Project)
|
35
|
+
|
36
|
+
SuperFinder::CacheManager.instance.refresh!(Project)
|
37
|
+
|
38
|
+
SuperFinder::CacheManager.instance.key(Project, @instance).should != key
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/unit_spec_helper')
|
2
|
+
|
3
|
+
describe SuperFinder::Config do
|
4
|
+
|
5
|
+
before(:each) do
|
6
|
+
SuperFinder::Config.instance.reset_attributes
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'should have default values' do
|
10
|
+
SuperFinder::Config.instance.url.should == { :name_prefix => nil, :action => :show }
|
11
|
+
SuperFinder::Config.instance.models.should be_empty
|
12
|
+
SuperFinder::Config.instance.scoper.should == { :column => nil, :getter => nil }
|
13
|
+
SuperFinder::Config.instance.before_filters.should be_empty
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should set custom values' do
|
17
|
+
SuperFinder::Config.instance.url = { :name_prefix => 'admin', :action => :edit }
|
18
|
+
SuperFinder::Config.instance.url.should == { :name_prefix => 'admin', :action => :edit }
|
19
|
+
|
20
|
+
SuperFinder::Config.instance.before_filters = ['require_account', 'set_scoper']
|
21
|
+
SuperFinder::Config.instance.before_filters.should == ['require_account', 'set_scoper']
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/unit_spec_helper')
|
2
|
+
|
3
|
+
describe SuperFinder::GeneratorController do
|
4
|
+
|
5
|
+
before(:all) do
|
6
|
+
class Project; end
|
7
|
+
class Task; end
|
8
|
+
class HelloWorld; end
|
9
|
+
|
10
|
+
SuperFinder::CacheSweeper.stubs(:instance).returns(nil)
|
11
|
+
SuperFinder::Initializer.run do |config|
|
12
|
+
config.url = {
|
13
|
+
:name_prefix => 'admin',
|
14
|
+
:action => :edit
|
15
|
+
}
|
16
|
+
config.before_filters = [:hello_world, :foo]
|
17
|
+
config.models = [:foo, :bar]
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
before(:each) do
|
22
|
+
@controller = SuperFinder::GeneratorController.new
|
23
|
+
@controller.stubs(:url_for).returns('<url>')
|
24
|
+
|
25
|
+
@entry = Project.new
|
26
|
+
@entry.stubs(:id).returns(42)
|
27
|
+
@entry.stubs(:attributes).returns({ 'title' => 'Simple one' })
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'should generate a label from a String or a Symbol' do
|
32
|
+
@controller.send(:label_name, { :label => "test" }).should == 'test'
|
33
|
+
@controller.send(:label_name, { :label => :hello }).should == 'hello'
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'should generate a label from a Proc' do
|
37
|
+
@controller.send(:label_name, { :label => Proc.new { |c| 'Test' } }).should == 'Test'
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'should generate a label even without an option' do
|
41
|
+
@controller.send(:label_name, { :klass => Project }).should == 'Fun project'
|
42
|
+
@controller.send(:label_name, { :klass => Task }).should == 'Task'
|
43
|
+
@controller.send(:label_name, { :klass => HelloWorld }).should == 'Helloworld'
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'should return the value of an entry from the String or Symbol column option' do
|
47
|
+
@controller.send(:column_value, @entry, { :klass => Project }).should_not == 'Simple one'
|
48
|
+
@controller.send(:column_value, @entry, { :klass => Project, :column => :title }).should == 'Simple one'
|
49
|
+
@controller.send(:column_value, @entry, { :klass => Project, :column => 'title' }).should == 'Simple one'
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'should return the value of an entry from an Proc column option' do
|
53
|
+
@entry.stubs(:foo).returns('Foo')
|
54
|
+
@controller.send(:column_value, @entry, { :klass => Project, :column => Proc.new { |p| p.foo } }).should == 'Foo'
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'should generate an url' do
|
58
|
+
@controller.expects(:url_for).with({ :controller => '/admin/projects', :action => :edit, :id => 42 })
|
59
|
+
@controller.send(:entry_url, @entry, { :klass => Project })
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'should generate an url from an Hash option' do
|
63
|
+
@controller.expects(:url_for).with({ :controller => '/projects', :action => :show, :id => 42 })
|
64
|
+
@controller.send(:entry_url, @entry, { :klass => Project, :url => { :name_prefix => nil, :action => 'show' } })
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'should generate an url from an Proc option' do
|
68
|
+
@controller.send(:entry_url, @entry, { :klass => Project, :url => Proc.new { |c, p| '/index.html' } }).should == '/index.html'
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'should have filters defined in the config instance' do
|
72
|
+
@controller.class.send(:filter_chain).count.should == 2
|
73
|
+
@controller.class.send(:filter_chain).collect(&:method).should == [:hello_world, :foo]
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/unit_spec_helper')
|
2
|
+
|
3
|
+
describe SuperFinder::Initializer do
|
4
|
+
|
5
|
+
before(:each) do
|
6
|
+
SuperFinder::Config.instance.reset_attributes
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'should update config settings' do
|
10
|
+
SuperFinder::Initializer.stubs(:apply).returns(true)
|
11
|
+
|
12
|
+
SuperFinder::Initializer.run do |config|
|
13
|
+
config.url = { :name_prefix => 'admin', :action => :edit }
|
14
|
+
config.models = ['foo', 'bar']
|
15
|
+
end
|
16
|
+
|
17
|
+
SuperFinder::Config.instance.url[:name_prefix].should == 'admin'
|
18
|
+
SuperFinder::Config.instance.url[:action].should == :edit
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'should need models' do
|
22
|
+
lambda {
|
23
|
+
SuperFinder::Initializer.run
|
24
|
+
}.should raise_error
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'should apply default config' do
|
28
|
+
SuperFinder::Initializer.expects(:apply).returns(true)
|
29
|
+
SuperFinder::Initializer.run do |config|
|
30
|
+
config.models = ['foo', 'bar']
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'should apply new config once they all have been set' do
|
35
|
+
SuperFinder::Initializer.expects(:apply).returns(true)
|
36
|
+
|
37
|
+
SuperFinder::Initializer.run do |config|
|
38
|
+
config.name_prefix = 'admin'
|
39
|
+
config.default_action = :edit
|
40
|
+
config.models = ['foo', 'bar']
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'spec_helper')
|
@@ -0,0 +1,92 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{super_finder}
|
8
|
+
s.version = "0.0.1"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Didier Lafforgue"]
|
12
|
+
s.date = %q{2010-04-07}
|
13
|
+
s.description = %q{TextMate's "cmd-T" functionality in a web app}
|
14
|
+
s.email = %q{didier@nocoffee.fr}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"README.textile"
|
17
|
+
]
|
18
|
+
s.files = [
|
19
|
+
".gitignore",
|
20
|
+
"MIT-LICENSE",
|
21
|
+
"README.textile",
|
22
|
+
"Rakefile",
|
23
|
+
"VERSION",
|
24
|
+
"assets/images/boxy-ne.png",
|
25
|
+
"assets/images/boxy-nw.png",
|
26
|
+
"assets/images/boxy-se.png",
|
27
|
+
"assets/images/boxy-sw.png",
|
28
|
+
"assets/images/close.png",
|
29
|
+
"assets/images/magnify.png",
|
30
|
+
"assets/javascripts/boxy.js",
|
31
|
+
"assets/javascripts/super_finder.js",
|
32
|
+
"assets/stylesheets/boxy.css",
|
33
|
+
"assets/stylesheets/super_finder.css",
|
34
|
+
"init.rb",
|
35
|
+
"install.rb",
|
36
|
+
"lib/super_finder.rb",
|
37
|
+
"lib/super_finder/cache_manager.rb",
|
38
|
+
"lib/super_finder/cache_sweeper.rb",
|
39
|
+
"lib/super_finder/config.rb",
|
40
|
+
"lib/super_finder/filters.rb",
|
41
|
+
"lib/super_finder/generator_controller.rb",
|
42
|
+
"lib/super_finder/helper.rb",
|
43
|
+
"lib/super_finder/initializer.rb",
|
44
|
+
"lib/super_finder/routes.rb",
|
45
|
+
"spec/assets/locales/en.yml",
|
46
|
+
"spec/functional/cache_spec.rb",
|
47
|
+
"spec/functional/controller_spec.rb",
|
48
|
+
"spec/functional/functional_spec_helper.rb",
|
49
|
+
"spec/functional/routes_spec.rb",
|
50
|
+
"spec/spec.opts",
|
51
|
+
"spec/spec_helper.rb",
|
52
|
+
"spec/unit/cache_manager_spec.rb",
|
53
|
+
"spec/unit/config_spec.rb",
|
54
|
+
"spec/unit/controller_spec.rb",
|
55
|
+
"spec/unit/initializer_spec.rb",
|
56
|
+
"spec/unit/unit_spec_helper.rb",
|
57
|
+
"super_finder.gemspec",
|
58
|
+
"tasks/super_finder_tasks.rake",
|
59
|
+
"uninstall.rb"
|
60
|
+
]
|
61
|
+
s.homepage = %q{http://github.com/did/super_finder}
|
62
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
63
|
+
s.require_paths = ["lib"]
|
64
|
+
s.rubygems_version = %q{1.3.6}
|
65
|
+
s.summary = %q{TextMate's "cmd-T" functionality in a web app}
|
66
|
+
s.test_files = [
|
67
|
+
"spec/functional/cache_spec.rb",
|
68
|
+
"spec/functional/controller_spec.rb",
|
69
|
+
"spec/functional/functional_spec_helper.rb",
|
70
|
+
"spec/functional/routes_spec.rb",
|
71
|
+
"spec/spec_helper.rb",
|
72
|
+
"spec/unit/cache_manager_spec.rb",
|
73
|
+
"spec/unit/config_spec.rb",
|
74
|
+
"spec/unit/controller_spec.rb",
|
75
|
+
"spec/unit/initializer_spec.rb",
|
76
|
+
"spec/unit/unit_spec_helper.rb"
|
77
|
+
]
|
78
|
+
|
79
|
+
if s.respond_to? :specification_version then
|
80
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
81
|
+
s.specification_version = 3
|
82
|
+
|
83
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
84
|
+
s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
|
85
|
+
else
|
86
|
+
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
87
|
+
end
|
88
|
+
else
|
89
|
+
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
data/uninstall.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# Uninstall hook code here
|
metadata
ADDED
@@ -0,0 +1,124 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: super_finder
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
version: 0.0.1
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Didier Lafforgue
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-04-07 00:00:00 +02:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: rspec
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 1
|
29
|
+
- 2
|
30
|
+
- 9
|
31
|
+
version: 1.2.9
|
32
|
+
type: :development
|
33
|
+
version_requirements: *id001
|
34
|
+
description: TextMate's "cmd-T" functionality in a web app
|
35
|
+
email: didier@nocoffee.fr
|
36
|
+
executables: []
|
37
|
+
|
38
|
+
extensions: []
|
39
|
+
|
40
|
+
extra_rdoc_files:
|
41
|
+
- README.textile
|
42
|
+
files:
|
43
|
+
- .gitignore
|
44
|
+
- MIT-LICENSE
|
45
|
+
- README.textile
|
46
|
+
- Rakefile
|
47
|
+
- VERSION
|
48
|
+
- assets/images/boxy-ne.png
|
49
|
+
- assets/images/boxy-nw.png
|
50
|
+
- assets/images/boxy-se.png
|
51
|
+
- assets/images/boxy-sw.png
|
52
|
+
- assets/images/close.png
|
53
|
+
- assets/images/magnify.png
|
54
|
+
- assets/javascripts/boxy.js
|
55
|
+
- assets/javascripts/super_finder.js
|
56
|
+
- assets/stylesheets/boxy.css
|
57
|
+
- assets/stylesheets/super_finder.css
|
58
|
+
- init.rb
|
59
|
+
- install.rb
|
60
|
+
- lib/super_finder.rb
|
61
|
+
- lib/super_finder/cache_manager.rb
|
62
|
+
- lib/super_finder/cache_sweeper.rb
|
63
|
+
- lib/super_finder/config.rb
|
64
|
+
- lib/super_finder/filters.rb
|
65
|
+
- lib/super_finder/generator_controller.rb
|
66
|
+
- lib/super_finder/helper.rb
|
67
|
+
- lib/super_finder/initializer.rb
|
68
|
+
- lib/super_finder/routes.rb
|
69
|
+
- spec/assets/locales/en.yml
|
70
|
+
- spec/functional/cache_spec.rb
|
71
|
+
- spec/functional/controller_spec.rb
|
72
|
+
- spec/functional/functional_spec_helper.rb
|
73
|
+
- spec/functional/routes_spec.rb
|
74
|
+
- spec/spec.opts
|
75
|
+
- spec/spec_helper.rb
|
76
|
+
- spec/unit/cache_manager_spec.rb
|
77
|
+
- spec/unit/config_spec.rb
|
78
|
+
- spec/unit/controller_spec.rb
|
79
|
+
- spec/unit/initializer_spec.rb
|
80
|
+
- spec/unit/unit_spec_helper.rb
|
81
|
+
- super_finder.gemspec
|
82
|
+
- tasks/super_finder_tasks.rake
|
83
|
+
- uninstall.rb
|
84
|
+
has_rdoc: true
|
85
|
+
homepage: http://github.com/did/super_finder
|
86
|
+
licenses: []
|
87
|
+
|
88
|
+
post_install_message:
|
89
|
+
rdoc_options:
|
90
|
+
- --charset=UTF-8
|
91
|
+
require_paths:
|
92
|
+
- lib
|
93
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
segments:
|
98
|
+
- 0
|
99
|
+
version: "0"
|
100
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
segments:
|
105
|
+
- 0
|
106
|
+
version: "0"
|
107
|
+
requirements: []
|
108
|
+
|
109
|
+
rubyforge_project:
|
110
|
+
rubygems_version: 1.3.6
|
111
|
+
signing_key:
|
112
|
+
specification_version: 3
|
113
|
+
summary: TextMate's "cmd-T" functionality in a web app
|
114
|
+
test_files:
|
115
|
+
- spec/functional/cache_spec.rb
|
116
|
+
- spec/functional/controller_spec.rb
|
117
|
+
- spec/functional/functional_spec_helper.rb
|
118
|
+
- spec/functional/routes_spec.rb
|
119
|
+
- spec/spec_helper.rb
|
120
|
+
- spec/unit/cache_manager_spec.rb
|
121
|
+
- spec/unit/config_spec.rb
|
122
|
+
- spec/unit/controller_spec.rb
|
123
|
+
- spec/unit/initializer_spec.rb
|
124
|
+
- spec/unit/unit_spec_helper.rb
|