big_band 0.2.5 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (96) hide show
  1. data/LICENSE +1 -1
  2. data/README.md +82 -0
  3. data/Rakefile +50 -170
  4. data/TODO.md +50 -0
  5. data/lib/big_band.rb +13 -258
  6. data/lib/sinatra/big_band.rb +65 -1
  7. data/spec/sinatra/big_band_spec.rb +32 -0
  8. data/spec/spec_helper.rb +2 -4
  9. data/subproject.rb +42 -0
  10. data/tasks/doc.task +9 -0
  11. data/tasks/gem.task +10 -0
  12. data/tasks/git.task +41 -0
  13. data/tasks/setup.task +34 -0
  14. data/tasks/spec.task +24 -0
  15. metadata +200 -140
  16. data/README.rdoc +0 -346
  17. data/README.rdoc.erb +0 -39
  18. data/big_band.gemspec +0 -25
  19. data/dependencies.rb +0 -12
  20. data/depgen/README.rdoc +0 -7
  21. data/depgen/Rakefile +0 -23
  22. data/depgen/depgen.rb +0 -123
  23. data/depgen/depgen.task +0 -42
  24. data/depgen/depgen_spec.rb +0 -127
  25. data/deps.rip +0 -8
  26. data/example/example.rb +0 -13
  27. data/example/views/index.haml +0 -8
  28. data/example/views/layout.haml +0 -2
  29. data/example/views/stylesheets/_base.sass +0 -1
  30. data/example/views/stylesheets/screen.sass +0 -12
  31. data/lib/big_band/advanced_routes.rb +0 -188
  32. data/lib/big_band/basic_extensions.rb +0 -176
  33. data/lib/big_band/compass.rb +0 -94
  34. data/lib/big_band/compass/big_band.rb +0 -4
  35. data/lib/big_band/compass/stylesheets/_big_band.sass +0 -1
  36. data/lib/big_band/compass/stylesheets/big_band/_blueprint.sass +0 -1
  37. data/lib/big_band/compass/stylesheets/big_band/_utilities.sass +0 -6
  38. data/lib/big_band/compass/stylesheets/big_band/blueprint/_html5.sass +0 -4
  39. data/lib/big_band/compass/stylesheets/big_band/layouts/_inspector.sass +0 -103
  40. data/lib/big_band/compass/stylesheets/big_band/utilities/_border_radius.sass +0 -27
  41. data/lib/big_band/compass/stylesheets/big_band/utilities/_css3_prefix.sass +0 -14
  42. data/lib/big_band/compass/stylesheets/big_band/utilities/_fancy_buttons.sass +0 -62
  43. data/lib/big_band/compass/stylesheets/big_band/utilities/_html5.sass +0 -3
  44. data/lib/big_band/config_file.rb +0 -48
  45. data/lib/big_band/files/overlay-button.png +0 -0
  46. data/lib/big_band/integration.rb +0 -39
  47. data/lib/big_band/integration/bacon.rb +0 -10
  48. data/lib/big_band/integration/monk.rb +0 -26
  49. data/lib/big_band/integration/rake.rb +0 -80
  50. data/lib/big_band/integration/rspec.rb +0 -11
  51. data/lib/big_band/integration/test.rb +0 -42
  52. data/lib/big_band/integration/test/spec.rb +0 -2
  53. data/lib/big_band/integration/test/unit.rb +0 -2
  54. data/lib/big_band/integration/test_spec.rb +0 -8
  55. data/lib/big_band/integration/test_unit.rb +0 -10
  56. data/lib/big_band/integration/yard.rb +0 -104
  57. data/lib/big_band/more_helpers.rb +0 -50
  58. data/lib/big_band/more_server.rb +0 -14
  59. data/lib/big_band/more_server/rainbows.rb +0 -13
  60. data/lib/big_band/more_server/unicorn.rb +0 -27
  61. data/lib/big_band/reloader.rb +0 -113
  62. data/lib/big_band/sass.rb +0 -28
  63. data/lib/big_band/version.rb +0 -3
  64. data/lib/big_band/web_inspector.rb +0 -178
  65. data/lib/big_bang.rb +0 -6
  66. data/lib/sinatra/big_band/advanced_routes.rb +0 -2
  67. data/lib/sinatra/big_band/basic_extensions.rb +0 -2
  68. data/lib/sinatra/big_band/compass.rb +0 -2
  69. data/lib/sinatra/big_band/compass/big_band.rb +0 -2
  70. data/lib/sinatra/big_band/config_file.rb +0 -2
  71. data/lib/sinatra/big_band/integration.rb +0 -2
  72. data/lib/sinatra/big_band/integration/bacon.rb +0 -2
  73. data/lib/sinatra/big_band/integration/monk.rb +0 -2
  74. data/lib/sinatra/big_band/integration/rake.rb +0 -2
  75. data/lib/sinatra/big_band/integration/rspec.rb +0 -2
  76. data/lib/sinatra/big_band/integration/test.rb +0 -2
  77. data/lib/sinatra/big_band/integration/test/spec.rb +0 -2
  78. data/lib/sinatra/big_band/integration/test/unit.rb +0 -2
  79. data/lib/sinatra/big_band/integration/test_spec.rb +0 -2
  80. data/lib/sinatra/big_band/integration/test_unit.rb +0 -2
  81. data/lib/sinatra/big_band/integration/yard.rb +0 -2
  82. data/lib/sinatra/big_band/more_helpers.rb +0 -2
  83. data/lib/sinatra/big_band/more_server.rb +0 -2
  84. data/lib/sinatra/big_band/more_server/rainbows.rb +0 -2
  85. data/lib/sinatra/big_band/more_server/unicorn.rb +0 -2
  86. data/lib/sinatra/big_band/reloader.rb +0 -2
  87. data/lib/sinatra/big_band/sass.rb +0 -2
  88. data/lib/sinatra/big_band/version.rb +0 -2
  89. data/lib/sinatra/big_band/web_inspector.rb +0 -2
  90. data/lib/yard-sinatra.rb +0 -2
  91. data/spec/big_band/advanced_routes_spec.rb +0 -70
  92. data/spec/big_band/basic_extensions_spec.rb +0 -39
  93. data/spec/big_band/more_server_spec.rb +0 -7
  94. data/spec/big_band/sass_spec.rb +0 -21
  95. data/spec/spec.opts +0 -5
  96. data/yard-sinatra.gemspec +0 -24
@@ -1,50 +0,0 @@
1
- require "haml"
2
- require "big_band/integration" unless defined? BigBand # so this is usable without sinatra
3
-
4
- class BigBand < Sinatra::Base
5
-
6
- # Adds more helper methods (more docs coming soon).
7
- module MoreHelpers
8
-
9
- module InstanceMethods
10
- include Haml::Helpers
11
-
12
- def content_for(name, &block)
13
- name = name.to_s
14
- @content_for ||= Hash.new {|h,k| h[k] = [] }
15
- @content_for[name] << block if block
16
- @content_for[name]
17
- end
18
-
19
- def yield_content(name, *args)
20
- haml_helper do
21
- content_for(name).each do |block|
22
- result = block.call(*args)
23
- haml_concat result unless block_is_haml? block
24
- end
25
- end
26
- end
27
-
28
- def get_content(name, *args)
29
- non_haml { yield_content(name, *args) }
30
- end
31
-
32
- private
33
-
34
- # Will make use of capture_haml depending on whether it is called from
35
- # within Haml code or not. Thus helpers may be shared between Haml and
36
- # others (like ERB), but still enjoy all the fancy Haml::Helpers tools.
37
- def haml_helper(&block)
38
- return capture_haml(&block) unless is_haml?
39
- yield
40
- end
41
-
42
- end
43
-
44
- def self.registered(klass)
45
- # Just in case #helpers does more magic some day.
46
- klass.helpers InstanceMethods
47
- end
48
-
49
- end
50
- end
@@ -1,14 +0,0 @@
1
- require "sinatra/base"
2
-
3
- class BigBand < Sinatra::Base
4
- # Adds more servers to Sinatra::Base#run! (currently unicorn and rainbows).
5
- module MoreServer
6
- autoload :Unicorn, "big_band/more_server/unicorn"
7
- autoload :Rainbows, "big_band/more_server/rainbows"
8
- def self.registered(klass)
9
- Rack::Handler.register "unicorn", "BigBand::MoreServer::Unicorn"
10
- Rack::Handler.register "rainbows", "BigBand::MoreServer::Rainbows"
11
- klass.server.unshift "rainbows", "unicorn"
12
- end
13
- end
14
- end
@@ -1,13 +0,0 @@
1
- require "big_band/more_server/unicorn"
2
- require "rainbows"
3
-
4
- class BigBand < Sinatra::Base
5
- module MoreServer
6
- # Rack Handler to use Rainbows for Sinatra::Base.run!
7
- module Rainbows
8
- def self.run(app, options = {})
9
- BigBand::MoreServer::Unicorn.run app, options.merge(:Backend => ::Rainbows)
10
- end
11
- end
12
- end
13
- end
@@ -1,27 +0,0 @@
1
- require "sinatra/base"
2
- require "unicorn"
3
- require "rack/content_length"
4
- require "rack/chunked"
5
-
6
- class BigBand < Sinatra::Base
7
- module MoreServer
8
- # Rack Handler to use Unicorn for Sinatra::Base.run!
9
- module Unicorn
10
- def self.run(app, options={})
11
- app = Rack::Builder.new do
12
- # TODO: env dependend stuff.
13
- use Rack::CommonLogger, $stderr
14
- use Rack::ShowExceptions
15
- run app
16
- end.to_app
17
- options[:Backend] ||= ::Unicorn
18
- options[:Host] ||= ::Unicorn::Const::DEFAULT_HOST
19
- options[:Port] ||= ::Unicorn::Const::DEFAULT_PORT
20
- options[:listeners] = ["#{options.delete :Host}:#{options.delete :Port}"]
21
- server = options.delete(:Backend)::HttpServer.new app, options
22
- yield server if block_given?
23
- server.start.join
24
- end
25
- end
26
- end
27
- end
@@ -1,113 +0,0 @@
1
- require "sinatra/base"
2
- require "big_band/basic_extensions"
3
-
4
- class BigBand < Sinatra::Base
5
-
6
- # Advanced reloader for sinatra. Reloads only files that have changed and automatically
7
- # detects orphaned routes that have to be removed. Files defining routes will be added
8
- # to the reload list per default. Avoid reloading with dont_reload. Add other files to
9
- # the reload list with also_reload.
10
- #
11
- # Usage:
12
- #
13
- # require "big_band"
14
- # class Foo < Sinatra::Base
15
- # configure(:development) do
16
- # register BigBand::Reloader
17
- # also_reload "app/models/*.rb"
18
- # dont_reload "lib/**/*.rb"
19
- # end
20
- # end
21
- #
22
- # Per default this will only be acitvated in development mode.
23
- module Reloader
24
-
25
- class FileWatcher < Array
26
-
27
- attr_reader :file, :mtime
28
-
29
- extend Enumerable
30
- @map ||= {}
31
-
32
- def self.register(route)
33
- new(route.file) << route if route.file?
34
- end
35
-
36
- def self.new(file)
37
- @map[file.expand_path] ||= super(file)
38
- end
39
-
40
- def self.each(&block)
41
- @map.values.each(&block)
42
- end
43
-
44
- def initialize(file)
45
- @reload = true
46
- @file, @mtime = file, File.mtime(file)
47
- super()
48
- end
49
-
50
- def changed?
51
- @mtime != File.mtime(file)
52
- end
53
-
54
- def dont_reload!(dont = true)
55
- @reload = false
56
- end
57
-
58
- def reload?
59
- @reload and changed?
60
- end
61
-
62
- def reload
63
- reload! if reload?
64
- end
65
-
66
- def reload!
67
- puts "reloading #{file}"
68
- each { |route| route.deactivate }
69
- $LOAD_PATH.delete file
70
- $LOAD_PATH.delete file.expand_path
71
- clear
72
- require file
73
- end
74
-
75
- end
76
-
77
- module ClassMethods
78
-
79
- def dont_reload(*files)
80
- files.flatten.each do |file|
81
- FileWatcher.new(file).dont_reload!
82
- end
83
- end
84
-
85
- def also_reload(*files)
86
- files.flatten.each do |file|
87
- FileWatcher.new(file).dont_reload! false
88
- end
89
- end
90
- end
91
-
92
- def self.registered(klass)
93
- klass.register AdvancedRoutes
94
- klass.extend ClassMethods
95
- klass.each_route { |route| advanced_route_added(route) }
96
- klass.before { Reloader.reload_routes }
97
- end
98
-
99
- def self.advanced_route_added(route)
100
- FileWatcher.register(route)
101
- end
102
-
103
- def self.thread_safe?
104
- Thread and Thread.list.size > 1 and Thread.respond_to? :exclusive
105
- end
106
-
107
- def self.reload_routes(thread_safe = true)
108
- return Thread.exclusive { reload_routes(false) } if thread_safe and thread_safe?
109
- FileWatcher.each { |file| file.reload }
110
- end
111
-
112
- end
113
- end
data/lib/big_band/sass.rb DELETED
@@ -1,28 +0,0 @@
1
- require "sass"
2
- require "big_band/integration" unless defined? BigBand # so this is usable without sinatra
3
-
4
- class BigBand < Sinatra::Base
5
-
6
- # BigBand::Sass extends SassScript with more functions like min or max.
7
- #
8
- # Example:
9
- # .someClass
10
- # width = max(!default_width - 10px, 200px)
11
- #
12
- # This can be used without BigBand or even Sinatra.
13
- module Sass
14
- module Functions
15
- ::Sass::Script::Functions.send :include, self
16
-
17
- def min(*args)
18
- args.min { |a, b| a.value <=> b.value }
19
- end
20
-
21
- def max(*args)
22
- args.max { |a, b| a.value <=> b.value }
23
- end
24
-
25
- end
26
- end
27
-
28
- end
@@ -1,3 +0,0 @@
1
- require "big_band/integration" unless defined? BigBand
2
- BigBand::VERSION = "0.2.5"
3
- BigBand::DATE = "2010-01-24"
@@ -1,178 +0,0 @@
1
- require "sinatra/base"
2
- require "monkey-lib"
3
- require "big_band/compass"
4
-
5
- class BigBand < Sinatra::Base
6
-
7
- # The WebInspector allowes you to inspect a running Sinatra app.
8
- # Just browse http://localhost:4567/\_\_inspect\_\_
9
- #
10
- # Per default this will only be activated in development mode.
11
- module WebInspector
12
-
13
- attr_reader :middleware
14
-
15
- class Middleware < Sinatra::Base
16
-
17
- attr_accessor :sinatra_app
18
- use_in_file_templates! __FILE__
19
- register BasicExtensions
20
- set :app_file, __FILE__
21
-
22
- # If this is a git project, then it returns the path to the .git directory.
23
- def git_directory
24
- @git_directory ||= root_glob(".{,.,./..,./../..}/.git").first
25
- end
26
-
27
- # Whether or not this is a git project.
28
- def git?
29
- !!git_directory
30
- end
31
-
32
- # Figures out some URLs to public git hosts by parsing the remote urls from the git config.
33
- # Currently detects: GitHub, Codaset and Gitorious.
34
- def git_remotes
35
- @git_remotes ||= (File.read(git_directory / :config).scan(/\s*url\s*=\s*(.*)\n/).flatten.collect do |url|
36
- case url
37
- when %r{(github.com)[:/](.+)/(.+)/?\.git$} then [$3, "GitHub", "http://#$1/#$2/#$3", "http://#$1"]
38
- when %r{(codaset.com)[:/](.+)/(.+)?\.git$} then [$3, "Codaset", "http://#$1/#$2/#$3", "http://#$1"]
39
- when %r{(gitorious.org)[:/](.+)/.+/?\.git$} then [$2, "Gitorious", "http://#$1/#$2", "http://#$1"]
40
- end
41
- end).compact
42
- end
43
-
44
- # Recent git log.
45
- def git_log
46
- @git_format ||= begin
47
- line = ["<a href='mailto:%ae'>%an</a>", "%s", "<date>%ai</date>"].map { |e| "<td>#{e}</td>" }.join
48
- "<tr>#{line}</tr>"
49
- end
50
- %x[git log -50 --pretty=format:"#{@git_format}"]
51
- end
52
-
53
- # webinspector stylesheet.
54
- get "/__inspect__/screen.css" do
55
- content_type 'text/css', :charset => 'utf-8'
56
- sass :stylesheet, ::Compass.sass_engine_options
57
- end
58
-
59
- # Route for inspection. Currently we display all information on a single page. In case the amount of data
60
- # increases, we might split this on multiple pages. Also, this would ease hooking own data into the front-end.
61
- get "/__inspect__/?" do
62
- ruby_env = %w[RUBY_VERSION RUBY_DESCRIPTION RUBY_PATCHLEVEL RUBY_PLATFORM RUBY_ENGINE RUBY_ENGINE_VERSION]
63
- ruby_env.map! { |var| [var, eval("#{var}.inspect if defined? #{var}")] }
64
- haml :inspect, {}, :ruby_env => ruby_env
65
- end
66
-
67
- end
68
-
69
- def self.registered(klass)
70
- klass.register BasicExtensions
71
- klass.register AdvancedRoutes
72
- klass.use(Middleware) { |m| m.sinatra_app = klass }
73
- end
74
-
75
- end
76
- end
77
-
78
- __END__
79
-
80
- @@layout
81
- !!!
82
- %html
83
- %head
84
- %meta{:charset=>"utf-8"}/
85
- %link{:rel => "stylesheet", :href => "/__inspect__/screen.css", :type => "text/css"}/
86
- %title= "#{sinatra_app.name}.inspect"
87
- %body
88
- %header
89
- %h1= "#{sinatra_app.name}.inspect"
90
- Generated on
91
- %date= Time.now
92
- %nav
93
- %a{:href => "/__inspect__/#routes" } Routes
94
- %a{:href => "/__inspect__/#extensions" } Extensions
95
- %a{:href => "/__inspect__/#middleware" } Middleware
96
- %a{:href => "/__inspect__/#system" } System
97
- - if git?
98
- %a{:href => "/__inspect__/#git_log" } Git Log
99
- %article
100
- !=yield
101
- %footer
102
- powered by
103
- %a{:href => "http://www.sinatrarb.com"} Sinatra
104
- and
105
- %a{:href => "http://github.com/rkh/big_band"} BigBand
106
-
107
- @@stylesheet
108
- @import big_band/layouts/inspector.sass
109
- +layout_inspector
110
-
111
- @@inspect
112
-
113
- %a{ :name => "routes" }
114
- %h2 Routes
115
- %table
116
- %tr
117
- %th Verb
118
- %th Pattern
119
- %th File
120
- %th Keys
121
- %th Conditions
122
- - sinatra_app.each_route do |route|
123
- %tr
124
- %td= route.verb
125
- %td= route.pattern.inspect
126
- %td
127
- - if route.file?
128
- = route.file
129
- %i= "(line #{route.line})" if route.line
130
- %td= route.keys.map { |e| e.inspect }.join ", "
131
- %td= route.conditions.map { |e| e.inspect }.join ", "
132
-
133
- %a{ :name => "extensions" }
134
- %h2 Extensions
135
- %table
136
- %tr
137
- %th Extension
138
- %th Status
139
- - sinatra_app.extensions.each do |extension|
140
- %tr
141
- %td= extension.name
142
- %td= extension.status if extension.respond_to? :status
143
-
144
- %a{ :name => "middleware" }
145
- %h2 Middleware
146
- %table
147
- %tr
148
- %th Middleware
149
- %th Arguments
150
- %th Block Given
151
- - sinatra_app.middleware.each do |name, arguments, block|
152
- %tr
153
- %td= name
154
- %td= arguments.map { |e| e.inspect }.join ", "
155
- %td= block ? "yes" : "no"
156
-
157
- %a{ :name => "system" }
158
- %h2 System
159
- %table
160
- %tr
161
- %th Variable
162
- %th Value
163
- - ruby_env.each do |key, value|
164
- %tr
165
- %td= key
166
- %td= value
167
-
168
- - if git?
169
- %a{ :name => "git_log" }
170
- %h2 Recent Git Log
171
- - git_remotes.each do |name, service, url, service_url|
172
- .note Visit <a href="#{url}">#{name}</a> on <a href="#{service_url}">#{service}</a>.
173
- %table
174
- %tr
175
- %th Author
176
- %th Subject
177
- %th Date
178
- != git_log
data/lib/big_bang.rb DELETED
@@ -1,6 +0,0 @@
1
- require "big_band"
2
-
3
- unless defined? BigBang
4
- warn "It is called BigBand, not BigBang!"
5
- BigBang = BigBand
6
- end
@@ -1,2 +0,0 @@
1
- # Generated file, run 'rake dummy_files' to regenerate
2
- require "big_band/advanced_routes"