rack-golem 0.1.0 → 0.1.1

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.md CHANGED
@@ -19,6 +19,7 @@ Config.ru is one of his names, so say it in a Rackup file.
19
19
 
20
20
  require 'db' # Loads ORM models and all
21
21
  require 'go' # Our controller (I do not like that word really)
22
+ require 'json' # not necessary but used in the example
22
23
  use Rack::ContentLength
23
24
  use Rack::Session::Cookies
24
25
  run Go
@@ -55,6 +56,15 @@ And the winner is:
55
56
  erb :post
56
57
  end
57
58
  end
59
+
60
+ def best_restaurants_json
61
+ # Golem replaces dots and dashes with underscores
62
+ # So you can trigger this handler by visiting /best-restaurant.json
63
+ @res['Content-Type'] = "text/json"
64
+ JSON.generate({
65
+ 'title' => 'Best restaurants in town',
66
+ 'list' => Restaurant.full_list
67
+ })
58
68
 
59
69
  def say(listener='me', *words)
60
70
  "Hey #{listener} I don't need ERB to tell you that #{words.join(' ')}"
data/lib/rack/golem.rb CHANGED
@@ -18,6 +18,7 @@ module Rack::Golem
18
18
  @dispatcher_block || proc{
19
19
  @path_atoms = @r.path_info.split('/').find_all{|s| s!=''}
20
20
  @action, *@action_arguments = @path_atoms
21
+ @action.gsub!(/[-.]/, '_') unless @action.nil?
21
22
  unless public_methods.include?(@action)||(@action&&public_methods.include?(@action.to_sym))
22
23
  if public_methods.include?('index')||public_methods.include?(:index) # For different RUBY_VERSION(s)
23
24
  @action, @action_arguments = 'index', @path_atoms
data/rack-golem.gemspec CHANGED
@@ -1,9 +1,9 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'rack-golem'
3
- s.version = "0.1.0"
3
+ s.version = "0.1.1"
4
4
  s.platform = Gem::Platform::RUBY
5
- s.summary = "A Controller middleware that is euh... basic"
6
- s.description = "A Controller middleware that is euh... basic. I would say it is a sort of Ramaze for kids"
5
+ s.summary = "A Controller middleware that is fairly basic"
6
+ s.description = "A Controller middleware that is fairly basic. I would say it is a sort of Ramaze for kids"
7
7
  s.files = `git ls-files`.split("\n").sort
8
8
  s.require_path = './lib'
9
9
  s.author = "Mickael Riga"
data/test/spec_golem.rb CHANGED
@@ -26,6 +26,7 @@ class Basic
26
26
  throw :response, [200,{'Content-Type'=>'text/html'},['Growl']]
27
27
  'Grrr'
28
28
  end
29
+ def best_restaurants_rss; '<xml>test</xml>'; end
29
30
  private
30
31
  def no_way; 'This is private'; end
31
32
  end
@@ -108,6 +109,10 @@ describe "Golem" do
108
109
  r.body.should=='NOT FOUND: /no'
109
110
  end
110
111
 
112
+ it "Should dispatch to appropriate underscored action when name contains '-' or '.'" do
113
+ BasicR.get('/best-restaurants.rss').body.should=='<xml>test</xml>'
114
+ end
115
+
111
116
  it "Should follow the rack stack if response is 404 and there are middlewares below" do
112
117
  r = BasicLobsterR.get("/no_way")
113
118
  r.status.should==200
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-golem
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 0
10
- version: 0.1.0
9
+ - 1
10
+ version: 0.1.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Mickael Riga
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-03-30 00:00:00 Z
18
+ date: 2012-06-18 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: tilt
@@ -49,7 +49,7 @@ dependencies:
49
49
  version: 1.1.0
50
50
  type: :development
51
51
  version_requirements: *id002
52
- description: A Controller middleware that is euh... basic. I would say it is a sort of Ramaze for kids
52
+ description: A Controller middleware that is fairly basic. I would say it is a sort of Ramaze for kids
53
53
  email: mig@campbellhay.com
54
54
  executables: []
55
55
 
@@ -95,6 +95,6 @@ rubyforge_project:
95
95
  rubygems_version: 1.8.15
96
96
  signing_key:
97
97
  specification_version: 3
98
- summary: A Controller middleware that is euh... basic
98
+ summary: A Controller middleware that is fairly basic
99
99
  test_files: []
100
100