rack-superfeedr 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/VERSION +1 -1
  2. data/lib/rack-superfeedr.rb +12 -7
  3. metadata +3 -3
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.3
1
+ 0.1.4
@@ -36,6 +36,11 @@ module Rack
36
36
  end
37
37
  endpoint = opts[:hub] || SUPERFEEDR_ENDPOINT
38
38
  opts.delete(:hub)
39
+
40
+ if endpoint == SUPERFEEDR_ENDPOINT
41
+ opts[:userpwd] = "#{@params[:login]}:#{@params[:password]}"
42
+ end
43
+
39
44
  response = ::Typhoeus::Request.post(endpoint,
40
45
  opts.merge({
41
46
  :params => {
@@ -49,10 +54,6 @@ module Rack
49
54
  }
50
55
  }))
51
56
 
52
- if endpoint == SUPERFEEDR_ENDPOINT
53
- opts[:userpwd] = "#{@params[:login]}:#{@params[:password]}"
54
- end
55
-
56
57
  @error = response.body
57
58
  @params[:async] && response.code == 202 || response.code == 204 # We return true to indicate the status.
58
59
  end
@@ -107,7 +108,9 @@ module Rack
107
108
  }
108
109
  @verifications = {}
109
110
  @params = params
111
+ @params[:port] = 80 unless params[:port]
110
112
  @app = app
113
+ @base_path = params[:base_path] || '/superfeedr/feed/'
111
114
  block.call(self)
112
115
  self
113
116
  end
@@ -125,7 +128,7 @@ module Rack
125
128
 
126
129
  def call(env)
127
130
  req = Rack::Request.new(env)
128
- if env['REQUEST_METHOD'] == 'GET' && feed_id = env['PATH_INFO'].match(/\/superfeedr\/feed\/(.*)/)
131
+ if env['REQUEST_METHOD'] == 'GET' && feed_id = env['PATH_INFO'].match(/#{@base_path}(.*)/)
129
132
  # Verification of intent!
130
133
  if @verifications[feed_id[1]] && verification = @verifications[feed_id[1]][req.params['hub.mode']]
131
134
  # Check with the user
@@ -138,7 +141,7 @@ module Rack
138
141
  # By default, we accept all
139
142
  Rack::Response.new(req.params['hub.challenge'], 200).finish
140
143
  end
141
- elsif env['REQUEST_METHOD'] == 'POST' && feed_id = env['PATH_INFO'].match(/\/superfeedr\/feed\/(.*)/)
144
+ elsif env['REQUEST_METHOD'] == 'POST' && feed_id = env['PATH_INFO'].match(/#{@base_path}(.*)/)
142
145
  # Notification
143
146
  content = nil
144
147
  # Body is a stream, not a string, so capture it once and save it
@@ -169,8 +172,10 @@ module Rack
169
172
  protected
170
173
 
171
174
  def generate_callback(url, feed_id)
172
- URI::HTTP.build({:host => @params[:host], :path => "/superfeedr/feed/#{feed_id}" }).to_s
175
+ scheme = params[:scheme] || 'http'
176
+ URI::HTTP.build({:scheme => scheme, :host => @params[:host], :path => "#{@base_path}#{feed_id}", :port => @params[:port] }).to_s
173
177
  end
174
178
 
175
179
  end
180
+
176
181
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: rack-superfeedr
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.3
5
+ version: 0.1.4
6
6
  platform: ruby
7
7
  authors:
8
8
  - julien51
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2013-07-03 00:00:00 Z
13
+ date: 2013-09-05 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rack
@@ -157,7 +157,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
157
157
  requirements:
158
158
  - - ">="
159
159
  - !ruby/object:Gem::Version
160
- hash: 1522793861721834200
160
+ hash: 3043805682238365043
161
161
  segments:
162
162
  - 0
163
163
  version: "0"