big_band 0.2.1 → 0.2.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/README.rdoc +33 -1
- data/lib/big_band/config_file.rb +48 -0
- data/lib/big_band/version.rb +2 -2
- data/lib/big_band.rb +3 -0
- data/lib/sinatra/big_band.rb +1 -0
- metadata +4 -2
data/README.rdoc
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
= BigBand 0.2.
|
1
|
+
= BigBand 0.2.2
|
2
2
|
BigBand is a collection of Sinatra extensions and offers better sinatra integration for common tools.
|
3
3
|
It is pluggable and each extension can be used in stand alone mode.
|
4
4
|
|
@@ -6,6 +6,7 @@ The main features are:
|
|
6
6
|
* Routes as first class objects
|
7
7
|
* Better handling of #set: Merges hashes, more hooks
|
8
8
|
* Better compass integration
|
9
|
+
* YAML config files mapping to set (overwriting present values/methods is prevented)
|
9
10
|
* Rails-like helpers, like content_for
|
10
11
|
* Unicorn and Rainbows integration
|
11
12
|
* Smart code reloader only reloading changed files and getting rid of old routes
|
@@ -141,6 +142,37 @@ But what about more complex setups?
|
|
141
142
|
Note that already generated routes will be deactivated by calling
|
142
143
|
get_compass again.
|
143
144
|
|
145
|
+
=== ConfigFile
|
146
|
+
|
147
|
+
Using YAML config files. Config files are expected to represent hashes.
|
148
|
+
When parsing such a config file it will use set to store that value, ignoring
|
149
|
+
those directly defined in the app (not those defined by the class it inherits
|
150
|
+
from, i.e. Sinatra::Base or BigBand).
|
151
|
+
|
152
|
+
Example:
|
153
|
+
|
154
|
+
class MyApp << BigBand
|
155
|
+
set :foo, "bar"
|
156
|
+
config_file "settings.yml" # general settings
|
157
|
+
config_file "#{environment}.settings.yml" # environment specific settings
|
158
|
+
foo # => "bar"
|
159
|
+
end
|
160
|
+
|
161
|
+
Now you could write in your settings.yml:
|
162
|
+
|
163
|
+
---
|
164
|
+
server: [thin, webrick] # use only thin or webrick for #run!
|
165
|
+
public: /var/www # load public files from /var/www
|
166
|
+
port: 8080 # run on port 8080
|
167
|
+
foo: baz
|
168
|
+
database:
|
169
|
+
adapter: sqlite
|
170
|
+
|
171
|
+
In you development.settings.yml:
|
172
|
+
|
173
|
+
database:
|
174
|
+
db_file: development.db
|
175
|
+
|
144
176
|
=== MoreHelpers
|
145
177
|
|
146
178
|
Adds more helper methods (more docs coming soon).
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require "sinatra/base"
|
2
|
+
require "yaml"
|
3
|
+
|
4
|
+
class BigBand < Sinatra::Base
|
5
|
+
# Using YAML config files. Config files are expected to represent hashes.
|
6
|
+
# When parsing such a config file it will use set to store that value, ignoring
|
7
|
+
# those directly defined in the app (not those defined by the class it inherits
|
8
|
+
# from, i.e. Sinatra::Base or BigBand).
|
9
|
+
#
|
10
|
+
# Example:
|
11
|
+
#
|
12
|
+
# class MyApp << BigBand
|
13
|
+
# set :foo, "bar"
|
14
|
+
# config_file "settings.yml" # general settings
|
15
|
+
# config_file "#{environment}.settings.yml" # environment specific settings
|
16
|
+
# foo # => "bar"
|
17
|
+
# end
|
18
|
+
#
|
19
|
+
# Now you could write in your settings.yml:
|
20
|
+
#
|
21
|
+
# ---
|
22
|
+
# server: [thin, webrick] # use only thin or webrick for #run!
|
23
|
+
# public: /var/www # load public files from /var/www
|
24
|
+
# port: 8080 # run on port 8080
|
25
|
+
# foo: baz
|
26
|
+
# database:
|
27
|
+
# adapter: sqlite
|
28
|
+
#
|
29
|
+
# In you development.settings.yml:
|
30
|
+
#
|
31
|
+
# database:
|
32
|
+
# db_file: development.db
|
33
|
+
module ConfigFile
|
34
|
+
|
35
|
+
def self.registered(klass)
|
36
|
+
klass.register BasicExtensions
|
37
|
+
end
|
38
|
+
|
39
|
+
def config_file(*paths)
|
40
|
+
paths.each do |pattern|
|
41
|
+
files = root_glob(pattern.to_s)
|
42
|
+
files.each { |f| YAML.load_file(f).each_pair { |k,v| set k, v unless methods(false).any? { |m| m.to_s = k.to_s } } }
|
43
|
+
warn "WARNING: could not load config file #{pattern}" if files.empty?
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
data/lib/big_band/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
require "big_band/integration" unless defined? BigBand
|
2
|
-
BigBand::VERSION = "0.2.
|
3
|
-
BigBand::DATE = "2009-12-
|
2
|
+
BigBand::VERSION = "0.2.2"
|
3
|
+
BigBand::DATE = "2009-12-30"
|
data/lib/big_band.rb
CHANGED
@@ -9,6 +9,7 @@ require "set"
|
|
9
9
|
# * Routes as first class objects
|
10
10
|
# * Better handling of #set: Merges hashes, more hooks
|
11
11
|
# * Better compass integration
|
12
|
+
# * YAML config files mapping to set (overwriting present values/methods is prevented)
|
12
13
|
# * Rails-like helpers, like content_for
|
13
14
|
# * Unicorn and Rainbows integration
|
14
15
|
# * Smart code reloader only reloading changed files and getting rid of old routes
|
@@ -210,6 +211,7 @@ class BigBand < Sinatra::Base
|
|
210
211
|
default_extension :AdvancedRoutes, "big_band/advanced_routes"
|
211
212
|
default_extension :BasicExtensions, "big_band/basic_extensions"
|
212
213
|
default_extension :Compass, "big_band/compass"
|
214
|
+
default_extension :ConfigFile, "big_band/config_file"
|
213
215
|
default_extension :MoreHelpers, "big_band/more_helpers"
|
214
216
|
default_extension :MoreServer, "big_band/more_server"
|
215
217
|
default_extension :Reloader, "big_band/reloader", :development
|
@@ -224,6 +226,7 @@ def BigBand(*options)
|
|
224
226
|
end
|
225
227
|
|
226
228
|
module Sinatra
|
229
|
+
BigBand = ::BigBand
|
227
230
|
module Delegator
|
228
231
|
# Hooks into Sinatra to allow easy integration with "require 'sinatra'".
|
229
232
|
def self.included(klass)
|
@@ -0,0 +1 @@
|
|
1
|
+
require "big_band"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: big_band
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Konstantin Haase
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-12-
|
12
|
+
date: 2009-12-30 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -90,6 +90,7 @@ files:
|
|
90
90
|
- lib/big_band/compass/stylesheets/big_band/utilities/_fancy_buttons.sass
|
91
91
|
- lib/big_band/compass/stylesheets/big_band/utilities/_html5.sass
|
92
92
|
- lib/big_band/compass.rb
|
93
|
+
- lib/big_band/config_file.rb
|
93
94
|
- lib/big_band/files/overlay-button.png
|
94
95
|
- lib/big_band/integration/bacon.rb
|
95
96
|
- lib/big_band/integration/monk.rb
|
@@ -112,6 +113,7 @@ files:
|
|
112
113
|
- lib/big_band/web_inspector.rb
|
113
114
|
- lib/big_band.rb
|
114
115
|
- lib/big_bang.rb
|
116
|
+
- lib/sinatra/big_band.rb
|
115
117
|
- lib/yard-sinatra.rb
|
116
118
|
- LICENSE
|
117
119
|
- Rakefile
|