yo_client 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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 78689d15bfac530539523a79d1ff1b65b7ec300e
4
+ data.tar.gz: 84bda1bec35c29c08d698a14671832175f7d8eab
5
+ SHA512:
6
+ metadata.gz: c27e20590014c4e3291bf170ab86b7aca3a5b207baa1171ee3724b03590c223c0abb017d1987572cecd95aca36d8683f2b486b85120d5526c9facf54ff05fa0f
7
+ data.tar.gz: 55f94566690d09a603149ba315697b17f87cbcf333fc326c676a4906c0fc2d613ccf2f692ee371d4e17afb2354ef59282a97f3179eb185faa229a549d06bfbae
data/.gitignore ADDED
@@ -0,0 +1,23 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
23
+ /vendor/bundle
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.2
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in yo_client.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 youcune
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,42 @@
1
+ # YoClient [![Build Status](https://travis-ci.org/youcune/yo_client.svg?branch=master)](https://travis-ci.org/youcune/yo_client)
2
+
3
+ is a Ruby client of [Yo](http://www.justyo.co/).
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```
10
+ gem 'yo_client', github: 'youcune/yo_client'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ ```
16
+ $ bundle
17
+ ```
18
+
19
+ ## Usage
20
+
21
+ ```
22
+ client = YoClient::Client.new(API_TOKEN)
23
+
24
+ # Send A Yo To All Subscribers
25
+ client.yoall
26
+
27
+ # Yo Individual Usernames
28
+ # Note that USERNAME will be upcased and sent to API
29
+ client.yo(USERNAME)
30
+
31
+ # Count Total Subscribers
32
+ client.subscribers_count # -> 5
33
+ ```
34
+
35
+ ## Contributing
36
+
37
+ 1. Fork it ( https://github.com/youcune/yo_client/fork )
38
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
39
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
40
+ 4. Push to the branch (`git push origin my-new-feature`)
41
+ 5. Create a new Pull Request
42
+
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
7
+
data/lib/yo_client.rb ADDED
@@ -0,0 +1,41 @@
1
+ require 'yo_client/version'
2
+ require 'faraday'
3
+ require 'faraday_middleware'
4
+
5
+ module YoClient
6
+ class Client
7
+ # Constructor
8
+ # @param [String] token Yo API Token
9
+ def initialize(api_token)
10
+ @api_token = api_token
11
+ @faraday = Faraday.new(url: 'http://api.justyo.co') do |faraday|
12
+ faraday.request :url_encoded
13
+ faraday.response :json
14
+ faraday.adapter :net_http
15
+ end
16
+ end
17
+
18
+ # Yo to all subscribers
19
+ def yoall
20
+ @faraday.post '/yoall/', token_hash
21
+ end
22
+
23
+ # Yo to specific user
24
+ # @param [String] username
25
+ def yo(username)
26
+ @faraday.post '/yo/', token_hash.merge(username: username.upcase)
27
+ end
28
+
29
+ # Get a number of subscribers
30
+ # @return [Integer] number of subscribers
31
+ def subscribers_count
32
+ response = @faraday.get '/subscribers_count/', token_hash
33
+ response.body['result']
34
+ end
35
+
36
+ private
37
+ def token_hash
38
+ { api_token: @api_token }
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,3 @@
1
+ module YoClient
2
+ VERSION = '0.0.2'
3
+ end
@@ -0,0 +1,3 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require 'yo_client'
3
+ require 'pry'
@@ -0,0 +1,50 @@
1
+ require 'spec_helper'
2
+
3
+ describe YoClient do
4
+ it 'has a version number' do
5
+ expect(YoClient::VERSION).not_to be nil
6
+ end
7
+
8
+ it 'can create instance' do
9
+ expect(YoClient::Client.new('test')).to be_an_instance_of(YoClient::Client)
10
+ end
11
+
12
+ describe 'Instance of YoClient::Client' do
13
+ before do
14
+ @client = YoClient::Client.new('test')
15
+ end
16
+
17
+ describe '#yoall' do
18
+ it 'hooks POST /yoall/' do
19
+ expect_any_instance_of(Faraday::Connection).to(
20
+ receive(:post)
21
+ .with('/yoall/', { api_token: 'test' })
22
+ .and_return(double('yo', body: {}))
23
+ )
24
+ @client.yoall
25
+ end
26
+ end
27
+
28
+ describe '#yo' do
29
+ it 'hooks POST /yo/' do
30
+ expect_any_instance_of(Faraday::Connection).to(
31
+ receive(:post)
32
+ .with('/yo/', { api_token: 'test', username: 'YOUCUNE' })
33
+ .and_return(double('yo', body: {}))
34
+ )
35
+ @client.yo('youcune')
36
+ end
37
+ end
38
+
39
+ describe '#subscribers_count' do
40
+ it 'hooks GET /subscribers_count/' do
41
+ expect_any_instance_of(Faraday::Connection).to(
42
+ receive(:get)
43
+ .with('/subscribers_count/', { api_token: 'test' })
44
+ .and_return(double('subscribers_count', body: { 'result' => 5 }))
45
+ )
46
+ expect(@client.subscribers_count).to eq 5
47
+ end
48
+ end
49
+ end
50
+ end
data/yo_client.gemspec ADDED
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'yo_client/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'yo_client'
8
+ spec.version = YoClient::VERSION
9
+ spec.authors = ['Yu Nakanishi']
10
+ spec.email = ['you@nakanishi.email']
11
+ spec.summary = 'Yo Client Library'
12
+ spec.description = 'Yo Client Library'
13
+ spec.homepage = 'https://github.com/youcune/yo_client'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_development_dependency 'bundler', '~> 1.6'
22
+ spec.add_development_dependency 'rake'
23
+ spec.add_development_dependency 'rspec'
24
+ spec.add_development_dependency 'pry-byebug'
25
+ spec.add_dependency 'faraday'
26
+ spec.add_dependency 'faraday_middleware'
27
+ end
metadata ADDED
@@ -0,0 +1,142 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: yo_client
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Yu Nakanishi
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-07-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry-byebug
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: faraday
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: faraday_middleware
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: Yo Client Library
98
+ email:
99
+ - you@nakanishi.email
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - ".gitignore"
105
+ - ".rspec"
106
+ - ".travis.yml"
107
+ - Gemfile
108
+ - LICENSE.txt
109
+ - README.md
110
+ - Rakefile
111
+ - lib/yo_client.rb
112
+ - lib/yo_client/version.rb
113
+ - spec/spec_helper.rb
114
+ - spec/yo_client_spec.rb
115
+ - yo_client.gemspec
116
+ homepage: https://github.com/youcune/yo_client
117
+ licenses:
118
+ - MIT
119
+ metadata: {}
120
+ post_install_message:
121
+ rdoc_options: []
122
+ require_paths:
123
+ - lib
124
+ required_ruby_version: !ruby/object:Gem::Requirement
125
+ requirements:
126
+ - - ">="
127
+ - !ruby/object:Gem::Version
128
+ version: '0'
129
+ required_rubygems_version: !ruby/object:Gem::Requirement
130
+ requirements:
131
+ - - ">="
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ requirements: []
135
+ rubyforge_project:
136
+ rubygems_version: 2.2.2
137
+ signing_key:
138
+ specification_version: 4
139
+ summary: Yo Client Library
140
+ test_files:
141
+ - spec/spec_helper.rb
142
+ - spec/yo_client_spec.rb