hypothesis 0.0.1 → 0.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 +4 -4
- data/README.md +8 -2
- data/lib/hypothesis/api.rb +4 -1
- data/lib/hypothesis/version.rb +1 -1
- data/lib/hypothesis.rb +7 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 26d6aaad780952c945bbc56900dbd4edaefa4c23
|
4
|
+
data.tar.gz: 9c782c976134aaafb1e925c0039ddbfb6e12d938
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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.
|
data/lib/hypothesis/api.rb
CHANGED
@@ -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)
|
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)
|
data/lib/hypothesis/version.rb
CHANGED
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
|