public
Rubygem
Description: JSON Web App Framework
Homepage: http://halcyon.rubyforge.org/
Clone URL: git://github.com/mtodd/halcyon.git
Click here to lend your support to: halcyon and make a donation at www.pledgie.com !
Fixed an error in the Pref Manager example and fixed the missing RubyGems 
dependency.
Added the root configuration option as the applications current active 
directory. This is to provide the ability to change the active root via a 
commandline or config file option.
Updated the server spec to test the root option.

git-svn-id: svn+ssh://rubyforge.org/var/svn/halcyon/trunk@36 
334d6d1c-2662-47f5-9f2d-00d938bdab95
mtodd (author)
Sat Jan 19 20:16:14 -0800 2008
commit  81401b2c208ac2c5af2902a99b207a510ccc353b
tree    b7be3c321dc9bc18c7f2b86db93a830d8d34cb9d
parent  15f60e6a00834cb774b1da3d1203ac7a0e47ab86
...
1
2
3
 
4
5
6
...
61
62
63
64
65
 
 
66
67
...
1
2
 
3
4
5
6
...
61
62
63
 
 
64
65
66
67
0
@@ -1,6 +1,6 @@
0
 #!/usr/bin/env ruby -wKU
0
 
0
-%w(halcyon/client).each{|dep|require dep}
0
+%w(rubygems halcyon/client).each{|dep|require dep}
0
 
0
 $port = 4447 if $0 == __FILE__
0
 
0
@@ -61,7 +61,7 @@ if $0 == __FILE__
0
   delivery_types = [:digest,:full,:none]
0
   users.each do |user|
0
     pref = Pref.find(user,'email')
0
- p.set delivery_types[rand(delivery_types.length)]
0
- p.save
0
+ pref.set delivery_types[rand(delivery_types.length)]
0
+ pref.save
0
   end
0
 end
...
1
2
3
 
4
5
6
...
1
2
 
3
4
5
6
0
@@ -1,6 +1,6 @@
0
 #!/usr/bin/env ruby -wKU
0
 
0
-%w(halcyon/server yaml/store).each{|dep|require dep}
0
+%w(rubygems halcyon/server yaml/store).each{|dep|require dep}
0
 
0
 # Handles the persistence of preferences.
0
 class Pref
...
17
18
19
 
20
21
22
...
17
18
19
20
21
22
23
0
@@ -17,6 +17,7 @@ module Halcyon
0
   class Server
0
     
0
     DEFAULT_OPTIONS = {
0
+ :root => Dir.pwd,
0
       :environment => 'none',
0
       :port => 9267,
0
       :host => 'localhost',
...
1
 
2
3
 
4
5
6
7
 
8
9
10
11
12
13
 
14
15
16
...
20
21
22
23
 
24
25
26
27
28
29
 
30
31
32
33
34
35
 
36
37
38
39
40
41
 
42
43
44
...
46
47
48
49
 
50
51
52
53
54
55
 
56
57
58
59
60
 
61
62
63
...
68
69
70
71
 
72
73
74
...
82
83
84
85
 
86
87
88
89
 
90
91
92
 
 
 
 
93
...
 
1
2
 
3
4
5
6
 
7
8
9
10
11
12
 
13
14
15
16
...
20
21
22
 
23
24
25
26
27
28
 
29
30
31
32
33
34
 
35
36
37
38
39
40
 
41
42
43
44
...
46
47
48
 
49
50
51
52
53
54
 
55
56
57
58
59
 
60
61
62
63
...
68
69
70
 
71
72
73
74
...
82
83
84
 
85
86
87
88
 
89
90
91
92
93
94
95
96
97
0
@@ -1,16 +1,16 @@
0
-context "Halcyon::Server" do
0
+describe "Halcyon::Server" do
0
   
0
- before(:each) do
0
+ before do
0
     @app = Specr.new :port => 4000
0
   end
0
   
0
- specify "should dispatch methods according to their respective routes" do
0
+ it "should dispatch methods according to their respective routes" do
0
     Rack::MockRequest.new(@app).get("/hello/Matt")
0
     last_line = File.new(@app.instance_variable_get("@config")[:log_file]).readlines.last
0
     last_line.should =~ /INFO \[\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\] \(\d+\) Specr#test :: \[200\] .* => greeter \(.+\)/
0
   end
0
   
0
- specify "should provide various shorthand methods for simple responses but take custom response values" do
0
+ it "should provide various shorthand methods for simple responses but take custom response values" do
0
     response = {:status => 200, :body => 'OK'}
0
     @app.ok.should == response
0
     @app.success.should == response
0
@@ -20,25 +20,25 @@ context "Halcyon::Server" do
0
     @app.ok(['OK', 'Sure Thang', 'Correcto']).should == {:status => 200, :body => ['OK', 'Sure Thang', 'Correcto']}
0
   end
0
   
0
- specify "should handle requests and respond with JSON" do
0
+ it "should handle requests and respond with JSON" do
0
     body = JSON.parse(Rack::MockRequest.new(@app).get("/").body)
0
     body['status'].should == 200
0
     body['body'].should == "Found"
0
   end
0
   
0
- specify "should handle requests with param values in the URL" do
0
+ it "should handle requests with param values in the URL" do
0
     body = JSON.parse(Rack::MockRequest.new(@app).get("/hello/Matt").body)
0
     body['status'].should == 200
0
     body['body'].should == "Hello Matt"
0
   end
0
   
0
- specify "should route unmatchable requests to the default route and return JSON with appropriate status" do
0
+ it "should route unmatchable requests to the default route and return JSON with appropriate status" do
0
     body = JSON.parse(Rack::MockRequest.new(@app).get("/garbage/request/url").body)
0
     body['status'].should == 404
0
     body['body'].should == "Not Found"
0
   end
0
   
0
- specify "should log activity" do
0
+ it "should log activity" do
0
     prev_line = File.new(@app.instance_variable_get("@config")[:log_file]).readlines.last
0
     Rack::MockRequest.new(@app).get("/url/that/will/not/be/found/#{rand}")
0
     last_line = File.new(@app.instance_variable_get("@config")[:log_file]).readlines.last
0
@@ -46,18 +46,18 @@ context "Halcyon::Server" do
0
     prev_line.should_not == last_line
0
   end
0
   
0
- specify "should create a PID file while running with the correct process ID" do
0
+ it "should create a PID file while running with the correct process ID" do
0
     pid_file = @app.instance_variable_get("@config")[:pid_file]
0
     File.exist?(pid_file).should be_true
0
     File.open(pid_file){|file|file.read.should == "#{$$}\n"}
0
   end
0
   
0
- specify "should parse URI query params correctly" do
0
+ it "should parse URI query params correctly" do
0
     Rack::MockRequest.new(@app).get("/?query=value&lang=en-US")
0
     @app.query_params.should == {'query' => 'value', 'lang' => 'en-US'}
0
   end
0
   
0
- specify "should parse the URI correctly" do
0
+ it "should parse the URI correctly" do
0
     Rack::MockRequest.new(@app).get("http://localhost:4000/slaughterhouse/5")
0
     @app.uri.should == '/slaughterhouse/5'
0
     
0
@@ -68,7 +68,7 @@ context "Halcyon::Server" do
0
     @app.uri.should == '/'
0
   end
0
   
0
- specify "should provide a quick way to find out what method the request was performed using" do
0
+ it "should provide a quick way to find out what method the request was performed using" do
0
     Rack::MockRequest.new(@app).get("/#{rand}")
0
     @app.method.should == :get
0
     
0
@@ -82,12 +82,16 @@ context "Halcyon::Server" do
0
     @app.method.should == :delete
0
   end
0
   
0
- specify "should deny all unacceptable requests" do
0
+ it "should deny all unacceptable requests" do
0
     conf = @app.instance_variable_get("@config")
0
     conf[:acceptable_requests] = Halcyon::Server::ACCEPTABLE_REQUESTS
0
     
0
- Rack::MockRequest.new(@app).put("/#{rand}")
0
+ Rack::MockRequest.new(@app).get("/#{rand}")
0
     @app.acceptable_request! rescue Halcyon::Exceptions::Base
0
   end
0
   
0
+ it "should record the correct environment details" do
0
+ @app.instance_eval { @config[:root].should == Dir.pwd }
0
+ end
0
+
0
 end

Comments

    No one has commented yet.