gist_pull 0.3.1 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/bin/gist_pull +28 -5
  2. metadata +3 -5
@@ -14,9 +14,14 @@ def print_help
14
14
  exit(0)
15
15
  end
16
16
 
17
+ print_help unless [1,2].include? ARGV.length
17
18
 
18
- print_help unless ARGV.length == 1
19
+ run = false
19
20
 
21
+ if ARGV.include? '-r'
22
+ run = true
23
+ ARGV.delete '-r'
24
+ end
20
25
 
21
26
  meta = ""
22
27
  open("http://gist.github.com/api/v1/json/#{ARGV[0]}") { |f|
@@ -27,7 +32,12 @@ meta = JSON.parse(meta)["gists"].first
27
32
  files = meta['files']
28
33
  #puts meta
29
34
 
30
- def download(uri, name)
35
+ def run_gist(filename)
36
+ puts " \e[33m---Running #{filename}---\e[0m"
37
+ system('ruby', filename)
38
+ end
39
+
40
+ def download(uri, name)
31
41
  gist = open(uri).read
32
42
  File.open(name, 'w+') do |f|
33
43
  f.puts gist
@@ -40,7 +50,10 @@ if files.length == 1
40
50
  uri = "https://gist.github.com/raw/#{ARGV[0]}/#{file_name}"
41
51
  puts "downloading: #{uri}"
42
52
  download(uri, file_name)
43
-
53
+
54
+ if run
55
+ run_gist file_name
56
+ end
44
57
  else
45
58
  puts "∆! multiple files in this gist:\n"
46
59
  files.each {|f| puts "\t #{f}"}
@@ -54,7 +67,17 @@ else
54
67
 
55
68
  files.select!{ |f| files_desired.include? f}
56
69
  puts "getting:"
57
- files.each do |f|
70
+ files.each do |f|
58
71
  download("https://gist.github.com/raw/#{ARGV[0]}/#{f}", f)
59
72
  end
60
- end
73
+
74
+ if run
75
+ print "Which file do you want to run?\n: "
76
+ run_which_file = STDIN.gets.chomp
77
+ if files.include? run_which_file
78
+ run_gist run_which_file
79
+ else
80
+ puts "no such file"
81
+ end
82
+ end
83
+ end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: gist_pull
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.3.1
5
+ version: 0.4.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Artem Titoulenko
@@ -10,8 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-08-13 00:00:00 -04:00
14
- default_executable:
13
+ date: 2011-09-08 00:00:00 Z
15
14
  dependencies: []
16
15
 
17
16
  description:
@@ -24,7 +23,6 @@ extra_rdoc_files: []
24
23
 
25
24
  files:
26
25
  - bin/gist_pull
27
- has_rdoc: true
28
26
  homepage: https://github.com/ArtemTitoulenko/Gist-Pull
29
27
  licenses: []
30
28
 
@@ -48,7 +46,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
48
46
  requirements: []
49
47
 
50
48
  rubyforge_project: nowarning
51
- rubygems_version: 1.6.1
49
+ rubygems_version: 1.8.8
52
50
  signing_key:
53
51
  specification_version: 3
54
52
  summary: A tool that clones gists to your local directory