rpw 0.0.3 → 1.0.1
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 +4 -4
- data/.github/workflows/test.yml +109 -0
- data/.gitignore +1 -0
- data/Gemfile.lock +12 -16
- data/HISTORY.md +21 -0
- data/exe/rpw +1 -252
- data/lib/rpw.rb +4 -374
- data/lib/rpw/README.md +58 -0
- data/lib/rpw/cli.rb +94 -0
- data/lib/rpw/cli/bannerlord.rb +59 -0
- data/lib/rpw/cli/key.rb +15 -0
- data/lib/rpw/cli/lesson.rb +101 -0
- data/lib/rpw/cli/progress.rb +34 -0
- data/lib/rpw/cli/quiz.rb +28 -0
- data/lib/rpw/cli/sub_command_base.rb +30 -0
- data/lib/rpw/client.rb +178 -0
- data/lib/rpw/client_data.rb +73 -0
- data/lib/rpw/gateway.rb +67 -0
- data/lib/rpw/version.rb +1 -1
- data/rpw.gemspec +1 -1
- metadata +15 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aee4cd056139ea78d75fc48a6c0337c32c7e9ca958ac0c24716ec7a27abc5617
|
4
|
+
data.tar.gz: 6688f3f8b1edef9c6004af6146d10e4d6b190d103f95ee233902523f73760043
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5682fb0676abd4d9a69ecee1193a332ed7d580ea5d8f37919d2925da01d64a4f911cb042ec0ec8e72e39479f75f3cb3fdfac3d640a178dd3d70f3b7c41bdf396
|
7
|
+
data.tar.gz: edc9f5b0994db202b3b9b94838efeec9ecc26f7d52e05e8fc73c35a6c22e10ff969e9065cb66a51c2151c31c93fea9e07f6a6277c420fbd6832ba58fe510f69d
|
@@ -0,0 +1,109 @@
|
|
1
|
+
name: Test
|
2
|
+
|
3
|
+
on: [push, pull_request]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
build:
|
7
|
+
name: >-
|
8
|
+
${{ matrix.os }} ${{ matrix.ruby }}
|
9
|
+
env:
|
10
|
+
CI: true
|
11
|
+
TESTOPTS: -v
|
12
|
+
|
13
|
+
runs-on: ${{ matrix.os }}
|
14
|
+
if: |
|
15
|
+
!( contains(github.event.pull_request.title, '[ci skip]')
|
16
|
+
|| contains(github.event.pull_request.title, '[skip ci]')
|
17
|
+
|| contains(github.event.head_commit.message, '[ci skip]')
|
18
|
+
|| contains(github.event.head_commit.message, '[skip ci]'))
|
19
|
+
strategy:
|
20
|
+
fail-fast: true
|
21
|
+
matrix:
|
22
|
+
os: [ ubuntu-20.04, macos-10.15, windows-2019 ]
|
23
|
+
ruby: [ 2.3, 2.6, 2.7, head ]
|
24
|
+
|
25
|
+
steps:
|
26
|
+
- name: repo checkout
|
27
|
+
uses: actions/checkout@v2
|
28
|
+
|
29
|
+
- name: load ruby
|
30
|
+
uses: MSP-Greg/setup-ruby-pkgs@v1
|
31
|
+
with:
|
32
|
+
ruby-version: ${{ matrix.ruby }}
|
33
|
+
|
34
|
+
- name: bundle install
|
35
|
+
run: |
|
36
|
+
bundle install --jobs 4 --retry 3
|
37
|
+
|
38
|
+
- name: standardrb
|
39
|
+
run: bundle exec standardrb
|
40
|
+
|
41
|
+
- name: test
|
42
|
+
run: bundle exec rake test
|
43
|
+
|
44
|
+
build-live:
|
45
|
+
services:
|
46
|
+
postgres:
|
47
|
+
image: postgres:alpine
|
48
|
+
env:
|
49
|
+
POSTGRES_PASSWORD: password
|
50
|
+
ports:
|
51
|
+
- 5432:5432
|
52
|
+
# needed because the postgres container does not provide a healthcheck
|
53
|
+
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
|
54
|
+
|
55
|
+
name: Test against a live server
|
56
|
+
env:
|
57
|
+
CI: true
|
58
|
+
TESTOPTS: -v
|
59
|
+
LIVE_SERVER: true
|
60
|
+
|
61
|
+
runs-on: ubuntu-latest
|
62
|
+
|
63
|
+
steps:
|
64
|
+
- name: repo checkout
|
65
|
+
uses: actions/checkout@v2
|
66
|
+
|
67
|
+
- name: load ruby
|
68
|
+
uses: MSP-Greg/setup-ruby-pkgs@v1
|
69
|
+
with:
|
70
|
+
ruby-version: 2.7.2
|
71
|
+
|
72
|
+
- name: bundle install
|
73
|
+
run: |
|
74
|
+
bundle install --jobs 4 --retry 3
|
75
|
+
|
76
|
+
- uses: actions/checkout@master
|
77
|
+
with:
|
78
|
+
repository: speedshop/licensor
|
79
|
+
path: server
|
80
|
+
|
81
|
+
- name: nuke server ruby requirement
|
82
|
+
run: grep -v "^ruby" Gemfile > temp && mv -f temp Gemfile
|
83
|
+
working-directory: ./server
|
84
|
+
|
85
|
+
- name: bundle install the server
|
86
|
+
run: |
|
87
|
+
bundle install --jobs 4 --retry 3
|
88
|
+
bundle exec rails db:setup
|
89
|
+
working-directory: ./server
|
90
|
+
env:
|
91
|
+
POSTGRES_USER: postgres
|
92
|
+
POSTGRES_PASSWORD: password
|
93
|
+
|
94
|
+
- name: start the server
|
95
|
+
run: rails server &
|
96
|
+
working-directory: ./server
|
97
|
+
env:
|
98
|
+
POSTGRES_USER: postgres
|
99
|
+
POSTGRES_PASSWORD: password
|
100
|
+
|
101
|
+
- name: wait for server
|
102
|
+
run: |
|
103
|
+
until $(curl --output /dev/null --silent --head --fail http://localhost:3000); do
|
104
|
+
printf '.'
|
105
|
+
sleep 1
|
106
|
+
done
|
107
|
+
|
108
|
+
- name: test
|
109
|
+
run: bundle exec rake test
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,51 +1,47 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rpw (
|
4
|
+
rpw (1.0.1)
|
5
|
+
excon
|
5
6
|
thor
|
6
7
|
thor-hollaback
|
7
|
-
typhoeus
|
8
8
|
|
9
9
|
GEM
|
10
10
|
remote: https://rubygems.org/
|
11
11
|
specs:
|
12
12
|
ast (2.4.1)
|
13
|
-
|
14
|
-
ffi (>= 1.3.0)
|
15
|
-
ffi (1.13.1)
|
13
|
+
excon (0.78.0)
|
16
14
|
hollaback (0.1.0)
|
17
15
|
minitest (5.14.2)
|
18
|
-
parallel (1.
|
19
|
-
parser (2.7.
|
16
|
+
parallel (1.20.0)
|
17
|
+
parser (2.7.2.0)
|
20
18
|
ast (~> 2.4.1)
|
21
19
|
rainbow (3.0.0)
|
22
20
|
rake (13.0.1)
|
23
|
-
regexp_parser (1.8.
|
21
|
+
regexp_parser (1.8.2)
|
24
22
|
rexml (3.2.4)
|
25
|
-
rubocop (
|
23
|
+
rubocop (1.2.0)
|
26
24
|
parallel (~> 1.10)
|
27
25
|
parser (>= 2.7.1.5)
|
28
26
|
rainbow (>= 2.2.2, < 4.0)
|
29
|
-
regexp_parser (>= 1.
|
27
|
+
regexp_parser (>= 1.8)
|
30
28
|
rexml
|
31
|
-
rubocop-ast (>= 0.
|
29
|
+
rubocop-ast (>= 1.0.1)
|
32
30
|
ruby-progressbar (~> 1.7)
|
33
31
|
unicode-display_width (>= 1.4.0, < 2.0)
|
34
|
-
rubocop-ast (
|
32
|
+
rubocop-ast (1.1.1)
|
35
33
|
parser (>= 2.7.1.5)
|
36
34
|
rubocop-performance (1.8.1)
|
37
35
|
rubocop (>= 0.87.0)
|
38
36
|
rubocop-ast (>= 0.4.0)
|
39
37
|
ruby-progressbar (1.10.1)
|
40
|
-
standard (0.
|
41
|
-
rubocop (= 0
|
38
|
+
standard (0.9.0)
|
39
|
+
rubocop (= 1.2.0)
|
42
40
|
rubocop-performance (= 1.8.1)
|
43
41
|
thor (1.0.1)
|
44
42
|
thor-hollaback (0.2.0)
|
45
43
|
hollaback (~> 0.1.0)
|
46
44
|
thor (>= 0.19.1)
|
47
|
-
typhoeus (1.4.0)
|
48
|
-
ethon (>= 0.9.0)
|
49
45
|
unicode-display_width (1.7.0)
|
50
46
|
|
51
47
|
PLATFORMS
|
data/HISTORY.md
CHANGED
@@ -1,3 +1,24 @@
|
|
1
|
+
## 1.0.1
|
2
|
+
|
3
|
+
* Pre-launch bugfix
|
4
|
+
|
5
|
+
## 1.0.0
|
6
|
+
|
7
|
+
* First release!
|
8
|
+
|
9
|
+
## 0.0.6
|
10
|
+
|
11
|
+
* more bugfixes from beta testers
|
12
|
+
* CI
|
13
|
+
|
14
|
+
## 0.0.5
|
15
|
+
|
16
|
+
* more bugfixes from beta testers
|
17
|
+
|
18
|
+
## 0.0.4
|
19
|
+
|
20
|
+
* bugfixes
|
21
|
+
|
1
22
|
## 0.0.3
|
2
23
|
|
3
24
|
* beta
|
data/exe/rpw
CHANGED
@@ -1,256 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
4
|
-
require "thor/hollaback"
|
5
|
-
require_relative "../lib/rpw"
|
6
|
-
|
7
|
-
module RPW
|
8
|
-
class SubCommandBase < Thor
|
9
|
-
def self.banner(command, namespace = nil, subcommand = false)
|
10
|
-
"#{basename} #{subcommand_prefix} #{command.usage}"
|
11
|
-
end
|
12
|
-
|
13
|
-
def self.subcommand_prefix
|
14
|
-
name.gsub(%r{.*::}, "").gsub(%r{^[A-Z]}) { |match| match[0].downcase }.gsub(%r{[A-Z]}) { |match| "-#{match[0].downcase}" }
|
15
|
-
end
|
16
|
-
|
17
|
-
no_commands do
|
18
|
-
def client
|
19
|
-
@client ||= RPW::Client.new
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
class Key < SubCommandBase
|
25
|
-
desc "register [EMAIL_ADDRESS]", "Change email registered with Speedshop. One-time only."
|
26
|
-
def register(email)
|
27
|
-
client.register_email(email)
|
28
|
-
say "License registered. You should receive a Slack invite soon."
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
class Lesson < SubCommandBase
|
33
|
-
class_before :exit_with_no_key
|
34
|
-
|
35
|
-
desc "next", "Proceed to the next lesson of the workshop"
|
36
|
-
option :open
|
37
|
-
def next
|
38
|
-
say "Proceeding to next lesson..."
|
39
|
-
client.next(options[:open])
|
40
|
-
end
|
41
|
-
|
42
|
-
desc "complete", "Mark the current lesson as complete"
|
43
|
-
|
44
|
-
def complete
|
45
|
-
say "Marked current lesson as complete"
|
46
|
-
client.complete
|
47
|
-
end
|
48
|
-
|
49
|
-
desc "list", "Show all available workshop lessons"
|
50
|
-
|
51
|
-
def list
|
52
|
-
say "All available workshop lessons:"
|
53
|
-
client.list.each do |lesson|
|
54
|
-
puts "#{" " * lesson["indent"]}[#{lesson["position"]}]: #{lesson["title"]}"
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
desc "download [CONTENT | all]", "Download one or all workshop contents"
|
59
|
-
|
60
|
-
def download(content)
|
61
|
-
client.download(content)
|
62
|
-
end
|
63
|
-
|
64
|
-
desc "show [CONTENT]", "Show any workshop lesson, shows current lesson w/no arguments"
|
65
|
-
option :open
|
66
|
-
def show(content = :current)
|
67
|
-
client.show(content, options[:open])
|
68
|
-
end
|
69
|
-
|
70
|
-
private
|
71
|
-
|
72
|
-
def exit_with_no_key
|
73
|
-
exit(1) unless client.setup?
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
class Progress < SubCommandBase
|
78
|
-
class_before :exit_with_no_key
|
79
|
-
|
80
|
-
desc "set [LESSON]", "Set current lesson to a particular lesson"
|
81
|
-
|
82
|
-
def set(lesson)
|
83
|
-
client.set_progress(lesson)
|
84
|
-
end
|
85
|
-
|
86
|
-
desc "reset", "Erase all progress and start over"
|
87
|
-
|
88
|
-
def reset
|
89
|
-
yes? "Are you sure you want to reset your progress? (Y/N)"
|
90
|
-
client.reset_progress
|
91
|
-
end
|
92
|
-
|
93
|
-
desc "show", "Show current workshop progress"
|
94
|
-
def show
|
95
|
-
data = client.progress
|
96
|
-
say "The Rails Performance Workshop"
|
97
|
-
say "You have completed #{data[:completed]} out of #{data[:total]} total sections."
|
98
|
-
say "Current lesson: #{data[:current_lesson]["title"]}"
|
99
|
-
say "Progress by Section (X == completed, O == current):"
|
100
|
-
data[:sections].each do |section|
|
101
|
-
say "#{section[:title]}: #{section[:progress]}"
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
private
|
106
|
-
|
107
|
-
def exit_with_no_key
|
108
|
-
exit(1) unless client.setup?
|
109
|
-
end
|
110
|
-
|
111
|
-
default_task :show
|
112
|
-
end
|
113
|
-
|
114
|
-
class CLI < Thor
|
115
|
-
class_before :check_version
|
116
|
-
class_before :check_setup
|
117
|
-
|
118
|
-
desc "key register [EMAIL_ADDRESS]", "Change email registered w/Speedshop"
|
119
|
-
subcommand "key", Key
|
120
|
-
desc "lesson [SUBCOMMAND]", "View and download lessons"
|
121
|
-
subcommand "lesson", Lesson
|
122
|
-
desc "progress [SUBCOMMAND]", "View and set progress"
|
123
|
-
subcommand "progress", Progress
|
124
|
-
|
125
|
-
def self.exit_on_failure?
|
126
|
-
true
|
127
|
-
end
|
128
|
-
|
129
|
-
desc "start", "Tutorial and onboarding"
|
130
|
-
|
131
|
-
def start
|
132
|
-
print_banner
|
133
|
-
say "Welcome to the Rails Performance Workshop."
|
134
|
-
say ""
|
135
|
-
say "This is rpw, the command line client for this workshop."
|
136
|
-
say ""
|
137
|
-
say "This client will download files from the internet into the current"
|
138
|
-
say "working directory, so it's best to run this client from a new directory"
|
139
|
-
say "that you'll use as your 'scratch space' for working on the Workshop."
|
140
|
-
say ""
|
141
|
-
return unless yes? "Are you in a directory that we can safely add new folders and files to? (Y/N)"
|
142
|
-
puts ""
|
143
|
-
say "We'll create a .rpw_info file at #{File.expand_path("~/.rpw")} to save your purchase key."
|
144
|
-
home_dir_ok = yes?("Is this OK? (Y/N) (N will create it in the current directory)")
|
145
|
-
|
146
|
-
key = ask("Your Purchase Key: ")
|
147
|
-
|
148
|
-
client.setup(key)
|
149
|
-
|
150
|
-
puts ""
|
151
|
-
|
152
|
-
say "Successfully authenticated with the RPW server and saved your key."
|
153
|
-
|
154
|
-
puts ""
|
155
|
-
|
156
|
-
say "rpw works by downloading files into the current working directory."
|
157
|
-
say "We're going to (idempotently!) create a few directories in the current working directory."
|
158
|
-
puts ""
|
159
|
-
return unless yes? "Is that OK? (Y/N)"
|
160
|
-
|
161
|
-
client.directory_setup
|
162
|
-
|
163
|
-
say "Setup complete!"
|
164
|
-
puts ""
|
165
|
-
say "Here are some important commands for you to know:"
|
166
|
-
say "$ rpw lesson next | Proceed to the next part of the workshop."
|
167
|
-
say "$ rpw lesson complete | Mark current lesson as complete."
|
168
|
-
say "$ rpw lesson list | List all workshop lessons. Note each lesson is preceded with an ID."
|
169
|
-
say "$ rpw lesson download | Download any or all lessons."
|
170
|
-
say "$ rpw lesson show | Show any particular workshop lesson."
|
171
|
-
say "$ rpw progress | Show where you're currently at in the workshop."
|
172
|
-
say "$ rpw help | Help! You can also ask in Slack."
|
173
|
-
puts ""
|
174
|
-
say "Generally, you'll just be doing a lot of $ rpw lesson next"
|
175
|
-
say "Remember to ask on Slack for help if you get stuck or encounter bugs."
|
176
|
-
say "Let's get going! $ rpw lesson next"
|
177
|
-
end
|
178
|
-
|
179
|
-
no_commands do
|
180
|
-
def print_banner
|
181
|
-
puts r
|
182
|
-
if `tput cols 80`.to_i < 80
|
183
|
-
puts small_banner
|
184
|
-
else
|
185
|
-
puts banner
|
186
|
-
end
|
187
|
-
puts reset
|
188
|
-
end
|
189
|
-
end
|
190
|
-
|
191
|
-
private
|
192
|
-
|
193
|
-
def client
|
194
|
-
@client ||= RPW::Client.new
|
195
|
-
end
|
196
|
-
|
197
|
-
def check_version
|
198
|
-
unless client.latest_version?
|
199
|
-
say "#{r}WARNING: You are running an old version of rpw."
|
200
|
-
say "WARNING: Please run `$ gem install rpw`#{reset}"
|
201
|
-
end
|
202
|
-
end
|
203
|
-
|
204
|
-
def check_setup
|
205
|
-
unless client.setup? || current_command_chain == [:start]
|
206
|
-
say "#{r}WARNING: You do not have a purchase key set. Run `$ rpw start`#{reset}"
|
207
|
-
end
|
208
|
-
end
|
209
|
-
|
210
|
-
def r
|
211
|
-
"\e[31m"
|
212
|
-
end
|
213
|
-
|
214
|
-
def reset
|
215
|
-
"\e[0m"
|
216
|
-
end
|
217
|
-
|
218
|
-
def small_banner
|
219
|
-
%(
|
220
|
-
_____ _ _____ _ _
|
221
|
-
|_ _| |_ ___ | __ |___|_| |___
|
222
|
-
| | | | -_| | -| .'| | |_ -|
|
223
|
-
|_| |_|_|___| |__|__|__,|_|_|___|
|
224
|
-
_____ ___
|
225
|
-
| _ |___ ___| _|___ ___ _____ ___ ___ ___ ___
|
226
|
-
| __| -_| _| _| . | _| | .'| | _| -_|
|
227
|
-
|__| |___|_| |_| |___|_| |_|_|_|__,|_|_|___|___|
|
228
|
-
_ _ _ _ _
|
229
|
-
| | | |___ ___| |_ ___| |_ ___ ___
|
230
|
-
| | | | . | _| '_|_ -| | . | . |
|
231
|
-
|_____|___|_| |_,_|___|_|_|___| _|
|
232
|
-
|_|
|
233
|
-
#{reset})
|
234
|
-
end
|
235
|
-
|
236
|
-
def banner
|
237
|
-
%(
|
238
|
-
_____ _ _____ _ _
|
239
|
-
+hmNMMMMMm/` -ymMMNh/ |_ _| |_ ___ | __ |___|_| |___
|
240
|
-
sMMMMMMMMMy +MMMMMMMMy | | | | -_| | -| .'| | |_ -|
|
241
|
-
yMMMMMMMMMMy` yMMMMMMMMN |_| |_|_|___| |__|__|__,|_|_|___|
|
242
|
-
`dMMMMMMMMMMm:-dMMMMMMm: _____ ___
|
243
|
-
`sNMMMMMMMMMMs.:+sso:` | _ |___ ___| _|___ ___ _____ ___ ___ ___ ___
|
244
|
-
:dMMMMMMMMMMm/ | __| -_| _| _| . | _| | .'| | _| -_|
|
245
|
-
`:oss+:.sNMMMMMMMMMMy` |__| |___|_| |_| |___|_| |_|_|_|__,|_|_|___|___|
|
246
|
-
/mMMMMMMd-:mMMMMMMMMMMd. _ _ _ _ _
|
247
|
-
NMMMMMMMMy `hMMMMMMMMMMh | | | |___ ___| |_ ___| |_ ___ ___
|
248
|
-
yMMMMMMMM+ `dMMMMMMMMMy | | | | . | _| '_|_ -| | . | . |
|
249
|
-
/hNMMmy- `/mMMMMMNmy/ |_____|___|_| |_,_|___|_|_|___| _|
|
250
|
-
|_|
|
251
|
-
#{reset})
|
252
|
-
end
|
253
|
-
end
|
254
|
-
end
|
3
|
+
require_relative "../lib/rpw/cli"
|
255
4
|
|
256
5
|
RPW::CLI.start(ARGV)
|