itch_rewards 0.1.2 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 532a40f260d7f2942244c1b983c20eea419c18eeea3ac601cb41f461e11eefd5
4
- data.tar.gz: 5609c23072f7f006ca5a781f1c561d613942fcf1d8856c48f0c9f294d2d46e18
3
+ metadata.gz: ddb2708480af47359babae6481ed315edf6eef8033c6e84029f7985b442361e0
4
+ data.tar.gz: 676f51d7aaae87d8223f229baee10254c6754c33f0456544c3a290ec43ec2cb0
5
5
  SHA512:
6
- metadata.gz: 63e1a8858b7250c27a782ba1e57bdd1af9833070c88d5e720fb371d1ef5689f4211f4cafbc62c4964e656bd88f12d497049f5e1fc7f24ac049e89d329e201d28
7
- data.tar.gz: b151326787353dabd45dfef0180c088edeac0180df15703b74fb297b8b2032d2950f542c0bec49632cf51874401fa0fdc293d26c32ab59bdf83a77aa18ee9d13
6
+ metadata.gz: cba9856144f8ecb5da7ba77564825f0f2a5426f70f03b6221fc474142a751ae3901df4eed349461d646e00aead877df02941f91ae0df9f3fa12bf5fbf9dadeb1
7
+ data.tar.gz: 76667982c457234f09ce323497d528d98643a1ca81ceb4d025bd856575c7b569c8ffb458e192c2b91bbbe5057ceae29e4c996fca2cde75a39281881a409d04ae
data/.gitignore CHANGED
@@ -11,3 +11,4 @@
11
11
  .rspec_status
12
12
  .itch-cookies.yml
13
13
  itch-reward-config.yml
14
+ .tool-versions
data/Gemfile.lock CHANGED
@@ -1,9 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- itch_rewards (0.1.2)
4
+ itch_rewards (0.1.4)
5
5
  dry-cli (~> 0.7.0)
6
- itch_client (~> 0.2.0)
6
+ itch_client (~> 0.4.1)
7
7
  pastel (~> 0.8.0)
8
8
  tty-prompt (~> 0.23.1)
9
9
  tty-table (~> 0.12.0)
@@ -11,22 +11,22 @@ PATH
11
11
  GEM
12
12
  remote: https://rubygems.org/
13
13
  specs:
14
- addressable (2.7.0)
14
+ addressable (2.8.0)
15
15
  public_suffix (>= 2.0.2, < 5.0)
16
16
  connection_pool (2.2.5)
17
17
  diff-lcs (1.4.4)
18
18
  domain_name (0.5.20190701)
19
19
  unf (>= 0.0.5, < 1.0.0)
20
20
  dry-cli (0.7.0)
21
- http-cookie (1.0.3)
21
+ http-cookie (1.0.5)
22
22
  domain_name (~> 0.5)
23
23
  io-console (0.5.9)
24
24
  irb (1.3.5)
25
25
  reline (>= 0.1.5)
26
- itch_client (0.2.0)
26
+ itch_client (0.4.1)
27
27
  mechanize (~> 2.8)
28
- mechanize (2.8.1)
29
- addressable (~> 2.7)
28
+ mechanize (2.8.5)
29
+ addressable (~> 2.8)
30
30
  domain_name (~> 0.5, >= 0.5.20190701)
31
31
  http-cookie (~> 1.0, >= 1.0.3)
32
32
  mime-types (~> 3.0)
@@ -36,18 +36,20 @@ GEM
36
36
  rubyntlm (~> 0.6, >= 0.6.3)
37
37
  webrick (~> 1.7)
38
38
  webrobots (~> 0.1.2)
39
- mime-types (3.3.1)
39
+ mime-types (3.4.1)
40
40
  mime-types-data (~> 3.2015)
41
- mime-types-data (3.2021.0225)
41
+ mime-types-data (3.2022.0105)
42
+ mini_portile2 (2.8.0)
42
43
  net-http-digest_auth (1.4.1)
43
44
  net-http-persistent (4.0.1)
44
45
  connection_pool (~> 2.2)
45
- nokogiri (1.11.6-x86_64-linux)
46
+ nokogiri (1.13.6)
47
+ mini_portile2 (~> 2.8.0)
46
48
  racc (~> 1.4)
47
49
  pastel (0.8.0)
48
50
  tty-color (~> 0.5)
49
- public_suffix (4.0.6)
50
- racc (1.5.2)
51
+ public_suffix (4.0.7)
52
+ racc (1.6.0)
51
53
  rake (13.0.3)
52
54
  reline (0.2.5)
53
55
  io-console (~> 0.5)
@@ -86,14 +88,15 @@ GEM
86
88
  tty-screen (~> 0.8)
87
89
  unf (0.1.4)
88
90
  unf_ext
89
- unf_ext (0.0.7.7)
90
- unicode-display_width (2.0.0)
91
+ unf_ext (0.0.8.2)
92
+ unicode-display_width (2.1.0)
91
93
  unicode_utils (1.4.0)
92
94
  webrick (1.7.0)
93
95
  webrobots (0.1.2)
94
96
  wisper (2.0.1)
95
97
 
96
98
  PLATFORMS
99
+ ruby
97
100
  x86_64-linux
98
101
 
99
102
  DEPENDENCIES
data/README.md CHANGED
@@ -12,12 +12,12 @@ Commandline tool to update game rewards on Itch.io, and automatically update rew
12
12
  Usage: itch-rewards COMMAND [options]
13
13
 
14
14
  Commands:
15
- itch-rewards list # List all rewards for a game
16
- itch-rewards list-games # List all games
17
- itch-rewards recalculate # Update reward quantity and description from configuration file
18
- itch-rewards setup # Save cookies for itch.io and create reward config example file
19
- itch-rewards update GAME_ID REWARD_ID # Update a reward
20
- itch-rewards version # Print version
15
+ itch-rewards list # List all rewards for a game
16
+ itch-rewards list-games # List all games
17
+ itch-rewards recalculate # Update reward quantity and description from configuration file
18
+ itch-rewards setup # Save cookies for itch.io and create reward config example file
19
+ itch-rewards update GAME_ID REWARD_ID # Update a reward
20
+ itch-rewards version # Print version
21
21
  ```
22
22
 
23
23
  ### Authenticating
@@ -47,12 +47,12 @@ You'll also be prompted to create an (optional) configuration file that can be u
47
47
  While logging in via cookies is easier (and required for non-interactive login, ex: for cron tasks), all commands also accept the following options.
48
48
 
49
49
  ```shell
50
- --username=VALUE, -u VALUE # Itch username
51
- --password=VALUE, -p VALUE # Itch password
52
- --cookie-path=VALUE # Path to cookies file for future logins, default: ".itch-cookies.yml"
53
- --[no-]cookies # Enable cookie storage, default: true
54
- --[no-]interactive # Enable interactive prompts, default: true
55
- --help, -h # Print help
50
+ --username=VALUE, -u VALUE # Itch username
51
+ --password=VALUE, -p VALUE # Itch password
52
+ --cookie-path=VALUE # Path to cookies file for future logins, default: ".itch-cookies.yml"
53
+ --[no-]cookies # Enable cookie storage, default: true
54
+ --[no-]interactive # Enable interactive prompts, default: true
55
+ --help, -h # Print help
56
56
  ```
57
57
 
58
58
  ### List games
@@ -105,15 +105,15 @@ Description:
105
105
  Update a reward
106
106
 
107
107
  Arguments:
108
- GAME_ID # REQUIRED Game with the reward to edit
109
- REWARD_ID # REQUIRED Reward ID to update
108
+ GAME_ID # REQUIRED Game with the reward to edit
109
+ REWARD_ID # REQUIRED Reward ID to update
110
110
 
111
111
  Options:
112
- --quantity=VALUE # Reward quantity (total, including redeemed)
113
- --title=VALUE # Reward title
114
- --[no-]archived # Reward archived status
115
- --description=VALUE # Reward description
116
- --price=VALUE # Reward price without currency (ex: 15.99)
112
+ --quantity=VALUE # Reward quantity (total, including redeemed)
113
+ --title=VALUE # Reward title
114
+ --[no-]archived # Reward archived status
115
+ --description=VALUE # Reward description
116
+ --price=VALUE # Reward price without currency (ex: 15.99)
117
117
 
118
118
  Examples:
119
119
  itch-rewards update 123456 78910 --quantity 5 # Set the reward count to 5 for reward ID 78910 in game ID 123456
@@ -132,8 +132,8 @@ Description:
132
132
  Update reward quantity and description from configuration file
133
133
 
134
134
  Options:
135
- --config=VALUE # Path to config file, default: "itch-reward-config.yml"
136
- --[no-]save # Saves changes when enabled. Otherwise, dry-run and show result, default: false
135
+ --config=VALUE # Path to config file, default: "itch-reward-config.yml"
136
+ --[no-]save # Saves changes when enabled. Otherwise, dry-run and show result, default: false
137
137
  ```
138
138
 
139
139
 
@@ -193,7 +193,7 @@ MyGame:
193
193
  id: 123456
194
194
  reward_id: 789012
195
195
  reward_by_purchase: 0
196
- reward_by_tip: 0.0
196
+ reward_by_tip: 1.0
197
197
  reward_offset: 0
198
198
  minimum_available: 0
199
199
  ```
@@ -229,4 +229,4 @@ The above will change the reward description to "Rewards added: 10".
229
229
  The following placehoder values are available:
230
230
  * `{ amount }`: The total number of reward copies in the pool, including redeemed rewards.
231
231
  * `{ remaining_percent }`: A number between 0.0 and 100.0, indicating the percentage until the next reward
232
- * `{ remaining_percent_integer }`: A number between 0 and 100. As above (but with no decimal value included).
232
+ * `{ remaining_percent_integer }`: A number between 0 and 100. As above (but with no decimal value included).
data/itch_rewards.gemspec CHANGED
@@ -27,7 +27,7 @@ Gem::Specification.new do |spec|
27
27
  spec.executables = ['itch-rewards']
28
28
  spec.require_paths = ["lib"]
29
29
 
30
- spec.add_dependency "itch_client", "~> 0.2.0"
30
+ spec.add_dependency "itch_client", "~> 0.4.1"
31
31
  spec.add_dependency "dry-cli", "~> 0.7.0"
32
32
  spec.add_dependency "tty-prompt", "~> 0.23.1"
33
33
  spec.add_dependency "tty-table", "~> 0.12.0"
@@ -77,6 +77,12 @@ module ItchRewards
77
77
 
78
78
  table.render(:unicode, multiline: true, padding: [0,1], resize: false, border: { style: :green })
79
79
  end
80
+
81
+ def show_rewards(game)
82
+ cli.say "Rewards for #{game.name} (id: #{game.id})"
83
+ table = objects_to_table(game.rewards.list)
84
+ cli.say render_table(table)
85
+ end
80
86
  end
81
87
 
82
88
  module Commands
@@ -97,6 +103,16 @@ module ItchRewards
97
103
  include AuthOptions
98
104
  @options = @options.reject {|opt| [:cookies, :interactive].include? opt.name }
99
105
 
106
+ def write_config(path, options)
107
+ require 'erb'
108
+ client = authenticated_client!(options)
109
+
110
+ games = client.game_map.map.values
111
+ template = File.read(File.join(__dir__, 'templates/reward_config.yml.erb'))
112
+
113
+ File.write(path, ERB.new(template, trim_mode: '-').result(binding))
114
+ end
115
+
100
116
  desc "Save cookies for itch.io and create reward config example file"
101
117
  def call(**options)
102
118
  options[:cookies] ||= cli.ask("Where would you like to store your login cookies? ", default: ".itch-cookies.yml")
@@ -114,7 +130,7 @@ module ItchRewards
114
130
  result = cli.yes?("Config file #{config_path} does not exist, would you like to create it?")
115
131
 
116
132
  if result
117
- Rewards.write_config(config_path, options)
133
+ write_config(config_path, options)
118
134
  cli.say "Config file written to #{config_path}"
119
135
  end
120
136
  else
@@ -140,31 +156,6 @@ module ItchRewards
140
156
  end
141
157
 
142
158
  module Rewards
143
- extend self
144
- include Helper
145
- def self.show_rewards(game)
146
- cli.say "Rewards for #{game.name} (id: #{game.id})"
147
- table = objects_to_table(game.rewards.list)
148
- cli.say render_table(table)
149
- end
150
-
151
- def self.write_config(path, options)
152
- require 'erb'
153
- client = authenticated_client!(options)
154
-
155
- games = client.game_map.map.values
156
- template = File.read(File.join(__dir__, 'templates/reward_config.yml.erb'))
157
-
158
- File.write(options[:config], ERB.new(template, trim_mode: '-').result(binding))
159
- end
160
-
161
- def self.load_config(path)
162
- YAML.load_file(path)
163
- rescue YAML::ParseError => e
164
- cli.error("Config file (#{path}) is not valid yaml")
165
- exit 1
166
- end
167
-
168
159
  class List < Dry::CLI::Command
169
160
  include AuthOptions
170
161
  include Helper
@@ -187,7 +178,7 @@ module ItchRewards
187
178
  client = authenticated_client!(options)
188
179
  game = options[:id] ? client.game(options[:id]) : client.game(name: options[:name])
189
180
 
190
- Rewards.show_rewards(game)
181
+ show_rewards(game)
191
182
  end
192
183
  end
193
184
 
@@ -238,7 +229,7 @@ module ItchRewards
238
229
 
239
230
  rewards.save reward_list
240
231
 
241
- Rewards.show_rewards(game)
232
+ show_rewards(game)
242
233
  end
243
234
  end
244
235
 
@@ -246,11 +237,18 @@ module ItchRewards
246
237
  include Helper
247
238
  include AuthOptions
248
239
 
240
+ def load_config(path)
241
+ YAML.load_file(path)
242
+ rescue YAML::ParseError => e
243
+ cli.error("Config file (#{path}) is not valid yaml")
244
+ exit 1
245
+ end
246
+
249
247
  desc "Update reward quantity and description from configuration file"
250
248
 
251
249
  option :config, required: true, desc: "Path to config file", default: "itch-reward-config.yml"
252
250
  option :save, type: :boolean, desc: "Saves changes when enabled. Otherwise, dry-run and show result", default: false
253
-
251
+
254
252
  def call(**options)
255
253
  client = authenticated_client!(options)
256
254
 
@@ -259,14 +257,14 @@ module ItchRewards
259
257
  exit 1
260
258
  end
261
259
 
262
- config = Rewards.load_config(options[:config])
260
+ config = load_config(options[:config])
263
261
  unless config["games"].is_a? Hash
264
262
  cli.error("No games configured for rewards updates in config file")
265
263
  exit 1
266
264
  end
267
265
 
268
266
  unless options[:save]
269
- cli.warn "Dry run, results will not not saved"
267
+ cli.warn "Dry run, results will not be saved"
270
268
  end
271
269
 
272
270
  purchases_by_game = client.purchases.history.each.group_by {|row| row['object_name'] }.to_h
@@ -20,7 +20,7 @@ games:
20
20
  # ex: with rewards_by_tip set to 0.5, a $10 tip on a $5 game would add 1 reward copy
21
21
  reward_by_tip: 0.0
22
22
 
23
- # Add a flat value to reward quantity available (ex: for adding initial reward copies )
23
+ # Add a flat value to reward quantity available (ex: for adding initial reward copies)
24
24
  reward_offset: 0
25
25
 
26
26
  # Minimum reward quantity available, regardless of other settings
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ItchRewards
4
- VERSION = "0.1.2"
4
+ VERSION = "0.1.5"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: itch_rewards
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.5
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-29 00:00:00.000000000 Z
11
+ date: 2022-06-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: itch_client
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.2.0
19
+ version: 0.4.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.2.0
26
+ version: 0.4.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: dry-cli
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -127,7 +127,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
127
127
  - !ruby/object:Gem::Version
128
128
  version: '0'
129
129
  requirements: []
130
- rubygems_version: 3.2.15
130
+ rubygems_version: 3.1.6
131
131
  signing_key:
132
132
  specification_version: 4
133
133
  summary: Itch community copy automation utility