Skip to content

Commit 2392c5f

Browse files
committed
Merge pull request #4 from youcune/feature/add_link
allows link parameter
2 parents 8f60dd8 + cbc653c commit 2392c5f

4 files changed

Lines changed: 43 additions & 17 deletions

File tree

README.md

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
is a Ruby client of [Yo](http://www.justyo.co/).
44
[![Build Status](https://travis-ci.org/youcune/yo_client.svg?branch=master)](https://travis-ci.org/youcune/yo_client)
5-
[![Coverage Status](https://coveralls.io/repos/youcune/yo_client/badge.png)](https://coveralls.io/r/youcune/yo_client)
65

76
## Requirements
87

@@ -31,10 +30,16 @@ client = YoClient::Client.new(API_TOKEN)
3130
# Yo all subscribers
3231
client.yoall
3332
34-
# Yo specific user
33+
# Yo all subscribers with a link (added from v0.1.0)
34+
client.yoall(link: 'http://youcune.com/')
35+
36+
# Yo the specific user
3537
# Note that USERNAME will be upcased before sending to API
3638
client.yo(USERNAME)
3739
40+
# Yo the specific user with a link (added from v0.1.0)
41+
client.yoall(USERNAME, link: 'http://youcune.com/')
42+
3843
# Count Total Subscribers
3944
client.subscribers_count # -> 5
4045
```
@@ -46,20 +51,20 @@ client.subscribers_count # -> 5
4651

4752
At the date of 13th July, even if API results in failure, it sometimes behaves as if it succeed. In this case, YoClient cannot tell succeeded or not.
4853

49-
## Contributing
50-
51-
1. Fork it ( https://github.com/youcune/yo_client/fork )
52-
2. Create your feature branch (`git checkout -b my-new-feature`)
53-
3. Commit your changes (`git commit -am 'Add some feature'`)
54-
4. Push to the branch (`git push origin my-new-feature`)
55-
5. Create a new Pull Request
56-
57-
## Yo the author
54+
## Yo the developer
5855

59-
[Yo YOUCUNE](http://justyo.co/YOUCUNE), author of YoClient, if you ...
56+
[Yo YOUCUNE](http://justyo.co/YOUCUNE), the developer of YoClient, if you ...
6057

6158
* like YoClient
6259
* dislike YoClient
6360
* have any ideas about YoClient
6461

6562
Thanks.
63+
64+
## Contributing
65+
66+
1. Fork it ( https://github.com/youcune/yo_client/fork )
67+
2. Create your feature branch (`git checkout -b my-new-feature`)
68+
3. Commit your changes (`git commit -am 'Add some feature'`)
69+
4. Push to the branch (`git push origin my-new-feature`)
70+
5. Create a new Pull Request

lib/yo_client.rb

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,23 @@ def initialize(api_token)
1616
end
1717

1818
# Yo to all subscribers
19+
# @param [Hash] options allowed only link for now
1920
# @return [Boolean] if request has succeed
20-
def yoall
21+
def yoall(options = {})
2122
response = connection_wrapper {
22-
@faraday.post '/yoall/', token_hash
23+
@faraday.post '/yoall/', token_hash.merge(options)
2324
}
2425
response.success?
2526
end
2627

2728
# Yo to specific user
2829
# @param [String] username usename to send yo
30+
# @param [Hash] options allowed only link for now
2931
# @return [Boolean] if request has succeed
30-
def yo(username)
32+
def yo(username, options = {})
33+
options.merge!(username: username.upcase)
3134
response = connection_wrapper {
32-
@faraday.post '/yo/', token_hash.merge(username: username.upcase)
35+
@faraday.post '/yo/', token_hash.merge(options)
3336
}
3437
response.success?
3538
end

lib/yo_client/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module YoClient
2-
VERSION = '0.0.3'
2+
VERSION = '0.1.0'
33
end

spec/yo_client_spec.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,15 @@
2323
)
2424
@client.yoall
2525
end
26+
27+
it 'sends Yo with a link' do
28+
expect_any_instance_of(Faraday::Connection).to(
29+
receive(:post)
30+
.with('/yoall/', { api_token: 'test', link: 'http://youcune.com/' })
31+
.and_return(double('yo', body: {}, success?: true))
32+
)
33+
@client.yoall(link: 'http://youcune.com/')
34+
end
2635
end
2736

2837
describe '#yo' do
@@ -34,6 +43,15 @@
3443
)
3544
@client.yo('youcune')
3645
end
46+
47+
it 'sends Yo with a link' do
48+
expect_any_instance_of(Faraday::Connection).to(
49+
receive(:post)
50+
.with('/yo/', { api_token: 'test', username: 'YOUCUNE', link: 'http://youcune.com/' })
51+
.and_return(double('yo', body: {}, success?: true))
52+
)
53+
@client.yo('youcune', link: 'http://youcune.com/')
54+
end
3755
end
3856

3957
describe '#subscribers_count' do

0 commit comments

Comments
 (0)