lense 0.2.8 → 0.2.9
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/bin/lense +2 -3
- data/lib/lense.rb +37 -23
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 42f7d998c22de788c925711797f679392d9578bc
|
4
|
+
data.tar.gz: 8bbf0fd8898dbc9182faec13c981cad50a2aaca4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9db174c14e17583408bf13c2a81fb2baafacbf05ac8489dca11f178b8f36b0a1435bdf6d9d4de748054a4ca91de65dcb4915b3ca88a4322166550cad64e3d8b2
|
7
|
+
data.tar.gz: 323b53f1507f408329e5eb89c33a3332f35f8184887050d2c6bb995ce1c1453263298cfe3bce180f9c0551e16eeae07e8e216830f928c387608a3e7fc9aec4ba
|
data/bin/lense
CHANGED
@@ -73,15 +73,14 @@ end
|
|
73
73
|
|
74
74
|
command :pull do |c|
|
75
75
|
c.action do |global_options,options,args|
|
76
|
-
|
77
|
-
LENSE_APP.install_repo args[0], :pull
|
76
|
+
LENSE_APP.pull
|
78
77
|
end
|
79
78
|
end
|
80
79
|
|
81
80
|
command :clone do |c|
|
82
81
|
c.action do |global_options,options,args|
|
83
82
|
exit_now!('Must supply a LENSE repository.') if args.count < 1
|
84
|
-
LENSE_APP.
|
83
|
+
LENSE_APP.clone args[0]
|
85
84
|
end
|
86
85
|
end
|
87
86
|
|
data/lib/lense.rb
CHANGED
@@ -7,7 +7,7 @@ require 'base64'
|
|
7
7
|
class LENSE
|
8
8
|
attr_reader :config, :current_course, :lense_file_hash
|
9
9
|
|
10
|
-
VERSION = '0.2.
|
10
|
+
VERSION = '0.2.9'
|
11
11
|
LENSE_DIR = File.join(ENV['HOME'],'.lense')
|
12
12
|
COURSES_DIR = File.join(LENSE_DIR,'courses')
|
13
13
|
CURRENT_COURSE_FILE = File.join(LENSE_DIR,'current_course')
|
@@ -257,7 +257,39 @@ class LENSE
|
|
257
257
|
exit_now!("Invalid repo name.") unless repo =~ /\A\w+\/\w+\Z/
|
258
258
|
end
|
259
259
|
|
260
|
+
def pull()
|
261
|
+
exit_now!("Not in a lense project.") unless File.directory? '.lense'
|
262
|
+
exit_now!("No repo found.") unless File.file? ".lense/repository"
|
263
|
+
repo = File.read '.lense/repository'
|
264
|
+
exit_now!("Invalid repo name.") unless repo =~ /\A\w+\/\w+\Z/
|
265
|
+
|
266
|
+
install_repo repo, 'pull'
|
267
|
+
end
|
268
|
+
|
269
|
+
def clone(repo)
|
270
|
+
say "making dirs ..."
|
271
|
+
# make repo dir in current directory
|
272
|
+
Dir.mkdir project_name unless File.directory? project_name
|
273
|
+
|
274
|
+
# cd into project dir
|
275
|
+
Dir.chdir project_name
|
276
|
+
|
277
|
+
# make .lense dir and .lense/temp
|
278
|
+
proj_lense_dir = '.lense'
|
279
|
+
Dir.mkdir proj_lense_dir unless File.directory? proj_lense_dir
|
280
|
+
|
281
|
+
temp_dir = File.join proj_lense_dir, 'temp'
|
282
|
+
Dir.mkdir temp_dir unless File.directory? temp_dir
|
283
|
+
|
284
|
+
# write repository name
|
285
|
+
repo_file = File.join proj_lense_dir, 'repository'
|
286
|
+
File.open(repo_file, 'w') { |f| f.write repo } unless File.file? repo_file
|
287
|
+
|
288
|
+
install_repo repo, 'clone'
|
289
|
+
end
|
290
|
+
|
260
291
|
def install_repo(repo,action)
|
292
|
+
puts caller
|
261
293
|
exit_now!("Invalid repo name.") unless repo =~ /\A\w+\/\w+\Z/
|
262
294
|
username, project_name = repo.split '/'
|
263
295
|
|
@@ -272,33 +304,15 @@ class LENSE
|
|
272
304
|
|
273
305
|
exit_now!("Failed download. Hash does not match.") unless hash_contents(tar_str) == tar_hash
|
274
306
|
|
275
|
-
if action == :clone
|
276
|
-
say "making dirs ..."
|
277
|
-
# make repo dir in current directory
|
278
|
-
Dir.mkdir project_name unless File.directory? project_name
|
279
|
-
|
280
|
-
# make .lense dir and .lense/temp
|
281
|
-
proj_lense_dir = File.join project_name, '.lense'
|
282
|
-
Dir.mkdir proj_lense_dir unless File.directory? proj_lense_dir
|
283
|
-
|
284
|
-
temp_dir = File.join proj_lense_dir, 'temp'
|
285
|
-
Dir.mkdir temp_dir unless File.directory? temp_dir
|
286
|
-
|
287
|
-
working_dir = "cd #{project_name} "
|
288
|
-
else
|
289
|
-
temp_dir = '.lense/temp'
|
290
|
-
working_dir = 'true'
|
291
|
-
end
|
292
|
-
|
293
|
-
# write tar file to .lense/temp/hash.tar
|
294
307
|
tar_fname = "#{tar_hash}.tar"
|
295
308
|
say "writing tar file ... #{tar_fname}"
|
296
|
-
|
309
|
+
|
310
|
+
rel_tar_path = File.join '.lense', 'temp', tar_fname
|
297
311
|
File.open(rel_tar_path, 'w') { |f| f.write tar_str }
|
298
312
|
|
299
|
-
#
|
313
|
+
# untar
|
300
314
|
say "untaring to ... #{rel_tar_path}"
|
301
|
-
|
315
|
+
`tar -x#{TARFLAGS}f #{rel_tar_path}`
|
302
316
|
|
303
317
|
say "done"
|
304
318
|
# read lensefile
|