rench 0.1.1 → 0.1.2
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/lib/rench.rb +19 -3
- data/lib/rench/version.rb +1 -1
- data/spec/lib/rench_spec.rb +22 -1
- 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: 737935eb503a9d4488b1bbea10f39c3dbca083aa
|
|
4
|
+
data.tar.gz: 1b91821f63fa3bb0d97d253ab04ae0273aef51d9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7b99f6d486bc73c8a63d7c1dc7b4b72322ec85970d61b08fc00d2e0209e9adc654a0f4a56891dfa9f3ef6911dfbf62f7e12d21dc2a0eda118d1729a8d082ab20
|
|
7
|
+
data.tar.gz: b5de442fab623c6a161fcf89be07318032b12b13e07be60778b7f8f6c9ad0a77b850de75d4c27990b79e712084ef2c44490e7cb1ea9f798832bc44c54a5551d2
|
data/lib/rench.rb
CHANGED
|
@@ -7,7 +7,9 @@ require 'readline'
|
|
|
7
7
|
class Rench::CLI
|
|
8
8
|
|
|
9
9
|
def crank
|
|
10
|
-
system("curl #{url} -o #{
|
|
10
|
+
if system("curl #{url} -o #{download_file_location} --create-dirs")
|
|
11
|
+
puts "\n > #{@filename} => #{download_file_location}\n\n"
|
|
12
|
+
end
|
|
11
13
|
end
|
|
12
14
|
|
|
13
15
|
def initialize(username = nil, filename = nil, new_file_location = nil)
|
|
@@ -17,11 +19,14 @@ class Rench::CLI
|
|
|
17
19
|
end
|
|
18
20
|
|
|
19
21
|
def github_username
|
|
20
|
-
@github_username ||= highline.ask "Enter a Github username"
|
|
22
|
+
@github_username ||= highline.ask "Enter a Github username:"
|
|
21
23
|
end
|
|
22
24
|
|
|
23
25
|
def filename
|
|
24
|
-
@filename ||=
|
|
26
|
+
@filename ||= begin
|
|
27
|
+
highline.say("\nChoose a tool:")
|
|
28
|
+
highline.choose(*tool_menu)
|
|
29
|
+
end
|
|
25
30
|
end
|
|
26
31
|
|
|
27
32
|
def tool_menu
|
|
@@ -32,6 +37,17 @@ class Rench::CLI
|
|
|
32
37
|
@file_location ||= choose_file_location
|
|
33
38
|
end
|
|
34
39
|
|
|
40
|
+
def download_file_location
|
|
41
|
+
if file_location.match /\w+\.\w+/
|
|
42
|
+
file_location
|
|
43
|
+
elsif file_location.match /\/$/
|
|
44
|
+
file_location + filename
|
|
45
|
+
else
|
|
46
|
+
file_location + "/" + filename
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
|
|
35
51
|
def choose_file_location
|
|
36
52
|
highline.ask("Where do you want to put '#{filename.to_s}'?", file_options) do |question|
|
|
37
53
|
question.readline = true
|
data/lib/rench/version.rb
CHANGED
data/spec/lib/rench_spec.rb
CHANGED
|
@@ -22,7 +22,7 @@ describe Rench::CLI do
|
|
|
22
22
|
context "when NOT initialized with a username" do
|
|
23
23
|
let(:rench) { Rench::CLI.new }
|
|
24
24
|
it "prompts for username" do
|
|
25
|
-
highline.should_receive(:ask).with("Enter a Github username")
|
|
25
|
+
highline.should_receive(:ask).with("Enter a Github username:")
|
|
26
26
|
rench.github_username
|
|
27
27
|
end
|
|
28
28
|
end
|
|
@@ -104,4 +104,25 @@ describe Rench::CLI do
|
|
|
104
104
|
end
|
|
105
105
|
end
|
|
106
106
|
|
|
107
|
+
describe "#download_file_location" do
|
|
108
|
+
context "when file_location ends with a slash" do
|
|
109
|
+
it "contactinates the string with the filename" do
|
|
110
|
+
rench.stub(file_location: "app/")
|
|
111
|
+
rench.download_file_location.should == "app/file.txt"
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
context "when the file_location has no file extension" do
|
|
115
|
+
it "joins the input and filename with a '/'" do
|
|
116
|
+
rench.stub(file_location: "app")
|
|
117
|
+
rench.download_file_location.should == "app/file.txt"
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
context "when the file_location has a file extension" do
|
|
121
|
+
it "returns just the input" do
|
|
122
|
+
rench.stub(file_location: "app.rb")
|
|
123
|
+
rench.download_file_location.should == "app.rb"
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
|
|
107
128
|
end
|