rench 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.gitignore +17 -0
- data/.rspec +2 -0
- data/.rvmrc +1 -0
- data/Gemfile +3 -0
- data/LICENSE +22 -0
- data/README.md +67 -0
- data/Rakefile +9 -0
- data/bin/rench +9 -0
- data/lib/rench/version.rb +3 -0
- data/lib/rench.rb +105 -0
- data/rench.gemspec +23 -0
- data/spec/lib/rench_spec.rb +139 -0
- metadata +100 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
OWQ3MGZjYzdhMmVkYzRlMDhlZDFkNjkyZTI0MTZiZTFjMDk0ODg2YQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
NmQ0NWMxMjkzNDFlYmE1ZDk3ZTQ5MGU3OWE5NWNhOWRkNzExNWFjYQ==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
NWUyMjNmNzAwNmEyY2Q4ZjhiZjRkNjc0OTllZGM2MmMwNjc2NDUyZmZiM2U1
|
10
|
+
MWRlNjhjM2Q4MDg2ODdmNzE1NjEzYjQ1MDg5YWE3YjZlZjU5ZmMxOGRhMTIw
|
11
|
+
OGFmNzQyOGZhYjNiOGEyODU5NTMyYjlmYzJjMWMwNDg0Y2IwMTg=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
MTM1Y2UzZTUxMmY4ZTRlYjdmM2YyOTFjMDkzNWJkNGI4NmJiZGJiZGUxOWEz
|
14
|
+
MDQ0YzQzNzA0NDc0MWQzMzE1ZWZmYTM1OGRiMjMyZTcyMzliMDU1YjJmYzJi
|
15
|
+
ZDJmMzNiZDYyMTI4Mzk4NjAxMTkwYWRjY2RhYmUxNTYyMWIzZTc=
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm gemset use ruby-1.9.3-p327@rench --create
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Hashrocket Workstation
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
# Rench
|
2
|
+
|
3
|
+
Do you ever have a list of files you pull from one project to another?
|
4
|
+
Here is a cooler way to do that:
|
5
|
+
|
6
|
+
Put them in your 'toolbox' repo, maintain them, share them, and most importantly- retrieve them easily.
|
7
|
+
|
8
|
+
- Make a Github repository called toolbox.
|
9
|
+
- Make a `toolbox/tools` directory
|
10
|
+
- Fill it with all the files you use have ever used on more than one
|
11
|
+
project.
|
12
|
+
- Make a .markdown file for all these tools so you, and anyone
|
13
|
+
else, can always know how to use your tools.
|
14
|
+
- When you're working on a project, grab your tools and stick them where
|
15
|
+
you need with Rench.
|
16
|
+
|
17
|
+
## Instructions
|
18
|
+
|
19
|
+
```bash
|
20
|
+
$ gem install rench
|
21
|
+
|
22
|
+
$ rench <github_username> <filename> [new_file_location]
|
23
|
+
# Rench will only look in the `/tools` directory for <filename>
|
24
|
+
|
25
|
+
$ rench mrmicahcooper active_model_spec_helper.rb
|
26
|
+
|
27
|
+
#=> Where do you wanna put "active_model_spec_helepr"?
|
28
|
+
|
29
|
+
(blank) #=> saves as: active_model_spec_helepr.rb
|
30
|
+
or
|
31
|
+
spec_helper.rb #=> saves as: spec_helper.rb
|
32
|
+
or
|
33
|
+
spec/ #=> saves as: spec/active_model_spec_helepr.rb
|
34
|
+
or
|
35
|
+
spec #=> saves as: spec/active_model_spec_helepr.rb
|
36
|
+
```
|
37
|
+
|
38
|
+
#### Alternatively
|
39
|
+
You can just enter a Github user and it will print their tools for you
|
40
|
+
to choose one.
|
41
|
+
|
42
|
+
```bash
|
43
|
+
|
44
|
+
$rench mrmicahcooper
|
45
|
+
|
46
|
+
Choose a file:
|
47
|
+
[0] active_record_spec_helper.rb
|
48
|
+
[1] formbuilder.rb
|
49
|
+
[2] html5.js
|
50
|
+
[3] mixins.sass
|
51
|
+
[4] step_definitions.rb
|
52
|
+
[5] support_paths.rb
|
53
|
+
[6] ui_controller.rb
|
54
|
+
|
55
|
+
$ 6
|
56
|
+
|
57
|
+
Where do you wanna put "ui_controller.rb"?
|
58
|
+
|
59
|
+
...
|
60
|
+
```
|
61
|
+
|
62
|
+
This is great for exploring other people's toolboxes.
|
63
|
+
|
64
|
+
|
65
|
+
### Dependencies
|
66
|
+
|
67
|
+
- curl
|
data/Rakefile
ADDED
data/bin/rench
ADDED
data/lib/rench.rb
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
require "rench/version"
|
2
|
+
require "faraday"
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
class Rench::CLI
|
6
|
+
|
7
|
+
attr_reader :github_username, :filename, :file_location
|
8
|
+
|
9
|
+
def ask_for_file_location
|
10
|
+
$stdout.write "Where do you wanna put \"#{filename}\"? "
|
11
|
+
file = $stdin.gets.to_s.strip
|
12
|
+
if file == ""
|
13
|
+
filename
|
14
|
+
else
|
15
|
+
file
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def ask_for_github_username
|
20
|
+
$stdout.puts "Please enter a Github username"
|
21
|
+
$stdin.gets.strip
|
22
|
+
end
|
23
|
+
|
24
|
+
def build_file_location(input)
|
25
|
+
if input.match /\w+\.\w+/
|
26
|
+
input
|
27
|
+
elsif input.match /\/$/
|
28
|
+
input + filename
|
29
|
+
elsif input == ""
|
30
|
+
""
|
31
|
+
else
|
32
|
+
input + "/" + filename
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def chosen_file
|
37
|
+
print_renches
|
38
|
+
chosen_file = $stdin.gets.to_i
|
39
|
+
toolbox[chosen_file]
|
40
|
+
end
|
41
|
+
|
42
|
+
def download_file
|
43
|
+
response = Faraday.new.get(url)
|
44
|
+
if response.status == 200
|
45
|
+
system("curl #{url} -o #{file_location} --create-dirs")
|
46
|
+
$stdout.puts "=> #{ file_location }"
|
47
|
+
else
|
48
|
+
$stdout.puts "File not found in #{github_username}'s toolbox"
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def file_location
|
53
|
+
build_file_location(@file_location ||= ask_for_file_location)
|
54
|
+
end
|
55
|
+
|
56
|
+
def filename
|
57
|
+
@filename ||= chosen_file
|
58
|
+
end
|
59
|
+
|
60
|
+
def github_username
|
61
|
+
@github_username ||= ask_for_github_username
|
62
|
+
end
|
63
|
+
|
64
|
+
def initialize(username = nil, filename = nil, new_file_location = nil)
|
65
|
+
@github_username = username
|
66
|
+
@filename = filename
|
67
|
+
@file_location = new_file_location
|
68
|
+
end
|
69
|
+
|
70
|
+
def print_renches
|
71
|
+
if tools_found?
|
72
|
+
$stdout.puts "Choose a file:"
|
73
|
+
toolbox.each_with_index do |tool, i|
|
74
|
+
$stdout.puts "[#{i}] #{tool}"
|
75
|
+
end
|
76
|
+
else
|
77
|
+
Kernel.abort "No tools found for \"#{github_username}\""
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def toolbox
|
82
|
+
toolbox_response_body.map{|tool_file| tool_file["name"] }
|
83
|
+
end
|
84
|
+
|
85
|
+
def toolbox_response
|
86
|
+
@toolbox_response ||= Faraday.get(toolbox_url)
|
87
|
+
end
|
88
|
+
|
89
|
+
def tools_found?
|
90
|
+
toolbox_response.status == 200
|
91
|
+
end
|
92
|
+
|
93
|
+
def toolbox_response_body
|
94
|
+
@toolbox_response_body ||= JSON.parse toolbox_response.body
|
95
|
+
end
|
96
|
+
|
97
|
+
def url
|
98
|
+
"https://raw.github.com/#{github_username}/toolbox/master/tools/#{filename}"
|
99
|
+
end
|
100
|
+
|
101
|
+
def toolbox_url
|
102
|
+
"https://api.github.com/repos/#{github_username}/toolbox/contents/tools"
|
103
|
+
end
|
104
|
+
|
105
|
+
end
|
data/rench.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/rench/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Micah Cooper"]
|
6
|
+
gem.email = ["mrmicahcooper@gmail.com"]
|
7
|
+
gem.description = %q{Keep all the files you use often in a Toolbox. Then easily grab them (or anyones) with Rench. }
|
8
|
+
gem.summary = "Have a toolbox of often used files. Use them and share them easily."
|
9
|
+
gem.homepage = "http://github.com/mrmicahcooper/rench"
|
10
|
+
|
11
|
+
gem.files = `git ls-files`.split($\)
|
12
|
+
gem.executables = ["rench"]
|
13
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
|
+
gem.name = "rench"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = Rench::VERSION
|
17
|
+
|
18
|
+
gem.add_dependency 'faraday'
|
19
|
+
|
20
|
+
gem.add_development_dependency 'pry'
|
21
|
+
gem.add_development_dependency 'rspec'
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,139 @@
|
|
1
|
+
require 'rench'
|
2
|
+
|
3
|
+
describe Rench::CLI do
|
4
|
+
|
5
|
+
let(:github_user) { "mrmicahcooper" }
|
6
|
+
|
7
|
+
subject { described_class.new(github_user, 'active_record_spec_helper.rb') }
|
8
|
+
|
9
|
+
describe "#ask_for_github_username" do
|
10
|
+
before { $stdin.stub(gets: "micah") }
|
11
|
+
it "asks for a username" do
|
12
|
+
subject.ask_for_github_username.should == "micah"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "#build_file_location" do
|
17
|
+
context "when input ends with a slash" do
|
18
|
+
it "contactinates the string with the filename" do
|
19
|
+
subject.build_file_location("app/").should == "app/active_record_spec_helper.rb"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
context "when the input has no file extension" do
|
23
|
+
it "joins the input and filename with a '/'" do
|
24
|
+
subject.build_file_location("app").should == "app/active_record_spec_helper.rb"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
context "when the input has a file extension" do
|
28
|
+
it "returns just the input" do
|
29
|
+
subject.build_file_location("app.rb").should == "app.rb"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
context "when input is blank" do
|
33
|
+
it "returns blank" do
|
34
|
+
subject.build_file_location("").should == ""
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe "#chosen_file" do
|
40
|
+
before do
|
41
|
+
subject.stub(toolbox: ["form_builder.rb"])
|
42
|
+
$stdin.stub(gets: "0")
|
43
|
+
end
|
44
|
+
it "returns a a list of tools from that github_user" do
|
45
|
+
subject.chosen_file.should == "form_builder.rb"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe "#download_file" do
|
50
|
+
context "when file is found" do
|
51
|
+
before { $stdin.stub(gets: "text.txt") }
|
52
|
+
it "downloads the specified tool file" do
|
53
|
+
subject.download_file
|
54
|
+
File.read("text.txt").should be
|
55
|
+
File.delete("text.txt")
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
context "when file is not found" do
|
60
|
+
before { $stdin.stub(gets: "text.txt") }
|
61
|
+
let(:github_user) { "someone_else" }
|
62
|
+
it "returns message that file was not found" do
|
63
|
+
$stdout.should_receive(:puts).with("File not found in someone_else's toolbox")
|
64
|
+
subject.download_file
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
context "when choosing a new directory" do
|
69
|
+
before { $stdin.stub(gets: "app/text.txt") }
|
70
|
+
it "creates the director(y|ies)" do
|
71
|
+
subject.download_file
|
72
|
+
File.read("app/text.txt").should be
|
73
|
+
FileUtils.rm_r("app/text.txt")
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
describe '#new' do
|
79
|
+
it "knows the github username" do
|
80
|
+
subject.github_username.should_not be_nil
|
81
|
+
end
|
82
|
+
it "knows the filename" do
|
83
|
+
subject.filename.should_not be_nil
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
describe "#print_renches" do
|
88
|
+
|
89
|
+
context "when toolbox is empty" do
|
90
|
+
before do
|
91
|
+
subject.stub(tools_found?: false)
|
92
|
+
Kernel.stub(:abort)
|
93
|
+
end
|
94
|
+
it "exits with a toolbox not found message" do
|
95
|
+
Kernel.should_receive(:abort).with("No tools found for \"mrmicahcooper\"")
|
96
|
+
subject.print_renches
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
context "when toolbox is not empty" do
|
101
|
+
before do
|
102
|
+
subject.stub(toolbox: ["file.rb", "file2.rb"])
|
103
|
+
subject.stub(tools_found?: true)
|
104
|
+
end
|
105
|
+
it "prints a list of all the renches with a number next to it" do
|
106
|
+
$stdout.should_receive(:puts).at_least(3)
|
107
|
+
subject.print_renches
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
end
|
112
|
+
|
113
|
+
describe "#toolbox" do
|
114
|
+
it "returns a collection of filenames from the github users toolbox repo" do
|
115
|
+
subject.toolbox.size.should > 2
|
116
|
+
subject.toolbox.inspect.should match /ui_controller.rb/
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
describe "#tool_found?" do
|
121
|
+
let(:github_user) { "121ivesnv" }
|
122
|
+
it "returns false if no toolbox is found" do
|
123
|
+
subject.tools_found?.should be_false
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
describe "#toolbox_url" do
|
128
|
+
it "builds the toolbox_url" do
|
129
|
+
subject.toolbox_url.should == "https://api.github.com/repos/mrmicahcooper/toolbox/contents/tools"
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
describe "#url" do
|
134
|
+
it "builds the github url" do
|
135
|
+
subject.url.should == "https://raw.github.com/mrmicahcooper/toolbox/master/tools/active_record_spec_helper.rb"
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
end
|
metadata
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rench
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Micah Cooper
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-03-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: faraday
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ! '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ! '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: pry
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ! '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ! '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: ! 'Keep all the files you use often in a Toolbox. Then easily grab them
|
56
|
+
(or anyones) with Rench. '
|
57
|
+
email:
|
58
|
+
- mrmicahcooper@gmail.com
|
59
|
+
executables:
|
60
|
+
- rench
|
61
|
+
extensions: []
|
62
|
+
extra_rdoc_files: []
|
63
|
+
files:
|
64
|
+
- .gitignore
|
65
|
+
- .rspec
|
66
|
+
- .rvmrc
|
67
|
+
- Gemfile
|
68
|
+
- LICENSE
|
69
|
+
- README.md
|
70
|
+
- Rakefile
|
71
|
+
- bin/rench
|
72
|
+
- lib/rench.rb
|
73
|
+
- lib/rench/version.rb
|
74
|
+
- rench.gemspec
|
75
|
+
- spec/lib/rench_spec.rb
|
76
|
+
homepage: http://github.com/mrmicahcooper/rench
|
77
|
+
licenses: []
|
78
|
+
metadata: {}
|
79
|
+
post_install_message:
|
80
|
+
rdoc_options: []
|
81
|
+
require_paths:
|
82
|
+
- lib
|
83
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - ! '>='
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
90
|
+
- - ! '>='
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '0'
|
93
|
+
requirements: []
|
94
|
+
rubyforge_project:
|
95
|
+
rubygems_version: 2.0.2
|
96
|
+
signing_key:
|
97
|
+
specification_version: 4
|
98
|
+
summary: Have a toolbox of often used files. Use them and share them easily.
|
99
|
+
test_files:
|
100
|
+
- spec/lib/rench_spec.rb
|