rpw 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +109 -0
- data/.gitignore +1 -0
- data/Gemfile.lock +12 -16
- data/HISTORY.md +5 -0
- data/exe/rpw +1 -243
- data/lib/rpw.rb +4 -391
- data/lib/{README.md → rpw/README.md} +12 -1
- data/lib/rpw/cli.rb +96 -0
- data/lib/rpw/cli/bannerlord.rb +59 -0
- data/lib/rpw/cli/key.rb +15 -0
- data/lib/rpw/cli/lesson.rb +99 -0
- data/lib/rpw/cli/progress.rb +32 -0
- data/lib/rpw/cli/quiz.rb +28 -0
- data/lib/rpw/cli/sub_command_base.rb +30 -0
- data/lib/rpw/client.rb +168 -0
- data/lib/rpw/client_data.rb +73 -0
- data/lib/rpw/gateway.rb +63 -0
- data/lib/rpw/version.rb +1 -1
- data/rpw.gemspec +1 -1
- metadata +15 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 796740f7cd5cfebc0f46f72669da6d1b2941436c984d2a624a18200ae3466495
|
4
|
+
data.tar.gz: 3b986dbab69c20f2e840b2197175119e428d19b117378ef9192a5ce31178cbac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6b5530f032ece3e44819374cb7001530359a913e5b025e04f19313c6afeb1ec2450667783c8d44e20a18b1d0c16220a19f60d29275b1f3e9852a5401a2f2b7ba
|
7
|
+
data.tar.gz: 1389deea5fe3705527d841abc84d9f6f33b112d5a8d02502bb8d8f8a5df90ffaedc520f8449da2891405d7702a31d65ac193087c12a5a3588afe53cf6f4dee14
|
@@ -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.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 (0.0.
|
4
|
+
rpw (0.0.6)
|
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
data/exe/rpw
CHANGED
@@ -1,247 +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
|
-
|
22
|
-
def exit_with_no_key
|
23
|
-
unless client.setup?
|
24
|
-
say "You have not yet set up the client. Run $ rpw start"
|
25
|
-
exit(1)
|
26
|
-
end
|
27
|
-
unless client.directories_ready?
|
28
|
-
say "You are not in your workshop scratch directory, or you have not yet"
|
29
|
-
say "set up the client. Change directory or run $ rpw start"
|
30
|
-
exit(1)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
class Key < SubCommandBase
|
37
|
-
desc "register [EMAIL_ADDRESS]", "Change email registered with Speedshop. One-time only."
|
38
|
-
def register(email)
|
39
|
-
client.register_email(email)
|
40
|
-
say "License registered. You should receive a Slack invite soon."
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
class Lesson < SubCommandBase
|
45
|
-
class_before :exit_with_no_key
|
46
|
-
|
47
|
-
desc "next", "Proceed to the next lesson of the workshop"
|
48
|
-
option :open
|
49
|
-
def next
|
50
|
-
say "Proceeding to next lesson..."
|
51
|
-
client.next(options[:open])
|
52
|
-
end
|
53
|
-
|
54
|
-
desc "complete", "Mark the current lesson as complete"
|
55
|
-
|
56
|
-
def complete
|
57
|
-
say "Marked current lesson as complete"
|
58
|
-
client.complete
|
59
|
-
end
|
60
|
-
|
61
|
-
desc "list", "Show all available workshop lessons"
|
62
|
-
|
63
|
-
def list
|
64
|
-
say "All available workshop lessons:"
|
65
|
-
client.list.each do |lesson|
|
66
|
-
puts "#{" " * lesson["indent"]}[#{lesson["position"]}]: #{lesson["title"]}"
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
desc "download [CONTENT | all]", "Download one or all workshop contents"
|
71
|
-
|
72
|
-
def download(content)
|
73
|
-
client.download(content)
|
74
|
-
end
|
75
|
-
|
76
|
-
desc "show [CONTENT]", "Show any workshop lesson, shows current lesson w/no arguments"
|
77
|
-
option :open
|
78
|
-
def show(content = :current)
|
79
|
-
client.show(content, options[:open])
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
class Progress < SubCommandBase
|
84
|
-
class_before :exit_with_no_key
|
85
|
-
|
86
|
-
desc "set [LESSON]", "Set current lesson to a particular lesson"
|
87
|
-
|
88
|
-
def set(lesson)
|
89
|
-
client.set_progress(lesson)
|
90
|
-
end
|
91
|
-
|
92
|
-
desc "reset", "Erase all progress and start over"
|
93
|
-
|
94
|
-
def reset
|
95
|
-
yes? "Are you sure you want to reset your progress? (Y/N)"
|
96
|
-
client.reset_progress
|
97
|
-
end
|
98
|
-
|
99
|
-
desc "show", "Show current workshop progress"
|
100
|
-
def show
|
101
|
-
data = client.progress
|
102
|
-
say "The Rails Performance Workshop"
|
103
|
-
say "You have completed #{data[:completed]} out of #{data[:total]} total sections."
|
104
|
-
say "Current lesson: #{data[:current_lesson]["title"]}"
|
105
|
-
say "Progress by Section (X == completed, O == current):"
|
106
|
-
data[:sections].each do |section|
|
107
|
-
say "#{section[:title]}: #{section[:progress]}"
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
private
|
112
|
-
|
113
|
-
default_task :show
|
114
|
-
end
|
115
|
-
|
116
|
-
class CLI < Thor
|
117
|
-
class_before :check_version
|
118
|
-
class_before :check_setup
|
119
|
-
|
120
|
-
desc "key register [EMAIL_ADDRESS]", "Change email registered w/Speedshop"
|
121
|
-
subcommand "key", Key
|
122
|
-
desc "lesson [SUBCOMMAND]", "View and download lessons"
|
123
|
-
subcommand "lesson", Lesson
|
124
|
-
desc "progress [SUBCOMMAND]", "View and set progress"
|
125
|
-
subcommand "progress", Progress
|
126
|
-
|
127
|
-
def self.exit_on_failure?
|
128
|
-
true
|
129
|
-
end
|
130
|
-
|
131
|
-
desc "start", "Tutorial and onboarding"
|
132
|
-
|
133
|
-
def start
|
134
|
-
warn_if_already_started
|
135
|
-
|
136
|
-
print_banner
|
137
|
-
say "Welcome to the Rails Performance Workshop."
|
138
|
-
say ""
|
139
|
-
say "This is rpw, the command line client for this workshop."
|
140
|
-
say ""
|
141
|
-
say "This client will download files from the internet into the current"
|
142
|
-
say "working directory, so it's best to run this client from a new directory"
|
143
|
-
say "that you'll use as your 'scratch space' for working on the Workshop."
|
144
|
-
say ""
|
145
|
-
say "We will create a handful of new files and folders in the current directory."
|
146
|
-
return unless yes? "Is this OK? (y/N) (N will quit)"
|
147
|
-
puts ""
|
148
|
-
say "We'll also create a .rpw_info file at #{File.expand_path("~/.rpw")} to save your purchase key."
|
149
|
-
home_dir_ok = yes?("Is this OK? (y/N) (N will create it in the current directory)")
|
150
|
-
client.directory_setup(home_dir_ok)
|
151
|
-
|
152
|
-
key = ask("Your Purchase Key: ")
|
153
|
-
|
154
|
-
client.setup(key)
|
155
|
-
puts ""
|
156
|
-
say "Successfully authenticated with the RPW server and saved your key."
|
157
|
-
puts ""
|
158
|
-
say "Setup complete!"
|
159
|
-
puts ""
|
160
|
-
say "To learn how to use this command-line client, consult README.md."
|
161
|
-
say "Remember to ask on Slack for help if you get stuck or encounter bugs."
|
162
|
-
say "Once you're ready to get going: $ rpw lesson next"
|
163
|
-
end
|
164
|
-
|
165
|
-
no_commands do
|
166
|
-
def print_banner
|
167
|
-
puts r
|
168
|
-
if `tput cols 80`.to_i < 80
|
169
|
-
puts small_banner
|
170
|
-
else
|
171
|
-
puts banner
|
172
|
-
end
|
173
|
-
puts reset
|
174
|
-
end
|
175
|
-
end
|
176
|
-
|
177
|
-
private
|
178
|
-
|
179
|
-
def client
|
180
|
-
@client ||= RPW::Client.new
|
181
|
-
end
|
182
|
-
|
183
|
-
def warn_if_already_started
|
184
|
-
return unless client.setup?
|
185
|
-
exit(0) unless yes? "You have already started the workshop. Continuing this command will wipe all of your current progress. Continue? (y/N)"
|
186
|
-
end
|
187
|
-
|
188
|
-
def check_version
|
189
|
-
unless client.latest_version?
|
190
|
-
say "#{r}WARNING: You are running an old version of rpw."
|
191
|
-
say "WARNING: Please run `$ gem install rpw`#{reset}"
|
192
|
-
end
|
193
|
-
end
|
194
|
-
|
195
|
-
def check_setup
|
196
|
-
unless client.setup? || current_command_chain == [:start]
|
197
|
-
say "#{r}WARNING: You do not have a purchase key set. Run `$ rpw start`#{reset}"
|
198
|
-
end
|
199
|
-
end
|
200
|
-
|
201
|
-
def r
|
202
|
-
"\e[31m"
|
203
|
-
end
|
204
|
-
|
205
|
-
def reset
|
206
|
-
"\e[0m"
|
207
|
-
end
|
208
|
-
|
209
|
-
def small_banner
|
210
|
-
%(
|
211
|
-
_____ _ _____ _ _
|
212
|
-
|_ _| |_ ___ | __ |___|_| |___
|
213
|
-
| | | | -_| | -| .'| | |_ -|
|
214
|
-
|_| |_|_|___| |__|__|__,|_|_|___|
|
215
|
-
_____ ___
|
216
|
-
| _ |___ ___| _|___ ___ _____ ___ ___ ___ ___
|
217
|
-
| __| -_| _| _| . | _| | .'| | _| -_|
|
218
|
-
|__| |___|_| |_| |___|_| |_|_|_|__,|_|_|___|___|
|
219
|
-
_ _ _ _ _
|
220
|
-
| | | |___ ___| |_ ___| |_ ___ ___
|
221
|
-
| | | | . | _| '_|_ -| | . | . |
|
222
|
-
|_____|___|_| |_,_|___|_|_|___| _|
|
223
|
-
|_|
|
224
|
-
#{reset})
|
225
|
-
end
|
226
|
-
|
227
|
-
def banner
|
228
|
-
%(
|
229
|
-
_____ _ _____ _ _
|
230
|
-
+hmNMMMMMm/` -ymMMNh/ |_ _| |_ ___ | __ |___|_| |___
|
231
|
-
sMMMMMMMMMy +MMMMMMMMy | | | | -_| | -| .'| | |_ -|
|
232
|
-
yMMMMMMMMMMy` yMMMMMMMMN |_| |_|_|___| |__|__|__,|_|_|___|
|
233
|
-
`dMMMMMMMMMMm:-dMMMMMMm: _____ ___
|
234
|
-
`sNMMMMMMMMMMs.:+sso:` | _ |___ ___| _|___ ___ _____ ___ ___ ___ ___
|
235
|
-
:dMMMMMMMMMMm/ | __| -_| _| _| . | _| | .'| | _| -_|
|
236
|
-
`:oss+:.sNMMMMMMMMMMy` |__| |___|_| |_| |___|_| |_|_|_|__,|_|_|___|___|
|
237
|
-
/mMMMMMMd-:mMMMMMMMMMMd. _ _ _ _ _
|
238
|
-
NMMMMMMMMy `hMMMMMMMMMMh | | | |___ ___| |_ ___| |_ ___ ___
|
239
|
-
yMMMMMMMM+ `dMMMMMMMMMy | | | | . | _| '_|_ -| | . | . |
|
240
|
-
/hNMMmy- `/mMMMMMNmy/ |_____|___|_| |_,_|___|_|_|___| _|
|
241
|
-
|_|
|
242
|
-
#{reset})
|
243
|
-
end
|
244
|
-
end
|
245
|
-
end
|
3
|
+
require_relative "../lib/rpw/cli"
|
246
4
|
|
247
5
|
RPW::CLI.start(ARGV)
|