actionframework 0.2 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MzkzOWM1OTQ5NzU1MTNkZjczYzk0OTYyY2E1Y2NmOGVlZTJjYTgwYg==
4
+ MWFhZWM0YWE5ZGNiNGZmOTliMjFhNWY2NjUzNWJmMGE2NzRjNzRmNA==
5
5
  data.tar.gz: !binary |-
6
- ZWIyOWE3ZjIxMjg2NGMyNDgyYTkwMDE4YmI1ZGZiNmE5MWIyOTY2Nw==
6
+ NDFjZDIwYTFlMWQxNGFiYjAyOWI2MzlhMjJlZDZjZGFkMzU2YWYxMQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZWE5YmRhODNkNjQ2ZjM2MGYwNDJkMWQ4Yzc3YTk5MTAzODM1ZTkxZmZhZTFj
10
- ZDBiOGQ3YTg5M2VjYzJiMzQzM2IzNmY4N2UxMGFmNzRlOWMwNGRkN2JhMTZj
11
- NzAwNGU0ODIzNTA1MTgyODVjYzkxZWY1NGYwOGM3OWNhZDUxZmU=
9
+ NjkyNTlkODJkZDI3MmIyN2IyMTAxNTg5MTlmMTk4ZmQwMDIwZmJmYzA0NjNk
10
+ MWMzYTZhNDc3NzlmMjE1MjljNzkwZWU1ZDQxNDQyNTJhYmE4OGM4Nzk5MjYy
11
+ ZDFhNjc5NDdkMGIwMzNlYzE4MzkzMjJkY2E1MDMyYWYzNTIxODg=
12
12
  data.tar.gz: !binary |-
13
- YTY2MmIxYjA0N2M1Y2JmYWJkMDI3MjgzNDEzYmU2Y2I4Y2ZkZWZmMWE3YTlh
14
- NDc5NjY2Zjg2M2Y4NTU4ZWM4NDMzNzc3OTJlNzEzOWNiNWUxNDA5ODViMmIw
15
- MzlmMGEzZWM3ZmVmZThhNTVkZWFlNWI0NmM0NmFmNGM4YTZlZTM=
13
+ YTM3NmFlODM2ZTA0MmU3MGFhMzVmNWVjMTFjNmNhYzA0ZDQ2MTNkNWM0YjY5
14
+ MGUxMjMwNWFhYjg3ZmRhMDg4OTUzY2M2NDhmZWZjOGJkZmU0NThkMzlmOTY1
15
+ NDdiMjJlNDcyNDY2NTE0ODg0ZmM4ZmIxYzUwNWRiZTY2M2JlMzk=
data/bin/action CHANGED
@@ -30,13 +30,13 @@ end
30
30
  class ActionFrameworkCLI < Optitron::CLI
31
31
  desc "About ActionFramework"
32
32
  def about
33
- puts "ActionFramework (previously called ActionFramework) is a web application framework that tries to be as flexible as sinatra and at the same time have the structure of rails.Enjoy!"
33
+ puts "ActionFramework is a web application framework that tries to be as flexible as sinatra and at the same time have the structure of rails.Enjoy!"
34
34
  end
35
35
  desc "Create ActionFramework project"
36
36
  def new projectname
37
37
  puts "Creating project directory"
38
38
  Dir.mkdir("#{projectname}")
39
- puts "Copying project template"
39
+ puts "Copying project template"
40
40
  path = ActionFramework::Gem.root.resources.project_template.to_s
41
41
  FileUtils.cp_r(Dir.glob(path+"/*"),"#{projectname}")
42
42
  system("cd #{projectname} && bundle install")
@@ -45,43 +45,19 @@ class ActionFrameworkCLI < Optitron::CLI
45
45
  end
46
46
 
47
47
  desc "Start ActionFramework server"
48
- def s
48
+ def s
49
49
  `rackup`
50
50
  end
51
51
 
52
52
  desc "Start ActionFramework console"
53
53
  def c
54
- $runningserver = ActionFramework::Server.new
54
+ $runningserver = ActionFramework::Server.current
55
55
  puts "Starting ActionFramework IRB"
56
56
  require 'irb'
57
- ARGV.clear
57
+ ARGV.clear
58
58
  IRB.start
59
59
  end
60
60
 
61
- desc "Install Stock plugables and add sources list"
62
- def init
63
- Dir.mkdir(Dir.home+"/.actionframework/")
64
- MiniGit.git(:clone ,"https://github.com/actionframework/plugables ~/.actionframework/plugables/")
65
- end
66
-
67
- desc "Update plugables"
68
- def update
69
- git = MiniGit.new(Dir.home+"/.actionframework/plugables")
70
- git.pull
71
- end
72
-
73
- desc "Generate command - see action g help"
74
- def g command
75
- case command;
76
- when "help"
77
- puts "action g authentication # Generates neccesary files for authentication"
78
- when "authentication"
79
- puts "Generation of neccesary files".green
80
-
81
- else
82
- puts "Undefined command #{command}"
83
- end
84
- end
85
61
  end
86
62
 
87
- ActionFrameworkCLI.dispatch
63
+ ActionFrameworkCLI.dispatch
@@ -2,20 +2,24 @@ require 'rack'
2
2
  require 'tilt'
3
3
  require 'json'
4
4
  require 'erb'
5
+ require 'action_mailer'
5
6
 
6
7
  require 'actionframework/string'
7
8
  require 'actionframework/gemextra'
8
9
  require 'actionframework/gem'
9
10
  require 'actionframework/routes'
10
11
  require 'actionframework/controller'
12
+ require 'actionframework/controller_supervisor'
11
13
  require 'actionframework/settings'
12
14
  require 'actionframework/error_handler'
13
15
  require 'actionframework/modelhelper'
14
16
  require 'actionframework/realtime'
15
17
  require 'actionframework/base'
16
18
  require 'actionframework/authentication'
19
+ require 'actionframework/mailer'
17
20
  require 'event_emitter'
18
21
 
22
+
19
23
  $runningserver = nil
20
24
 
21
25
  module ActionFramework
@@ -23,7 +27,7 @@ module ActionFramework
23
27
  def initialize
24
28
  require 'bundler'
25
29
  Bundler.require(:default)
26
-
30
+
27
31
  @routesklass = ActionFramework::Routes.new
28
32
  @settings = ActionFramework::Settings.new
29
33
  end
@@ -37,7 +41,7 @@ module ActionFramework
37
41
  $runningserver
38
42
  end
39
43
  end
40
-
44
+
41
45
  def self.current=(runningserver)
42
46
  $runningserver = runningserver
43
47
  end
@@ -47,6 +51,10 @@ module ActionFramework
47
51
  require './'+file
48
52
  end
49
53
 
54
+ Dir.glob("controller/mailers/*.rb") do |file|
55
+ require './'+file
56
+ end
57
+
50
58
  Dir.glob("models/*.rb").each do |file|
51
59
  require './'+file
52
60
  end
@@ -54,6 +62,7 @@ module ActionFramework
54
62
  require './config/routes'
55
63
  require './config/settings'
56
64
  require './config/plugables'
65
+ require './config/mailer'
57
66
 
58
67
  Dir.glob("initializers/*.rb").each do |file|
59
68
  require './'+file
@@ -71,7 +80,7 @@ module ActionFramework
71
80
  res.redirect(redirect.to)
72
81
  return res.finish
73
82
  end
74
-
83
+
75
84
 
76
85
  # auto-api feature (only at path /api/*)
77
86
  reso = getModelResponse(req,res)
@@ -84,13 +93,12 @@ module ActionFramework
84
93
  res.body = [ActionFramework::ErrorHandler.new(env,req,res,{}).send("error_404")]
85
94
  res.status = 404
86
95
  return res.finish
87
- end
96
+ end
88
97
 
89
98
  controller = controllerinfo[0]
90
99
  matcheddata = controllerinfo[1]
91
100
 
92
- control = controller.split("#")
93
- result = Object.const_get(control[0]).new(env,req,res,matcheddata).send(control[1])
101
+ result = ActionFramework::ControllerSupervisor.new.run(controller,env,req,res,matcheddata)
94
102
  res.write result
95
103
  res.finish
96
104
  end
@@ -113,7 +121,7 @@ module ActionFramework
113
121
  def getModelResponse req,res
114
122
  if(matcheddata = req.path.match(Regexp.new("/api/(?<modelname>(.*))")))
115
123
  return nil unless @routesklass.models.include?(matcheddata[:modelname])
116
-
124
+
117
125
  res["Content-type"] = "application/json"
118
126
  model = Object.const_get(matcheddata[:modelname].capitalize)
119
127
  model.instance_variable_set("@req",req)
@@ -126,12 +134,12 @@ module ActionFramework
126
134
  when "UPDATE"
127
135
  return ActionFramework::ModelHelper.update model,res
128
136
  when "DELETE"
129
-
137
+
130
138
  else
131
139
 
132
140
  end
133
141
  end
134
142
  nil
135
143
  end
136
- end
144
+ end
137
145
  end
@@ -5,6 +5,8 @@
5
5
 
6
6
  module ActionFramework
7
7
  class Controller
8
+ @@run_before = []
9
+
8
10
  def initialize env,req,res,url
9
11
  @req = req
10
12
  @res = res
@@ -65,5 +67,27 @@ module ActionFramework
65
67
  response.redirect path
66
68
  ""
67
69
  end
70
+
71
+ def self.run_before(*args)
72
+ args.each do |methodname|
73
+ @@run_before << methodname
74
+ end
75
+ end
76
+
77
+ def execute_run_before
78
+ output = nil
79
+ @@run_before.each do |methodname|
80
+ returns = self.send(methodname)
81
+
82
+ if(returns.class.to_s == "String")
83
+ output = returns
84
+ break
85
+ end
86
+
87
+ end
88
+
89
+ return output
90
+ end
91
+
68
92
  end
69
- end
93
+ end
@@ -0,0 +1,12 @@
1
+ module ActionFramework
2
+ class ControllerSupervisor
3
+ def run(execute_cmd,env,req,res,url)
4
+ classname, methodname = execute_cmd.split("#")[0], execute_cmd.split("#")[1]
5
+
6
+ controller = Object.const_get(classname).new(env,req,res,url)
7
+ object_from_run_before = controller.execute_run_before
8
+ return object_from_run_before unless object_from_run_before.nil?
9
+ return controller.send(methodname);
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,8 @@
1
+ module ActionFramework
2
+ class Mailer
3
+ def self.config &block
4
+ ActionMailer::Base.class_eval &block
5
+ ActionMailer::Base.view_paths = "./views/mailer/"
6
+ end
7
+ end
8
+ end
File without changes
@@ -0,0 +1,12 @@
1
+ ActionFramework::Mailer.config do
2
+ delivery_method = :smtp
3
+ smtp_settings = {
4
+ :address => "smtp.example.com",
5
+ :port => 587,
6
+ :domain => "example.com",
7
+ :authentication => :plain,
8
+ :user_name => "root",
9
+ :password => "password",
10
+ :enable_starttls_auto => true
11
+ }
12
+ end
File without changes
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: actionframework
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
  - Bram Vandenbogaerde
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-01 00:00:00.000000000 Z
11
+ date: 2014-04-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tilt
@@ -164,6 +164,20 @@ dependencies:
164
164
  - - ! '>='
165
165
  - !ruby/object:Gem::Version
166
166
  version: '0'
167
+ - !ruby/object:Gem::Dependency
168
+ name: actionmailer
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ! '>='
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ type: :runtime
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ! '>='
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
167
181
  description: A web framework built on top of Rack, it has the simplicity of sinatra
168
182
  and the structure of rails
169
183
  email: bram.vandenbogaerde@gmail.com
@@ -177,9 +191,11 @@ files:
177
191
  - lib/actionframework/authentication.rb
178
192
  - lib/actionframework/base.rb
179
193
  - lib/actionframework/controller.rb
194
+ - lib/actionframework/controller_supervisor.rb
180
195
  - lib/actionframework/error_handler.rb
181
196
  - lib/actionframework/gem.rb
182
197
  - lib/actionframework/gemextra.rb
198
+ - lib/actionframework/mailer.rb
183
199
  - lib/actionframework/model.rb
184
200
  - lib/actionframework/modelhelper.rb
185
201
  - lib/actionframework/plugables.rb
@@ -191,15 +207,18 @@ files:
191
207
  - lib/actionframework/routes.rb
192
208
  - lib/actionframework/settings.rb
193
209
  - lib/actionframework/string.rb
210
+ - lib/actionframework/untitled
194
211
  - resources/config/auth.rb
195
212
  - resources/project_template/Gemfile
196
213
  - resources/project_template/authentication/README.md
197
214
  - resources/project_template/config.ru
198
215
  - resources/project_template/config/auth.rb
216
+ - resources/project_template/config/mailer.rb
199
217
  - resources/project_template/config/plugables.rb
200
218
  - resources/project_template/config/routes.rb
201
219
  - resources/project_template/config/settings.rb
202
220
  - resources/project_template/controllers/default_controller.rb
221
+ - resources/project_template/controllers/mailers/README.md
203
222
  - resources/project_template/initializers/README.md
204
223
  - resources/project_template/models/README.md
205
224
  - resources/project_template/static/README.md
@@ -209,6 +228,7 @@ files:
209
228
  - resources/templates/layout.html.erb
210
229
  - resources/views/errors/404.html.erb
211
230
  - resources/views/errors/layout.html.erb
231
+ - resources/views/mailer/README.md
212
232
  homepage: http://actionframework.io
213
233
  licenses:
214
234
  - MIT