smoke-rack 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -12,8 +12,11 @@ begin
12
12
  gem.authors = ["Ben Schwarz"]
13
13
  gem.rubyforge_project = "smoke-rack"
14
14
  gem.add_development_dependency "rspec"
15
- gem.add_dependency "smoke", "0.5.16"
15
+ gem.add_development_dependency "rack-test"
16
+ gem.add_dependency "smoke", "0.5.17"
16
17
  gem.add_dependency "haml"
18
+ gem.add_dependency "sinatra"
19
+
17
20
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
18
21
  end
19
22
  Jeweler::GemcutterTasks.new
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.3
1
+ 0.0.4
data/config.ru CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  # Ensure your sources (and smoke) are required before smoke-rack
4
4
  require 'examples/smoke-source'
5
- require 'lib/smoke-rack'
6
- use Smoke::Rack
5
+ require 'lib/rack/smoke'
6
+ use Rack::Smoke
7
7
 
8
8
  run Sinatra::Application
9
9
  get '/' do
@@ -50,6 +50,8 @@ Smoke.data(:github) do
50
50
  end
51
51
 
52
52
  Smoke.data(:slideshare) do
53
+ conceal
54
+
53
55
  prepare do
54
56
  timestamp = Time.now.to_i
55
57
  hash = Digest::SHA1.hexdigest("FeXBxg0G#{timestamp}")
@@ -0,0 +1,37 @@
1
+ require 'sinatra'
2
+ require 'haml'
3
+ require 'md5'
4
+
5
+ module Rack
6
+ class Smoke < Sinatra::Base
7
+ set :root, "#{::File.dirname(__FILE__)}/../../"
8
+ set :haml, {:format => :html5, :attr_wrapper => '"'}
9
+ enable :static
10
+
11
+ mime :xml, "application/xml"
12
+ mime :json, "application/json"
13
+ mime :yaml, "application/x-yaml"
14
+
15
+ get "/smoke" do
16
+ @sources = ::Smoke.exposed_sources.keys
17
+ haml :index
18
+ end
19
+
20
+ ::Smoke.exposed_sources.keys.each do |source|
21
+ get "/smoke/#{source.to_s}" do
22
+ @source = source
23
+ haml :usage
24
+ end
25
+
26
+ get "/smoke/#{source.to_s}.:format" do
27
+ format = params[:format].to_sym
28
+ output = ::Smoke.send(source).output(format)
29
+
30
+ content_type format
31
+ etag Digest::MD5.hexdigest(output)
32
+
33
+ output
34
+ end
35
+ end
36
+ end
37
+ end
@@ -1,33 +1 @@
1
- require 'sinatra'
2
-
3
- module Smoke
4
- class Rack < Sinatra::Base
5
- set :public, File.join(File.dirname(__FILE__), '..', 'public')
6
- set :views, File.join(File.dirname(__FILE__), '..', 'views')
7
- set :haml, {:format => :html5, :attr_wrapper => '"'}
8
- enable :static
9
-
10
- mime :xml, "application/xml"
11
- mime :json, "application/json"
12
- mime :yaml, "application/x-yaml"
13
-
14
- get '/smoke' do
15
- @sources = Smoke.active_sources.keys
16
- haml :index
17
- end
18
-
19
- Smoke.active_sources.keys.each do |source|
20
- get "/smoke/#{source.to_s}" do
21
- @source = source
22
- haml :usage
23
- end
24
-
25
- get "/smoke/#{source.to_s}.:format" do
26
- format = params[:format].to_sym
27
-
28
- content_type format
29
- Smoke.send(source).output(format)
30
- end
31
- end
32
- end
33
- end
1
+ require 'rack/smoke'
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{smoke-rack}
8
- s.version = "0.0.3"
8
+ s.version = "0.0.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Ben Schwarz"]
12
- s.date = %q{2009-10-25}
12
+ s.date = %q{2009-10-29}
13
13
  s.description = %q{Expose Smoke sources and transcode them into JSON, XML or YAML}
14
14
  s.email = %q{ben.schwarz@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -25,6 +25,7 @@ Gem::Specification.new do |s|
25
25
  "VERSION",
26
26
  "config.ru",
27
27
  "examples/smoke-source.rb",
28
+ "lib/rack/smoke.rb",
28
29
  "lib/smoke-rack.rb",
29
30
  "public/css/base.css",
30
31
  "public/css/reset.css",
@@ -55,17 +56,23 @@ Gem::Specification.new do |s|
55
56
 
56
57
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
57
58
  s.add_development_dependency(%q<rspec>, [">= 0"])
58
- s.add_runtime_dependency(%q<smoke>, ["= 0.5.16"])
59
+ s.add_development_dependency(%q<rack-test>, [">= 0"])
60
+ s.add_runtime_dependency(%q<smoke>, ["= 0.5.17"])
59
61
  s.add_runtime_dependency(%q<haml>, [">= 0"])
62
+ s.add_runtime_dependency(%q<sinatra>, [">= 0"])
60
63
  else
61
64
  s.add_dependency(%q<rspec>, [">= 0"])
62
- s.add_dependency(%q<smoke>, ["= 0.5.16"])
65
+ s.add_dependency(%q<rack-test>, [">= 0"])
66
+ s.add_dependency(%q<smoke>, ["= 0.5.17"])
63
67
  s.add_dependency(%q<haml>, [">= 0"])
68
+ s.add_dependency(%q<sinatra>, [">= 0"])
64
69
  end
65
70
  else
66
71
  s.add_dependency(%q<rspec>, [">= 0"])
67
- s.add_dependency(%q<smoke>, ["= 0.5.16"])
72
+ s.add_dependency(%q<rack-test>, [">= 0"])
73
+ s.add_dependency(%q<smoke>, ["= 0.5.17"])
68
74
  s.add_dependency(%q<haml>, [">= 0"])
75
+ s.add_dependency(%q<sinatra>, [">= 0"])
69
76
  end
70
77
  end
71
78
 
@@ -4,7 +4,7 @@ describe "SmokeRack" do
4
4
  include Rack::Test::Methods
5
5
 
6
6
  def app
7
- Smoke::Rack
7
+ Rack::Smoke
8
8
  end
9
9
 
10
10
  it "renders the index" do
@@ -34,6 +34,11 @@ describe "SmokeRack" do
34
34
  get "/smoke/github.#{format}"
35
35
  last_response.content_type.should include(format)
36
36
  end
37
+
38
+ it "should have an etag set" do
39
+ get "/smoke/github.#{format}"
40
+ last_response.headers.should have_key("ETag")
41
+ end
37
42
  end
38
43
  end
39
44
  end
@@ -1,5 +1,7 @@
1
- $LOAD_PATH.unshift(File.dirname(__FILE__))
2
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
1
+ unless defined? SPEC_DIR
2
+ SPEC_DIR = File.join(File.dirname(__FILE__))
3
+ end
4
+
3
5
  require 'rubygems'
4
6
  require 'spec'
5
7
  require 'spec/autorun'
@@ -7,8 +9,8 @@ require 'rack/test'
7
9
 
8
10
  gem 'smoke', '>= 0.5.16'
9
11
  require 'smoke'
10
- require 'support/source'
11
- require 'smoke-rack'
12
+ require "#{SPEC_DIR}/support/source"
13
+ require File.join(File.dirname(__FILE__), '..', 'lib', 'rack', 'smoke')
12
14
 
13
15
  set :environment, :test
14
16
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smoke-rack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Schwarz
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-10-25 00:00:00 +11:00
12
+ date: 2009-10-29 00:00:00 +11:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -22,6 +22,16 @@ dependencies:
22
22
  - !ruby/object:Gem::Version
23
23
  version: "0"
24
24
  version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: rack-test
27
+ type: :development
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: "0"
34
+ version:
25
35
  - !ruby/object:Gem::Dependency
26
36
  name: smoke
27
37
  type: :runtime
@@ -30,7 +40,7 @@ dependencies:
30
40
  requirements:
31
41
  - - "="
32
42
  - !ruby/object:Gem::Version
33
- version: 0.5.16
43
+ version: 0.5.17
34
44
  version:
35
45
  - !ruby/object:Gem::Dependency
36
46
  name: haml
@@ -42,6 +52,16 @@ dependencies:
42
52
  - !ruby/object:Gem::Version
43
53
  version: "0"
44
54
  version:
55
+ - !ruby/object:Gem::Dependency
56
+ name: sinatra
57
+ type: :runtime
58
+ version_requirement:
59
+ version_requirements: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: "0"
64
+ version:
45
65
  description: Expose Smoke sources and transcode them into JSON, XML or YAML
46
66
  email: ben.schwarz@gmail.com
47
67
  executables: []
@@ -60,6 +80,7 @@ files:
60
80
  - VERSION
61
81
  - config.ru
62
82
  - examples/smoke-source.rb
83
+ - lib/rack/smoke.rb
63
84
  - lib/smoke-rack.rb
64
85
  - public/css/base.css
65
86
  - public/css/reset.css