itch_client 0.2.0 → 0.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9e207ec3ac07a0a26dd3315a9e0cf1a9e0e6440559b07dffbc2f673aaac24231
4
- data.tar.gz: f2165aebc46c8486531bf679d03efbd2c0c5104b6854369031f69375088b9cf4
3
+ metadata.gz: 8d5a506c76194715b52cb040986184ea7a86875914f759f0afa8491aa0b31449
4
+ data.tar.gz: c6665dd7c4595990cf43b01cebf66c97aec781d3624d46b28d3f232daf1555c0
5
5
  SHA512:
6
- metadata.gz: feb4a98fcfd03fee02025981aa54a242cec85d4122fb74eede970d3b189c580c0898b5fea59c795e63beefb36aaf6bd5714ca8fb56406f5ed2c7812c9bdf452f
7
- data.tar.gz: 48b5f07013f2e6b8435d8dafb0c708ff3b97f93d4fa4273f30024a838299c2b5c9532f669b6d6025c94b425bcdf99faaada80fcf30856c38c427e6b32cda0e33
6
+ metadata.gz: 9398d54b0995e61779c54fc6cdb55f26b618d51e601afe68eb06baf4f8b961ce796f40865d276574b914ffab819338e5402f1b0fc67ead8d034e4d46f2804170
7
+ data.tar.gz: b01cb911f08c8a4c22c7266e89c80074268dbadf7fee91fb22b884af7c048e19ba28f746ec4cf562fdd200a49b470601fa0a13484bd6cd5c8c6307634d929985
data/CHANGELOG.md CHANGED
@@ -1,4 +1,10 @@
1
- ## [Unreleased]
1
+ ## [0.3.0] - 2021-10-13
2
+
3
+ - Added bundle list
4
+
5
+ ## [0.2.0] - 2021-05-27
6
+
7
+ - Improved error responses
2
8
 
3
9
  ## [0.1.0] - 2021-05-22
4
10
 
data/Gemfile CHANGED
@@ -12,3 +12,5 @@ gem "rspec", "~> 3.0"
12
12
  gem "rubocop", "~> 1.7"
13
13
 
14
14
  gem "irb", "~> 1.3"
15
+
16
+ gem "pry"
data/Gemfile.lock CHANGED
@@ -1,15 +1,16 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- itch_client (0.2.0)
4
+ itch_client (0.3.0)
5
5
  mechanize (~> 2.8)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- addressable (2.7.0)
10
+ addressable (2.8.0)
11
11
  public_suffix (>= 2.0.2, < 5.0)
12
12
  ast (2.4.2)
13
+ coderay (1.1.3)
13
14
  connection_pool (2.2.5)
14
15
  diff-lcs (1.4.4)
15
16
  domain_name (0.5.20190701)
@@ -30,17 +31,21 @@ GEM
30
31
  rubyntlm (~> 0.6, >= 0.6.3)
31
32
  webrick (~> 1.7)
32
33
  webrobots (~> 0.1.2)
34
+ method_source (1.0.0)
33
35
  mime-types (3.3.1)
34
36
  mime-types-data (~> 3.2015)
35
37
  mime-types-data (3.2021.0225)
36
38
  net-http-digest_auth (1.4.1)
37
39
  net-http-persistent (4.0.1)
38
40
  connection_pool (~> 2.2)
39
- nokogiri (1.11.5-x86_64-linux)
41
+ nokogiri (1.12.5-x86_64-linux)
40
42
  racc (~> 1.4)
41
43
  parallel (1.20.1)
42
44
  parser (3.0.1.1)
43
45
  ast (~> 2.4.1)
46
+ pry (0.14.1)
47
+ coderay (~> 1.1)
48
+ method_source (~> 1.0)
44
49
  public_suffix (4.0.6)
45
50
  racc (1.5.2)
46
51
  rainbow (3.0.0)
@@ -88,6 +93,7 @@ PLATFORMS
88
93
  DEPENDENCIES
89
94
  irb (~> 1.3)
90
95
  itch_client!
96
+ pry
91
97
  rake (~> 13.0)
92
98
  rspec (~> 3.0)
93
99
  rubocop (~> 1.7)
data/README.md CHANGED
@@ -252,6 +252,23 @@ filtered_rewards = rewards.select do |reward|
252
252
  end
253
253
  client.game(12345).rewards.save(filtered_rewards)
254
254
  ```
255
+ ### Bundles
256
+
257
+ Fetch current bundles
258
+
259
+ ```ruby
260
+ client.bundles.list
261
+
262
+ #=>
263
+ [
264
+ #<Itch::Bundle:0x0000557aa98c7930
265
+ @id="123",
266
+ @earnings=BigDecimal(123.00),
267
+ @price=BigDecimal(10.00),
268
+ @purchases=10,
269
+ @title="My Bundle!"
270
+ ]
271
+ ```
255
272
 
256
273
  ## Development
257
274
 
@@ -0,0 +1,24 @@
1
+ require_relative "simple_inspect"
2
+
3
+ module Itch
4
+ # Data container for single bundle
5
+ class Bundle
6
+ include SimpleInspect
7
+
8
+ attr_accessor :id, :title, :games, :purchases, :price, :earnings
9
+
10
+ # rubocop:disable Metrics/ParameterLists
11
+ def initialize(id, title, purchases, price, earnings)
12
+ @id = id
13
+ @title = title
14
+ @purchases = purchases
15
+ @price = price
16
+ @earnings = earnings
17
+ end
18
+ # rubocop:enable Metrics/ParameterLists
19
+
20
+ def url
21
+ format(Itch::URL::BUNDLE, id: @id)
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+ require 'bigdecimal'
3
+
4
+ require_relative "simple_inspect"
5
+ require_relative "bundle"
6
+ require_relative "request"
7
+ require_relative "require_auth"
8
+
9
+
10
+ module Itch
11
+ # Fetch bundles
12
+ class Bundles
13
+ include RequireAuth
14
+ include SimpleInspect
15
+ include Request
16
+
17
+ def initialize(agent)
18
+ @agent = agent
19
+ end
20
+
21
+ def list
22
+ page = with_login do
23
+ @agent.get(bundles_url)
24
+ end
25
+
26
+ page.css('.bundle_list table > tr').map do |row|
27
+ parse_row(row)
28
+ end
29
+ end
30
+
31
+ def parse_row(row)
32
+ id = row.at_xpath('td[2]/a/@href').value.match(%r[^/b/(\d+)/])[1]
33
+ vals = row.css('td').map(&:text)
34
+ price = BigDecimal(vals[5].gsub(/[^\d.-]/, ''))
35
+ earnings = BigDecimal(vals[6].gsub(/[\D-]/, ''))
36
+
37
+ Bundle.new(id, vals[1], vals[4].to_i, price, earnings)
38
+ end
39
+
40
+ def bundles_url
41
+ Itch::URL::BUNDLES
42
+ end
43
+ end
44
+ end
data/lib/itch/client.rb CHANGED
@@ -4,6 +4,7 @@ require "forwardable"
4
4
  require "mechanize"
5
5
 
6
6
  require_relative "auth"
7
+ require_relative "bundles"
7
8
  require_relative "game"
8
9
  require_relative "game_map"
9
10
  require_relative "purchases"
@@ -35,6 +36,10 @@ module Itch
35
36
  @purchases ||= Purchases.new(@agent)
36
37
  end
37
38
 
39
+ def bundles
40
+ @bundles ||= Bundles.new(@agent)
41
+ end
42
+
38
43
  def game_map
39
44
  @game_map ||= GameMap.new(@agent)
40
45
  end
data/lib/itch/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Itch
4
- VERSION = "0.2.0"
4
+ VERSION = "0.3.0"
5
5
  end
data/lib/itch_client.rb CHANGED
@@ -28,6 +28,8 @@ module Itch
28
28
 
29
29
  module URL
30
30
  DASHBOARD = "https://itch.io/dashboard"
31
+ BUNDLES = "https://itch.io/dashboard/bundles"
32
+ BUNDLE = "https://itch.io/bundle/%<id>d"
31
33
  EDIT_GAME = "https://itch.io/game/edit/%<id>d"
32
34
  GAME = "https://%<username>s.itch.io/%<slug>s"
33
35
  LOGIN = "https://itch.io/login"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: itch_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Billiam
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-05-27 00:00:00.000000000 Z
11
+ date: 2021-10-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mechanize
@@ -45,6 +45,8 @@ files:
45
45
  - bin/setup
46
46
  - itch_client.gemspec
47
47
  - lib/itch/auth.rb
48
+ - lib/itch/bundle.rb
49
+ - lib/itch/bundles.rb
48
50
  - lib/itch/client.rb
49
51
  - lib/itch/game.rb
50
52
  - lib/itch/game_map.rb