ostatus2 0.1.1 → 0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 53864441f9a3c0a536a52f316390630d8982ccbf
4
- data.tar.gz: c8699fed6438b98e12c82075c3aecdd3ca98bf6c
3
+ metadata.gz: a0f2bf068c141d0b56b19918f2e63c7cdb09d1f7
4
+ data.tar.gz: 1dac4281a76c4271da2f983d2fc681d3aef40fbc
5
5
  SHA512:
6
- metadata.gz: 0f5b426461d8508c31d82fc40253eddaaf06d45ed848324edfdc96186d28b71b2dd1bb6a62973659bbfbd5fa613698fce6a04f9336159d4733f74037e3ecfca1
7
- data.tar.gz: 488bd014fe2b8d546e28e191eb48a07a3b9805e1e81020f958bfbebef21eded45fb654d3d205d941b38f93cde60155ff73051f8a0288d0b97ba85037a728cdee
6
+ metadata.gz: 2bdf235fd69bf66163458baf423e362627a9e20f08cf971756b03f8e38037b22b3c98d826b6b23a106b6fbc09a9ae35faf5075e0ab2d6f80390501a7f284101a
7
+ data.tar.gz: 522c7df5fd213a553e911fedb6266fe3e21807ee108c34b2a3591dfb83806801077e04dec039c856319def7fcb3f4566bdcd31f6c919b09e52c3dae6f3eb3c7e
@@ -51,8 +51,8 @@ module OStatus2
51
51
 
52
52
  def update_subscription(mode)
53
53
  hub_url = Addressable::URI.parse(@hub)
54
- response = http_client.post(hub_url, form: { 'hub.mode' => mode.to_s, 'hub.callback' => @webhook_url, 'hub.verify' => 'async', 'hub.verify_token' => @token, 'hub.lease_seconds' => '', 'hub.secret' => @secret, 'hub.topic' => @topic_url })
55
- response.code == 200
54
+ response = http_client.post(hub_url, form: { 'hub.mode' => mode.to_s, 'hub.callback' => @webhook_url, 'hub.verify' => 'async', 'hub.verify_token' => @token, 'hub.secret' => @secret, 'hub.topic' => @topic_url })
55
+ SubscriptionResponse.new(response.code, response.body.to_s)
56
56
  end
57
57
 
58
58
  def http_client
@@ -0,0 +1,28 @@
1
+ module OStatus2
2
+ class SubscriptionResponse
3
+ # @param [Integer] code HTTP status code
4
+ # @param [String] body HTTP response body
5
+ def initialize(code, body)
6
+ @code = code
7
+ @body = body
8
+ end
9
+
10
+ # Was the hub operation successful?
11
+ # @return [Boolean]
12
+ def successful?
13
+ @code == 202
14
+ end
15
+
16
+ # Was the hub operation not successful?
17
+ # @return [Boolean]
18
+ def failed?
19
+ !success?
20
+ end
21
+
22
+ # Returns error message if the operation was not successful
23
+ # @return [String]
24
+ def message
25
+ @body
26
+ end
27
+ end
28
+ end
@@ -1,3 +1,3 @@
1
1
  module OStatus2
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2"
3
3
  end
data/lib/ostatus2.rb CHANGED
@@ -6,6 +6,7 @@ require 'nokogiri'
6
6
 
7
7
  require 'ostatus2/version'
8
8
  require 'ostatus2/publication'
9
+ require 'ostatus2/subscription_response'
9
10
  require 'ostatus2/subscription'
10
11
  require 'ostatus2/salmon'
11
12
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ostatus2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: '0.2'
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-02-20 00:00:00.000000000 Z
11
+ date: 2016-09-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http
@@ -78,6 +78,7 @@ files:
78
78
  - lib/ostatus2/publication.rb
79
79
  - lib/ostatus2/salmon.rb
80
80
  - lib/ostatus2/subscription.rb
81
+ - lib/ostatus2/subscription_response.rb
81
82
  - lib/ostatus2/version.rb
82
83
  homepage: https://github.com/Gargron/ostatus2
83
84
  licenses:
@@ -99,9 +100,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
99
100
  version: '0'
100
101
  requirements: []
101
102
  rubyforge_project:
102
- rubygems_version: 2.4.6
103
+ rubygems_version: 2.4.5.1
103
104
  signing_key:
104
105
  specification_version: 4
105
106
  summary: Toolset for interacting with the OStatus2 suite of protocols
106
107
  test_files: []
107
- has_rdoc: