rpw 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/HISTORY.md +4 -0
- data/exe/rpw +25 -34
- data/lib/README.md +11 -0
- data/lib/rpw.rb +41 -24
- data/lib/rpw/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d147256fce52a088acb2caa0043222c16dfc73e09292006929e1b9d40372d70a
|
4
|
+
data.tar.gz: 211b34b2aff01a30220d65ad12120a240042634c2f815d91e2e4e72023a9fbf7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d2985f855f66246dd289959e287985011ae11e828a2daeb90c4f3e49a45e99b5ee05ba9b0fa67596c9067ec492cf40f548ecc5649e2c6769c6e366d74f402fb8
|
7
|
+
data.tar.gz: ef3be513985a20e01a16249fd2b71e2a026875327fcfe101a83e8da0d05751b7ccd594fd7f984b046f669fa7b49552969967d922d48d00f29767add9906f7d01
|
data/Gemfile.lock
CHANGED
data/HISTORY.md
CHANGED
data/exe/rpw
CHANGED
@@ -18,6 +18,18 @@ module RPW
|
|
18
18
|
def client
|
19
19
|
@client ||= RPW::Client.new
|
20
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
|
21
33
|
end
|
22
34
|
end
|
23
35
|
|
@@ -66,12 +78,6 @@ module RPW
|
|
66
78
|
def show(content = :current)
|
67
79
|
client.show(content, options[:open])
|
68
80
|
end
|
69
|
-
|
70
|
-
private
|
71
|
-
|
72
|
-
def exit_with_no_key
|
73
|
-
exit(1) unless client.setup?
|
74
|
-
end
|
75
81
|
end
|
76
82
|
|
77
83
|
class Progress < SubCommandBase
|
@@ -104,10 +110,6 @@ module RPW
|
|
104
110
|
|
105
111
|
private
|
106
112
|
|
107
|
-
def exit_with_no_key
|
108
|
-
exit(1) unless client.setup?
|
109
|
-
end
|
110
|
-
|
111
113
|
default_task :show
|
112
114
|
end
|
113
115
|
|
@@ -129,6 +131,8 @@ module RPW
|
|
129
131
|
desc "start", "Tutorial and onboarding"
|
130
132
|
|
131
133
|
def start
|
134
|
+
warn_if_already_started
|
135
|
+
|
132
136
|
print_banner
|
133
137
|
say "Welcome to the Rails Performance Workshop."
|
134
138
|
say ""
|
@@ -138,42 +142,24 @@ module RPW
|
|
138
142
|
say "working directory, so it's best to run this client from a new directory"
|
139
143
|
say "that you'll use as your 'scratch space' for working on the Workshop."
|
140
144
|
say ""
|
141
|
-
|
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)"
|
142
147
|
puts ""
|
143
|
-
say "We'll create a .rpw_info file at #{File.expand_path("~/.rpw")} to save your purchase key."
|
148
|
+
say "We'll also create a .rpw_info file at #{File.expand_path("~/.rpw")} to save your purchase key."
|
144
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)
|
145
151
|
|
146
152
|
key = ask("Your Purchase Key: ")
|
147
153
|
|
148
154
|
client.setup(key)
|
149
|
-
|
150
155
|
puts ""
|
151
|
-
|
152
156
|
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
157
|
puts ""
|
159
|
-
return unless yes? "Is that OK? (y/N)"
|
160
|
-
|
161
|
-
client.directory_setup
|
162
|
-
|
163
158
|
say "Setup complete!"
|
164
159
|
puts ""
|
165
|
-
say "
|
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"
|
160
|
+
say "To learn how to use this command-line client, consult README.md."
|
175
161
|
say "Remember to ask on Slack for help if you get stuck or encounter bugs."
|
176
|
-
say "
|
162
|
+
say "Once you're ready to get going: $ rpw lesson next"
|
177
163
|
end
|
178
164
|
|
179
165
|
no_commands do
|
@@ -194,6 +180,11 @@ module RPW
|
|
194
180
|
@client ||= RPW::Client.new
|
195
181
|
end
|
196
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
|
+
|
197
188
|
def check_version
|
198
189
|
unless client.latest_version?
|
199
190
|
say "#{r}WARNING: You are running an old version of rpw."
|
data/lib/README.md
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
Here are some important commands for you to know:
|
2
|
+
|
3
|
+
$ rpw lesson next | Proceed to the next part of the workshop.
|
4
|
+
$ rpw lesson complete | Mark current lesson as complete.
|
5
|
+
$ rpw lesson list | List all workshop lessons. Note each lesson is preceded with an ID.
|
6
|
+
$ rpw lesson download | Download any or all lessons.
|
7
|
+
$ rpw lesson show | Show any particular workshop lesson.
|
8
|
+
$ rpw progress | Show where you're currently at in the workshop.
|
9
|
+
$ rpw help | Help! You can also ask in Slack.
|
10
|
+
|
11
|
+
Generally, you'll just be doing a lot of $ rpw lesson next
|
data/lib/rpw.rb
CHANGED
@@ -74,12 +74,16 @@ module RPW
|
|
74
74
|
gateway.register_email(email)
|
75
75
|
end
|
76
76
|
|
77
|
-
def directory_setup
|
77
|
+
def directory_setup(home_dir_ok = true)
|
78
78
|
["video", "quiz", "lab", "text", "cgrp"].each do |path|
|
79
79
|
FileUtils.mkdir_p(path) unless File.directory?(path)
|
80
80
|
end
|
81
81
|
|
82
|
-
|
82
|
+
if home_dir_ok
|
83
|
+
ClientData.create_in_home!
|
84
|
+
else
|
85
|
+
ClientData.create_in_pwd!
|
86
|
+
end
|
83
87
|
|
84
88
|
unless File.exist?(".gitignore") && File.read(".gitignore").match(/rpw_key/)
|
85
89
|
File.open(".gitignore", "a") do |f|
|
@@ -93,6 +97,10 @@ module RPW
|
|
93
97
|
f.puts "cgrp\n"
|
94
98
|
end
|
95
99
|
end
|
100
|
+
|
101
|
+
File.open("README.md", "w+") do |f|
|
102
|
+
f.puts File.read(File.join(File.dirname(__FILE__), "README.md"))
|
103
|
+
end
|
96
104
|
end
|
97
105
|
|
98
106
|
def next(open_after = false)
|
@@ -172,6 +180,8 @@ module RPW
|
|
172
180
|
end
|
173
181
|
|
174
182
|
def latest_version?
|
183
|
+
return true unless ClientData.exists?
|
184
|
+
|
175
185
|
if client_data["last_version_check"]
|
176
186
|
return true if client_data["last_version_check"] >= Time.now - (60 * 60 * 24)
|
177
187
|
return false if client_data["last_version_check"] == false
|
@@ -191,9 +201,16 @@ module RPW
|
|
191
201
|
end
|
192
202
|
|
193
203
|
def setup?
|
204
|
+
return false unless ClientData.exists?
|
194
205
|
client_data["key"]
|
195
206
|
end
|
196
207
|
|
208
|
+
def directories_ready?
|
209
|
+
["video", "quiz", "lab", "text", "cgrp"].all? do |path|
|
210
|
+
File.directory?(path)
|
211
|
+
end
|
212
|
+
end
|
213
|
+
|
197
214
|
private
|
198
215
|
|
199
216
|
def finished_workshop
|
@@ -243,23 +260,27 @@ module RPW
|
|
243
260
|
|
244
261
|
def display_content(content, open_after)
|
245
262
|
puts "\nCurrent Lesson: #{content["title"]}"
|
263
|
+
openable = false
|
246
264
|
case content["style"]
|
247
265
|
when "video"
|
248
266
|
location = "video/#{content["s3_key"]}"
|
267
|
+
openable = true
|
249
268
|
when "quiz"
|
250
269
|
Quiz.start(["give_quiz", "quiz/" + content["s3_key"]])
|
251
270
|
when "lab"
|
252
|
-
location = "lab/#{content["s3_key"]}"
|
271
|
+
location = "lab/#{content["s3_key"][0..-8]}"
|
253
272
|
when "text"
|
254
273
|
location = "lab/#{content["s3_key"]}"
|
274
|
+
openable = true
|
255
275
|
when "cgrp"
|
256
276
|
puts "The Complete Guide to Rails Performance has been downloaded and extracted to the ./cgrp directory."
|
257
277
|
puts "All source code for the CGRP is in the src directory, PDF and other compiled formats are in the release directory."
|
258
278
|
end
|
259
279
|
if location
|
280
|
+
puts "This file can be opened automatically if you add the --open flag." if openable && !open_after
|
260
281
|
puts "Downloaded to:"
|
261
282
|
puts location.to_s
|
262
|
-
if open_after
|
283
|
+
if open_after && openable
|
263
284
|
exec "#{open_command} #{location}"
|
264
285
|
end
|
265
286
|
end
|
@@ -286,7 +307,6 @@ module RPW
|
|
286
307
|
DOTFILE_NAME = ".rpw_info"
|
287
308
|
|
288
309
|
def initialize
|
289
|
-
make_sure_dotfile_exists
|
290
310
|
data # access file to load
|
291
311
|
end
|
292
312
|
|
@@ -306,16 +326,29 @@ module RPW
|
|
306
326
|
end
|
307
327
|
end
|
308
328
|
|
329
|
+
def self.create_in_pwd!
|
330
|
+
FileUtils.touch(File.expand_path("./" + DOTFILE_NAME))
|
331
|
+
end
|
332
|
+
|
333
|
+
def self.create_in_home!
|
334
|
+
FileUtils.mkdir_p("~/.rpw/") unless File.directory?("~/.rpw/")
|
335
|
+
FileUtils.touch(File.expand_path("~/.rpw/" + DOTFILE_NAME))
|
336
|
+
end
|
337
|
+
|
309
338
|
def self.delete_filestore
|
310
339
|
return unless File.exist?(filestore_location)
|
311
340
|
FileUtils.remove(filestore_location)
|
312
341
|
end
|
313
342
|
|
343
|
+
def self.exists?
|
344
|
+
File.exist? filestore_location
|
345
|
+
end
|
346
|
+
|
314
347
|
def self.filestore_location
|
315
|
-
if File.exist?(File.expand_path("./" +
|
316
|
-
File.expand_path("./" +
|
348
|
+
if File.exist?(File.expand_path("./" + DOTFILE_NAME))
|
349
|
+
File.expand_path("./" + DOTFILE_NAME)
|
317
350
|
else
|
318
|
-
File.expand_path("~/.rpw/" +
|
351
|
+
File.expand_path("~/.rpw/" + DOTFILE_NAME)
|
319
352
|
end
|
320
353
|
end
|
321
354
|
|
@@ -325,28 +358,12 @@ module RPW
|
|
325
358
|
self.class.filestore_location
|
326
359
|
end
|
327
360
|
|
328
|
-
def create_client_data_directory(path)
|
329
|
-
dirname = File.dirname(path)
|
330
|
-
FileUtils.mkdir_p(dirname) unless File.directory?(dirname)
|
331
|
-
end
|
332
|
-
|
333
361
|
def data
|
334
362
|
@data ||= begin
|
335
363
|
yaml = YAML.safe_load(File.read(filestore_location), permitted_classes: [Time])
|
336
364
|
yaml || {}
|
337
365
|
end
|
338
366
|
end
|
339
|
-
|
340
|
-
def make_sure_dotfile_exists
|
341
|
-
return true if File.exist?(filestore_location)
|
342
|
-
create_client_data_directory(filestore_location)
|
343
|
-
begin
|
344
|
-
FileUtils.touch(filestore_location)
|
345
|
-
rescue
|
346
|
-
raise Error, "Could not create the RPW data file at ~/.rpw/ \
|
347
|
-
Check your file permissions."
|
348
|
-
end
|
349
|
-
end
|
350
367
|
end
|
351
368
|
|
352
369
|
require "digest"
|
data/lib/rpw/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rpw
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nate Berkopec
|
@@ -70,6 +70,7 @@ files:
|
|
70
70
|
- README.md
|
71
71
|
- Rakefile
|
72
72
|
- exe/rpw
|
73
|
+
- lib/README.md
|
73
74
|
- lib/rpw.rb
|
74
75
|
- lib/rpw/version.rb
|
75
76
|
- rpw.gemspec
|