keybase-unofficial 0.0.6 → 0.0.7

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: 2edd9a6909fd527cc22f65bc1a4f3ba918179e80
4
- data.tar.gz: d847cc38999955a7eb438b17a966f9e0b6f38b4b
3
+ metadata.gz: 92b8d2bb03033f025a8a8e778f11d5e2d470a88a
4
+ data.tar.gz: 9fb4001568fcddebd690431706c93d87459e2e87
5
5
  SHA512:
6
- metadata.gz: 94b656684f60c93c94e8ed1453c37231e3df3c3caf4c7a1314b32e0c4c133f0fe21033936c83fa1b59f9e3be18da3a1c8c0ad151764381dae027502eab9f616a
7
- data.tar.gz: 00553731d8f691ab623328c2142f853c7c0162c498b6a6bb4ed27b2dd4c9532debb5f0795676658b5aa883e8c0bb5fbf89a11ee64224cfd513ca1cde7ecadef7
6
+ metadata.gz: c42a9078a6129bd77e4aa06c73dd6b7525883638fec692fcf645012b89d75714598b6d708faaa8f7d4d2fe8e02fd0250a277237892910805de28a0425608213e
7
+ data.tar.gz: 3947bf4f71286973f63966a1f444ba2a2a6a2f8c495a216a241f41fdd93a360e4a831ca2f9100cfe61804851f8b30fd071e85ddb517c578211a4af2b63f951b1
data/README.md CHANGED
@@ -7,6 +7,12 @@ An unofficial ruby library for Keybase and the Keybase API.
7
7
 
8
8
  Work in progress.
9
9
 
10
+ ### Installation
11
+
12
+ ```bash
13
+ $ gem install keybase-unofficial
14
+ ```
15
+
10
16
  ### Documentation
11
17
 
12
18
  Documentation for the current release can be found on
@@ -20,7 +26,10 @@ require "keybase"
20
26
  # reads your local configuration
21
27
  Keybase.current_user # => "yossarian"
22
28
 
23
- # API access
29
+ # Chatting API
30
+ Keybase::Chat.send_message ["yossarian", "you"], "hello"
31
+
32
+ # REST API
24
33
  person = Keybase::API.lookup username: "yossarian"
25
34
  person.them.profile.bio # => "Computer Science and Philosophy student at the University of Maryland, College Park.\n"
26
35
  ```
data/lib/keybase.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative "keybase/exceptions"
2
4
  require_relative "keybase/configuration"
3
5
  require_relative "keybase/u"
@@ -9,7 +11,7 @@ require_relative "keybase/chat"
9
11
  # The primary namespace for keybase-unofficial.
10
12
  module Keybase
11
13
  # keybase-unofficial's current version
12
- VERSION = "0.0.6".freeze
14
+ VERSION = "0.0.7"
13
15
 
14
16
  extend Configuration
15
17
  end
data/lib/keybase/api.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "faraday"
2
4
  require "json"
3
5
  require "ostruct"
@@ -22,12 +24,9 @@ module Keybase
22
24
  # `hackernews`, `reddit`, `github`, etc.)
23
25
  # @see https://keybase.io/docs/api/1.0/call/user/lookup
24
26
  def lookup(**query)
25
- if query[:usernames]
26
- query[:usernames] = U[query[:usernames]]
27
- end
27
+ query[:usernames] = U[query[:usernames]]
28
28
 
29
- response = Faraday.get "#{BASE_URL}/user/lookup.json", query
30
- JSON.parse(response.body, object_class: OpenStruct)
29
+ fetch_and_structify "/user/lookup.json", query
31
30
  end
32
31
 
33
32
  # Search Keybase for identity components.
@@ -37,8 +36,7 @@ module Keybase
37
36
  # Keybase::API.autocomplete "William Woodruff"
38
37
  # @see https://keybase.io/docs/api/1.0/call/user/autocomplete
39
38
  def autocomplete(query)
40
- response = Faraday.get "#{BASE_URL}/user/autocomplete.json", q: query
41
- JSON.parse(response.body, object_class: OpenStruct)
39
+ fetch_and_structify "/user/autocomplete.json", q: query
42
40
  end
43
41
 
44
42
  # Discover Keybase users from external identities.
@@ -53,8 +51,7 @@ module Keybase
53
51
  # `hackernews`, `reddit`, `github`, etc.)
54
52
  # @see https://keybase.io/docs/api/1.0/call/user/discover
55
53
  def discover(**query)
56
- response = Faraday.get "#{BASE_URL}/user/discover.json", query
57
- JSON.parse(response.body, object_class: OpenStruct)
54
+ fetch_and_structify "/user/discover.json", query
58
55
  end
59
56
 
60
57
  # Retrieve the current site-wide Merkle root hash.
@@ -65,8 +62,7 @@ module Keybase
65
62
  # @return [OpenStruct] a struct mapping of the JSON response
66
63
  # @see https://keybase.io/docs/api/1.0/call/merkle/root
67
64
  def merkle_root(**query)
68
- response = Faraday.get "#{BASE_URL}/merkle/root.json", query
69
- JSON.parse(response.body, object_class: OpenStruct)
65
+ fetch_and_structify "/merkle/root.json", query
70
66
  end
71
67
 
72
68
  # Retrieve a Merkle node corresponding to a given hash.
@@ -75,7 +71,16 @@ module Keybase
75
71
  # @return [OpenStruct] a struct mapping of the JSON response
76
72
  # @see https://keybase.io/docs/api/1.0/call/merkle/block
77
73
  def merkle_block(**query)
78
- response = Faraday.get "#{BASE_URL}/merkle/block.json", query
74
+ fetch_and_structify "/merkle/block.json", query
75
+ end
76
+
77
+ # Make a GET request to the given endpoint with the given parameters.
78
+ # @param endpoint [String] the keybase API endpoint
79
+ # @param query [Hash] the request parameters
80
+ # @return [OpenStruct] a struct mapping of the JSON response
81
+ # @api private
82
+ def fetch_and_structify(endpoint, query)
83
+ response = Faraday.get "#{BASE_URL}#{endpoint}", query
79
84
  JSON.parse(response.body, object_class: OpenStruct)
80
85
  end
81
86
  end
data/lib/keybase/chat.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "open3"
2
4
  require "json"
3
5
  require "ostruct"
@@ -6,7 +8,7 @@ module Keybase
6
8
  # Represents Keybase's JSON chat API.
7
9
  class Chat
8
10
  # The initial arguments to pass when executing Keybase for chatting.
9
- CHAT_EXEC_ARGS = ["keybase", "chat", "api"]
11
+ CHAT_EXEC_ARGS = %w[keybase chat api].freeze
10
12
 
11
13
  class << self
12
14
  # @param meth [Symbol] the chat method
@@ -75,7 +77,7 @@ module Keybase
75
77
  },
76
78
  message: {
77
79
  body: message,
78
- }
80
+ },
79
81
  }
80
82
 
81
83
  chat_call payload
@@ -109,7 +111,7 @@ module Keybase
109
111
  message_id: id,
110
112
  message: {
111
113
  body: message,
112
- }
114
+ },
113
115
  }
114
116
 
115
117
  chat_call payload
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "json"
2
4
 
3
5
  module Keybase
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Keybase
2
4
  # A top-level exception for the library.
3
5
  class KeybaseError < RuntimeError
data/lib/keybase/kbfs.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Keybase
2
4
  # Represents the Keybase filesystem.
3
5
  # @note This is just a stub for the time being.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Keybase
2
4
  # Represents a user known to the local Keybase process.
3
5
  # These are (presumably) users that have been logged into locally.
data/lib/keybase/u.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Keybase
2
4
  # A class for converting arrays of users into Keybase-style strings.
3
5
  class U
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: keybase-unofficial
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - William Woodruff
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-08 00:00:00.000000000 Z
11
+ date: 2017-06-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -61,7 +61,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
61
61
  version: '0'
62
62
  requirements: []
63
63
  rubyforge_project:
64
- rubygems_version: 2.6.8
64
+ rubygems_version: 2.6.11
65
65
  signing_key:
66
66
  specification_version: 4
67
67
  summary: keybase-unofficial - An unofficial library for Keybase.