sinatra-sugar 0.4.0.a → 0.4.0.b
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/README.md +7 -4
- data/lib/sinatra/sugar.rb +3 -13
- data/spec/spec_helper.rb +0 -1
- metadata +56 -26
data/README.md
CHANGED
@@ -12,6 +12,11 @@ BigBand
|
|
12
12
|
Sinatra::Sugar is part of the [BigBand](http://github.com/rkh/big_band) stack.
|
13
13
|
Check it out if you are looking for other fancy Sinatra extensions.
|
14
14
|
|
15
|
+
Installation
|
16
|
+
------------
|
17
|
+
|
18
|
+
gem install sinatra-sugar --prerelease
|
19
|
+
|
15
20
|
More advanced set
|
16
21
|
-----------------
|
17
22
|
|
@@ -22,16 +27,14 @@ More advanced set
|
|
22
27
|
set :haml, :excape_html => false
|
23
28
|
haml # => { :format => :html5, :escape_html => false }
|
24
29
|
|
25
|
-
-
|
30
|
+
- Allows passing a block in Sinatra 0.9, too:
|
26
31
|
|
27
32
|
set(:foo) { Time.now }
|
28
|
-
|
29
|
-
- Defines a helper to access #{key} and #{key}? unless a helper/method with that name already exists.
|
30
33
|
|
31
34
|
More advanced register
|
32
35
|
----------------------
|
33
36
|
|
34
|
-
If an
|
37
|
+
If an extension is registered twice, the registered hook will only be called once.
|
35
38
|
|
36
39
|
Ability to extend command line options
|
37
40
|
--------------------------------------
|
data/lib/sinatra/sugar.rb
CHANGED
@@ -34,12 +34,11 @@ module Sinatra
|
|
34
34
|
# set :haml, :format => :html5, :escape_html => true
|
35
35
|
# set :haml, :excape_html => false
|
36
36
|
# haml # => { :format => :html5, :escape_html => false }
|
37
|
-
# - Allowes passing a block:
|
37
|
+
# - Allowes passing a block (for Sinatra 0.9.x):
|
38
38
|
# set(:foo) { Time.now }
|
39
|
-
# - Defines a helper to access #{key} and #{key}? unless a helper/method with that name already exists.
|
40
39
|
def set(key, value = self, &block)
|
41
40
|
# FIXME: refactor, refactor, refactor
|
42
|
-
if block_given?
|
41
|
+
if block_given? and Sinatra::VERSION < "1.0"
|
43
42
|
raise ArgumentError, "both a value and a block given" if value != self
|
44
43
|
value = block
|
45
44
|
end
|
@@ -47,11 +46,6 @@ module Sinatra
|
|
47
46
|
old_value = (send(symbolized) if symbolized and respond_to? symbolized)
|
48
47
|
value = old_value.merge value if value.is_a? Hash and old_value.is_a? Hash
|
49
48
|
super(key, value)
|
50
|
-
if symbolized
|
51
|
-
method_names = instance_methods.map { |m| m.to_s }
|
52
|
-
define_method(key) { self.class.send(key) } unless method_names.include? key.to_s
|
53
|
-
define_method("#{key}?") { self.class.send("#{key}?") } unless method_names.include? "#{key}?"
|
54
|
-
end
|
55
49
|
# HACK: Sinatra::Base.set uses recursion and in the final step value always
|
56
50
|
# is a Proc. Also, if value is a Proc no step ever follows. I abuse this to
|
57
51
|
# invoke the hooks only once per set.
|
@@ -85,7 +79,7 @@ module Sinatra
|
|
85
79
|
# root_glob("app", "{models,views,controllers}", "*.rb") { |file| load file }
|
86
80
|
# end
|
87
81
|
def root_glob(*args, &block)
|
88
|
-
Dir.glob(root_path(*args)
|
82
|
+
Dir.glob(root_path(*args)).each(&block)
|
89
83
|
end
|
90
84
|
|
91
85
|
# Whether or not to start a webserver.
|
@@ -168,12 +162,8 @@ module Sinatra
|
|
168
162
|
end
|
169
163
|
|
170
164
|
def self.registered(klass)
|
171
|
-
klass.set :app_file, klass.caller_files.first.expand_path unless klass.app_file?
|
172
165
|
klass.extend ClassMethods
|
173
166
|
klass.send :include, InstanceMethods
|
174
|
-
klass.set :haml, :format => :html5, :escape_html => true
|
175
|
-
klass.use Rack::Session::Cookie
|
176
|
-
klass.enable :sessions
|
177
167
|
end
|
178
168
|
|
179
169
|
def self.set_app_file(klass)
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sinatra-sugar
|
3
|
-
version:
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: true
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 4
|
8
|
+
- 0
|
9
|
+
- b
|
10
|
+
version: 0.4.0.b
|
5
11
|
platform: ruby
|
6
12
|
authors:
|
7
13
|
- Konstantin Haase
|
@@ -9,47 +15,67 @@ autorequire:
|
|
9
15
|
bindir: bin
|
10
16
|
cert_chain: []
|
11
17
|
|
12
|
-
date: 2010-
|
18
|
+
date: 2010-03-30 00:00:00 +02:00
|
13
19
|
default_executable:
|
14
20
|
dependencies:
|
15
21
|
- !ruby/object:Gem::Dependency
|
16
22
|
name: monkey-lib
|
17
|
-
|
18
|
-
|
19
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
25
|
requirements:
|
21
|
-
- -
|
22
|
-
-
|
23
|
-
|
26
|
+
- - ~>
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
segments:
|
29
|
+
- 0
|
30
|
+
- 4
|
31
|
+
- 0
|
32
|
+
- b
|
33
|
+
version: 0.4.0.b
|
34
|
+
type: :runtime
|
35
|
+
version_requirements: *id001
|
24
36
|
- !ruby/object:Gem::Dependency
|
25
37
|
name: sinatra-test-helper
|
26
|
-
|
27
|
-
|
28
|
-
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
prerelease: false
|
39
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
29
40
|
requirements:
|
30
|
-
- -
|
31
|
-
-
|
32
|
-
|
41
|
+
- - ~>
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
segments:
|
44
|
+
- 0
|
45
|
+
- 4
|
46
|
+
- 0
|
47
|
+
- b
|
48
|
+
version: 0.4.0.b
|
49
|
+
type: :development
|
50
|
+
version_requirements: *id002
|
33
51
|
- !ruby/object:Gem::Dependency
|
34
52
|
name: sinatra
|
35
|
-
|
36
|
-
|
37
|
-
version_requirements: !ruby/object:Gem::Requirement
|
53
|
+
prerelease: false
|
54
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
38
55
|
requirements:
|
39
56
|
- - ">="
|
40
57
|
- !ruby/object:Gem::Version
|
58
|
+
segments:
|
59
|
+
- 0
|
60
|
+
- 9
|
61
|
+
- 4
|
41
62
|
version: 0.9.4
|
42
|
-
|
63
|
+
type: :runtime
|
64
|
+
version_requirements: *id003
|
43
65
|
- !ruby/object:Gem::Dependency
|
44
66
|
name: rspec
|
45
|
-
|
46
|
-
|
47
|
-
version_requirements: !ruby/object:Gem::Requirement
|
67
|
+
prerelease: false
|
68
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
48
69
|
requirements:
|
49
70
|
- - ">="
|
50
71
|
- !ruby/object:Gem::Version
|
72
|
+
segments:
|
73
|
+
- 1
|
74
|
+
- 3
|
75
|
+
- 0
|
51
76
|
version: 1.3.0
|
52
|
-
|
77
|
+
type: :development
|
78
|
+
version_requirements: *id004
|
53
79
|
description: Some extensions to the sinatra default behavior (usefull for other Sintatra extensions, part of BigBand).
|
54
80
|
email: konstantin.mailinglists@googlemail.com
|
55
81
|
executables: []
|
@@ -76,18 +102,22 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
76
102
|
requirements:
|
77
103
|
- - ">="
|
78
104
|
- !ruby/object:Gem::Version
|
105
|
+
segments:
|
106
|
+
- 0
|
79
107
|
version: "0"
|
80
|
-
version:
|
81
108
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
109
|
requirements:
|
83
110
|
- - ">"
|
84
111
|
- !ruby/object:Gem::Version
|
112
|
+
segments:
|
113
|
+
- 1
|
114
|
+
- 3
|
115
|
+
- 1
|
85
116
|
version: 1.3.1
|
86
|
-
version:
|
87
117
|
requirements: []
|
88
118
|
|
89
119
|
rubyforge_project:
|
90
|
-
rubygems_version: 1.3.
|
120
|
+
rubygems_version: 1.3.6
|
91
121
|
signing_key:
|
92
122
|
specification_version: 3
|
93
123
|
summary: Some extensions to the sinatra default behavior (usefull for other Sintatra extensions, part of BigBand).
|