lense 0.2.7 → 0.2.8
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 -2
- data/lib/lense.rb +19 -18
- 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: 48127f642dcb072a7efa9f4d06f27a2c3e876d37
|
4
|
+
data.tar.gz: d7d70a6dd8266744ea3f505cc584ff788d39dd8d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 155623f8e880665d2bc61ec35f9a628cab6d72867c3007f98340bca1477eded15d8fae7e064997cfa19268d42f36a00fb347835c72a9802dddcaace7cd16c7f1
|
7
|
+
data.tar.gz: 130d36f3322ed64512efa4a892088ff3233ca563ce5fbe273a76b45ba21705a24130c6f1f145f13f26400463868f427a438dcda680e28333bb81eb5242d5298b
|
data/bin/lense
CHANGED
@@ -74,14 +74,14 @@ end
|
|
74
74
|
command :pull do |c|
|
75
75
|
c.action do |global_options,options,args|
|
76
76
|
exit_now!('Must supply a LENSE repository.') if args.count < 1
|
77
|
-
LENSE_APP.
|
77
|
+
LENSE_APP.install_repo args[0], :pull
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
81
81
|
command :clone do |c|
|
82
82
|
c.action do |global_options,options,args|
|
83
83
|
exit_now!('Must supply a LENSE repository.') if args.count < 1
|
84
|
-
LENSE_APP.
|
84
|
+
LENSE_APP.install_repo args[0], :clone
|
85
85
|
end
|
86
86
|
end
|
87
87
|
|
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.8'
|
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,18 +257,12 @@ class LENSE
|
|
257
257
|
exit_now!("Invalid repo name.") unless repo =~ /\A\w+\/\w+\Z/
|
258
258
|
end
|
259
259
|
|
260
|
-
def
|
261
|
-
exit_now!("Invalid repo name.") unless repo =~ /\A\w+\/\w+\Z/
|
262
|
-
response = RestClient.get "#{API_BASE}/#{repo}/pull", { params: { format: 'json' } }
|
263
|
-
repository = JSON.parse(response)
|
264
|
-
end
|
265
|
-
|
266
|
-
def clone(repo)
|
260
|
+
def install_repo(repo,action)
|
267
261
|
exit_now!("Invalid repo name.") unless repo =~ /\A\w+\/\w+\Z/
|
268
262
|
username, project_name = repo.split '/'
|
269
263
|
|
270
264
|
say "making rest call"
|
271
|
-
response = RestClient.get "#{API_BASE}/#{repo}
|
265
|
+
response = RestClient.get "#{API_BASE}/#{repo}/#{action.to_s}", { params: { format: 'json' } }
|
272
266
|
repository = JSON.parse(response)
|
273
267
|
|
274
268
|
# reading and checking tar file
|
@@ -278,16 +272,23 @@ class LENSE
|
|
278
272
|
|
279
273
|
exit_now!("Failed download. Hash does not match.") unless hash_contents(tar_str) == tar_hash
|
280
274
|
|
281
|
-
|
282
|
-
|
283
|
-
|
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
|
284
279
|
|
285
|
-
|
286
|
-
|
287
|
-
|
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
|
288
283
|
|
289
|
-
|
290
|
-
|
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
|
291
292
|
|
292
293
|
# write tar file to .lense/temp/hash.tar
|
293
294
|
tar_fname = "#{tar_hash}.tar"
|
@@ -297,7 +298,7 @@ class LENSE
|
|
297
298
|
|
298
299
|
# cd into repo dir and untar
|
299
300
|
say "untaring to ... #{rel_tar_path}"
|
300
|
-
|
301
|
+
`#{working_dir} && tar -x#{TARFLAGS}f .lense/temp/#{tar_fname}`
|
301
302
|
|
302
303
|
say "done"
|
303
304
|
# read lensefile
|