strelka 0.0.1.pre.324 → 0.0.1.pre.328
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +78 -1
- data/lib/strelka/app/templating.rb +51 -1
- data/lib/strelka/app.rb +23 -14
- data/lib/strelka/authprovider.rb +11 -6
- data/spec/lib/helpers.rb +10 -0
- data/spec/strelka/app/templating_spec.rb +75 -1
- data/spec/strelka/app_spec.rb +0 -11
- data/spec/strelka/authprovider_spec.rb +13 -12
- data.tar.gz.sig +0 -0
- metadata +2 -2
- metadata.gz.sig +0 -0
data/ChangeLog
CHANGED
@@ -1,8 +1,85 @@
|
|
1
|
+
2012-10-11 Michael Granger <ged@FaerieMUD.org>
|
2
|
+
|
3
|
+
* lib/strelka/app.rb, lib/strelka/app/templating.rb,
|
4
|
+
spec/lib/helpers.rb, spec/strelka/app/templating_spec.rb,
|
5
|
+
spec/strelka/app_spec.rb:
|
6
|
+
Add template-directory discovery to the :templating plugin.
|
7
|
+
[cde8aaae8b47] [tip]
|
8
|
+
|
9
|
+
2012-10-03 Michael Granger <ged@FaerieMUD.org>
|
10
|
+
|
11
|
+
* Rakefile:
|
12
|
+
Don't load the manualgen Hoe plugin
|
13
|
+
[da2c8cd59ba9]
|
14
|
+
|
15
|
+
2012-10-09 Michael Granger <ged@FaerieMUD.org>
|
16
|
+
|
17
|
+
* bin/leash, contrib/hoetemplate/.autotest.erb,
|
18
|
+
contrib/hoetemplate/data/file_name/apps/file_name_app,
|
19
|
+
contrib/hoetemplate/data/file_name/templates/layout.tmpl.erb,
|
20
|
+
contrib/hoetemplate/data/file_name/templates/top.tmpl.erb,
|
21
|
+
data/strelka/apps/hello-world, lib/strelka/app/defaultrouter.rb,
|
22
|
+
lib/strelka/app/exclusiverouter.rb,
|
23
|
+
lib/strelka/app/paramvalidator.rb, lib/strelka/app/plugins.rb,
|
24
|
+
lib/strelka/app/router.rb, lib/strelka/logging.rb,
|
25
|
+
manual/layouts/default.erb, manual/lib/api-filter.rb, manual/lib
|
26
|
+
/editorial-filter.rb, manual/lib/examples-filter.rb, manual/lib
|
27
|
+
/links-filter.rb, manual/resources/css/manual.css,
|
28
|
+
manual/resources/fonts/GraublauWeb.otf,
|
29
|
+
manual/resources/fonts/GraublauWebBold.otf,
|
30
|
+
manual/resources/fonts/Inconsolata.otf,
|
31
|
+
manual/resources/images/arrow_225_small.png,
|
32
|
+
manual/resources/images/arrow_315_small.png,
|
33
|
+
manual/resources/images/arrow_skip.png, manual/resources/images/cc-
|
34
|
+
by.png, manual/resources/images/dialog-error.png,
|
35
|
+
manual/resources/images/dialog-information.png,
|
36
|
+
manual/resources/images/dialog-warning.png, manual/resources/images
|
37
|
+
/emblem-important.png, manual/resources/images/help.png,
|
38
|
+
manual/resources/images/information.png,
|
39
|
+
manual/resources/images/magnifier.png,
|
40
|
+
manual/resources/images/magnifier_left.png,
|
41
|
+
manual/resources/images/page_white_code.png,
|
42
|
+
manual/resources/images/page_white_copy.png,
|
43
|
+
manual/resources/images/printer.png, manual/resources/images
|
44
|
+
/project-layout.png, manual/resources/images/question.png,
|
45
|
+
manual/resources/images/scripts_code.png, manual/resources/images
|
46
|
+
/strelka-dogs/doggie6.svg, manual/resources/images/strelka-
|
47
|
+
dogs/doggie7.svg, manual/resources/images/wrap.png,
|
48
|
+
manual/resources/images/wrapping.png,
|
49
|
+
manual/resources/js/jquery-1.4.4.min.js,
|
50
|
+
manual/resources/js/manual.js, manual/resources/js/sh.js,
|
51
|
+
manual/resources/swf/clipboard.swf, manual/src/cookbook.page,
|
52
|
+
manual/src/deploying.page, manual/src/index.page,
|
53
|
+
manual/src/plugins.page, manual/src/writing.page,
|
54
|
+
spec/strelka/app/defaultrouter_spec.rb,
|
55
|
+
spec/strelka/app/exclusiverouter_spec.rb,
|
56
|
+
spec/strelka/app/paramvalidator_spec.rb,
|
57
|
+
spec/strelka/app/plugins_spec.rb, spec/strelka/app/router_spec.rb,
|
58
|
+
spec/strelka/logging_spec.rb:
|
59
|
+
Merge: Resurrect the strelka doggies under contrib/
|
60
|
+
[a38210d27bbd]
|
61
|
+
|
62
|
+
* contrib/strelka-dogs/doggie6.svg, contrib/strelka-dogs/doggie7.svg:
|
63
|
+
Oops, didn't mean to delete these
|
64
|
+
[d9cde3c8a778]
|
65
|
+
|
66
|
+
2012-10-08 Michael Granger <ged@FaerieMUD.org>
|
67
|
+
|
68
|
+
* lib/strelka/authprovider.rb, spec/strelka/authprovider_spec.rb:
|
69
|
+
Fix the documentation and specs for AuthProvider#authorize.
|
70
|
+
[accb655c57b4]
|
71
|
+
|
72
|
+
2012-10-03 Michael Granger <ged@FaerieMUD.org>
|
73
|
+
|
74
|
+
* .rvm.gems, Rakefile:
|
75
|
+
Bump dependency to the latest version of Mongrel2.
|
76
|
+
[a11bf994ae39]
|
77
|
+
|
1
78
|
2012-10-02 Michael Granger <ged@FaerieMUD.org>
|
2
79
|
|
3
80
|
* bin/strelka:
|
4
81
|
Don't fork for 'strelka start'.
|
5
|
-
[8882a71efc41]
|
82
|
+
[8882a71efc41]
|
6
83
|
|
7
84
|
2012-09-28 Michael Granger <ged@FaerieMUD.org>
|
8
85
|
|
@@ -19,6 +19,7 @@ require 'strelka/plugins'
|
|
19
19
|
# * a mechanism for fetching templates from the table
|
20
20
|
# * a global layout template which is automatically wrapped around responses
|
21
21
|
#
|
22
|
+
#
|
22
23
|
# == Usage
|
23
24
|
#
|
24
25
|
# To use it, just load the <tt>:templating</tt> plugin in your app:
|
@@ -88,14 +89,63 @@ require 'strelka/plugins'
|
|
88
89
|
#
|
89
90
|
# <?import request, strelka_version, route ?>
|
90
91
|
#
|
92
|
+
#
|
93
|
+
# == Template Locations
|
94
|
+
#
|
95
|
+
# Inversion looks for templates in a load path much like Ruby does for libraries that
|
96
|
+
# you 'require'. It contains just the current working directory by default. You can add
|
97
|
+
# your own template directories via the config file (under +template_paths+ in
|
98
|
+
# the +templates+ section), or programmatically from your application, but very often you'll
|
99
|
+
# want to distribute templates with the application gem.
|
100
|
+
#
|
101
|
+
# The plugin supports this by looking for a +templates/+ directory under your gem's
|
102
|
+
# data directory. If it finds such a directory for any loaded gem that has a Strelka dependency,
|
103
|
+
# it appends it to Inversion's +template_paths+. This also works for plugins, should you
|
104
|
+
# write your own, and want to provide some default templates. See the 'laika-fancyerrors'
|
105
|
+
# gem for an example of this.
|
106
|
+
#
|
91
107
|
module Strelka::App::Templating
|
92
108
|
include Strelka::Constants
|
93
|
-
extend Strelka::Plugin
|
109
|
+
extend Strelka::Plugin,
|
110
|
+
Loggability
|
94
111
|
|
112
|
+
|
113
|
+
# Loggability API -- log to strelka's logger
|
114
|
+
log_to :strelka
|
115
|
+
|
116
|
+
# Run order
|
95
117
|
run_before :routing, :negotiation, :errors
|
96
118
|
run_after :filters
|
97
119
|
|
98
120
|
|
121
|
+
### Return an Array of Pathnames to all directories named 'templates' under the
|
122
|
+
### data dirctories of loaded gems which have a dependency on Strelka.
|
123
|
+
def self::discover_template_dirs
|
124
|
+
directories = Strelka::App.discover_data_dirs.values.flatten
|
125
|
+
|
126
|
+
self.log.debug "Discovered data directories: %p" % [ directories ]
|
127
|
+
|
128
|
+
return directories.inject( [] ) do |array, dir|
|
129
|
+
pattern = File.join( dir, 'templates' )
|
130
|
+
self.log.debug " adding: %s" % [ pattern ]
|
131
|
+
array += Pathname.glob( pattern )
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
|
136
|
+
### Inclusion callback -- add the plugin's templates directory right before activation
|
137
|
+
### so loading the config doesn't clobber it.
|
138
|
+
def self::included( mod )
|
139
|
+
|
140
|
+
# Add the plugin's template directory to Inversion's template path
|
141
|
+
dirs = self.discover_template_dirs
|
142
|
+
self.log.info "Discovered template directories: %p" % [ dirs ]
|
143
|
+
Inversion::Template.template_paths.concat( dirs )
|
144
|
+
|
145
|
+
super
|
146
|
+
end
|
147
|
+
|
148
|
+
|
99
149
|
# Class methods to add to classes with templating.
|
100
150
|
module ClassMethods
|
101
151
|
|
data/lib/strelka/app.rb
CHANGED
@@ -138,11 +138,12 @@ class Strelka::App < Mongrel2::Handler
|
|
138
138
|
end
|
139
139
|
|
140
140
|
|
141
|
-
### Return a Hash of
|
142
|
-
###
|
143
|
-
|
144
|
-
|
145
|
-
|
141
|
+
### Return a Hash of glob patterns for matching data directories for the latest
|
142
|
+
### versions of all installed gems which have a dependency on Strelka, keyed
|
143
|
+
### by gem name.
|
144
|
+
def self::discover_data_dirs
|
145
|
+
datadirs = {
|
146
|
+
'' => self.local_data_dirs
|
146
147
|
}
|
147
148
|
|
148
149
|
# Find all the gems that depend on Strelka
|
@@ -156,15 +157,23 @@ class Strelka::App < Mongrel2::Handler
|
|
156
157
|
# pattern
|
157
158
|
gems.sort.reverse.each do |gemspec|
|
158
159
|
# Only look at the latest version of the gem
|
159
|
-
next if
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
160
|
+
next if datadirs.key?( gemspec.name )
|
161
|
+
datadirs[ gemspec.name ] = File.join( gemspec.full_gem_path, "data", gemspec.name )
|
162
|
+
end
|
163
|
+
|
164
|
+
self.log.debug " returning data directories: %p" % [ datadirs ]
|
165
|
+
return datadirs
|
166
|
+
end
|
167
|
+
|
168
|
+
|
169
|
+
### Return a Hash of Strelka app files as Pathname objects from installed gems,
|
170
|
+
### keyed by gemspec name .
|
171
|
+
def self::discover_paths
|
172
|
+
appfiles = {}
|
173
|
+
|
174
|
+
self.discover_data_dirs.each do |gemname, dir|
|
175
|
+
pattern = File.join( dir, self.app_glob_pattern )
|
176
|
+
appfiles[ gemname ] = Pathname.glob( pattern )
|
168
177
|
end
|
169
178
|
|
170
179
|
return appfiles
|
data/lib/strelka/authprovider.rb
CHANGED
@@ -83,12 +83,17 @@ class Strelka::AuthProvider
|
|
83
83
|
end
|
84
84
|
|
85
85
|
|
86
|
-
###
|
87
|
-
###
|
88
|
-
###
|
89
|
-
|
90
|
-
|
91
|
-
|
86
|
+
### You should override this method if you want to provide authorization in your
|
87
|
+
### provider. The +credentials+ will be the same object as the one returned by #authenticate,
|
88
|
+
### the +request+ is the current Strelka::HTTPRequest, and +perms+ is the Array of Symbols
|
89
|
+
### the represents the permissions that apply to the request as specified by the
|
90
|
+
### application's +require_perms_for+ and +no_perms_for+ declarations, as an Array of
|
91
|
+
### Symbols.
|
92
|
+
###
|
93
|
+
### The default behavior is to throw an 403 FORBIDDEN response if any +perms+ were
|
94
|
+
### required.
|
95
|
+
def authorize( credentials, request, perms )
|
96
|
+
return true if perms.empty?
|
92
97
|
self.require_authorization
|
93
98
|
end
|
94
99
|
|
data/spec/lib/helpers.rb
CHANGED
@@ -90,6 +90,16 @@ module Strelka::SpecHelpers
|
|
90
90
|
return tempdir
|
91
91
|
end
|
92
92
|
|
93
|
+
|
94
|
+
### Make and return a dummy gemspec with the given +name+ and +version+, and inject a
|
95
|
+
### dependency on 'strelka' if +strelka_dep+ is true.
|
96
|
+
def make_gemspec( name, version, strelka_dep=true )
|
97
|
+
spec = Gem::Specification.new( name, version )
|
98
|
+
spec.add_runtime_dependency( 'strelka', '~> 0.0' ) if strelka_dep
|
99
|
+
return spec
|
100
|
+
end
|
101
|
+
|
102
|
+
|
93
103
|
end
|
94
104
|
|
95
105
|
|
@@ -27,11 +27,13 @@ require 'strelka/behavior/plugin'
|
|
27
27
|
describe Strelka::App::Templating do
|
28
28
|
|
29
29
|
before( :all ) do
|
30
|
-
setup_logging(
|
30
|
+
setup_logging()
|
31
31
|
@request_factory = Mongrel2::RequestFactory.new( route: '/user' )
|
32
|
+
@original_template_paths = Inversion::Template.template_paths.dup
|
32
33
|
end
|
33
34
|
|
34
35
|
after( :all ) do
|
36
|
+
Inversion::Template.template_paths.replace( @original_template_paths )
|
35
37
|
reset_logging()
|
36
38
|
end
|
37
39
|
|
@@ -39,6 +41,78 @@ describe Strelka::App::Templating do
|
|
39
41
|
it_should_behave_like( "A Strelka::App Plugin" )
|
40
42
|
|
41
43
|
|
44
|
+
describe "template discovery" do
|
45
|
+
|
46
|
+
before( :each ) do
|
47
|
+
Inversion::Template.template_paths.replace( @original_template_paths )
|
48
|
+
end
|
49
|
+
|
50
|
+
it "can discover template directories for loaded gems that depend on Strelka" do
|
51
|
+
specs = {}
|
52
|
+
specs[:gymnastics] = make_gemspec( 'gymnastics', '1.0.0' )
|
53
|
+
specs[:cycling_old] = make_gemspec( 'cycling', '1.0.0' )
|
54
|
+
specs[:cycling_new] = make_gemspec( 'cycling', '1.0.8' )
|
55
|
+
specs[:karate] = make_gemspec( 'karate', '1.0.0', false )
|
56
|
+
specs[:javelin] = make_gemspec( 'javelin', '1.0.0' )
|
57
|
+
|
58
|
+
expectation = Gem::Specification.should_receive( :each )
|
59
|
+
specs.values.each {|spec| expectation.and_yield(spec) }
|
60
|
+
|
61
|
+
gymnastics_path = specs[:gymnastics].full_gem_path
|
62
|
+
cycling_path = specs[:cycling_new].full_gem_path
|
63
|
+
javelin_path = specs[:javelin].full_gem_path
|
64
|
+
|
65
|
+
Dir.should_receive( :glob ).with( 'data/*/templates' ).
|
66
|
+
and_return([ "data/foom/templates" ])
|
67
|
+
Dir.should_receive( :glob ).with( "#{javelin_path}/data/javelin/templates" ).
|
68
|
+
and_return([ "#{javelin_path}/data/javelin/templates" ])
|
69
|
+
Dir.should_receive( :glob ).with( "#{gymnastics_path}/data/gymnastics/templates" ).
|
70
|
+
and_return([ "#{gymnastics_path}/data/gymnastics/templates" ])
|
71
|
+
|
72
|
+
Dir.should_receive( :glob ).with( "#{cycling_path}/data/cycling/templates" ).
|
73
|
+
and_return([])
|
74
|
+
|
75
|
+
template_dirs = described_class.discover_template_dirs
|
76
|
+
|
77
|
+
# template_dirs.should have( 4 ).members
|
78
|
+
template_dirs.should include(
|
79
|
+
Pathname("data/foom/templates"),
|
80
|
+
Pathname("#{javelin_path}/data/javelin/templates"),
|
81
|
+
Pathname("#{gymnastics_path}/data/gymnastics/templates")
|
82
|
+
)
|
83
|
+
end
|
84
|
+
|
85
|
+
|
86
|
+
it "injects template directories from loaded gems into Inversion's template path" do
|
87
|
+
specs = {}
|
88
|
+
specs[:gymnastics] = make_gemspec( 'gymnastics', '1.0.0' )
|
89
|
+
specs[:javelin] = make_gemspec( 'javelin', '1.0.0' )
|
90
|
+
|
91
|
+
expectation = Gem::Specification.should_receive( :each )
|
92
|
+
specs.values.each {|spec| expectation.and_yield(spec) }
|
93
|
+
|
94
|
+
gymnastics_path = specs[:gymnastics].full_gem_path
|
95
|
+
javelin_path = specs[:javelin].full_gem_path
|
96
|
+
|
97
|
+
Dir.should_receive( :glob ).with( 'data/*/templates' ).
|
98
|
+
and_return([ "data/foom/templates" ])
|
99
|
+
Dir.should_receive( :glob ).with( "#{javelin_path}/data/javelin/templates" ).
|
100
|
+
and_return([ "#{javelin_path}/data/javelin/templates" ])
|
101
|
+
Dir.should_receive( :glob ).with( "#{gymnastics_path}/data/gymnastics/templates" ).
|
102
|
+
and_return([ "#{gymnastics_path}/data/gymnastics/templates" ])
|
103
|
+
|
104
|
+
Module.new { include Strelka::App::Templating }
|
105
|
+
|
106
|
+
Inversion::Template.template_paths.should include(
|
107
|
+
Pathname("data/foom/templates"),
|
108
|
+
Pathname("#{javelin_path}/data/javelin/templates"),
|
109
|
+
Pathname("#{gymnastics_path}/data/gymnastics/templates")
|
110
|
+
)
|
111
|
+
end
|
112
|
+
|
113
|
+
end
|
114
|
+
|
115
|
+
|
42
116
|
describe "an including App" do
|
43
117
|
|
44
118
|
before( :each ) do
|
data/spec/strelka/app_spec.rb
CHANGED
@@ -62,17 +62,6 @@ describe Strelka::App do
|
|
62
62
|
end
|
63
63
|
|
64
64
|
|
65
|
-
#
|
66
|
-
# Helpers
|
67
|
-
#
|
68
|
-
|
69
|
-
def make_gemspec( name, version, strelka_dep=true )
|
70
|
-
spec = Gem::Specification.new( name, version )
|
71
|
-
spec.add_runtime_dependency( 'strelka', '~> 0.0' ) if strelka_dep
|
72
|
-
return spec
|
73
|
-
end
|
74
|
-
|
75
|
-
|
76
65
|
#
|
77
66
|
# Examples
|
78
67
|
#
|
@@ -45,9 +45,17 @@ describe Strelka::AuthProvider do
|
|
45
45
|
|
46
46
|
describe "a subclass" do
|
47
47
|
|
48
|
+
before( :all ) do
|
49
|
+
@appclass = Class.new( Strelka::App ) do
|
50
|
+
def initialize( appid='authprovider-test', sspec=TEST_SEND_SPEC, rspec=TEST_RECV_SPEC )
|
51
|
+
super
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
48
56
|
before( :each ) do
|
49
57
|
@subclass = Class.new( described_class )
|
50
|
-
@app =
|
58
|
+
@app = @appclass.new
|
51
59
|
@provider = @subclass.new( @app )
|
52
60
|
end
|
53
61
|
|
@@ -69,25 +77,18 @@ describe Strelka::AuthProvider do
|
|
69
77
|
|
70
78
|
context "Authorization" do
|
71
79
|
|
72
|
-
it "doesn't fail if the application doesn't
|
73
|
-
req = @request_factory.get( '/admin/console' )
|
74
|
-
expect {
|
75
|
-
@provider.authorize( 'anonymous', req )
|
76
|
-
}.to_not throw_symbol()
|
77
|
-
end
|
78
|
-
|
79
|
-
it "doesn't fail if the application's authz callback returns true" do
|
80
|
+
it "doesn't fail if the application doesn't require any perms" do
|
80
81
|
req = @request_factory.get( '/admin/console' )
|
81
82
|
expect {
|
82
|
-
@provider.authorize( 'anonymous', req )
|
83
|
+
@provider.authorize( 'anonymous', req, [] )
|
83
84
|
}.to_not throw_symbol()
|
84
85
|
end
|
85
86
|
|
86
|
-
it "fails with a 403 (Forbidden) if the app
|
87
|
+
it "fails with a 403 (Forbidden) if the app does require perms" do
|
87
88
|
req = @request_factory.get( '/admin/console' )
|
88
89
|
|
89
90
|
expect {
|
90
|
-
@provider.authorize( 'anonymous', req )
|
91
|
+
@provider.authorize( 'anonymous', req, [:write] )
|
91
92
|
}.to finish_with( HTTP::FORBIDDEN, /you are not authorized/i )
|
92
93
|
end
|
93
94
|
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: strelka
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.1.pre.
|
4
|
+
version: 0.0.1.pre.328
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -36,7 +36,7 @@ cert_chain:
|
|
36
36
|
YUhDS0xaZFNLai9SSHVUT3QrZ2JsUmV4OEZBaDhOZUEKY21saFhlNDZwWk5K
|
37
37
|
Z1dLYnhaYWg4NWpJang5NWhSOHZPSStOQU01aUg5a09xSzEzRHJ4YWNUS1Bo
|
38
38
|
cWo1UGp3RgotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg==
|
39
|
-
date: 2012-10-
|
39
|
+
date: 2012-10-12 00:00:00.000000000 Z
|
40
40
|
dependencies:
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: configurability
|
metadata.gz.sig
CHANGED
Binary file
|