pubsubhubbub-rails 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 03e9b6b69ab33bb77de497c4f4ab2390c07e042a
4
- data.tar.gz: cd017828e6c4251cdad04a1bf1a567d19b892004
3
+ metadata.gz: 2e1e57ed25a60b5353d6a2a0be5383ec687f5348
4
+ data.tar.gz: fe069db3bb82d6b97c480d6081074190cb2ba4f5
5
5
  SHA512:
6
- metadata.gz: f479aa3bcbdb92e5f6ca7b0f63360d2c6b678b7f65d3f8f0831076264e90151cafcc77717581fd92d5cfeeb2f6f61ed2fc935ee8cc5be00bb2cf9454b76cd974
7
- data.tar.gz: 70e2f01dc594db5732642cc78c9fd50f81c94a8abd54b44556cba23e7030c36159c5d25416230be3919b4a5b2de861d7d96586379a3c804ee3b619207214f249
6
+ metadata.gz: 5495c78dc0562ff98871987caa3a4c0bfc4729e0fa981bf7ab58cb7b6440675dbfeb3527849205d614726dafbd10d3da2fe06fd9cbbbb3f0c34531ed2fef572c
7
+ data.tar.gz: 7d67a52dc39f8c60c093f45b90b9636bededbbcb6271e12e84a1594be2363bd496dd127cea21314bb8ae2edc05a64018504a61dfbe652411ebfaae70bccaceba
data/README.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Pubsubhubbub
2
2
 
3
+ [![Gem Version](http://img.shields.io/gem/v/pubsubhubbub-rails.svg)][gem]
4
+ [![Dependency Status](http://img.shields.io/gemnasium/Gargron/pubsubhubbub.svg)][gemnasium]
5
+
6
+ [gem]: https://rubygems.org/gems/pubsubhubbub-rails
7
+ [gemnasium]: https://gemnasium.com/Gargron/pubsubhubbub
8
+
3
9
  This is a mountable PubSubHubbub server conforming to the v0.4 of the spec.
4
10
 
5
11
  ## Usage
data/Rakefile CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  begin
2
3
  require 'bundler/setup'
3
4
  rescue LoadError
@@ -14,24 +15,9 @@ RDoc::Task.new(:rdoc) do |rdoc|
14
15
  rdoc.rdoc_files.include('lib/**/*.rb')
15
16
  end
16
17
 
17
- APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
18
+ APP_RAKEFILE = File.expand_path('../spec/dummy/Rakefile', __FILE__)
18
19
  load 'rails/tasks/engine.rake'
19
20
 
20
-
21
21
  load 'rails/tasks/statistics.rake'
22
22
 
23
-
24
-
25
23
  require 'bundler/gem_tasks'
26
-
27
- require 'rake/testtask'
28
-
29
- Rake::TestTask.new(:test) do |t|
30
- t.libs << 'lib'
31
- t.libs << 'test'
32
- t.pattern = 'test/**/*_test.rb'
33
- t.verbose = false
34
- end
35
-
36
-
37
- task default: :test
@@ -40,10 +40,10 @@ module Pubsubhubbub
40
40
  xml = Nokogiri::XML(response.body)
41
41
  xml.encoding = 'utf-8'
42
42
 
43
- link = xml.at_xpath('//xmlns:link[@rel="hub"]')
44
- topic = xml.at_xpath('//xmlns:link[@rel="self"]')
43
+ link = xml.at_xpath('//xmlns:link[@rel="hub"]', xmlns: XMLNS)
44
+ topic = xml.at_xpath('//xmlns:link[@rel="self"]', xmlns: XMLNS)
45
45
 
46
- link['href'] == hub_url && topic['href'] == @topic
46
+ link&.attribute('href')&.value == hub_url && topic&.attribute('href')&.value == @topic
47
47
  end
48
48
 
49
49
  def subscribe
@@ -9,7 +9,7 @@ module Pubsubhubbub
9
9
  link = LinkHeader.new([[hub_url, [%w(rel hub)]], [subscription.topic, [%w(rel self)]]])
10
10
  headers = {}
11
11
 
12
- headers['Link'] = link
12
+ headers['Link'] = link.to_s
13
13
  headers['X-Hub-Signature'] = sign_payload(subscription.secret, current_payload) if subscription.secret
14
14
 
15
15
  response = HTTP.timeout(:per_operation, write: 60, connect: 20, read: 60)
@@ -14,11 +14,16 @@ module Pubsubhubbub
14
14
  end
15
15
 
16
16
  before_validation :generate_challenge
17
+ before_validation :set_min_expiration
17
18
 
18
19
  private
19
20
 
20
21
  def generate_challenge
21
22
  self.challenge = SecureRandom.hex
22
23
  end
24
+
25
+ def set_min_expiration
26
+ self.lease_seconds = 0 unless expires_at
27
+ end
23
28
  end
24
29
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  class CreatePubsubhubbubSubscriptions < ActiveRecord::Migration[5.0]
2
3
  def change
3
4
  create_table :pubsubhubbub_subscriptions do |t|
data/lib/pubsubhubbub.rb CHANGED
@@ -7,6 +7,8 @@ require 'link_header'
7
7
  require 'httplog'
8
8
 
9
9
  module Pubsubhubbub
10
+ XMLNS = 'http://www.w3.org/2005/Atom'
11
+
10
12
  class FailedDeliveryError < StandardError
11
13
  end
12
14
  end
@@ -2,5 +2,9 @@
2
2
  module Pubsubhubbub
3
3
  class Engine < ::Rails::Engine
4
4
  isolate_namespace Pubsubhubbub
5
+
6
+ config.generators do |g|
7
+ g.test_framework :rspec, fixture: false
8
+ end
5
9
  end
6
10
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Pubsubhubbub
3
- VERSION = '0.1.0'
3
+ VERSION = '0.2.0'
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pubsubhubbub-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eugen Rochko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-26 00:00:00.000000000 Z
11
+ date: 2016-11-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -86,48 +86,6 @@ dependencies:
86
86
  - - "~>"
87
87
  - !ruby/object:Gem::Version
88
88
  version: '0.0'
89
- - !ruby/object:Gem::Dependency
90
- name: sqlite3
91
- requirement: !ruby/object:Gem::Requirement
92
- requirements:
93
- - - ">="
94
- - !ruby/object:Gem::Version
95
- version: '0'
96
- type: :development
97
- prerelease: false
98
- version_requirements: !ruby/object:Gem::Requirement
99
- requirements:
100
- - - ">="
101
- - !ruby/object:Gem::Version
102
- version: '0'
103
- - !ruby/object:Gem::Dependency
104
- name: pry-rails
105
- requirement: !ruby/object:Gem::Requirement
106
- requirements:
107
- - - ">="
108
- - !ruby/object:Gem::Version
109
- version: '0'
110
- type: :development
111
- prerelease: false
112
- version_requirements: !ruby/object:Gem::Requirement
113
- requirements:
114
- - - ">="
115
- - !ruby/object:Gem::Version
116
- version: '0'
117
- - !ruby/object:Gem::Dependency
118
- name: httplog
119
- requirement: !ruby/object:Gem::Requirement
120
- requirements:
121
- - - ">="
122
- - !ruby/object:Gem::Version
123
- version: '0'
124
- type: :development
125
- prerelease: false
126
- version_requirements: !ruby/object:Gem::Requirement
127
- requirements:
128
- - - ">="
129
- - !ruby/object:Gem::Version
130
- version: '0'
131
89
  description: A PubSubHubbub server conforming to the v0.4 spec, mountable from a Rails
132
90
  app
133
91
  email: