bang-bang 0.1.6 → 0.2.0
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/Gemfile.lock +1 -1
- data/README.markdown +6 -6
- data/lib/bang-bang/controller.rb +2 -15
- data/lib/bang-bang/version.rb +1 -1
- data/lib/bang-bang.rb +3 -8
- data/spec/fixture-app/app.rb +1 -1
- metadata +1 -1
data/Gemfile.lock
CHANGED
data/README.markdown
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
#
|
|
1
|
+
# BangBang
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
BangBang is a lightweight Sinatra web VC stack. Currently, it doesn't have strong opinions, to allow flexibility to discover good idioms.
|
|
4
4
|
|
|
5
5
|
## Basic Layout
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
BangBang has a basic app structure, similar to Rails.
|
|
8
8
|
Right now, no conventions are "forced" on you. This is done to allow experimentation and keep things lightweight.
|
|
9
9
|
|
|
10
10
|
You pick the model library.
|
|
11
11
|
|
|
12
12
|
Right now there are no generators.
|
|
13
13
|
|
|
14
|
-
###
|
|
14
|
+
### BangBang::Controller
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
BangBang::Controller is a subclass of Sinatra::Base.
|
|
17
17
|
It's meant to provide an encapsulated unit of functionality within your app.
|
|
18
18
|
How you group your actions is up to you.
|
|
19
19
|
|
|
20
20
|
### NamedRoutes
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
BangBang uses the [named-routes](https://github.com/btakita/named-routes) library.
|
|
23
23
|
|
|
24
24
|
Here is a good pattern to follow:
|
|
25
25
|
|
data/lib/bang-bang/controller.rb
CHANGED
|
@@ -5,21 +5,8 @@ module BangBang
|
|
|
5
5
|
|
|
6
6
|
class_inheritable_accessor :config
|
|
7
7
|
extend(Module.new do
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def views_class
|
|
13
|
-
config.views_class
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def path(*args, &block)
|
|
17
|
-
uris.path(*args, &block)
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def services
|
|
21
|
-
config.services
|
|
22
|
-
end
|
|
8
|
+
delegate :uris, :views_class, :services, :to => :config
|
|
9
|
+
delegate :path, :to => :uris
|
|
23
10
|
end)
|
|
24
11
|
|
|
25
12
|
TEMPLATE_TYPE_NAME = "Template"
|
data/lib/bang-bang/version.rb
CHANGED
data/lib/bang-bang.rb
CHANGED
|
@@ -18,27 +18,22 @@ module BangBang
|
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
module ClassMethods
|
|
21
|
-
attr_accessor :
|
|
21
|
+
attr_accessor :application_name, :named_routes, :stderr_dir, :stdout_dir, :root_dir, :views_class
|
|
22
22
|
alias_method :uris, :named_routes
|
|
23
|
-
delegate :define_routes, :to => :controller
|
|
24
23
|
|
|
25
24
|
include ::BangBang::EnvMethods
|
|
26
25
|
|
|
27
26
|
def init(params={})
|
|
28
|
-
self.controller = params[:controller] || raise(ArgumentError, "You must provide an :controller param")
|
|
29
27
|
self.application_name = params[:application_name] || raise(ArgumentError, "You must provide an :application_name param")
|
|
30
28
|
self.root_dir = params[:root_dir] || raise(ArgumentError, "You must provide a :root_dir param")
|
|
31
29
|
self.named_routes = params[:named_routes] || raise(ArgumentError, "You must provide a :named_routes param")
|
|
32
30
|
self.views_class = params[:views_class] || raise(ArgumentError, "You must provide a :views_class param")
|
|
33
|
-
self.controller.config = self
|
|
34
31
|
|
|
35
32
|
plugins.init
|
|
36
33
|
end
|
|
37
34
|
|
|
38
|
-
def
|
|
39
|
-
|
|
40
|
-
run controller
|
|
41
|
-
end.to_app
|
|
35
|
+
def register_controller(controller)
|
|
36
|
+
controller.config = self
|
|
42
37
|
end
|
|
43
38
|
|
|
44
39
|
def register_service(path, &block)
|
data/spec/fixture-app/app.rb
CHANGED
|
@@ -11,6 +11,7 @@ module FixtureApp
|
|
|
11
11
|
class Controller < ::BangBang::Controller
|
|
12
12
|
set :dump_errors, false
|
|
13
13
|
end
|
|
14
|
+
register_controller Controller
|
|
14
15
|
|
|
15
16
|
class Views < ::BangBang::Views
|
|
16
17
|
end
|
|
@@ -20,7 +21,6 @@ module FixtureApp
|
|
|
20
21
|
end
|
|
21
22
|
|
|
22
23
|
FixtureApp.init(
|
|
23
|
-
:controller => FixtureApp::Controller,
|
|
24
24
|
:application_name => "fixture-app",
|
|
25
25
|
:root_dir => File.dirname(__FILE__),
|
|
26
26
|
:named_routes => FixtureApp::Routes,
|