stubs 1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/stubs +68 -0
- metadata +65 -0
data/stubs
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
def puts_c(text, color_code)
|
4
|
+
puts "\e[#{color_code}m#{text}\e[0m"
|
5
|
+
end
|
6
|
+
|
7
|
+
class Stubs
|
8
|
+
def initialize
|
9
|
+
@stubs_dir = File.expand_path("~/.stubs")
|
10
|
+
Dir.mkdir(@stubs_dir) unless File.directory?(@stubs_dir)
|
11
|
+
|
12
|
+
if ARGV.length == 0
|
13
|
+
help
|
14
|
+
else
|
15
|
+
if ARGV[0] == "--list"
|
16
|
+
list
|
17
|
+
else
|
18
|
+
generate(ARGV[0]) if ARGV.length
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def help
|
24
|
+
puts_c " List available stubs: stubs --list\n Generate stub: stubs [stub-name]", 33
|
25
|
+
end
|
26
|
+
|
27
|
+
def list
|
28
|
+
entries = Dir.entries(@stubs_dir)
|
29
|
+
puts_c "There are no stubs defined in ~/.stubs", 33 if entries.count == 2
|
30
|
+
|
31
|
+
entries.each do |path|
|
32
|
+
puts_c " #{path}", 36 unless [".", ".."].include? path
|
33
|
+
end
|
34
|
+
rescue
|
35
|
+
puts_c "Stubs directory does not exist and could not be created", 31
|
36
|
+
end
|
37
|
+
|
38
|
+
def generate(stub)
|
39
|
+
stub_dir = File.join(@stubs_dir, stub)
|
40
|
+
|
41
|
+
if File.directory?(stub_dir)
|
42
|
+
copy_contents_of_dir(stub_dir, Dir.pwd)
|
43
|
+
puts_c "Generated stub \"#{stub}\"", 32
|
44
|
+
else
|
45
|
+
puts_c "You have no stub called \"#{stub}\"", 31
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
def copy_contents_of_dir(dir, to)
|
52
|
+
Dir.entries(dir).each do |path|
|
53
|
+
unless [".", ".."].include? path
|
54
|
+
full_path = File.join(dir, path)
|
55
|
+
full_path_to = File.join(to, path)
|
56
|
+
|
57
|
+
if File.directory?(full_path)
|
58
|
+
Dir.mkdir(full_path_to) unless File.exists? full_path_to
|
59
|
+
copy_contents_of_dir(full_path, full_path_to)
|
60
|
+
else
|
61
|
+
File.open(full_path_to, 'w') { |f| f.write File.open(full_path).read } unless File.exists? full_path_to
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
Stubs.new
|
metadata
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: stubs
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 1
|
7
|
+
- 0
|
8
|
+
version: "1.0"
|
9
|
+
platform: ruby
|
10
|
+
authors:
|
11
|
+
- Christoffer Lejdborg
|
12
|
+
autorequire:
|
13
|
+
bindir: .
|
14
|
+
cert_chain: []
|
15
|
+
|
16
|
+
date: 2011-10-18 00:00:00 +02:00
|
17
|
+
default_executable: stubs
|
18
|
+
dependencies: []
|
19
|
+
|
20
|
+
description: "Finding yourself creating the same project structures over and over? Do you loathe setting up new projects because it\xE2\x80\x99s time consuming and you just want to work? Then stubs is for you!"
|
21
|
+
email: hello@9muses.se
|
22
|
+
executables:
|
23
|
+
- stubs
|
24
|
+
extensions: []
|
25
|
+
|
26
|
+
extra_rdoc_files: []
|
27
|
+
|
28
|
+
files: []
|
29
|
+
|
30
|
+
has_rdoc: true
|
31
|
+
homepage: http://github.com/Lejdborg/Stubs
|
32
|
+
licenses: []
|
33
|
+
|
34
|
+
post_install_message:
|
35
|
+
rdoc_options: []
|
36
|
+
|
37
|
+
require_paths:
|
38
|
+
- .
|
39
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
segments:
|
44
|
+
- 1
|
45
|
+
- 8
|
46
|
+
- 7
|
47
|
+
version: 1.8.7
|
48
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
segments:
|
53
|
+
- 1
|
54
|
+
- 3
|
55
|
+
- 6
|
56
|
+
version: 1.3.6
|
57
|
+
requirements: []
|
58
|
+
|
59
|
+
rubyforge_project:
|
60
|
+
rubygems_version: 1.3.6
|
61
|
+
signing_key:
|
62
|
+
specification_version: 3
|
63
|
+
summary: Automate project startup using stubs.
|
64
|
+
test_files: []
|
65
|
+
|