twoffein-client 0.1.0
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.
- data/.gitignore +7 -0
- data/.rspec +2 -0
- data/.rvmrc +1 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +207 -0
- data/README.md.erb +52 -0
- data/Rakefile +67 -0
- data/VERSION +1 -0
- data/bin/twoffein-client +84 -0
- data/features/step_definitions/twoffein-client_steps.rb +1 -0
- data/features/support/env.rb +16 -0
- data/features/twoffein-client.feature +13 -0
- data/fixtures/vcr_cassettes/cookie.yml +234 -0
- data/fixtures/vcr_cassettes/drink.yml +60 -0
- data/fixtures/vcr_cassettes/drinks.yml +461 -0
- data/fixtures/vcr_cassettes/profile.yml +69 -0
- data/fixtures/vcr_cassettes/tweet.yml +103 -0
- data/lib/twoffein-client.rb +12 -0
- data/lib/twoffein-client/constants.rb +9 -0
- data/lib/twoffein-client/cookie.rb +23 -0
- data/lib/twoffein-client/credentials.rb +5 -0
- data/lib/twoffein-client/drink.rb +43 -0
- data/lib/twoffein-client/drinks.rb +96 -0
- data/lib/twoffein-client/exceptions.rb +15 -0
- data/lib/twoffein-client/http.rb +96 -0
- data/lib/twoffein-client/profile.rb +61 -0
- data/lib/twoffein-client/tweet.rb +31 -0
- data/lib/twoffein-client/util.rb +7 -0
- data/lib/twoffein-client/version.rb +7 -0
- data/spec/constants_spec.rb +11 -0
- data/spec/cookie_spec.rb +25 -0
- data/spec/drink_spec.rb +49 -0
- data/spec/drinks_spec.rb +154 -0
- data/spec/exceptions_spec.rb +14 -0
- data/spec/http_spec.rb +94 -0
- data/spec/profile_spec.rb +58 -0
- data/spec/spec_helper.rb +25 -0
- data/spec/tweet_spec.rb +41 -0
- data/spec/util_spec.rb +20 -0
- data/twoffein-client.gemspec +28 -0
- metadata +245 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
require_relative "spec_helper"
|
|
3
|
+
include SpecHelper
|
|
4
|
+
|
|
5
|
+
describe Profile do
|
|
6
|
+
it "#init" do
|
|
7
|
+
profile = Profile.new(:quest => "", :drink => "clubmate", :ranke => 1234, :rank_title => "title", :drunken => 123, :bluttwoffeinkonzentration => "high", :first_login => Time.now, :screen_name => SCREEN_NAME, :novalid => true)
|
|
8
|
+
profile.members.count.should be 8
|
|
9
|
+
expect { profile.novalid }.to raise_error
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
it "#init without values" do
|
|
13
|
+
profile = Profile.new
|
|
14
|
+
profile.members.count.should be 8
|
|
15
|
+
profile.members.each do |member, val|
|
|
16
|
+
val.should be_nil
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it "::get" do
|
|
21
|
+
VCR.use_cassette("profile") do
|
|
22
|
+
profile = Profile.get
|
|
23
|
+
profile.quest.should eq "Blitzlicht"
|
|
24
|
+
profile.drink.should eq "Club-Mate"
|
|
25
|
+
profile.rank.should eq 74
|
|
26
|
+
profile.rank_title.should eq "Kaffeekännchen"
|
|
27
|
+
profile.drunken.should eq "15"
|
|
28
|
+
profile.bluttwoffeinkonzentration.should eq "1%"
|
|
29
|
+
profile.first_login.should eq "1341747375"
|
|
30
|
+
profile.screen_name.should eq SCREEN_NAME
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
it "::get with profile" do
|
|
35
|
+
VCR.use_cassette("profile") do
|
|
36
|
+
pending "Server has to implement"
|
|
37
|
+
profile = Profile.get("BakeRolls")
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
it "#to_s" do
|
|
42
|
+
pending ""
|
|
43
|
+
VCR.use_cassette("profile") do
|
|
44
|
+
profile = Profile.get
|
|
45
|
+
output = <<-EOF
|
|
46
|
+
Quest: Blitzlicht
|
|
47
|
+
Drink: Club-Mate
|
|
48
|
+
Rank: 74
|
|
49
|
+
Rank Title: Kaffeekännchen
|
|
50
|
+
Drunken: 15
|
|
51
|
+
Bluttwoffeinkonzentration: 1%
|
|
52
|
+
First Login: 2012-07-08 13:36
|
|
53
|
+
Screen Name: DSIW
|
|
54
|
+
EOF
|
|
55
|
+
profile.to_s.should eq output
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
data/spec/spec_helper.rb
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
require_relative "../lib/twoffein-client"
|
|
2
|
+
require "vcr"
|
|
3
|
+
|
|
4
|
+
module SpecHelper
|
|
5
|
+
VCR.configure do |c|
|
|
6
|
+
c.cassette_library_dir = 'fixtures/vcr_cassettes'
|
|
7
|
+
c.hook_into :webmock # or :fakeweb
|
|
8
|
+
c.default_cassette_options = {
|
|
9
|
+
:record => :new_episodes,
|
|
10
|
+
:erb => true
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
c.register_request_matcher :ignore_query_param_ordering do |request1, request2|
|
|
14
|
+
uri1 = URI(request1.uri)
|
|
15
|
+
uri2 = URI(request2.uri)
|
|
16
|
+
|
|
17
|
+
uri1.scheme == uri2.scheme &&
|
|
18
|
+
uri1.host == uri2.host &&
|
|
19
|
+
uri1.path == uri2.path &&
|
|
20
|
+
CGI.parse(uri1.query) == CGI.parse(uri2.query)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
include Twoffein
|
|
25
|
+
end
|
data/spec/tweet_spec.rb
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
require_relative "spec_helper"
|
|
2
|
+
include SpecHelper
|
|
3
|
+
|
|
4
|
+
describe Tweet do
|
|
5
|
+
it "#init without default" do
|
|
6
|
+
tweet = Tweet.new :clubmate, "BakeRolls"
|
|
7
|
+
tweet.drink.should eq :clubmate
|
|
8
|
+
tweet.target_screen_name.should eq "BakeRolls"
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it "#init without default" do
|
|
12
|
+
tweet = Tweet.new "clubmate", "BakeRolls"
|
|
13
|
+
tweet.drink.should eq :clubmate
|
|
14
|
+
tweet.target_screen_name.should eq "BakeRolls"
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it "#post with target_screen_name" do
|
|
18
|
+
VCR.use_cassette("tweet") do
|
|
19
|
+
tweet = Tweet.new "clubmate", "UserDoesNotExistTest"
|
|
20
|
+
info = tweet.post
|
|
21
|
+
info[:code].to_sym.should be :luna
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it "#post without target_screen_name" do
|
|
26
|
+
VCR.use_cassette("tweet") do
|
|
27
|
+
tweet = Tweet.new "clubmate"
|
|
28
|
+
info = tweet.post
|
|
29
|
+
info[:code].to_sym.should be :luna
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
it "#to_s" do
|
|
34
|
+
VCR.use_cassette("drinks") do
|
|
35
|
+
tweet = Tweet.new :clubmate, "BakeRolls"
|
|
36
|
+
tweet.to_s.should == "Ich trinke gerade Club-Mate mit BakeRolls."
|
|
37
|
+
tweet = Tweet.new :clubmate
|
|
38
|
+
tweet.to_s.should == "Ich trinke gerade Club-Mate."
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
data/spec/util_spec.rb
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
require_relative "spec_helper"
|
|
2
|
+
include SpecHelper
|
|
3
|
+
|
|
4
|
+
describe Util do
|
|
5
|
+
it "::compact!" do
|
|
6
|
+
hash = {
|
|
7
|
+
:zero => "ok",
|
|
8
|
+
:first => nil,
|
|
9
|
+
:second => "",
|
|
10
|
+
:third => '',
|
|
11
|
+
:test => :test,
|
|
12
|
+
}
|
|
13
|
+
Util.compact!(hash)
|
|
14
|
+
compacted = {
|
|
15
|
+
:zero => "ok",
|
|
16
|
+
:test => :test,
|
|
17
|
+
}
|
|
18
|
+
hash.should == compacted
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
require File.absolute_path('../lib/twoffein-client/version', __FILE__)
|
|
3
|
+
|
|
4
|
+
Gem::Specification.new do |gem|
|
|
5
|
+
gem.authors = ["DSIW"]
|
|
6
|
+
gem.email = ["dsiw@dsiw-it.de"]
|
|
7
|
+
gem.description = %q{Client for twoffein.de API}
|
|
8
|
+
gem.summary = %q{Client for twoffein.de API}
|
|
9
|
+
gem.homepage = "https://github.com/DSIW/twoffein-client"
|
|
10
|
+
|
|
11
|
+
gem.files = `git ls-files`.split($\)
|
|
12
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
|
13
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
|
14
|
+
gem.name = "twoffein-client"
|
|
15
|
+
gem.require_paths = ["lib"]
|
|
16
|
+
gem.license = "MIT"
|
|
17
|
+
gem.version = Twoffein::Client::VERSION
|
|
18
|
+
gem.post_install_message = "Thanks for installing!"
|
|
19
|
+
gem.add_development_dependency('rdoc')
|
|
20
|
+
gem.add_development_dependency('aruba')
|
|
21
|
+
gem.add_development_dependency('rake','~> 0.9.2')
|
|
22
|
+
gem.add_development_dependency('pry')
|
|
23
|
+
gem.add_development_dependency('webmock')
|
|
24
|
+
gem.add_development_dependency('vcr')
|
|
25
|
+
gem.add_development_dependency('version')
|
|
26
|
+
gem.add_dependency('methadone', '~>1.0.0.rc4')
|
|
27
|
+
gem.add_dependency('gli')
|
|
28
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: twoffein-client
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
prerelease:
|
|
6
|
+
platform: ruby
|
|
7
|
+
authors:
|
|
8
|
+
- DSIW
|
|
9
|
+
autorequire:
|
|
10
|
+
bindir: bin
|
|
11
|
+
cert_chain: []
|
|
12
|
+
date: 2012-08-23 00:00:00.000000000 Z
|
|
13
|
+
dependencies:
|
|
14
|
+
- !ruby/object:Gem::Dependency
|
|
15
|
+
name: rdoc
|
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
|
17
|
+
none: false
|
|
18
|
+
requirements:
|
|
19
|
+
- - ! '>='
|
|
20
|
+
- !ruby/object:Gem::Version
|
|
21
|
+
version: '0'
|
|
22
|
+
type: :development
|
|
23
|
+
prerelease: false
|
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
25
|
+
none: false
|
|
26
|
+
requirements:
|
|
27
|
+
- - ! '>='
|
|
28
|
+
- !ruby/object:Gem::Version
|
|
29
|
+
version: '0'
|
|
30
|
+
- !ruby/object:Gem::Dependency
|
|
31
|
+
name: aruba
|
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
|
33
|
+
none: false
|
|
34
|
+
requirements:
|
|
35
|
+
- - ! '>='
|
|
36
|
+
- !ruby/object:Gem::Version
|
|
37
|
+
version: '0'
|
|
38
|
+
type: :development
|
|
39
|
+
prerelease: false
|
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
41
|
+
none: false
|
|
42
|
+
requirements:
|
|
43
|
+
- - ! '>='
|
|
44
|
+
- !ruby/object:Gem::Version
|
|
45
|
+
version: '0'
|
|
46
|
+
- !ruby/object:Gem::Dependency
|
|
47
|
+
name: rake
|
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
|
49
|
+
none: false
|
|
50
|
+
requirements:
|
|
51
|
+
- - ~>
|
|
52
|
+
- !ruby/object:Gem::Version
|
|
53
|
+
version: 0.9.2
|
|
54
|
+
type: :development
|
|
55
|
+
prerelease: false
|
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
57
|
+
none: false
|
|
58
|
+
requirements:
|
|
59
|
+
- - ~>
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: 0.9.2
|
|
62
|
+
- !ruby/object:Gem::Dependency
|
|
63
|
+
name: pry
|
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
|
65
|
+
none: false
|
|
66
|
+
requirements:
|
|
67
|
+
- - ! '>='
|
|
68
|
+
- !ruby/object:Gem::Version
|
|
69
|
+
version: '0'
|
|
70
|
+
type: :development
|
|
71
|
+
prerelease: false
|
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
73
|
+
none: false
|
|
74
|
+
requirements:
|
|
75
|
+
- - ! '>='
|
|
76
|
+
- !ruby/object:Gem::Version
|
|
77
|
+
version: '0'
|
|
78
|
+
- !ruby/object:Gem::Dependency
|
|
79
|
+
name: webmock
|
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
|
81
|
+
none: false
|
|
82
|
+
requirements:
|
|
83
|
+
- - ! '>='
|
|
84
|
+
- !ruby/object:Gem::Version
|
|
85
|
+
version: '0'
|
|
86
|
+
type: :development
|
|
87
|
+
prerelease: false
|
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
89
|
+
none: false
|
|
90
|
+
requirements:
|
|
91
|
+
- - ! '>='
|
|
92
|
+
- !ruby/object:Gem::Version
|
|
93
|
+
version: '0'
|
|
94
|
+
- !ruby/object:Gem::Dependency
|
|
95
|
+
name: vcr
|
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
|
97
|
+
none: false
|
|
98
|
+
requirements:
|
|
99
|
+
- - ! '>='
|
|
100
|
+
- !ruby/object:Gem::Version
|
|
101
|
+
version: '0'
|
|
102
|
+
type: :development
|
|
103
|
+
prerelease: false
|
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
105
|
+
none: false
|
|
106
|
+
requirements:
|
|
107
|
+
- - ! '>='
|
|
108
|
+
- !ruby/object:Gem::Version
|
|
109
|
+
version: '0'
|
|
110
|
+
- !ruby/object:Gem::Dependency
|
|
111
|
+
name: version
|
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
|
113
|
+
none: false
|
|
114
|
+
requirements:
|
|
115
|
+
- - ! '>='
|
|
116
|
+
- !ruby/object:Gem::Version
|
|
117
|
+
version: '0'
|
|
118
|
+
type: :development
|
|
119
|
+
prerelease: false
|
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
121
|
+
none: false
|
|
122
|
+
requirements:
|
|
123
|
+
- - ! '>='
|
|
124
|
+
- !ruby/object:Gem::Version
|
|
125
|
+
version: '0'
|
|
126
|
+
- !ruby/object:Gem::Dependency
|
|
127
|
+
name: methadone
|
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
|
129
|
+
none: false
|
|
130
|
+
requirements:
|
|
131
|
+
- - ~>
|
|
132
|
+
- !ruby/object:Gem::Version
|
|
133
|
+
version: 1.0.0.rc4
|
|
134
|
+
type: :runtime
|
|
135
|
+
prerelease: false
|
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
137
|
+
none: false
|
|
138
|
+
requirements:
|
|
139
|
+
- - ~>
|
|
140
|
+
- !ruby/object:Gem::Version
|
|
141
|
+
version: 1.0.0.rc4
|
|
142
|
+
- !ruby/object:Gem::Dependency
|
|
143
|
+
name: gli
|
|
144
|
+
requirement: !ruby/object:Gem::Requirement
|
|
145
|
+
none: false
|
|
146
|
+
requirements:
|
|
147
|
+
- - ! '>='
|
|
148
|
+
- !ruby/object:Gem::Version
|
|
149
|
+
version: '0'
|
|
150
|
+
type: :runtime
|
|
151
|
+
prerelease: false
|
|
152
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
153
|
+
none: false
|
|
154
|
+
requirements:
|
|
155
|
+
- - ! '>='
|
|
156
|
+
- !ruby/object:Gem::Version
|
|
157
|
+
version: '0'
|
|
158
|
+
description: Client for twoffein.de API
|
|
159
|
+
email:
|
|
160
|
+
- dsiw@dsiw-it.de
|
|
161
|
+
executables:
|
|
162
|
+
- twoffein-client
|
|
163
|
+
extensions: []
|
|
164
|
+
extra_rdoc_files: []
|
|
165
|
+
files:
|
|
166
|
+
- .gitignore
|
|
167
|
+
- .rspec
|
|
168
|
+
- .rvmrc
|
|
169
|
+
- Gemfile
|
|
170
|
+
- LICENSE
|
|
171
|
+
- README.md
|
|
172
|
+
- README.md.erb
|
|
173
|
+
- Rakefile
|
|
174
|
+
- VERSION
|
|
175
|
+
- bin/twoffein-client
|
|
176
|
+
- features/step_definitions/twoffein-client_steps.rb
|
|
177
|
+
- features/support/env.rb
|
|
178
|
+
- features/twoffein-client.feature
|
|
179
|
+
- fixtures/vcr_cassettes/cookie.yml
|
|
180
|
+
- fixtures/vcr_cassettes/drink.yml
|
|
181
|
+
- fixtures/vcr_cassettes/drinks.yml
|
|
182
|
+
- fixtures/vcr_cassettes/profile.yml
|
|
183
|
+
- fixtures/vcr_cassettes/tweet.yml
|
|
184
|
+
- lib/twoffein-client.rb
|
|
185
|
+
- lib/twoffein-client/constants.rb
|
|
186
|
+
- lib/twoffein-client/cookie.rb
|
|
187
|
+
- lib/twoffein-client/credentials.rb
|
|
188
|
+
- lib/twoffein-client/drink.rb
|
|
189
|
+
- lib/twoffein-client/drinks.rb
|
|
190
|
+
- lib/twoffein-client/exceptions.rb
|
|
191
|
+
- lib/twoffein-client/http.rb
|
|
192
|
+
- lib/twoffein-client/profile.rb
|
|
193
|
+
- lib/twoffein-client/tweet.rb
|
|
194
|
+
- lib/twoffein-client/util.rb
|
|
195
|
+
- lib/twoffein-client/version.rb
|
|
196
|
+
- spec/constants_spec.rb
|
|
197
|
+
- spec/cookie_spec.rb
|
|
198
|
+
- spec/drink_spec.rb
|
|
199
|
+
- spec/drinks_spec.rb
|
|
200
|
+
- spec/exceptions_spec.rb
|
|
201
|
+
- spec/http_spec.rb
|
|
202
|
+
- spec/profile_spec.rb
|
|
203
|
+
- spec/spec_helper.rb
|
|
204
|
+
- spec/tweet_spec.rb
|
|
205
|
+
- spec/util_spec.rb
|
|
206
|
+
- twoffein-client.gemspec
|
|
207
|
+
homepage: https://github.com/DSIW/twoffein-client
|
|
208
|
+
licenses:
|
|
209
|
+
- MIT
|
|
210
|
+
post_install_message: Thanks for installing!
|
|
211
|
+
rdoc_options: []
|
|
212
|
+
require_paths:
|
|
213
|
+
- lib
|
|
214
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
215
|
+
none: false
|
|
216
|
+
requirements:
|
|
217
|
+
- - ! '>='
|
|
218
|
+
- !ruby/object:Gem::Version
|
|
219
|
+
version: '0'
|
|
220
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
221
|
+
none: false
|
|
222
|
+
requirements:
|
|
223
|
+
- - ! '>='
|
|
224
|
+
- !ruby/object:Gem::Version
|
|
225
|
+
version: '0'
|
|
226
|
+
requirements: []
|
|
227
|
+
rubyforge_project:
|
|
228
|
+
rubygems_version: 1.8.24
|
|
229
|
+
signing_key:
|
|
230
|
+
specification_version: 3
|
|
231
|
+
summary: Client for twoffein.de API
|
|
232
|
+
test_files:
|
|
233
|
+
- features/step_definitions/twoffein-client_steps.rb
|
|
234
|
+
- features/support/env.rb
|
|
235
|
+
- features/twoffein-client.feature
|
|
236
|
+
- spec/constants_spec.rb
|
|
237
|
+
- spec/cookie_spec.rb
|
|
238
|
+
- spec/drink_spec.rb
|
|
239
|
+
- spec/drinks_spec.rb
|
|
240
|
+
- spec/exceptions_spec.rb
|
|
241
|
+
- spec/http_spec.rb
|
|
242
|
+
- spec/profile_spec.rb
|
|
243
|
+
- spec/spec_helper.rb
|
|
244
|
+
- spec/tweet_spec.rb
|
|
245
|
+
- spec/util_spec.rb
|