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
data/depgen/depgen.rb DELETED
@@ -1,123 +0,0 @@
1
- require "fileutils"
2
-
3
- class Depgen
4
-
5
- SETUP_TOOLS = [:bundler, :gem, :monk, :rip, :vendor]
6
-
7
- class << self
8
- include Enumerable
9
- attr_reader :all, :option_stack
10
-
11
- def default_options
12
- @option_stack.inject({}) { |a, b| a.merge b }
13
- end
14
-
15
- def each(&block)
16
- all.values.each(&block)
17
- end
18
-
19
- def github(user, project = nil, options = {}, &block)
20
- raise "cannot call github within #{@wrapper}" if @wrapper and @wrapper != :github
21
- project ||= {}
22
- if block
23
- @user, @wrapper, wrapper_was, user_was = user, :github, @wrapper, @user
24
- result = with_options(options.merge(project), &block)
25
- @user, @wrapper = user_was, wrapper_was
26
- elsif @wrapper
27
- wrapper_was, @wrapper = @wrapper, nil
28
- result = send :github, @user, user, options.merge(project)
29
- @wrapper = wrapper_was
30
- else
31
- raise ArgumentError, "no project given" if project.nil? or project.is_a? Hash
32
- result = new project, options.merge(:git => "git://github.com/#{user}/#{project}.git")
33
- end
34
- result
35
- end
36
-
37
- def inherited(klass)
38
- super
39
- klass.set_defaults
40
- end
41
-
42
- def new(name, options = {})
43
- return send(@wrapper, name, options) if @wrapper
44
- result = (all[name] ||= super()).apply default_options.merge(options).merge(:name => name)
45
- yield result if block_given?
46
- @stack << result if @stack
47
- result
48
- end
49
-
50
- alias add new
51
- alias [] new
52
-
53
- def set_defaults
54
- @all ||= {}
55
- @option_stack ||= []
56
- end
57
-
58
- def with_options(options = {})
59
- @stack, stack_was = [], @stack
60
- @option_stack.push options
61
- yield(self)
62
- @stack, result = stack_was, @stack
63
- @stack.push(*result) if @stack
64
- @option_stack.pop
65
- result
66
- end
67
-
68
- SETUP_TOOLS.each do |tool|
69
- eval "def setup_#{tool}(*args); each { |e| e.setup_#{tool}(*args) if e.only.include? #{tool.inspect} }; end"
70
- end
71
- end
72
-
73
- set_defaults
74
- attr_accessor :name, :git, :version, :git_ref, :gem_comp, :only
75
-
76
- def apply(options = {})
77
- options.each { |k,v| send "#{k}=", v }
78
- self
79
- end
80
-
81
- def git_ref
82
- version ? @git_ref % version : "HEAD"
83
- end
84
-
85
- def initialize
86
- super
87
- apply :git_ref => "%s", :only => SETUP_TOOLS, :gem_comp => ">="
88
- end
89
-
90
- def only
91
- [@only].flatten
92
- end
93
-
94
- def setup_bundler(bundler, options = {})
95
- bundler.gem(name, version, {:git => git, :ref => git_ref, :require_as => nil}.merge(options))
96
- end
97
-
98
- def setup_gem(spec)
99
- spec.add_dependency name, "#{gem_comp} #{version}"
100
- end
101
-
102
- def setup_monk(output)
103
- output.puts [name, gem_comp, version, git].compact.join(" ")
104
- end
105
-
106
- def setup_rip(output)
107
- output.puts "#{git} #{git_ref}"
108
- end
109
-
110
- def setup_vendor(dir = "vendor", verbose = true, &run_cmd)
111
- util = verbose ? FileUtils::Verbose : FileUtils
112
- run_cmd ||= proc { |cmd| exit 1 unless system cmd }
113
- util.mkdir_p dir
114
- util.chdir(dir) do
115
- run_cmd["git clone #{git} #{name}"] unless File.exist? name
116
- util.chdir(name) do
117
- run_cmd["git checkout master && git pull"]
118
- run_cmd["git checkout #{git_ref}"]
119
- end
120
- end
121
- end
122
-
123
- end
data/depgen/depgen.task DELETED
@@ -1,42 +0,0 @@
1
- DEP_FILE = ENV["DEP_FILE"] || "dependencies.rb" unless defined? DEP_FILE
2
- DEP_CLASS = ENV["DEP_CLASS"] || "Dependencies" unless defined? DEP_CLASS
3
-
4
- unless File.exist? DEP_FILE
5
- File.open(DEP_FILE, "w") do |f|
6
- f.puts 'require "depgen/depgen"', "class #{DEP_CLASS} < Depgen", "end"
7
- end
8
- end
9
-
10
- def dep_generate(name, file, &block)
11
- desc "generate #{name} configuration"
12
- task(name) { File.open(file, "w", &block)}
13
- end
14
-
15
- load DEP_FILE
16
- DEPENDENCIES = Object.const_get DEP_CLASS
17
-
18
- namespace :dependencies do
19
-
20
- namespace :vendor do
21
- desc "unpack all dependencies in vendor/"
22
- task(:all) { DEPENDENCIES.setup_vendor { |cmd| sh cmd } }
23
- DEPENDENCIES.each do |dep|
24
- desc "unpack #{dep.name} #{dep.version} in vendor/#{dep.name}/"
25
- task(dep.name) { dep.setup_vendor { |cmd| sh cmd } }
26
- end
27
- end
28
-
29
- namespace :generate do
30
- dep_generate(:rip, "deps.rip") { |f| DEPENDENCIES.setup_rip(f) }
31
- dep_generate(:bundler, "Gemfile") { |f| f.puts "load #{DEP_FILE.inspect}", "#{DEP_CLASS}.setup_bunlder(self)" }
32
- dep_generate(:monk, "dependencies") {|f| DEPENDENCIES.setup_rip(f) }
33
- end
34
-
35
- desc "list all dependencies"
36
- task :list do
37
- DEPENDENCIES.each do |dep|
38
- puts "#{dep.name} #{dep.version}"
39
- end
40
- end
41
-
42
- end
@@ -1,127 +0,0 @@
1
- require "depgen"
2
- require "fileutils"
3
- include FileUtils
4
-
5
-
6
- TEMP_DIR = File.join File.dirname(__FILE__), "tmp"
7
- TEMP_DIR.replace SPEC_TEMP_DIR if defined? SPEC_TEMP_DIR and SPEC_TEMP_DIR
8
- mkdir_p TEMP_DIR
9
-
10
- describe Depgen do
11
-
12
- def depgen(&block)
13
- Class.new(Depgen, &block)
14
- end
15
-
16
- before { @dep = depgen }
17
-
18
- describe :default_options do
19
-
20
- it "is empty per default" do
21
- @dep.default_options.should be_empty
22
- end
23
-
24
- it "contains elements from the option stack" do
25
- @dep.option_stack.push :foo => 10, :bar => 23
26
- @dep.default_options[:foo].should == 10
27
- @dep.option_stack.push :foo => 42
28
- @dep.default_options[:foo].should == 42
29
- @dep.default_options[:bar].should == 23
30
- @dep.option_stack.pop
31
- @dep.default_options[:foo].should == 10
32
- end
33
-
34
- end
35
-
36
- describe :each do
37
-
38
- before do
39
- @foo = @dep.add "foo"
40
- @bar = depgen.add "bar"
41
- end
42
-
43
- it "yields through directly created dependencies" do
44
- @dep.each { |d| d.should == @foo }
45
- end
46
-
47
- it "yields not through dependencies from other subclasses" do
48
- @dep.each { |d| d.should != @foo }
49
- end
50
-
51
- end
52
-
53
- describe :github do
54
-
55
- it "sets up git url correctly" do
56
- @dep.github("rkh", "depgen").git.should == "git://github.com/rkh/depgen.git"
57
- end
58
-
59
- it "takes a block so you don't have to repeat yourself" do
60
- @dep.github("rkh") do |d|
61
- d.add("depgen").git.should == "git://github.com/rkh/depgen.git"
62
- d.add("big_band").git.should == "git://github.com/rkh/big_band.git"
63
- end
64
- end
65
-
66
- end
67
-
68
- describe "#git_ref" do
69
-
70
- it "equals version per default" do
71
- @dep.add("foo", :version => "bar").git_ref == "bar"
72
- end
73
-
74
- it "subistutes %s with version" do
75
- @dep.add("foo", :version => "bar", :git_ref => "foo%sbaz").git_ref == "foobarbaz"
76
- end
77
-
78
- end
79
-
80
- describe "#setup_bundler" do
81
- it "uses Bundler's gem to set up dependencies" do
82
- @dep.add "foo", :version => "1.0", :git => "bar"
83
- bundler = mock("bundler")
84
- bundler.should_receive(:gem).once.with "foo", "1.0", hash_including(:git => "bar", :require_as => nil, :foo => :bar)
85
- @dep.setup_bundler bundler, :foo => :bar
86
- end
87
- end
88
-
89
- describe "#setup_gem" do
90
- it "uses gemspec method add_dependency" do
91
- @dep.add "foo", :version => "1.0", :gem_comp => ">="
92
- gemspec = mock("gemspec")
93
- gemspec.should_receive(:add_dependency).once.with "foo", ">= 1.0"
94
- @dep.setup_gem gemspec
95
- end
96
- end
97
-
98
- describe "#setup_monk" do
99
- it "produces valid lines" do
100
- @dep.add "foo", :version => "1.0", :git => "bar", :gem_comp => ">="
101
- out = StringIO.new
102
- @dep.setup_monk out
103
- out.rewind
104
- out.read.should == "foo >= 1.0 bar\n"
105
- end
106
- end
107
-
108
- describe "#setup_rip" do
109
- it "produces valid lines" do
110
- @dep.add "foo", :version => "1.0", :git => "bar", :gem_comp => ">="
111
- out = StringIO.new
112
- @dep.setup_rip out
113
- out.rewind
114
- out.read.should == "bar 1.0\n"
115
- end
116
- end
117
-
118
- describe "#setup_vendor" do
119
- it "populates the given vendor directory" do
120
- @dep.github "rkh", "big_band", :git_ref => "HEAD"
121
- @dep.setup_vendor "#{TEMP_DIR}/vendor"
122
- File.directory?("#{TEMP_DIR}/vendor/big_band").should be_true
123
- rm_rf "#{TEMP_DIR}/vendor"
124
- end
125
- end
126
-
127
- end
data/deps.rip DELETED
@@ -1,8 +0,0 @@
1
- git://github.com/chriseppstein/compass.git v0.8.17
2
- git://github.com/nex3/haml.git 2.2.17
3
- git://github.com/lsegal/yard.git 0.5.2
4
- git://github.com/dchelimsky/rspec.git 1.3.0
5
- git://github.com/rkh/monkey-lib.git v0.3.5
6
- git://github.com/rack/rack.git 1.0.1
7
- git://github.com/sinatra/sinatra.git 0.9.4
8
- git://github.com/brynary/rack-test.git v0.5.3
data/example/example.rb DELETED
@@ -1,13 +0,0 @@
1
- $LOAD_PATH.unshift(File.expand_path(__FILE__ + "/../../lib"), *Dir.glob(File.expand_path(__FILE__ + "/../../vendor/*/lib")))
2
- require "big_band"
3
-
4
- class Example < BigBand
5
-
6
- # The index page. You should see this comment in YARD.
7
- get "/" do
8
- haml :index
9
- end
10
-
11
- run! if run?
12
-
13
- end
@@ -1,8 +0,0 @@
1
- index page
2
- %a{:href => "/", :class => "fancy-button1"} fancy
3
- %a{:href => "/", :class => "fancy-button2"} fancy
4
- %a{:href => "/", :class => "fancy-button3"} fancy
5
- %a{:href => "/", :class => "fancy-button4"} fancy
6
- %a{:href => "/", :class => "fancy-button5"} fancy
7
- %a{:href => "/", :class => "fancy-button6"} fancy
8
- %a{:href => "/", :class => "fancy-button7"} fancy
@@ -1,2 +0,0 @@
1
- %link{:rel => "stylesheet", :href => "/stylesheets/screen.css", :type => "text/css"}/
2
- !=yield
@@ -1 +0,0 @@
1
- @import big_band.sass
@@ -1,12 +0,0 @@
1
- @import base.sass
2
-
3
- body
4
- padding: 1em
5
- background-color: #eee
6
-
7
- @for !i from 1 through 7
8
- a.fancy-button#{!i}
9
- +fancy-button-link(#800, 10px + 10px * !i)
10
-
11
- =attr(!name, !value)
12
- #{!name} = !value
@@ -1,188 +0,0 @@
1
- require "sinatra/base"
2
-
3
- class BigBand < Sinatra::Base
4
-
5
- # AdvancedRoutes makes routes first class objects in Sinatra:
6
- #
7
- # require "sinatra"
8
- # require "big_band"
9
- #
10
- # admin_route = get "/admin" do
11
- # administrate_stuff
12
- # end
13
- #
14
- # before do
15
- # # Let's deactivate the route if we have no password file.
16
- # if File.exists? "admin_password"
17
- # admin_route.activate
18
- # else
19
- # admin_route.deactivate
20
- # end
21
- # end
22
- #
23
- # first_route = get "/:name" do
24
- # # stuff
25
- # end
26
- #
27
- # other_route = get "/foo_:name" do
28
- # # other stuff
29
- # end
30
- #
31
- # # Unfortunatly first_route will catch all the requests other_route would
32
- # # have gotten, since it has been defined first. But wait, we can fix this!
33
- # other_route.promote
34
- module AdvancedRoutes
35
-
36
- module ArrayMethods
37
- ::Array.send :include, self
38
-
39
- def to_route(verb, args = {})
40
- dup.to_route! verb, args
41
- end
42
-
43
- def to_route!(verb, args = {})
44
- extend BigBand::AdvancedRoutes::Route
45
- self.verb = verb
46
- args.each do |key, value|
47
- send "#{key}=", value
48
- end
49
- self
50
- end
51
-
52
- def signature
53
- self
54
- end
55
-
56
- end
57
-
58
- module Route
59
-
60
- def self.new(verb, args = {})
61
- [].to_route! verb, args
62
- end
63
-
64
- attr_accessor :app, :verb, :file, :line, :path, :docstring
65
-
66
- def pattern; self[0]; end
67
- def keys; self[1]; end
68
- def conditions; self[2]; end
69
- def block; self[3]; end
70
- alias to_proc block
71
-
72
- def pattern=(value); self[0] = value; end
73
- def keys=(value); self[1] = value; end
74
- def conditions=(value); self[2] = value; end
75
- def block=(value); self[3] = value; end
76
-
77
- def signature
78
- [pattern, keys, conditions, block]
79
- end
80
-
81
- def active?
82
- app.routes[verb].include? self
83
- end
84
-
85
- def activate(at_top = false)
86
- also_change.each { |r| r.activate }
87
- return if active?
88
- meth = at_top ? :unshift : :push
89
- (app.routes[verb] ||= []).send(meth, self)
90
- invoke_hook :route_added, verb, path, block
91
- invoke_hook :advanced_root_activated, self
92
- self
93
- end
94
-
95
- def deactivate
96
- also_change.each { |r| r.deactivate }
97
- return unless active?
98
- (app.routes[verb] ||= []).delete(signature)
99
- invoke_hook :route_removed, verb, path, block
100
- invoke_hook :advanced_root_deactivated, self
101
- self
102
- end
103
-
104
- def promote(upwards = true)
105
- also_change.each { |r| r.promote(upwards) }
106
- deactivate
107
- activate(upwards)
108
- end
109
-
110
- def file?
111
- !!@file
112
- end
113
-
114
- def inspect
115
- "#<BigBand::AdvancedRoutes::Route #{ivar_inspect.join ", "}>"
116
- end
117
-
118
- def to_route(verb, args = {})
119
- args = args.dup
120
- [:app, :verb, :file, :line, :path].each { |key| args[key] ||= send(key) }
121
- super(verb, args)
122
- end
123
-
124
- def also_change(*other_routes)
125
- (@also_change ||= []).push(*other_routes)
126
- end
127
-
128
- private
129
-
130
- def ivar_inspect
131
- [:signature, :verb, :app, :file, :line].map do |var|
132
- value = send(var)
133
- "@#{var}=#{value.inspect}" unless value.nil?
134
- end.compact
135
- end
136
-
137
- def invoke_hook(*args)
138
- app.send(:invoke_hook, *args)
139
- end
140
-
141
- end
142
-
143
- module ClassMethods
144
-
145
- def get(path, opts={}, &block)
146
- first_route, *other_routes = capture_routes { super }
147
- first_route.also_change(*other_routes)
148
- first_route
149
- end
150
-
151
- def route(verb, path, options={}, &block)
152
- file, line = block.source_location if block.respond_to? :source_location
153
- file ||= caller_files.first
154
- route = super(verb, path, options, &block)
155
- route.to_route! verb, :app => self, :file => file.expand_path, :line => line, :path => path
156
- invoke_hook :advanced_root_added, route
157
- @capture_routes << route if @capture_routes
158
- route
159
- end
160
-
161
- def each_route(&block)
162
- return enum_for(:each_route) if respond_to? :enum_for and not block
163
- routes.inject([]) { |result, (verb, list)| result.push *list.each(&block) }
164
- end
165
-
166
- private
167
-
168
- def capture_routes
169
- capture_routes_was, @capture_routes = @capture_routes, []
170
- yield
171
- captured, @capture_routes = @capture_routes, capture_routes_was
172
- captured
173
- end
174
-
175
- end
176
-
177
- def self.registered(klass)
178
- klass.extend ClassMethods
179
- klass.routes.each do |verb, routes|
180
- routes.each do |route|
181
- route.to_route! verb, :app => klass
182
- klass.send :invoke_hook, :advanced_root_added, route
183
- end
184
- end
185
- end
186
-
187
- end
188
- end