embargo 0.3.6 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d25b9c0620ef0ef5d9fdd24cf0e3fc066f14e715
4
- data.tar.gz: 94dde09b12bdff0b649279f4d7832216dba645a7
3
+ metadata.gz: 615332e4a7a1dbdc6708665bd7d7b1063ddaf420
4
+ data.tar.gz: 479032e9796ca794708268d556b1bc612483be44
5
5
  SHA512:
6
- metadata.gz: d647d3e7dae981153951e4d6d121da77ffc8239140531b913c101cf6dda595d4e538c8f3b8ada117affe30461fdcb9be258964c523ad79765af2a7ecae902097
7
- data.tar.gz: bac29f7d83c7878f5079e2cc8260de5b091c9aac73921dd00abcc1f94a844056d02745bcdd7e49b855a723e1b497cb8c8fc87fb61b74d48df82cab33d8fcbbdd
6
+ metadata.gz: 5b11b64e94982083fb234908ce29c9e93dd27c9b1517581315603a8793f97d1bc4c7931a9e1596b978f2f24616afbfbbf12c8c68bd98d7532b36a5173df6cb00
7
+ data.tar.gz: 4843155d2ef310ae821c71de6e19f03156971e17a9f227d35efc99a4147e76b8ab4c0cf5a64798994a1697d469673fa64a6d6d24459e3f1997eba36cc1dc8fbb
@@ -0,0 +1,7 @@
1
+ class ApiController < Embargo
2
+
3
+ on get do
4
+ res.write("The API Embargo is on!")
5
+ end
6
+
7
+ end
@@ -0,0 +1,18 @@
1
+ # This is the main cntroller for your application. This file must be in your project. You can
2
+ # include other controllers by following the example below for `/api`
3
+
4
+ class ApplicationController < Embargo
5
+ define do
6
+ on "api" do
7
+ run ApiController
8
+ end
9
+
10
+ on root do
11
+ res.write(MyModel.find.my_item)
12
+ end
13
+
14
+ on default do
15
+ render "index", body_class: "page-index", page: "index"
16
+ end
17
+ end
18
+ end
@@ -2,6 +2,6 @@ require 'ostruct'
2
2
 
3
3
  class MyModel
4
4
  def self.find
5
- OpenStruct.new(my_item: "Hello world!")
5
+ OpenStruct.new(my_item: "The Embargo is on!")
6
6
  end
7
7
  end
@@ -1,3 +1,3 @@
1
1
  require "embargo"
2
2
 
3
- run Embargo.application
3
+ run Embargo
data/lib/embargo.rb CHANGED
@@ -13,102 +13,52 @@ Cuba.plugin(Cuba::Render)
13
13
  Cuba.use Rack::Session::Cookie, :secret => "__a_very_long_string__"
14
14
  Cuba.use Rack::Protection
15
15
 
16
- class Embargo
17
- def self.application
18
- Pages
19
- end
20
- def self.app_directory
21
- @@magis_working_directory ||= Dir.pwd
22
- end
16
+ Dir[__FILE__+"/lib/helpers/*.rb"].each {|file| require file }
23
17
 
24
- def self.directory
25
- @@magis_directory ||= __FILE__
26
- end
18
+ class Embargo < Cuba
19
+ def content_for(key, &block)
20
+ if block
21
+ @_content_for ||= {}
22
+ buf_was = @haml_buffer.buffer
23
+ @haml_buffer.buffer = ''
24
+ yield
25
+ @_content_for[key] = @haml_buffer.buffer
26
+ @haml_buffer.buffer = buf_was
27
+ elsif @_content_for
28
+ @_content_for[key]
29
+ end
30
+ end
31
+
32
+ def self.app_directory
33
+ @@app_directory ||= Dir.pwd
34
+ end
27
35
 
28
- def self.require_file(file_name)
29
- project_file_name = Embargo.app_directory + "/" + file_name
30
- project_file_exists = File.exist?(project_file_name)
36
+ def self.require_file(file_name)
37
+ project_file_name = Embargo.app_directory + "/" + file_name
38
+ project_file_exists = File.exist?(project_file_name)
31
39
 
32
40
  if project_file_exists
33
41
  require project_file_name
34
42
  else
35
- embargo_file_name = Embargo.directory + "/" + file_name
36
- embargo_file_exists = File.exist?(embargo_file_name)
43
+ embargo_file_name = Embargo.directory + "/" + file_name
44
+ embargo_file_exists = File.exist?(embargo_file_name)
37
45
  if embargo_file_exists
38
46
  require embargo_file_name
39
47
  end
40
- end
41
- end
42
-
43
- def self.action(&block)
44
- @@actions ||= Array.new
45
- @@actions.push(block)
46
- end
47
- def self.actions
48
- $actions ||= @@actions
49
- end
50
- def self.first_load?
51
- !$actions
52
- end
53
- end
54
-
55
- #################
56
- # Content For
57
- #################
58
- class Cuba
59
- module Render
60
- def content_for(key, &block)
61
- if block
62
- @_content_for ||= {}
63
- buf_was = @haml_buffer.buffer
64
- @haml_buffer.buffer = ''
65
- yield
66
- @_content_for[key] = @haml_buffer.buffer
67
- @haml_buffer.buffer = buf_was
68
- elsif @_content_for
69
- @_content_for[key]
70
- end
71
48
  end
72
49
  end
73
50
  end
74
51
 
75
- #################
76
- # Blank
77
- #################
78
- class Object
79
- def blank?
80
- respond_to?(:empty?) ? !!empty? : !self
81
- end
82
- end
83
-
84
- #################
85
- # Humanize
86
- #################
87
- class String
88
- def humanize
89
- sub(/\A_+/, '')
90
- .tr('_', ' ')
91
- .sub(/\A\w/) { |match| match.upcase }
92
- end
93
- end
94
-
95
- class Symbol
96
- def humanize
97
- to_s.humanize
98
- end
99
- end
100
-
101
- class Api < Cuba; end
102
- class Pages < Cuba; end
103
-
104
- #################
105
- # Project Files
106
- #################
107
52
  Embargo.require_file("config/app.rb")
108
53
  Dir[Embargo.app_directory+"/lib/*.rb"].each {|file| require file }
109
54
  Dir[Embargo.app_directory+"/config/initializers/*.rb"].each {|file| require file }
110
55
  Dir[Embargo.app_directory+"/app/models/*.rb"].each {|file| require file }
111
56
  Dir[Embargo.app_directory+"/app/serializers/*.rb"].each {|file| require file }
112
- Embargo.require_file("app/pages_controller.rb")
113
- Embargo.require_file("app/api_controller.rb")
114
- Embargo.require_file("app/pages_controller.rb")
57
+ Dir[Embargo.app_directory+"/app/controllers/*_controller.rb"].each {|file| require file }
58
+ Dir[Embargo.app_directory+"/app/controllers/**/*_controller.rb"].each {|file| require file }
59
+
60
+ Embargo.define do
61
+ on default do
62
+ run ApplicationController
63
+ end
64
+ end
@@ -0,0 +1,25 @@
1
+ #################
2
+ # Blank
3
+ #################
4
+ class Object
5
+ def blank?
6
+ respond_to?(:empty?) ? !!empty? : !self
7
+ end
8
+ end
9
+
10
+ #################
11
+ # Humanize
12
+ #################
13
+ class String
14
+ def humanize
15
+ sub(/\A_+/, '')
16
+ .tr('_', ' ')
17
+ .sub(/\A\w/) { |match| match.upcase }
18
+ end
19
+ end
20
+
21
+ class Symbol
22
+ def humanize
23
+ to_s.humanize
24
+ end
25
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: embargo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.6
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Fleming
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2014-12-29 00:00:00.000000000 Z
13
+ date: 2015-01-09 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: cuba
@@ -226,7 +226,6 @@ files:
226
226
  - boilerplate/project/Procfile
227
227
  - boilerplate/project/Procfile.prod
228
228
  - boilerplate/project/README.md
229
- - boilerplate/project/app/api_controller.rb
230
229
  - boilerplate/project/app/assets/gulpfile.js
231
230
  - boilerplate/project/app/assets/package.json
232
231
  - boilerplate/project/app/assets/src/apple-touch-icon-precomposed.png
@@ -234,8 +233,9 @@ files:
234
233
  - boilerplate/project/app/assets/src/favicon.ico
235
234
  - boilerplate/project/app/assets/src/humans.txt
236
235
  - boilerplate/project/app/assets/src/robots.txt
236
+ - boilerplate/project/app/controllers/api_controller.rb
237
+ - boilerplate/project/app/controllers/application_controller.rb
237
238
  - boilerplate/project/app/models/my_model.rb
238
- - boilerplate/project/app/pages_controller.rb
239
239
  - boilerplate/project/app/views/index.haml
240
240
  - boilerplate/project/app/views/layout.haml
241
241
  - boilerplate/project/app/views/partials/_footer.haml
@@ -245,8 +245,8 @@ files:
245
245
  - lib/config/environments/development.rb
246
246
  - lib/config/init.rb
247
247
  - lib/config/unicorn.rb
248
- - lib/content_for.rb
249
248
  - lib/embargo.rb
249
+ - lib/helpers/ruby_ext.rb
250
250
  homepage: https://rubygems.org/gems/embargo
251
251
  licenses:
252
252
  - MIT
@@ -1,10 +0,0 @@
1
- Cuba.define do
2
- on get do
3
- on root do
4
- res.write(MyModel.find.my_item)
5
- end
6
- on "home" do
7
- render "index", body_class: "page-index", page: "index"
8
- end
9
- end
10
- end
@@ -1,13 +0,0 @@
1
- Pages.define do
2
- on get do
3
- on root do
4
- res.write(MyModel.find.my_item)
5
- end
6
- on "home" do
7
- render "index", body_class: "page-index", page: "index"
8
- end
9
- end
10
- on "api" do
11
- run Api
12
- end
13
- end
data/lib/content_for.rb DELETED
@@ -1 +0,0 @@
1
-