sinatra-sugar 0.5.0 → 0.5.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.
@@ -25,32 +25,8 @@ module Sinatra
25
25
  end
26
26
 
27
27
  module ClassMethods
28
-
29
28
  attr_writer :root, :guessed_root
30
29
 
31
- # More advanced set:
32
- # - Adds set_#{key} and set_value hooks to set.
33
- # - Merges the old value with the new one, if both are hashes:
34
- # set :haml, :format => :html5, :escape_html => true
35
- # set :haml, :excape_html => false
36
- # haml # => { :format => :html5, :escape_html => false }
37
- # - Allowes passing a block (for Sinatra 0.9.x):
38
- # set(:foo) { Time.now }
39
- def set(key, value = self, &block)
40
- symbolized = (key.to_sym if key.respond_to? :to_sym)
41
- old_value = (send(symbolized) if symbolized and respond_to? symbolized)
42
- value = old_value.merge value if value.is_a? Hash and old_value.is_a? Hash
43
- super
44
- # HACK: Sinatra::Base.set uses recursion and in the final step value always
45
- # is a Proc. Also, if value is a Proc no step ever follows. I abuse this to
46
- # invoke the hooks only once per set.
47
- if value.is_a? Proc
48
- invoke_hook "set_#{key}", self
49
- invoke_hook :set_value, self, key
50
- end
51
- self
52
- end
53
-
54
30
  # More advanced register:
55
31
  # - If an exntesion is registered twice, the registered hook will only be called once.
56
32
  def register(*extensions, &block)
@@ -76,64 +52,9 @@ module Sinatra
76
52
  def root_glob(*args, &block)
77
53
  Dir.glob(root_path(*args)).each(&block)
78
54
  end
79
-
80
- # Whether or not to start a webserver.
81
- def run?
82
- @run ||= true
83
- @run and !@running and app_file? and $0.expand_path == app_file.expand_path
84
- end
85
-
86
- # Disable automatically running this class as soon it is subclassed.
87
- def inherited
88
- super
89
- @run = false
90
- end
91
-
92
- # The application's root directory. BigBand will guess if missing.
93
- def root
94
- return ".".expand_path unless app_file?
95
- return @root if @root
96
- @guessed_root ||= begin
97
- dir = app_file.expand_path.dirname
98
- if dir.basename == "lib" and not (dir / "lib").directory?
99
- dir.dirname
100
- else
101
- dir
102
- end
103
- end
104
- end
105
-
106
- # Returns true if the #root is known.
107
- def root?
108
- !!@root || app_file?
109
- end
110
-
111
- # Option parser for #run!
112
- def run_option_parser
113
- @run_option_parser ||= begin
114
- require 'optparse'
115
- OptionParser.new do |op|
116
- op.on('-x') { set :lock, true }
117
- op.on('-e env') { |val| set :environment, val.to_sym }
118
- op.on('-s server') { |val| set :server, val }
119
- op.on('-p port') { |val| set :port, val.to_i }
120
- end
121
- end
122
- end
123
-
124
- # Extended #run!, offers an extandable option parser for
125
- # BigBand with the same standard options as the one of
126
- # Sinatra::Base (see #run_option_parser).
127
- def run!(options = {})
128
- run_option_parser.parse!(ARGV.dup) unless ARGV.empty?
129
- @running = true
130
- super(options)
131
- end
132
-
133
55
  end
134
56
 
135
57
  module InstanceMethods
136
-
137
58
  # See BigBand::BasicExtentions::ClassMethods#root_path
138
59
  def root_path(*args)
139
60
  self.class.root_path(*args)
@@ -153,7 +74,6 @@ module Sinatra
153
74
  def root?
154
75
  self.class.root
155
76
  end
156
-
157
77
  end
158
78
 
159
79
  def self.registered(klass)
@@ -164,10 +84,8 @@ module Sinatra
164
84
  def self.set_app_file(klass)
165
85
  klass.guessed_root = nil
166
86
  end
167
-
168
87
  end
169
-
88
+
170
89
  Base.ignore_caller
171
90
  register Sugar
172
-
173
91
  end
@@ -4,30 +4,6 @@ describe Sinatra::Sugar do
4
4
  before { app :Sugar }
5
5
  it_should_behave_like 'sinatra'
6
6
 
7
- describe "set" do
8
-
9
- it "adds hooks to Sinatra::Base#set" do
10
- extension = Module.new
11
- extension.should_receive(:set_foo).with(app)
12
- extension.should_receive(:set_value).with(app, :foo)
13
- app.register extension
14
- app.set :foo, 42
15
- end
16
-
17
- it "allows passing a block" do
18
- app.set(:foo) { 42 }
19
- app.foo.should == 42
20
- end
21
-
22
- it "merges hash values" do
23
- app.set :foo, :bar => 42
24
- app.set :foo, :baz => 23
25
- app.foo[:bar].should == 42
26
- app.foo[:baz].should == 23
27
- end
28
-
29
- end
30
-
31
7
  describe "register" do
32
8
  it "registers an extension only once" do
33
9
  extension = Module.new
@@ -35,5 +11,4 @@ describe Sinatra::Sugar do
35
11
  10.times { app.register extension }
36
12
  end
37
13
  end
38
-
39
14
  end
metadata CHANGED
@@ -1,13 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinatra-sugar
3
3
  version: !ruby/object:Gem::Version
4
- hash: 11
5
- prerelease: false
6
- segments:
7
- - 0
8
- - 5
9
- - 0
10
- version: 0.5.0
4
+ prerelease:
5
+ version: 0.5.1
11
6
  platform: ruby
12
7
  authors:
13
8
  - Konstantin Haase
@@ -15,8 +10,7 @@ autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
12
 
18
- date: 2010-07-09 00:00:00 +02:00
19
- default_executable:
13
+ date: 2011-05-02 00:00:00 Z
20
14
  dependencies:
21
15
  - !ruby/object:Gem::Dependency
22
16
  name: monkey-lib
@@ -26,11 +20,6 @@ dependencies:
26
20
  requirements:
27
21
  - - ~>
28
22
  - !ruby/object:Gem::Version
29
- hash: 11
30
- segments:
31
- - 0
32
- - 5
33
- - 0
34
23
  version: 0.5.0
35
24
  type: :runtime
36
25
  version_requirements: *id001
@@ -42,11 +31,6 @@ dependencies:
42
31
  requirements:
43
32
  - - ~>
44
33
  - !ruby/object:Gem::Version
45
- hash: 11
46
- segments:
47
- - 0
48
- - 5
49
- - 0
50
34
  version: 0.5.0
51
35
  type: :development
52
36
  version_requirements: *id002
@@ -58,10 +42,6 @@ dependencies:
58
42
  requirements:
59
43
  - - ~>
60
44
  - !ruby/object:Gem::Version
61
- hash: 15
62
- segments:
63
- - 1
64
- - 0
65
45
  version: "1.0"
66
46
  type: :runtime
67
47
  version_requirements: *id003
@@ -73,11 +53,6 @@ dependencies:
73
53
  requirements:
74
54
  - - ">="
75
55
  - !ruby/object:Gem::Version
76
- hash: 27
77
- segments:
78
- - 1
79
- - 3
80
- - 0
81
56
  version: 1.3.0
82
57
  type: :development
83
58
  version_requirements: *id004
@@ -95,7 +70,6 @@ files:
95
70
  - spec/spec_helper.rb
96
71
  - README.md
97
72
  - LICENSE
98
- has_rdoc: yard
99
73
  homepage: http://github.com/rkh/sinatra-sugar
100
74
  licenses: []
101
75
 
@@ -109,23 +83,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
109
83
  requirements:
110
84
  - - ">="
111
85
  - !ruby/object:Gem::Version
112
- hash: 3
113
- segments:
114
- - 0
115
86
  version: "0"
116
87
  required_rubygems_version: !ruby/object:Gem::Requirement
117
88
  none: false
118
89
  requirements:
119
90
  - - ">="
120
91
  - !ruby/object:Gem::Version
121
- hash: 3
122
- segments:
123
- - 0
124
92
  version: "0"
125
93
  requirements: []
126
94
 
127
95
  rubyforge_project:
128
- rubygems_version: 1.3.7
96
+ rubygems_version: 1.7.2
129
97
  signing_key:
130
98
  specification_version: 3
131
99
  summary: Some extensions to the sinatra default behavior (usefull for other Sintatra extensions, part of BigBand).