anypow 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/Procfile ADDED
@@ -0,0 +1 @@
1
+ web: rackup -p $PORT config.ru
data/README.md CHANGED
@@ -21,6 +21,7 @@ Or install it yourself as:
21
21
  ## Usage
22
22
 
23
23
  $ cat config.ru
24
+ require "anypow"
24
25
  run Anypow::App.new("python -m SimpleHTTPServer $PORT")
25
26
 
26
27
  ## Contributing
data/config.ru CHANGED
@@ -1,4 +1,6 @@
1
1
  $:.unshift File.expand_path("../lib", __FILE__)
2
2
  require "anypow"
3
+ extend Anypow
4
+ run_pow "foreman start -p $PORT"
3
5
 
4
- run Anypow::App.new("python -m SimpleHTTPServer $PORT")
6
+ run Proc.new {|env| [200, {"Content-Type" => "text/plain", "Content-Length" => "11"}, ["Hello Rack!"]]}
@@ -1,3 +1,3 @@
1
1
  module Anypow
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/lib/anypow.rb CHANGED
@@ -5,4 +5,20 @@ module Anypow
5
5
  def self.ruby_18?
6
6
  defined?(RUBY_VERSION) and RUBY_VERSION =~ /^1\.8\.\d+/
7
7
  end
8
+
9
+ def run(app)
10
+ if is_pow?
11
+ super(app) if app.class == Anypow::App
12
+ else
13
+ super(app) if app.class != Anypow::App
14
+ end
15
+ end
16
+
17
+ def run_pow(command)
18
+ run Anypow::App.new(command) if is_pow?
19
+ end
20
+
21
+ def is_pow?
22
+ self.class.to_s == "Nack::Builder"
23
+ end
8
24
  end
data/spec/anypow_spec.rb CHANGED
@@ -1,6 +1,23 @@
1
+ require "rack/test"
2
+
1
3
  describe Anypow do
4
+ include Rack::Test::Methods
2
5
  describe "VERSION" do
3
6
  subject { Anypow::VERSION }
4
7
  it { should be_a String }
5
8
  end
9
+
10
+ describe "extend config.ru" do
11
+ def app
12
+ config = File.expand_path("../resources/anypow.ru", __FILE__)
13
+ app, options = Nack::Builder.parse_file(config)
14
+ app
15
+ end
16
+
17
+ it "respond from the normal rack app" do
18
+ get '/'
19
+ expect(last_response).to be_ok
20
+ expect(last_response.body).to eq("Hello Rack!")
21
+ end
22
+ end
6
23
  end
@@ -0,0 +1,7 @@
1
+ $:.unshift File.expand_path("../../../lib", __FILE__)
2
+ require "anypow"
3
+ extend Anypow
4
+ config = File.expand_path(__FILE__)
5
+ run_pow "rackup -p $PORT -s webrick #{config}"
6
+
7
+ run Proc.new {|env| [200, {"Content-Type" => "text/plain", "Content-Length" => "11"}, ["Hello Rack!"]]}
@@ -1,2 +1,2 @@
1
1
  require 'rack'
2
- run Proc.new {|env| [200, {"Content-Type" => "text/html"}, ["Hello Rack!"]]}
2
+ run Proc.new {|env| [200, {"Content-Type" => "text/plain", "Content-Length" => "11"}, ["Hello Rack!"]]}
data/spec/spec_helper.rb CHANGED
@@ -1,2 +1,12 @@
1
1
  require "rspec"
2
2
  require "anypow"
3
+ require "rack"
4
+
5
+ module Nack
6
+ class Builder < Rack::Builder
7
+ def self.new_from_string(builder_script, file="(rackup)")
8
+ eval "Nack::Builder.new {\n" + builder_script + "\n}.to_app",
9
+ TOPLEVEL_BINDING, file, 0
10
+ end
11
+ end
12
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: anypow
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-07-13 00:00:00.000000000 Z
12
+ date: 2013-07-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rack-proxy
@@ -118,6 +118,7 @@ files:
118
118
  - .travis.yml
119
119
  - Gemfile
120
120
  - LICENSE.txt
121
+ - Procfile
121
122
  - README.md
122
123
  - Rakefile
123
124
  - anypow.gemspec
@@ -127,6 +128,7 @@ files:
127
128
  - lib/anypow/version.rb
128
129
  - spec/anypow/app_spec.rb
129
130
  - spec/anypow_spec.rb
131
+ - spec/resources/anypow.ru
130
132
  - spec/resources/config.ru
131
133
  - spec/spec_helper.rb
132
134
  homepage: https://github.com/riywo/anypow
@@ -157,5 +159,6 @@ summary: Simpe rack proxy to use Pow in any language.
157
159
  test_files:
158
160
  - spec/anypow/app_spec.rb
159
161
  - spec/anypow_spec.rb
162
+ - spec/resources/anypow.ru
160
163
  - spec/resources/config.ru
161
164
  - spec/spec_helper.rb