absolute 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ .rvmrc
2
+ .powrc
data/Gemfile ADDED
@@ -0,0 +1,16 @@
1
+ source :gemcutter
2
+ source "http://rubygems.org"
3
+
4
+ group :development, :test do
5
+ gem 'rake'
6
+ gem 'rspec'
7
+ gem 'rspec-mocks'
8
+ gem 'guard'
9
+ gem 'guard-rspec'
10
+ gem 'rb-fsevent'
11
+ gem 'faraday'
12
+ gem 'rack-test'
13
+ end
14
+
15
+ gem 'sinatra', :require => 'sinatra/base'
16
+ gem 'awesome_print'
data/Gemfile.lock ADDED
@@ -0,0 +1,52 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ remote: http://rubygems.org/
4
+ specs:
5
+ awesome_print (1.1.0)
6
+ diff-lcs (1.1.3)
7
+ faraday (0.8.4)
8
+ multipart-post (~> 1.1)
9
+ guard (1.4.0)
10
+ listen (>= 0.4.2)
11
+ thor (>= 0.14.6)
12
+ guard-rspec (2.1.0)
13
+ guard (>= 1.1)
14
+ rspec (~> 2.11)
15
+ listen (0.5.3)
16
+ multipart-post (1.1.5)
17
+ rack (1.4.1)
18
+ rack-protection (1.2.0)
19
+ rack
20
+ rack-test (0.6.2)
21
+ rack (>= 1.0)
22
+ rake (0.9.2.2)
23
+ rb-fsevent (0.9.1)
24
+ rspec (2.11.0)
25
+ rspec-core (~> 2.11.0)
26
+ rspec-expectations (~> 2.11.0)
27
+ rspec-mocks (~> 2.11.0)
28
+ rspec-core (2.11.1)
29
+ rspec-expectations (2.11.3)
30
+ diff-lcs (~> 1.1.3)
31
+ rspec-mocks (2.11.3)
32
+ sinatra (1.3.3)
33
+ rack (~> 1.3, >= 1.3.6)
34
+ rack-protection (~> 1.2)
35
+ tilt (~> 1.3, >= 1.3.3)
36
+ thor (0.16.0)
37
+ tilt (1.3.3)
38
+
39
+ PLATFORMS
40
+ ruby
41
+
42
+ DEPENDENCIES
43
+ awesome_print
44
+ faraday
45
+ guard
46
+ guard-rspec
47
+ rack-test
48
+ rake
49
+ rb-fsevent
50
+ rspec
51
+ rspec-mocks
52
+ sinatra
data/Guardfile ADDED
@@ -0,0 +1,9 @@
1
+ guard 'rspec',
2
+ :cli => "--color --format doc",
3
+ :all_on_start => false,
4
+ :all_after_pass => false do
5
+ watch(%r{^spec/.+_spec\.rb$})
6
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
7
+ watch('spec/spec_helper.rb') { "spec" }
8
+ end
9
+
data/README.md CHANGED
@@ -1,3 +1,44 @@
1
1
  absolute.gem
2
2
  ============
3
3
 
4
+ ### absolute is just getting started...
5
+
6
+
7
+ ### install absolute gem
8
+
9
+ <pre>gem install absolute</pre>
10
+
11
+ Experiment 1
12
+ ------------
13
+
14
+ ### make a [Rack](http://rack.github.com/) (usually `config.ru`) file with:
15
+
16
+ <pre>
17
+
18
+ require 'absolute'
19
+
20
+ Absolute::post_received do |data|
21
+
22
+ #
23
+ # data is the post body
24
+ #
25
+
26
+ puts "\n\nDID YOU: #{data}\n\n"
27
+
28
+ end
29
+
30
+ run Absolute::App
31
+
32
+ </pre>
33
+
34
+ ### start the rack (up)
35
+
36
+ <pre>rackup config.ru
37
+
38
+ ### post a spot of json
39
+
40
+ <pre>
41
+
42
+ curl -i -X POST -d '{"c":"this"}' http://localhost:9292
43
+
44
+ </pre>
data/absolute.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = %q{absolute}
3
- spec.version = '0.0.3'
3
+ spec.version = '0.0.4'
4
4
  spec.summary = %q{}
5
5
  spec.date = DateTime.now.strftime( "%Y-%m-%d" )
6
6
  spec.authors = ["nomilous","","",""]
data/app/example.rb CHANGED
@@ -1,4 +1,10 @@
1
1
  lib = File.expand_path(File.dirname(__FILE__) + '/../lib')
2
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
 
4
+ require 'rubygems'
5
+ require 'bundler'
6
+
7
+ Bundler.setup(:default, ENV['RACK_ENV'] || 'development')
8
+ Bundler.require
9
+
4
10
  require 'absolute'
data/config.ru CHANGED
@@ -1,3 +1,9 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/app/example')
2
2
 
3
+ Absolute::post_received do |data|
4
+
5
+ STDERR << "RECEIVED: #{data}\n"
6
+
7
+ end
8
+
3
9
  run Absolute::App
data/lib/absolute.rb CHANGED
@@ -1,41 +1,2 @@
1
- module Absolute
2
-
3
- module App
4
-
5
- module Response
6
-
7
- class << self
8
-
9
- def each( &block )
10
-
11
- yield 'absolute'
12
-
13
- end
14
-
15
- def length
16
-
17
- 'absolute'.length
18
-
19
- end
20
-
21
- end
22
-
23
- end
24
-
25
- class << self
26
-
27
- def call( env )
28
-
29
- headers = {}
30
- headers['Content-Length'] = Response.length.to_s
31
- headers['Content-Type'] = "text/html"
32
-
33
- [200, headers, Response]
34
-
35
- end
36
-
37
- end
38
-
39
- end
40
-
41
- end
1
+ require 'json'
2
+ require 'absolute/app'
@@ -0,0 +1,33 @@
1
+ module Absolute
2
+
3
+ class << self
4
+
5
+ def post_block
6
+
7
+ @post_block
8
+
9
+ end
10
+
11
+ def post_received( *args, &block )
12
+
13
+ @post_block = block
14
+
15
+ end
16
+
17
+ end
18
+
19
+ class App < Sinatra::Base
20
+
21
+ post '/' do
22
+
23
+ request.body.rewind
24
+
25
+ Absolute::post_block.yield JSON.parse( request.body.read )
26
+
27
+ [200, 'okgood']
28
+
29
+ end
30
+
31
+ end
32
+
33
+ end
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+
3
+ Absolute::post_received do |data|; end
4
+
5
+ describe Absolute::App do
6
+
7
+ it 'yields posted data' do
8
+
9
+ Absolute::instance_variable_get(:@post_block).should_receive(
10
+
11
+ :yield ).with( { "data" => "Alfven wave" }
12
+
13
+ )
14
+
15
+ post '/', {
16
+
17
+ data: 'Alfven wave'
18
+
19
+ #
20
+ # curoisity |noun| ~ http://en.wikipedia.org/wiki/Alfv%C3%A9n_wave#Heating_the_Corona
21
+ #
22
+
23
+ }.to_json, "CONTENT_TYPE" => "application/json"
24
+
25
+ end
26
+
27
+ end
@@ -0,0 +1,18 @@
1
+ ENV['RACK_ENV'] = 'test'
2
+
3
+ require './app/example'
4
+
5
+ require 'json'
6
+ require 'rack/test'
7
+
8
+ RSpec.configure do |conf|
9
+
10
+ conf.include Rack::Test::Methods
11
+
12
+ end
13
+
14
+ def app
15
+
16
+ Absolute::App
17
+
18
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: absolute
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -20,11 +20,18 @@ executables: []
20
20
  extensions: []
21
21
  extra_rdoc_files: []
22
22
  files:
23
+ - .gitignore
24
+ - Gemfile
25
+ - Gemfile.lock
26
+ - Guardfile
23
27
  - README.md
24
28
  - absolute.gemspec
25
29
  - app/example.rb
26
30
  - config.ru
27
31
  - lib/absolute.rb
32
+ - lib/absolute/app.rb
33
+ - spec/absolute/app_spec.rb
34
+ - spec/spec_helper.rb
28
35
  homepage:
29
36
  licenses: []
30
37
  post_install_message: