hey 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/README.md +6 -2
- data/lib/hey/version.rb +1 -1
- data/lib/hey/yo.rb +15 -8
- data/test/yo_test.rb +17 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MTU2MWYxNDU2NzFmYTY1MzFlZTcwZDY4ZjU4Y2ZkMzBjZWQ4Mjc5Yg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YTNiYTliNzc0ODEyZDMxMTdlNTdlYWIxN2FhMzUxOGEyNTE1ZjQ1MQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZjQ3ZjI4NDMxZjIyM2NhMWFkYzRmZmNmZTFmNGQ3MDhhYjJhYjBiYjcyNjQ2
|
10
|
+
MjExNGJlNDFhMWVmYjdlYWFlYTExNjNhYzlkMzQ0YjM5ZTdmYjBmMDEwNWYy
|
11
|
+
NzM1ZjUxMWQ5ZDQyYWI5ZmEyY2I3YmJhYTE3NjUzZWVjNmRjZjY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NjkzYzQ2MjVmMjFkMmNkNzc0NWZlODMwOGZiYzMwNGM1ZDlhMGVmYzAyYWY3
|
14
|
+
NzIxNDJjMDI3ODEzOGE3NzcxODIwNmI3NGIxM2M3MTFkZTUzNmI3ZTE0YWYx
|
15
|
+
YWZkODNmMTU1ZThmNzk2OWQ5MjQ3Mjk4NGRlMzc2ZDM0MjZjZmI=
|
data/README.md
CHANGED
@@ -19,14 +19,18 @@ First [get an API token](http://yoapi.justyo.co).
|
|
19
19
|
Then:
|
20
20
|
|
21
21
|
```ruby
|
22
|
-
Hey.api_token =
|
22
|
+
Hey.api_token = "3858f62230ac3c915f300c664312c63f"
|
23
23
|
Hey::Yo.all # or yo a specific user...
|
24
24
|
Hey::Yo.user "WORLDCUP"
|
25
25
|
Hey::Subscriber.count
|
26
26
|
|
27
|
+
# Additional parameters can be sent to Yo endpoints.
|
28
|
+
Hey::Yo.all link: "http://justyo.co"
|
29
|
+
Hey::Yo.user "WORLDCUP", link: "http://justyo.co"
|
30
|
+
|
27
31
|
# or set api_token on a Yo instance:
|
28
32
|
|
29
|
-
yo = Hey::Yo.new
|
33
|
+
yo = Hey::Yo.new api_token: "3858f62230ac3c915f300c664312c63f"
|
30
34
|
yo.all
|
31
35
|
yo.user "WORLDCUP"
|
32
36
|
yo.subscribers.count
|
data/lib/hey/version.rb
CHANGED
data/lib/hey/yo.rb
CHANGED
@@ -8,19 +8,25 @@ module Hey
|
|
8
8
|
# Sends a request to the +yoall+ endpoint.
|
9
9
|
# Raises a +MissingAPITokenError+ error if an API token
|
10
10
|
# hasn't been set on the Hey module or Yo instance.
|
11
|
-
|
11
|
+
# Accepts an optional hash of additional parameters to
|
12
|
+
# send with the request.
|
13
|
+
def all params = {}
|
12
14
|
raise_for_missing_api_token!
|
13
|
-
post 'yoall'
|
15
|
+
post 'yoall', params
|
14
16
|
end
|
15
17
|
|
16
18
|
# Sends a request to a user using the +yo+ endpoint.
|
17
19
|
# Raises a +MissingAPITokenError+ error if an API token
|
18
20
|
# hasn't been set on the Hey module or Yo instance.
|
21
|
+
# Accepts an optional hash of additional parameters to
|
22
|
+
# send with the request.
|
19
23
|
#
|
20
24
|
# Hey::Yo.new.user "worldcup"
|
21
|
-
|
25
|
+
# Hey::Yo.new.user "worldcup", link: "http://example.com"
|
26
|
+
def user name, params = {}
|
22
27
|
raise_for_missing_api_token!
|
23
|
-
|
28
|
+
params.merge! username: name
|
29
|
+
post 'yo', params
|
24
30
|
end
|
25
31
|
|
26
32
|
# Accesses subscriber endpoints using the same API key
|
@@ -34,8 +40,8 @@ module Hey
|
|
34
40
|
|
35
41
|
# Sends a request to the +yoall+ endpoint using the
|
36
42
|
# API token set on the Hey module.
|
37
|
-
def self.all
|
38
|
-
new.all
|
43
|
+
def self.all *args
|
44
|
+
new.all *args
|
39
45
|
end
|
40
46
|
|
41
47
|
# Sends a request to a user using the +yo+ endpoint.
|
@@ -43,8 +49,9 @@ module Hey
|
|
43
49
|
# hasn't been set on the Hey module.
|
44
50
|
#
|
45
51
|
# Hey::Yo.user "worldcup"
|
46
|
-
|
47
|
-
|
52
|
+
# Hey::Yo.user "worldcup", link: "http://example.com"
|
53
|
+
def self.user *args
|
54
|
+
new.user *args
|
48
55
|
end
|
49
56
|
|
50
57
|
end
|
data/test/yo_test.rb
CHANGED
@@ -52,5 +52,22 @@ class YoTest < Minitest::Test
|
|
52
52
|
assert subscriber.is_a?(Hey::Subscriber)
|
53
53
|
assert_equal subscriber.api_token, yo.api_token
|
54
54
|
end
|
55
|
+
|
56
|
+
def test_sends_link_to_all
|
57
|
+
stub_post = stub_request(:post, "http://api.justyo.co/yoall/")
|
58
|
+
.with(:body => {"api_token"=>"foo", "link"=>"http://example.com"})
|
59
|
+
Hey.api_token = 'foo'
|
60
|
+
Hey::Yo.all link: "http://example.com"
|
61
|
+
assert_requested stub_post
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_sends_link_to_user
|
65
|
+
stub_post = stub_request(:post, "http://api.justyo.co/yo/")
|
66
|
+
.with(:body => {"api_token"=>"foo", "link"=>"http://example.com",
|
67
|
+
"username"=>"YOJOBS"})
|
68
|
+
Hey.api_token = 'foo'
|
69
|
+
Hey::Yo.user "YOJOBS", link: "http://example.com"
|
70
|
+
assert_requested stub_post
|
71
|
+
end
|
55
72
|
|
56
73
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hey
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jack Jennings
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-10-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|