hypothesis 0.0.1 → 0.0.2

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: 9c94a80a10fbaf61310d93b0faeb5d11e32b08d0
4
- data.tar.gz: f7230d2e87642a4c2e126759f7e3d8ac574f50f1
3
+ metadata.gz: 26d6aaad780952c945bbc56900dbd4edaefa4c23
4
+ data.tar.gz: 9c782c976134aaafb1e925c0039ddbfb6e12d938
5
5
  SHA512:
6
- metadata.gz: 6e8a14f333d98897609163da4d16daf3c61a4f28c9508d60e78250a851704cd5563cc1f62a418ef80955309fe808afb04dcfdd259b8c5611ec0e48d05c3ecc7c
7
- data.tar.gz: bb5691fb09a333d00d39f452dd747d8248e63b6c7b98aaba47a12e403022117a9a507ccb3f3d43c5e72cdebbc93f0ac5334b33350e5f2c72bc6484ed4411ae0a
6
+ metadata.gz: 29c97ad4ead21deb9265f5fdc328ad0ecf8e65bf155206601e66506ed92a1fb6779f541e76aab3e9f96a784fb2de65a22e04a5b21d947744e8c8351f7aea7dd4
7
+ data.tar.gz: 6a382dbb5184db8ca3ab01d0418d4f72255e42d0a11a248de36c85e875f3316d554ea1c570a64639a31f8a4cb7d7daa7c5a302383c8143017fe55559408ead75
data/README.md CHANGED
@@ -8,7 +8,6 @@ Unofficial [hypothesis](https://hypothes.is) ruby gem.
8
8
 
9
9
  You'll need to generate an API token on your [Hypothesis developer page](https://hypothes.is/account/developer).
10
10
 
11
-
12
11
  ```ruby
13
12
  require 'rubygems'
14
13
  require 'hypothesis'
@@ -18,12 +17,19 @@ puts hypothesis.search({ user: 'javier', limit: 10 })
18
17
 
19
18
  ```
20
19
 
21
- That will output a JSON with the found items:
20
+ That will output a Hash with the found items:
22
21
 
23
22
  ```ruby
24
23
  => {"rows"=>[{"updated"=>"2016-08-21T13:08:33.877253+00:00", "group"=>"__world__", "target"=>[{"source"=>"http://thelongandshort.org/society/war-on-cash", "selector"=>[{"endContainer"=>"/main[1]/article[1]/div[1]/div[6]/div[1]/p[3]", "startContainer"=>"/main[1]/article[1]/div[1]/div[6]/div[1]/p[3]", "type"=>"RangeSelector", "startOffset"=>0, "endOffset"=>368}, {"type"=>"TextPositionSelector", "end"=>9811, "start"=>9443}, {"exact"=>"Anyone defending cash in this context will be labelled as an anti-progress, reactionary, and nostalgic Luddite. That's why we must not defend cash. Rather, we should focus on pointing out that the Death of Cash means the Rise of Something Else. We are fighting a broader battle to maintain alternatives to the growing digital panopticon that is emerging all around us.", "prefix"=>"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", "type"=>"TextQuoteSelector", "suffix"=>"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"}]}], "links"=>{"json"=>"https://hypothes.is/api/annotations/XUdzmGegAeaMle8incguxg", "html"=>"https://hypothes.is/a/XUdzmGegEeaNle8inzguxg", "incontext"=>"https://hyp.is/XUdzmGegAeaMle8incguxg/thelongandshort.org/society/war-on-cash"}, "tags"=>[], "text"=>"", "created"=>"2016-08-21T13:08:33.877245+00:00", "uri"=>"http://thelongandshort.org/society/war-on-cash", "user"=>"acct:javier@hypothes.is", "document"=>{"title"=>["The War on Cash"]}, "id"=>"XUdzmGegAeaMle8incguxg", "permissions"=>{"read"=>["acct:javier@hypothes.is"], "admin"=>["acct:javier@hypothes.is"], "update"=>["acct:javier@hypothes.is"], "delete"=>["acct:javier@hypothes.is"]}}], "total"=>1}
25
24
  ```
26
25
 
26
+ Currently this gem only supports the `root`, `search`, and `read` endpoints.
27
+
27
28
  ### API reference
28
29
 
29
30
  [The Hypothesis API](https://h.readthedocs.io/en/latest/api/)
31
+
32
+ ### License
33
+
34
+
35
+ This work is licensed under the [MIT License (MIT)](LICENSE) and it is not associated with [TinyLetter](https://www.tinyletter.com) in any way.
@@ -1,5 +1,7 @@
1
1
  require 'logger'
2
2
  require 'httparty'
3
+ require 'json'
4
+ require 'ostruct'
3
5
 
4
6
  module Hypothesis
5
7
  class API
@@ -33,7 +35,8 @@ module Hypothesis
33
35
 
34
36
  def get(url, options = {})
35
37
  header = @api_key ? { 'Authorization' => 'Bearer ' + @api_key } : {}
36
- HTTParty.get(url, query: options, headers: header).parsed_response
38
+ results = HTTParty.get(url, query: options, headers: header)
39
+ JSON.parse(results.to_json, object_class: OpenStruct)
37
40
  end
38
41
 
39
42
  def log(msg)
@@ -1,3 +1,3 @@
1
1
  module Hypothesis
2
- VERSION = '0.0.1'.freeze
2
+ VERSION = '0.0.2'.freeze
3
3
  end
data/lib/hypothesis.rb CHANGED
@@ -6,6 +6,13 @@ module Hypothesis
6
6
  class << self
7
7
  attr_accessor :log
8
8
  attr_accessor :debug
9
+
10
+ # Public: An alias for Hypothesis::API.new
11
+ #
12
+ # Returns a Hypothesis::API object
13
+ def new(options = {})
14
+ Hypothesis::API.new(options)
15
+ end
9
16
  end
10
17
 
11
18
  self.log = false
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hypothesis
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Javier Arce