rack-smoke 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ *.sw?
2
+ .DS_Store
3
+ coverage
4
+ rdoc
5
+ pkg
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Ben Schwarz
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,55 @@
1
+ # rack-smoke
2
+
3
+ Rack::Smoke allows you to expose Smoke sources and transcode them into JSON, XML or YAML.
4
+
5
+ ## What are the benefits?
6
+
7
+ * Pluggable caching, cache remote web services and rely on your own infrastructure
8
+ * Join Smoke sources together, reinterpret them, then offer them as a simple web service
9
+
10
+ Rack::Smoke gives you a bunch of HTML screens (found at `/smoke`) that outline the Smoke sources that are found within your current environment.
11
+ ![Rack::Smoke home screen](http://img.skitch.com/20100124-t55yrg8wij4yah1ebd8a7mfdmq.jpg)
12
+
13
+ From there, you'll be able to see the formats that you can get the stream in, or if they require any additional query strings.
14
+ ![Twitter source details](http://img.skitch.com/20100124-m8gu8nfbknrqgfhb3aax6idnrp.jpg)
15
+
16
+
17
+ ## Smoke?
18
+
19
+ Smoke allows you to take single serve sources from around the web. Then it does a bunch of smart stuff like automagically transferring as gzip, request caching and understands the content that it gets back. YQL, Atom / RSS feeds, json and xml are all converted to ruby arrays.
20
+
21
+ Smoke-rack allows you to transcode that information and provide an API like layer of your own.
22
+
23
+ ## How do I include it in my project?
24
+
25
+ # config.ru
26
+ require 'rubygems'
27
+
28
+ # Ensure your app has some Smoke sources
29
+ require 'your-app'
30
+
31
+ require 'rack-smoke'
32
+ use Rack::Smoke
33
+
34
+ run Sinatra::Application
35
+
36
+ Then navigate to localhost:PORT/smoke to get a list of available sources
37
+
38
+ ## Installation
39
+
40
+ gem install rack-smoke
41
+
42
+ ## Note on Patches/Pull Requests
43
+
44
+ * Fork the project.
45
+ * Make your feature addition or bug fix.
46
+ * Add tests for it. This is important so I don't break it in a
47
+ future version unintentionally.
48
+ * Commit, do not mess with rakefile, version, or history.
49
+ (if you want to have your own version, that is fine but
50
+ bump version in a commit by itself I can ignore when I pull)
51
+ * Send me a pull request. Bonus points for topic branches.
52
+
53
+ ## Copyright
54
+
55
+ Copyright (c) 2010 Ben Schwarz. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,57 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "rack-smoke"
8
+ gem.summary = %Q{Expose Smoke sources and transcode them into JSON, XML or YAML}
9
+ gem.description = %Q{Expose Smoke sources and transcode them into JSON, XML or YAML}
10
+ gem.email = "ben.schwarz@gmail.com"
11
+ gem.homepage = "http://github.com/benschwarz/rack-smoke"
12
+ gem.authors = ["Ben Schwarz"]
13
+ gem.rubyforge_project = "rack-smoke"
14
+ gem.add_development_dependency "rack-test"
15
+ gem.add_development_dependency "rspec"
16
+ gem.add_dependency "smoke", ">= 0.5.19"
17
+ gem.add_dependency "haml"
18
+ gem.add_dependency "sinatra"
19
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
20
+ end
21
+ Jeweler::GemcutterTasks.new
22
+ Jeweler::RubyforgeTasks.new do |rubyforge|
23
+ rubyforge.doc_task = "rdoc"
24
+ end
25
+ rescue LoadError
26
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
27
+ end
28
+
29
+ require 'spec/rake/spectask'
30
+ Spec::Rake::SpecTask.new(:spec) do |spec|
31
+ spec.libs << 'lib' << 'spec'
32
+ spec.spec_files = FileList['spec/**/*_spec.rb']
33
+ end
34
+
35
+ Spec::Rake::SpecTask.new(:rcov) do |spec|
36
+ spec.libs << 'lib' << 'spec'
37
+ spec.pattern = 'spec/**/*_spec.rb'
38
+ spec.rcov = true
39
+ end
40
+
41
+ task :spec => :check_dependencies
42
+
43
+ task :default => :spec
44
+
45
+ require 'rake/rdoctask'
46
+ Rake::RDocTask.new do |rdoc|
47
+ if File.exist?('VERSION')
48
+ version = File.read('VERSION')
49
+ else
50
+ version = ""
51
+ end
52
+
53
+ rdoc.rdoc_dir = 'rdoc'
54
+ rdoc.title = "rack-smoke #{version}"
55
+ rdoc.rdoc_files.include('README*')
56
+ rdoc.rdoc_files.include('lib/**/*.rb')
57
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.0.0
data/config.ru ADDED
@@ -0,0 +1,6 @@
1
+ # Just here to test easily
2
+
3
+ # Ensure your sources (and smoke) are required before rack-smoke
4
+ require 'examples/smoke-source'
5
+ require 'lib/rack/smoke'
6
+ run Rack::Smoke
@@ -0,0 +1,62 @@
1
+ # Pinched from github.com/benschwarz/benschwarz-site
2
+
3
+ require 'smoke'
4
+ require 'digest/sha1'
5
+
6
+ Smoke.configure do |c|
7
+ c[:cache][:enabled] = true
8
+ c[:cache][:store] = :memory
9
+ c[:cache][:expire_in] = 1800
10
+ end
11
+
12
+ Smoke.yql(:flickr) do
13
+ select :all
14
+ from 'flickr.photos.search'
15
+ where :user_id, "36821533@N00"
16
+ where :tags, "germanforblack-site"
17
+
18
+ path :query, :results, :photo
19
+ end
20
+
21
+ Smoke.data(:twitter) do
22
+ prepare :require => :username do
23
+ url "http://twitter.com/users/show.json?screen_name=#{username}", :format => :json
24
+ end
25
+ end
26
+
27
+ Smoke.feed(:delicious) do
28
+ url "http://feeds.delicious.com/v2/rss/bschwarz?count=5"
29
+ end
30
+
31
+ Smoke.data(:upcoming) do
32
+ url "http://upcoming.yahooapis.com/services/rest/?method=user.getWatchlist&api_key=7c06afe3f8&user_id=908522&show=upcoming&format=json"
33
+ path :rsp, :event
34
+
35
+ emit do
36
+ keep :status, /attend/
37
+ truncate 1
38
+ end
39
+ end
40
+
41
+ Smoke.data(:github) do
42
+ url "http://github.com/api/v2/json/repos/show/benschwarz"
43
+ path :repositories
44
+
45
+ emit do
46
+ sort :watchers
47
+ reverse
48
+ truncate 5
49
+ end
50
+ end
51
+
52
+ Smoke.data(:slideshare) do
53
+ conceal
54
+
55
+ prepare do
56
+ timestamp = Time.now.to_i
57
+ hash = Digest::SHA1.hexdigest("FeXBxg0G#{timestamp}")
58
+ url "http://www.slideshare.net/api/2/get_slideshows_by_user?username_for=benschwarz&api_key=uQqJ57cz&ts=#{timestamp}&hash=#{hash}"
59
+ end
60
+
61
+ path :User, :Slideshow
62
+ end
@@ -0,0 +1,13 @@
1
+ # Nabbed, http://www.ruby-forum.com/topic/149449
2
+ class Hash
3
+
4
+ # Returns a new hash with only the given keys.
5
+ def slice(keys = [])
6
+ h = {}
7
+ keys.each do |key|
8
+ raise IndexError if self[key].nil?
9
+ h[key] = self[key]
10
+ end
11
+ h
12
+ end
13
+ end
data/lib/rack/smoke.rb ADDED
@@ -0,0 +1,42 @@
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
+ get "/smoke/:source.:format" do
21
+ raise Sinatra::NotFound if ::Smoke[params["source"].to_sym].nil?
22
+
23
+ format = params.delete("format").to_sym
24
+ content_type format rescue status 400
25
+
26
+ begin
27
+ name = params.delete("source").to_sym
28
+ output = ::Smoke.__send__(name, params).output(format)
29
+ etag Digest::MD5.hexdigest(output)
30
+ output
31
+ rescue ::Smoke::Origin::UnavailableFormat, NameError # Requirements not met for source
32
+ status 400
33
+ end
34
+ end
35
+
36
+ get "/smoke/:source" do
37
+ raise Sinatra::NotFound if ::Smoke[params["source"].to_sym].nil?
38
+ @source = ::Smoke[params["source"].to_sym]
39
+ haml :usage
40
+ end
41
+ end
42
+ end
data/lib/smoke-rack.rb ADDED
@@ -0,0 +1 @@
1
+ require 'rack/smoke'
@@ -0,0 +1,24 @@
1
+ body { font-family: Helvetica, Arial; }
2
+ #container { width: 550px; margin: 0 auto; }
3
+
4
+ h1 { font-size: 3em; text-transform: lowercase; margin-bottom: 1.5em; }
5
+ h2 { font-size: 1.3em; }
6
+ h1 + h2 { margin-top : -3em; font-style: italic; font-weight: normal; font-size: 0.9em; color: #999;}
7
+
8
+ header { margin: 4em 0; }
9
+
10
+ p { margin: 1em 0; }
11
+ li { margin: 0.3em 0; }
12
+ pre { display: inline-block; margin: 2em 0; }
13
+ code { font-size: 1em; background-color: #eee; padding: 0.6em; }
14
+ a { color: #666; }
15
+ a.back { margin-left: -10em; margin-top: 1.8em; position: absolute; }
16
+
17
+ footer { clear: left; text-align: right; border-top: 1px solid #ccc; padding-top: 0.5em; margin: 2em 0; }
18
+ footer a { color: #999; font-size: 0.7em; font-style: italic; }
19
+ footer a:hover { color: #666; }
20
+
21
+ #sources { margin-top: 2em; }
22
+ #sources li { font-size: 2em; background-color: #eee; padding: 0.6em; }
23
+ #sources li:hover { background-color: #ccc; }
24
+ #sources li:hover a { color: black;}
@@ -0,0 +1,58 @@
1
+ /* http://meyerweb.com/eric/tools/css/reset/ */
2
+ /* v1.0 | 20080212 */
3
+
4
+ html, body, div, span, applet, object, iframe,
5
+ h1, h2, h3, h4, h5, h6, p, blockquote, pre,
6
+ a, abbr, acronym, address, big, cite, code,
7
+ del, dfn, em, font, img, ins, kbd, q, s, samp,
8
+ small, strike, strong, sub, sup, tt, var,
9
+ b, u, i, center,
10
+ dl, dt, dd, ol, ul, li,
11
+ fieldset, form, label, legend,
12
+ table, caption, tbody, tfoot, thead, tr, th, td,
13
+ nav, aside, figure, header, article {
14
+ margin: 0;
15
+ padding: 0;
16
+ border: 0;
17
+ outline: 0;
18
+ font-size: 100%;
19
+ vertical-align: baseline;
20
+ background: transparent;
21
+ }
22
+ body {
23
+ line-height: 1;
24
+ }
25
+ ol, ul {
26
+ list-style: none;
27
+ }
28
+ blockquote, q {
29
+ quotes: none;
30
+ }
31
+ blockquote:before, blockquote:after,
32
+ q:before, q:after {
33
+ content: '';
34
+ content: none;
35
+ }
36
+
37
+ /* remember to define focus styles! */
38
+ :focus {
39
+ outline: 0;
40
+ }
41
+
42
+ /* remember to highlight inserts somehow! */
43
+ ins {
44
+ text-decoration: none;
45
+ }
46
+ del {
47
+ text-decoration: line-through;
48
+ }
49
+
50
+ /* tables still need 'cellspacing="0"' in the markup */
51
+ table {
52
+ border-collapse: collapse;
53
+ border-spacing: 0;
54
+ }
55
+
56
+
57
+ /* Makes HTML5 structural elements structural */
58
+ article, aside, footer, header, nav, section {display: block;}
@@ -0,0 +1,82 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{rack-smoke}
8
+ s.version = "1.0.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Ben Schwarz"]
12
+ s.date = %q{2010-01-24}
13
+ s.description = %q{Expose Smoke sources and transcode them into JSON, XML or YAML}
14
+ s.email = %q{ben.schwarz@gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.md"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".gitignore",
22
+ "LICENSE",
23
+ "README.md",
24
+ "Rakefile",
25
+ "VERSION",
26
+ "config.ru",
27
+ "examples/smoke-source.rb",
28
+ "lib/core_ext/hash.rb",
29
+ "lib/rack/smoke.rb",
30
+ "lib/smoke-rack.rb",
31
+ "public/css/base.css",
32
+ "public/css/reset.css",
33
+ "rack-smoke.gemspec",
34
+ "smoke-rack.gemspec",
35
+ "spec/smoke-rack_spec.rb",
36
+ "spec/spec.opts",
37
+ "spec/spec_helper.rb",
38
+ "spec/support/source.rb",
39
+ "views/index.haml",
40
+ "views/layout.haml",
41
+ "views/not_found.haml",
42
+ "views/usage.haml"
43
+ ]
44
+ s.homepage = %q{http://github.com/benschwarz/rack-smoke}
45
+ s.rdoc_options = ["--charset=UTF-8"]
46
+ s.require_paths = ["lib"]
47
+ s.rubyforge_project = %q{rack-smoke}
48
+ s.rubygems_version = %q{1.3.5}
49
+ s.summary = %q{Expose Smoke sources and transcode them into JSON, XML or YAML}
50
+ s.test_files = [
51
+ "spec/smoke-rack_spec.rb",
52
+ "spec/spec_helper.rb",
53
+ "spec/support/source.rb",
54
+ "examples/smoke-source.rb"
55
+ ]
56
+
57
+ if s.respond_to? :specification_version then
58
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
59
+ s.specification_version = 3
60
+
61
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
62
+ s.add_development_dependency(%q<rack-test>, [">= 0"])
63
+ s.add_development_dependency(%q<rspec>, [">= 0"])
64
+ s.add_runtime_dependency(%q<smoke>, [">= 0.5.19"])
65
+ s.add_runtime_dependency(%q<haml>, [">= 0"])
66
+ s.add_runtime_dependency(%q<sinatra>, [">= 0"])
67
+ else
68
+ s.add_dependency(%q<rack-test>, [">= 0"])
69
+ s.add_dependency(%q<rspec>, [">= 0"])
70
+ s.add_dependency(%q<smoke>, [">= 0.5.19"])
71
+ s.add_dependency(%q<haml>, [">= 0"])
72
+ s.add_dependency(%q<sinatra>, [">= 0"])
73
+ end
74
+ else
75
+ s.add_dependency(%q<rack-test>, [">= 0"])
76
+ s.add_dependency(%q<rspec>, [">= 0"])
77
+ s.add_dependency(%q<smoke>, [">= 0.5.19"])
78
+ s.add_dependency(%q<haml>, [">= 0"])
79
+ s.add_dependency(%q<sinatra>, [">= 0"])
80
+ end
81
+ end
82
+
@@ -0,0 +1,78 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{rack-smoke}
8
+ s.version = "0.0.4"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Ben Schwarz"]
12
+ s.date = %q{2009-10-29}
13
+ s.description = %q{Expose Smoke sources and transcode them into JSON, XML or YAML}
14
+ s.email = %q{ben.schwarz@gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.md"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".gitignore",
22
+ "LICENSE",
23
+ "README.md",
24
+ "Rakefile",
25
+ "VERSION",
26
+ "config.ru",
27
+ "examples/smoke-source.rb",
28
+ "lib/rack/smoke.rb",
29
+ "lib/rack-smoke.rb",
30
+ "public/css/base.css",
31
+ "public/css/reset.css",
32
+ "rack-smoke.gemspec",
33
+ "spec/rack-smoke_spec.rb",
34
+ "spec/spec_helper.rb",
35
+ "spec/support/source.rb",
36
+ "views/index.haml",
37
+ "views/layout.haml",
38
+ "views/usage.haml"
39
+ ]
40
+ s.homepage = %q{http://github.com/benschwarz/rack-smoke}
41
+ s.rdoc_options = ["--charset=UTF-8"]
42
+ s.require_paths = ["lib"]
43
+ s.rubyforge_project = %q{rack-smoke}
44
+ s.rubygems_version = %q{1.3.5}
45
+ s.summary = %q{Expose Smoke sources and transcode them into JSON, XML or YAML}
46
+ s.test_files = [
47
+ "spec/rack-smoke_spec.rb",
48
+ "spec/spec_helper.rb",
49
+ "spec/support/source.rb",
50
+ "examples/smoke-source.rb"
51
+ ]
52
+
53
+ if s.respond_to? :specification_version then
54
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
55
+ s.specification_version = 3
56
+
57
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
58
+ s.add_development_dependency(%q<rspec>, [">= 0"])
59
+ s.add_development_dependency(%q<rack-test>, [">= 0"])
60
+ s.add_runtime_dependency(%q<smoke>, ["= 0.5.17"])
61
+ s.add_runtime_dependency(%q<haml>, [">= 0"])
62
+ s.add_runtime_dependency(%q<sinatra>, [">= 0"])
63
+ else
64
+ s.add_dependency(%q<rspec>, [">= 0"])
65
+ s.add_dependency(%q<rack-test>, [">= 0"])
66
+ s.add_dependency(%q<smoke>, ["= 0.5.17"])
67
+ s.add_dependency(%q<haml>, [">= 0"])
68
+ s.add_dependency(%q<sinatra>, [">= 0"])
69
+ end
70
+ else
71
+ s.add_dependency(%q<rspec>, [">= 0"])
72
+ s.add_dependency(%q<rack-test>, [">= 0"])
73
+ s.add_dependency(%q<smoke>, ["= 0.5.17"])
74
+ s.add_dependency(%q<haml>, [">= 0"])
75
+ s.add_dependency(%q<sinatra>, [">= 0"])
76
+ end
77
+ end
78
+
@@ -0,0 +1,62 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "SmokeRack" do
4
+ include Rack::Test::Methods
5
+
6
+ def app
7
+ Rack::Smoke.new
8
+ end
9
+
10
+ it "renders the index" do
11
+ get '/smoke'
12
+ last_response.should be_ok
13
+ end
14
+
15
+ it "should list the sources" do
16
+ get '/smoke'
17
+ last_response.body.should include "<a href=\"/smoke/github\">github</a>"
18
+ end
19
+
20
+ describe "github source" do
21
+ it "should be okay" do
22
+ get '/smoke/github'
23
+ last_response.should be_ok
24
+ end
25
+
26
+ describe "formats" do
27
+ %w(json yaml xml).each do |format|
28
+ it "should be okay serving #{format}" do
29
+ get "/smoke/github.#{format}"
30
+ last_response.should be_ok
31
+ end
32
+
33
+ it "should serve using the correct content_type" do
34
+ get "/smoke/github.#{format}"
35
+ last_response.content_type.should include(format)
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
42
+ end
43
+ end
44
+ end
45
+
46
+ describe "source requirements" do
47
+ it "should render a 400 when requirements are not met" do
48
+ get '/smoke/twitter.xml'
49
+ last_response.status.should == 400
50
+ end
51
+
52
+ it "should be successful with requirements" do
53
+ get '/smoke/twitter.xml', {:username => "benschwarz"}
54
+ last_response.should be_ok
55
+ end
56
+ end
57
+
58
+ it "should not be successful with a bung format" do
59
+ get '/smoke/github.xyz'
60
+ last_response.status.should == 400
61
+ end
62
+ end
data/spec/spec.opts ADDED
@@ -0,0 +1 @@
1
+ -c
@@ -0,0 +1,20 @@
1
+ unless defined? SPEC_DIR
2
+ SPEC_DIR = File.join(File.dirname(__FILE__))
3
+ end
4
+
5
+ require 'rubygems'
6
+ require 'spec'
7
+ require 'spec/autorun'
8
+ require 'rack/test'
9
+
10
+ require 'smoke'
11
+
12
+ # The source must be required before rack-smoke
13
+ require "#{SPEC_DIR}/support/source"
14
+ require File.join(File.dirname(__FILE__), '..', 'lib', 'rack', 'smoke')
15
+
16
+ set :environment, :test
17
+
18
+ Spec::Runner.configure do |config|
19
+
20
+ end
@@ -0,0 +1,22 @@
1
+ Smoke.configure do |c|
2
+ c[:cache][:enabled] = true
3
+ c[:cache][:store] = :memory
4
+ c[:cache][:expire_in] = 1800
5
+ end
6
+
7
+ Smoke.data(:github) do
8
+ url "http://github.com/api/v2/json/repos/show/benschwarz"
9
+ path :repositories
10
+
11
+ emit do
12
+ sort :watchers
13
+ reverse
14
+ truncate 5
15
+ end
16
+ end
17
+
18
+ Smoke.data(:twitter) do
19
+ prepare :require => :username do
20
+ url "http://twitter.com/users/show.json?screen_name=#{username}", :format => :json
21
+ end
22
+ end
data/views/index.haml ADDED
@@ -0,0 +1,18 @@
1
+ %header
2
+ %h1 rack-smoke
3
+ %h2 Put more smoke in the air than the chinese at new years
4
+
5
+ %p Rack::Smoke allows you to expose Smoke sources and transcode them into JSON, XML or YAML.
6
+
7
+ %section#sources
8
+ - if @sources.empty?
9
+ %p
10
+ You don't have any sources specified yet, maybe checkout the
11
+ %a{:href => "http://github.com/benschwarz/smoke"} Smoke readme
12
+ to get started
13
+ - else
14
+ %ul
15
+ - @sources.each do |source|
16
+ %li
17
+ %a{:href => "/smoke/#{source}"}= source
18
+ %h2
data/views/layout.haml ADDED
@@ -0,0 +1,20 @@
1
+ !!!
2
+ %html{:lang => "en"}
3
+ %head
4
+ %meta{"http-equiv" => 'Content-Type', :content => 'text/html; charset=utf-8'}
5
+ %meta{:name => "author", :content => "Ben Schwarz"}
6
+
7
+ /[if IE]
8
+ %script{:src => " http://html5shiv.googlecode.com/svn/trunk/html5.js"}
9
+
10
+ %title Rack::Smoke
11
+ %link{:rel => "stylesheet", :href => "/css/reset.css", :type => "text/css", :media => "screen"}
12
+ %link{:rel => "stylesheet", :href => "/css/base.css", :type => "text/css", :media => "screen"}
13
+
14
+ %body
15
+ %section#container
16
+ = yield
17
+
18
+ %footer
19
+ %a{:href => "http://github.com/benschwarz/rack-smoke", :title => "Rack::Smoke on Github"} Rack::Smoke on Github
20
+
@@ -0,0 +1,5 @@
1
+ %header
2
+ %a.back{:href => "/smoke"}
3
+ &laquo; Back to docs
4
+ %h1 Failure
5
+ %h2 You've missed something important about the source that you're trying to use. Read about its requirements and try adding some querystrings
data/views/usage.haml ADDED
@@ -0,0 +1,22 @@
1
+ %header
2
+ %a.back{:href => "/smoke"} &laquo; Back to docs
3
+ %h1= @source.name
4
+ %h2 Try these neat examples in your console
5
+
6
+ - %w(json yaml xml).each do |format|
7
+ %h2= "In #{format.upcase}"
8
+ %pre
9
+ %code= "curl -i http://#{env["HTTP_HOST"]}/smoke/#{@source.name}.#{format}"
10
+ - if @source.requirements.any?
11
+ %h2 Requirements
12
+ %p
13
+ You must set these properties before calling
14
+ %code output.
15
+ This can be done by adding query strings to your get requests.
16
+ - @source.requirements.each do |requirement|
17
+ %li
18
+ = requirement.to_s
19
+ %pre
20
+ %code= "http://#{env["HTTP_HOST"]}/smoke/#{@source.name}.(json|yaml|xml)?#{requirement}=string"
21
+
22
+
metadata ADDED
@@ -0,0 +1,130 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rack-smoke
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Ben Schwarz
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2010-01-24 00:00:00 +11:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rack-test
17
+ type: :development
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: rspec
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:
35
+ - !ruby/object:Gem::Dependency
36
+ name: smoke
37
+ type: :runtime
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: 0.5.19
44
+ version:
45
+ - !ruby/object:Gem::Dependency
46
+ name: haml
47
+ type: :runtime
48
+ version_requirement:
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: "0"
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:
65
+ description: Expose Smoke sources and transcode them into JSON, XML or YAML
66
+ email: ben.schwarz@gmail.com
67
+ executables: []
68
+
69
+ extensions: []
70
+
71
+ extra_rdoc_files:
72
+ - LICENSE
73
+ - README.md
74
+ files:
75
+ - .document
76
+ - .gitignore
77
+ - LICENSE
78
+ - README.md
79
+ - Rakefile
80
+ - VERSION
81
+ - config.ru
82
+ - examples/smoke-source.rb
83
+ - lib/core_ext/hash.rb
84
+ - lib/rack/smoke.rb
85
+ - lib/smoke-rack.rb
86
+ - public/css/base.css
87
+ - public/css/reset.css
88
+ - rack-smoke.gemspec
89
+ - smoke-rack.gemspec
90
+ - spec/smoke-rack_spec.rb
91
+ - spec/spec.opts
92
+ - spec/spec_helper.rb
93
+ - spec/support/source.rb
94
+ - views/index.haml
95
+ - views/layout.haml
96
+ - views/not_found.haml
97
+ - views/usage.haml
98
+ has_rdoc: true
99
+ homepage: http://github.com/benschwarz/rack-smoke
100
+ licenses: []
101
+
102
+ post_install_message:
103
+ rdoc_options:
104
+ - --charset=UTF-8
105
+ require_paths:
106
+ - lib
107
+ required_ruby_version: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: "0"
112
+ version:
113
+ required_rubygems_version: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: "0"
118
+ version:
119
+ requirements: []
120
+
121
+ rubyforge_project: rack-smoke
122
+ rubygems_version: 1.3.5
123
+ signing_key:
124
+ specification_version: 3
125
+ summary: Expose Smoke sources and transcode them into JSON, XML or YAML
126
+ test_files:
127
+ - spec/smoke-rack_spec.rb
128
+ - spec/spec_helper.rb
129
+ - spec/support/source.rb
130
+ - examples/smoke-source.rb