ruby-lichess 0.3.0 → 0.4.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.
- checksums.yaml +5 -5
- data/.gitignore +2 -0
- data/README.md +14 -0
- data/lib/lichess/exceptions.rb +1 -0
- data/lib/lichess/games_gateway.rb +14 -2
- data/lib/lichess/version.rb +1 -1
- data/ruby-lichess.gemspec +2 -2
- metadata +7 -9
- data/Gemfile.lock +0 -63
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 8e1a27261e0a8bc8e8c2bdbdf74a1260f3389418698dfc9db8137f02d7ff7e62
|
4
|
+
data.tar.gz: 01a6467e60c0c1f5bea3ef40c8164e02246bd3f3fc02687541638f2d3ab9f2dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8de88aa6328173b70c815516aafdb31d63800a57941d05f2450e4f6820f2cb14d056449cb07f492e5f9288843f6a4b4d2cb5f640224d11c94586bd706cbdbd24
|
7
|
+
data.tar.gz: 23dc2c584f5fb867958fc97bd908269942d1f12239b7ea8cb301106f3a8f3edb678396dac39f3dab23eaaafc4708eb1effff952cc4b46dd866b42b6e26fba456
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -18,6 +18,14 @@ Or install it yourself as:
|
|
18
18
|
|
19
19
|
## Usage
|
20
20
|
|
21
|
+
### Client
|
22
|
+
|
23
|
+
Get started by first creating a client
|
24
|
+
|
25
|
+
```
|
26
|
+
lichess = Lichess::Client.new(LICHESS_API_TOKEN)
|
27
|
+
```
|
28
|
+
|
21
29
|
### Users
|
22
30
|
|
23
31
|
*All Top Ten*
|
@@ -50,6 +58,12 @@ Get a users data
|
|
50
58
|
result = lichess.users.get("username")
|
51
59
|
```
|
52
60
|
|
61
|
+
Get multiple users by passing in an array
|
62
|
+
|
63
|
+
```
|
64
|
+
result = lichess.users.get(["username1", "username2"])
|
65
|
+
```
|
66
|
+
|
53
67
|
## Development
|
54
68
|
|
55
69
|
## Contributing
|
data/lib/lichess/exceptions.rb
CHANGED
@@ -6,6 +6,10 @@ module Lichess
|
|
6
6
|
|
7
7
|
MAX_GAMES = 30
|
8
8
|
|
9
|
+
VALID_PARAMS = {
|
10
|
+
users_games: %w{perf perfType since until max vs rated color analysed ongoing movies pgnInJson tags clocks evals opening players ongoing, num_games}.map(&:to_sym)
|
11
|
+
}
|
12
|
+
|
9
13
|
def initialize(client)
|
10
14
|
@client = client
|
11
15
|
end
|
@@ -21,6 +25,7 @@ module Lichess
|
|
21
25
|
JSON.parse(result.body)
|
22
26
|
end
|
23
27
|
|
28
|
+
|
24
29
|
def users_games(user_id, options = {}, &blk)
|
25
30
|
num_games = options[:num_games] || 10
|
26
31
|
|
@@ -28,10 +33,17 @@ module Lichess
|
|
28
33
|
raise Exception::TooManyGames.new("Cannot request more than 30 games")
|
29
34
|
end
|
30
35
|
|
36
|
+
invalid_params = options.keys.reject { |k| VALID_PARAMS[:users_games].include? k }
|
37
|
+
raise Exception::InvalidParameter.new("#{invalid_params.join(",")} parameters were supplied, but are invalid") if invalid_params.any?
|
38
|
+
|
31
39
|
path = "/api/games/user/#{user_id}?max=#{num_games}"
|
32
|
-
|
40
|
+
|
41
|
+
# kept to keep backward compat
|
33
42
|
path << "&perfType=#{options[:perf]}" if options[:perf]
|
34
|
-
|
43
|
+
|
44
|
+
options.each do |key, value|
|
45
|
+
path << "&#{key}=#{value}"
|
46
|
+
end
|
35
47
|
|
36
48
|
result = @client.get(path, http_headers: ndjson_headers)
|
37
49
|
stringio = StringIO.new(result.body)
|
data/lib/lichess/version.rb
CHANGED
data/ruby-lichess.gemspec
CHANGED
@@ -27,9 +27,9 @@ Gem::Specification.new do |spec|
|
|
27
27
|
spec.add_dependency "ndjson", "~> 1.0"
|
28
28
|
spec.add_dependency "http", "~> 4.0"
|
29
29
|
|
30
|
-
spec.add_development_dependency "bundler", "~>
|
30
|
+
spec.add_development_dependency "bundler", "~> 2.2"
|
31
31
|
spec.add_development_dependency "dotenv", "2.5.0"
|
32
|
-
spec.add_development_dependency "rake", "~>
|
32
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
33
33
|
spec.add_development_dependency "rspec", "~> 3.0"
|
34
34
|
spec.add_development_dependency "pry", "~> 0.11"
|
35
35
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-lichess
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- omgrr
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-05-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ndjson
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '2.2'
|
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
|
-
version: '
|
54
|
+
version: '2.2'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: dotenv
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
75
|
+
version: '13.0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
82
|
+
version: '13.0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: rspec
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -118,7 +118,6 @@ files:
|
|
118
118
|
- ".gitignore"
|
119
119
|
- ".rspec"
|
120
120
|
- Gemfile
|
121
|
-
- Gemfile.lock
|
122
121
|
- LICENSE.txt
|
123
122
|
- README.md
|
124
123
|
- Rakefile
|
@@ -150,8 +149,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
150
149
|
- !ruby/object:Gem::Version
|
151
150
|
version: '0'
|
152
151
|
requirements: []
|
153
|
-
|
154
|
-
rubygems_version: 2.6.14.1
|
152
|
+
rubygems_version: 3.1.4
|
155
153
|
signing_key:
|
156
154
|
specification_version: 4
|
157
155
|
summary: Ruby library for lichess api
|
data/Gemfile.lock
DELETED
@@ -1,63 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
ruby-lichess (0.2.1)
|
5
|
-
http (~> 4.0)
|
6
|
-
ndjson (~> 1.0)
|
7
|
-
|
8
|
-
GEM
|
9
|
-
remote: https://rubygems.org/
|
10
|
-
specs:
|
11
|
-
addressable (2.7.0)
|
12
|
-
public_suffix (>= 2.0.2, < 5.0)
|
13
|
-
coderay (1.1.2)
|
14
|
-
diff-lcs (1.3)
|
15
|
-
domain_name (0.5.20190701)
|
16
|
-
unf (>= 0.0.5, < 1.0.0)
|
17
|
-
dotenv (2.5.0)
|
18
|
-
http (4.1.1)
|
19
|
-
addressable (~> 2.3)
|
20
|
-
http-cookie (~> 1.0)
|
21
|
-
http-form_data (~> 2.0)
|
22
|
-
http_parser.rb (~> 0.6.0)
|
23
|
-
http-cookie (1.0.3)
|
24
|
-
domain_name (~> 0.5)
|
25
|
-
http-form_data (2.1.1)
|
26
|
-
http_parser.rb (0.6.0)
|
27
|
-
method_source (0.9.0)
|
28
|
-
ndjson (1.0.0)
|
29
|
-
pry (0.11.3)
|
30
|
-
coderay (~> 1.1.0)
|
31
|
-
method_source (~> 0.9.0)
|
32
|
-
public_suffix (4.0.1)
|
33
|
-
rake (10.5.0)
|
34
|
-
rspec (3.8.0)
|
35
|
-
rspec-core (~> 3.8.0)
|
36
|
-
rspec-expectations (~> 3.8.0)
|
37
|
-
rspec-mocks (~> 3.8.0)
|
38
|
-
rspec-core (3.8.0)
|
39
|
-
rspec-support (~> 3.8.0)
|
40
|
-
rspec-expectations (3.8.1)
|
41
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
42
|
-
rspec-support (~> 3.8.0)
|
43
|
-
rspec-mocks (3.8.0)
|
44
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
45
|
-
rspec-support (~> 3.8.0)
|
46
|
-
rspec-support (3.8.0)
|
47
|
-
unf (0.1.4)
|
48
|
-
unf_ext
|
49
|
-
unf_ext (0.0.7.6)
|
50
|
-
|
51
|
-
PLATFORMS
|
52
|
-
ruby
|
53
|
-
|
54
|
-
DEPENDENCIES
|
55
|
-
bundler (~> 1.16)
|
56
|
-
dotenv (= 2.5.0)
|
57
|
-
pry (~> 0.11)
|
58
|
-
rake (~> 10.0)
|
59
|
-
rspec (~> 3.0)
|
60
|
-
ruby-lichess!
|
61
|
-
|
62
|
-
BUNDLED WITH
|
63
|
-
1.16.1
|