yoyo 0.1.0 → 0.1.1
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/lib/yoyo.rb +30 -0
- data/lib/yoyo/version.rb +3 -1
- data/test/yoyo_test.rb +8 -0
- metadata +16 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ffca99b3259c955b70b3d4e3612f3ca0d86350d6
|
4
|
+
data.tar.gz: b59d30b8bef71f37888449ab7d2cdb7b0e85d798
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ffe2558b41f29847c30a53f92796fc0527ab71cfdefef132cdc2c260c371aab8ac8361c87319bcff0490fb121838a343cd4d560e657e94376bdc0a168a537494
|
7
|
+
data.tar.gz: e3be52000804fd804525f4902ea7320e43199e31c0b2af2b9e5723e5a6077a237893b28f8f57f12641cea2c12ae0a7694a57f52bc4d9da07ffbd97a036c8958d
|
data/lib/yoyo.rb
CHANGED
@@ -3,9 +3,20 @@ require 'faraday'
|
|
3
3
|
|
4
4
|
module Yoyo
|
5
5
|
class Yo
|
6
|
+
# = Yoyo
|
7
|
+
#
|
8
|
+
# Yoyo is a gem for accessing the YO api. I hope you like it!
|
9
|
+
|
10
|
+
# This is your API token.
|
11
|
+
# There are many like it, but this one is yours. See http://dev.justyo.co/
|
6
12
|
attr_reader :api_token
|
13
|
+
|
14
|
+
# This is just a reference to the HTTP connection to the YO mothership.
|
15
|
+
# I mean API.
|
7
16
|
attr_reader :api_connection
|
8
17
|
|
18
|
+
# You're going to need an API token to get started.
|
19
|
+
# You can get one from http://dev.justyo.co/
|
9
20
|
def initialize(api_token)
|
10
21
|
@api_token = api_token
|
11
22
|
@api_connection = Faraday.new(:url => "http://api.justyo.co/") do |f|
|
@@ -15,13 +26,32 @@ module Yoyo
|
|
15
26
|
end
|
16
27
|
|
17
28
|
# Say YO to someone from your API account
|
29
|
+
# Usage: yo("PHILCRISSMAN")
|
30
|
+
# Returns a Faraday response, so you can see the HTTP status and errors, if any
|
18
31
|
def yo(some_user)
|
19
32
|
api_connection.post "/yo/", { api_token: api_token, username: some_user }
|
20
33
|
end
|
21
34
|
|
22
35
|
# Say YO to everyone who has ever YO'd your API account
|
36
|
+
# Should return an empty body. YOs all your subscribers
|
23
37
|
def yo_all
|
24
38
|
api_connection.post "/yoall/", { api_token: api_token }
|
25
39
|
end
|
40
|
+
|
41
|
+
# Get the number of subscribers you have. That sounds handy.
|
42
|
+
# Does YO document this anywhere? I can't find it.
|
43
|
+
# Returns a Faraday response.
|
44
|
+
# To get the count, you could:
|
45
|
+
#
|
46
|
+
# require 'JSON'
|
47
|
+
# yo = Yoyo::Yo.new('your-token')
|
48
|
+
# count = yo.subscribers_count
|
49
|
+
# response_hash = JSON.parse(count.body)
|
50
|
+
# response_hash['result']
|
51
|
+
#
|
52
|
+
# That's not too hard.
|
53
|
+
def subscribers_count
|
54
|
+
api_connection.get "/subscribers_count/", { api_token: api_token }
|
55
|
+
end
|
26
56
|
end
|
27
57
|
end
|
data/lib/yoyo/version.rb
CHANGED
data/test/yoyo_test.rb
CHANGED
@@ -9,6 +9,7 @@ class YoyoTest < Minitest::Test
|
|
9
9
|
builder.adapter :test do |stub|
|
10
10
|
stub.post('/yo/') { [200, {}, "{\"result\": \"OK\"}"] }
|
11
11
|
stub.post('/yoall/') { [201, {}, "{}"] }
|
12
|
+
stub.get('/subscribers_count/') { [200, {}, "{\"result\": 9001}"] }
|
12
13
|
end
|
13
14
|
end
|
14
15
|
|
@@ -39,4 +40,11 @@ class YoyoTest < Minitest::Test
|
|
39
40
|
response = yo.yo_all
|
40
41
|
assert_equal "{}", response.body
|
41
42
|
end
|
43
|
+
|
44
|
+
def test_get_subscriber_count
|
45
|
+
yo = Yoyo::Yo.new("some-token")
|
46
|
+
|
47
|
+
response = yo.subscribers_count
|
48
|
+
assert_equal "{\"result\": 9001}", response.body
|
49
|
+
end
|
42
50
|
end
|
metadata
CHANGED
@@ -1,83 +1,83 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yoyo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Phil Crissman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-07-
|
11
|
+
date: 2014-07-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.6'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.6'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: minitest
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: mocha
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: faraday
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
description: It's a ruby gem for using the YO API. You need to get an API Token, okay?
|
@@ -87,7 +87,7 @@ executables: []
|
|
87
87
|
extensions: []
|
88
88
|
extra_rdoc_files: []
|
89
89
|
files:
|
90
|
-
- .gitignore
|
90
|
+
- ".gitignore"
|
91
91
|
- Gemfile
|
92
92
|
- LICENSE.txt
|
93
93
|
- README.md
|
@@ -106,17 +106,17 @@ require_paths:
|
|
106
106
|
- lib
|
107
107
|
required_ruby_version: !ruby/object:Gem::Requirement
|
108
108
|
requirements:
|
109
|
-
- -
|
109
|
+
- - ">="
|
110
110
|
- !ruby/object:Gem::Version
|
111
111
|
version: '0'
|
112
112
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
113
113
|
requirements:
|
114
|
-
- -
|
114
|
+
- - ">="
|
115
115
|
- !ruby/object:Gem::Version
|
116
116
|
version: '0'
|
117
117
|
requirements: []
|
118
118
|
rubyforge_project:
|
119
|
-
rubygems_version: 2.
|
119
|
+
rubygems_version: 2.3.0
|
120
120
|
signing_key:
|
121
121
|
specification_version: 4
|
122
122
|
summary: A ruby gem for using the YO API
|