moomerman-rambo 0.4.2 → 0.4.3

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/README CHANGED
@@ -5,8 +5,9 @@ sudo gem install moomerman-rambo
5
5
 
6
6
  To run the example:
7
7
 
8
- clone the repo (the examples are not part of the gem)
8
+ git clone git://github.com/moomerman/rambo.git
9
9
  cd rambo/example/blog/
10
- thin start -R server.ru -p 4000 --threaded
10
+ rake db:setup # assumes database named rambo_blog
11
+ rake server
11
12
 
12
13
  head over to http://localhost:4000/
data/lib/rambo/env.rb ADDED
@@ -0,0 +1,44 @@
1
+ module Rambo
2
+ class Env
3
+ def initialize
4
+ # load from config - only do this IF database required
5
+ require 'dm-core'
6
+ require 'dm-validations'
7
+ require 'dm-timestamps'
8
+ #DataMapper.setup(:default, 'mysql://localhost/moo_development')
9
+ @connection ||= DataMapper.setup(
10
+ :default,
11
+ :adapter => :mysql,
12
+ :host => 'localhost',
13
+ :database => 'rambo_blog',
14
+ :username => 'root',
15
+ :password => ''
16
+ )
17
+ #DataObjects::Mysql.logger = DataObjects::Logger.new(STDOUT, :debug)
18
+
19
+ Dir["controller/*.rb"].each { |x| funkyload x }
20
+ Dir["model/*.rb"].each { |x| funkyload x }
21
+ Dir["lib/*.rb"].each { |x| funkyload x }
22
+ end
23
+
24
+ private
25
+ # turn this into a thread that checks every x seconds
26
+ # (any chance of a callback?) so it is outside of the
27
+ # request/response cycle
28
+ def funkyload(file)
29
+ @@loadcache ||= {}
30
+ if cache = @@loadcache[file]
31
+ if (mtime = File.mtime(file)) > cache
32
+ #puts "reloading: #{file}"
33
+ load file
34
+ @@loadcache[file] = mtime
35
+ end
36
+ else
37
+ #puts "loading: #{file}"
38
+ load file
39
+ @@loadcache[file] = File.mtime(file)
40
+ end
41
+ end
42
+
43
+ end
44
+ end
@@ -0,0 +1,3 @@
1
+ require 'rambo/middleware/lock'
2
+ require 'rambo/middleware/proxy'
3
+ require 'rambo/middleware/upload'
File without changes
File without changes
File without changes
data/lib/rambo/server.rb CHANGED
@@ -3,33 +3,23 @@
3
3
  require 'rubygems'
4
4
  require 'thin'
5
5
 
6
- require 'rambo/lock'
7
- require 'rambo/proxy'
6
+ require 'rambo/env'
8
7
  require 'rambo/controller'
8
+ require 'rambo/middleware'
9
9
  require 'rambo/time'
10
- require 'rambo/upload'
11
10
  require 'rambo/request'
12
11
  require 'rambo/response'
13
12
 
14
13
  module Rambo
15
14
  class Server
16
-
15
+
17
16
  def initialize(options = {})
18
17
  @options = options
19
- # load from config - only do this IF database required
20
- require 'dm-core'
21
- require 'dm-validations'
22
- require 'dm-timestamps'
23
- #DataMapper.setup(:default, 'mysql://localhost/moo_development')
24
- DataMapper.setup(:default, :adapter => :mysql, :host => 'localhost', :database => 'moo_development', :username => 'root', :password => '')
25
- #DataObjects::Mysql.logger = DataObjects::Logger.new(STDOUT, :debug)
26
18
  end
27
19
 
28
20
  def call(env)
29
21
  begin
30
- Dir["controller/*.rb"].each { |x| funkyload x }
31
- Dir["model/*.rb"].each { |x| funkyload x }
32
- Dir["lib/*.rb"].each { |x| funkyload x }
22
+ Rambo::Env.new
33
23
 
34
24
  request = Request.new(env)
35
25
  response = Response.new
@@ -56,24 +46,5 @@ module Rambo
56
46
  return [500, response.header, "<pre><b>#{e.message.gsub("<","&lt;")}</b>\n#{e.backtrace.join("\n")}</pre>"]
57
47
  end
58
48
  end
59
-
60
- private
61
- # turn this into a thread that checks every x seconds
62
- # (any chance of a callback?) so it is outside of the
63
- # request/response cycle
64
- def funkyload(file)
65
- @@loadcache ||= {}
66
- if cache = @@loadcache[file]
67
- if (mtime = File.mtime(file)) > cache
68
- #puts "reloading: #{file}"
69
- load file
70
- @@loadcache[file] = mtime
71
- end
72
- else
73
- #puts "loading: #{file}"
74
- load file
75
- @@loadcache[file] = File.mtime(file)
76
- end
77
- end
78
49
  end
79
50
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: moomerman-rambo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Taylor
@@ -34,19 +34,22 @@ files:
34
34
  - README
35
35
  - lib/rambo.rb
36
36
  - lib/rambo
37
+ - lib/rambo/env.rb
37
38
  - lib/rambo/controller.rb
38
39
  - lib/rambo/controller
39
40
  - lib/rambo/controller/template.rb
40
41
  - lib/rambo/controller/cache.rb
41
42
  - lib/rambo/controller/redirect.rb
42
43
  - lib/rambo/controller/params.rb
43
- - lib/rambo/lock.rb
44
+ - lib/rambo/middleware.rb
45
+ - lib/rambo/middleware
46
+ - lib/rambo/middleware/lock.rb
44
47
  - lib/rambo/server.rb
45
- - lib/rambo/proxy.rb
48
+ - lib/rambo/middleware/proxy.rb
46
49
  - lib/rambo/request.rb
47
50
  - lib/rambo/response.rb
48
51
  - lib/rambo/time.rb
49
- - lib/rambo/upload.rb
52
+ - lib/rambo/middleware/upload.rb
50
53
  has_rdoc: false
51
54
  homepage: http://github.com/moomerman/rambo
52
55
  post_install_message: