drcapulet-russell 0.1.0
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.
- data/CHANGELOG.rdoc +3 -0
- data/README.rdoc +61 -0
- data/VERSION.yml +4 -0
- data/bin/russell +9 -0
- data/lib/russell/commands/install_all.rb +77 -0
- data/lib/russell/commands/install_config.rb +87 -0
- data/lib/russell/commands/install_one.rb +90 -0
- data/lib/russell/commands/list_fw.rb +34 -0
- data/lib/russell/commands/new_fw.rb +103 -0
- data/lib/russell/commands/print_version.rb +23 -0
- data/lib/russell/exec.rb +98 -0
- data/lib/russell/version.rb +68 -0
- data/lib/russell.rb +19 -0
- metadata +68 -0
data/CHANGELOG.rdoc
ADDED
data/README.rdoc
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
= Russell
|
2
|
+
|
3
|
+
Ruby gem for setting up new web development projects
|
4
|
+
|
5
|
+
It can read from user input or from a default config file
|
6
|
+
|
7
|
+
== Install
|
8
|
+
|
9
|
+
sudo gem install drcapulet-russell
|
10
|
+
|
11
|
+
== Usage
|
12
|
+
|
13
|
+
To create a new project in the current directory, and be asked about every
|
14
|
+
available framework
|
15
|
+
|
16
|
+
russell
|
17
|
+
|
18
|
+
To create a project using a single framework, use
|
19
|
+
|
20
|
+
russell -f FRAMEWORK
|
21
|
+
|
22
|
+
To use a config file, use
|
23
|
+
|
24
|
+
russell -c
|
25
|
+
|
26
|
+
This command will automatically ask you to create a config file if it doesn't find one. Otherwise
|
27
|
+
it will automatically proceed through the install (in the current directory) without any prompts
|
28
|
+
|
29
|
+
All of the options:
|
30
|
+
|
31
|
+
-c, --config Read the config file from the user's home directory
|
32
|
+
-f, --framework FRAMEWORK Set up a new project using the specified framework.
|
33
|
+
-l, --list List all available frameworks
|
34
|
+
-n, --new Adds a new framework to the central system
|
35
|
+
-?, -h, --help Show this message
|
36
|
+
-v, --version Print version
|
37
|
+
|
38
|
+
|
39
|
+
|
40
|
+
== License
|
41
|
+
|
42
|
+
Copyright (c) 2008 Alex Coomans
|
43
|
+
|
44
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
45
|
+
a copy of this software and associated documentation files (the
|
46
|
+
"Software"), to deal in the Software without restriction, including
|
47
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
48
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
49
|
+
permit persons to whom the Software is furnished to do so, subject to
|
50
|
+
the following conditions:
|
51
|
+
|
52
|
+
The above copyright notice and this permission notice shall be
|
53
|
+
included in all copies or substantial portions of the Software.
|
54
|
+
|
55
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
56
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
57
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
58
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
59
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
60
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
61
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/VERSION.yml
ADDED
data/bin/russell
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# russell command line utility
|
3
|
+
|
4
|
+
|
5
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'russell'))
|
6
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'russell', 'exec'))
|
7
|
+
|
8
|
+
command = Russell::Exec::Russell.new(ARGV)
|
9
|
+
command.run!
|
@@ -0,0 +1,77 @@
|
|
1
|
+
module Russell
|
2
|
+
module Commands
|
3
|
+
class InstallAll
|
4
|
+
attr_accessor :options
|
5
|
+
def initialize(working_path, options)
|
6
|
+
#self.options = options
|
7
|
+
end
|
8
|
+
|
9
|
+
def perform
|
10
|
+
@currentdir = Dir.pwd # Setting the Current Driectory
|
11
|
+
# CSS Installer Framework Variables
|
12
|
+
@css = {}
|
13
|
+
@css["prefix"] = "Would you like to install the"
|
14
|
+
@css["response"] = "installing the"
|
15
|
+
|
16
|
+
@cssframeworks = YAML::load(File.open("#{Russell.base_directory}/frameworks/manifest.yml"))
|
17
|
+
@cssframeworks.each do |framework|
|
18
|
+
|
19
|
+
@config = YAML::load(File.open("#{Russell.base_directory}/frameworks/#{framework.chomp}.yml"))
|
20
|
+
@css['type'] = check_fw_type(@config)
|
21
|
+
q = ask(@css["prefix"], framework.capitalize.chomp, @css["type"], @css["response"])
|
22
|
+
if (q == 1)
|
23
|
+
@config['manifest'].each do |file|
|
24
|
+
puts " [add] - #{file}"
|
25
|
+
end
|
26
|
+
show_src_code(@config)
|
27
|
+
if @config['inside']
|
28
|
+
cmd = `cp -R #{Russell.base_directory}/frameworks/#{framework.chomp} #{@currentdir}/#{framework}`
|
29
|
+
else
|
30
|
+
cmd = `cp -R #{Russell.base_directory}/frameworks/#{framework.chomp}/* #{@currentdir}`
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
protected
|
37
|
+
|
38
|
+
def ask(prefix, question, endr, response)
|
39
|
+
print "#{prefix} #{question} #{endr}? [y/n] "
|
40
|
+
input = gets.chomp
|
41
|
+
if (input == "y")
|
42
|
+
puts "#{response.capitalize.to_s} #{question.to_s} #{endr}"
|
43
|
+
return 1
|
44
|
+
elsif (input == "n")
|
45
|
+
puts "Not #{response} #{question} #{endr}"
|
46
|
+
return 0
|
47
|
+
else
|
48
|
+
puts "Error!"
|
49
|
+
exit
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def show_src_code(config)
|
54
|
+
puts ""
|
55
|
+
puts "----------------------------"
|
56
|
+
puts "To include in your project, add the following to the head section of your file:"
|
57
|
+
puts ""
|
58
|
+
config['src'].each do |line|
|
59
|
+
puts " #{line}"
|
60
|
+
end
|
61
|
+
puts ""
|
62
|
+
end
|
63
|
+
|
64
|
+
def check_fw_type(config)
|
65
|
+
if (config['type'] == "CSS")
|
66
|
+
return "CSS Framework"
|
67
|
+
elsif (config['type'] == "JS")
|
68
|
+
return "Javascript Framework"
|
69
|
+
else
|
70
|
+
return ""
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
# End Class Declaration
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
require "yaml"
|
2
|
+
|
3
|
+
module Russell
|
4
|
+
module Commands
|
5
|
+
class InstallConfig
|
6
|
+
attr_accessor :options
|
7
|
+
def initialize(working_path, options)
|
8
|
+
self.options = options
|
9
|
+
end
|
10
|
+
|
11
|
+
def perform
|
12
|
+
begin
|
13
|
+
@config = YAML::load(File.open("#{Russell.base_directory}/russell.config"))
|
14
|
+
read_and_install_with_config(@config)
|
15
|
+
rescue
|
16
|
+
q = ask("No config file exists. Create one?", "Not creating one. Exiting")
|
17
|
+
if (q == 1)
|
18
|
+
create_config
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
protected
|
25
|
+
|
26
|
+
def ask(question, exit)
|
27
|
+
print "#{question} [y/n] "
|
28
|
+
input = gets.chomp
|
29
|
+
if (input == "y")
|
30
|
+
return 1
|
31
|
+
else
|
32
|
+
puts exit
|
33
|
+
exit
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def create_config
|
38
|
+
config = {}
|
39
|
+
@frameworks = YAML::load(File.open("#{Russell.base_directory}/frameworks/manifest.yml"))
|
40
|
+
@frameworks.each do |fwname|
|
41
|
+
q = ask("Do you want to automatically install the #{fwname.chomp.capitalize} framework using you config file?", "")
|
42
|
+
if (q == 1)
|
43
|
+
config["#{fwname}"] = true
|
44
|
+
else
|
45
|
+
config["#{fwname}"] = false
|
46
|
+
end
|
47
|
+
end
|
48
|
+
write_config(config)
|
49
|
+
end
|
50
|
+
|
51
|
+
def write_config(config)
|
52
|
+
wconfig = ""
|
53
|
+
config.each do |key, value|
|
54
|
+
wconfig = wconfig + "#{key.chomp}: #{value}
|
55
|
+
|
56
|
+
"
|
57
|
+
end
|
58
|
+
File.open( "#{Russell.base_directory}/russell.config", "w" ) do |file|
|
59
|
+
file.puts "#{wconfig}"
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def read_and_install_with_config(config)
|
64
|
+
command = :install_one
|
65
|
+
config.each do |fw, value|
|
66
|
+
if value
|
67
|
+
self.options[:noask] = true
|
68
|
+
self.options[:framework] = fw
|
69
|
+
do_command(command, options)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def do_command(command, options)
|
75
|
+
command_class_name = command.to_s.split(/_/).map{|p| p.capitalize}.join('')
|
76
|
+
command_class = eval("::Russell::Commands::#{command_class_name}")
|
77
|
+
command_class.new(Dir.getwd, options).perform
|
78
|
+
end
|
79
|
+
|
80
|
+
# End Class Declaration
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
Dir.glob(File.join(Russell.lib_directory, 'russell', 'commands', "*.rb")).each do |file|
|
86
|
+
require file
|
87
|
+
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
require "yaml"
|
2
|
+
|
3
|
+
module Russell
|
4
|
+
module Commands
|
5
|
+
class InstallOne
|
6
|
+
attr_accessor :options
|
7
|
+
def initialize(working_path, options)
|
8
|
+
self.options = options
|
9
|
+
end
|
10
|
+
|
11
|
+
def perform
|
12
|
+
framework = self.options[:framework]
|
13
|
+
@currentdir = Dir.pwd # Setting the Current Driectory
|
14
|
+
# CSS Installer Framework Variables
|
15
|
+
@css = {}
|
16
|
+
@css["prefix"] = "You are going to install the"
|
17
|
+
@css["response"] = "installing the"
|
18
|
+
|
19
|
+
begin
|
20
|
+
@config = YAML::load(File.open("#{Russell.base_directory}/frameworks/#{framework.chomp}.yml"))
|
21
|
+
rescue
|
22
|
+
puts "The specifiec framework is not available! Exiting!"
|
23
|
+
exit
|
24
|
+
end
|
25
|
+
|
26
|
+
@css["type"] = check_fw_type(@config)
|
27
|
+
|
28
|
+
if (self.options[:noask] == false)
|
29
|
+
q = ask(@css["prefix"], framework.capitalize.chomp, @css["type"], @css["response"])
|
30
|
+
else
|
31
|
+
q = 1
|
32
|
+
end
|
33
|
+
|
34
|
+
if (q == 1)
|
35
|
+
@config['manifest'].each do |file|
|
36
|
+
puts " [add] - #{file}"
|
37
|
+
end
|
38
|
+
show_src_code(@config)
|
39
|
+
if @config['inside']
|
40
|
+
cmd = `cp -R #{Russell.base_directory}/frameworks/#{framework.chomp} #{@currentdir}/#{framework}`
|
41
|
+
else
|
42
|
+
cmd = `cp -R #{Russell.base_directory}/frameworks/#{framework.chomp}/* #{@currentdir}`
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
protected
|
48
|
+
|
49
|
+
def ask(prefix, question, endr, response)
|
50
|
+
print "#{prefix} #{question} #{endr}. Continue? [y/n] "
|
51
|
+
input = gets.chomp
|
52
|
+
if (input == "y")
|
53
|
+
puts "#{response.capitalize.to_s} #{question.to_s} #{endr}"
|
54
|
+
return 1
|
55
|
+
elsif (input == "n")
|
56
|
+
puts "Not #{response} #{question} #{endr}"
|
57
|
+
return 0
|
58
|
+
else
|
59
|
+
puts "Error!"
|
60
|
+
exit
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def show_src_code(config)
|
65
|
+
if config['src']
|
66
|
+
puts ""
|
67
|
+
puts "----------------------------"
|
68
|
+
puts "To include in your project, add the following to the head section of your file:"
|
69
|
+
puts ""
|
70
|
+
config['src'].each do |line|
|
71
|
+
puts " #{line}"
|
72
|
+
end
|
73
|
+
puts ""
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def check_fw_type(config)
|
78
|
+
if (config['type'] == "CSS")
|
79
|
+
return "CSS Framework"
|
80
|
+
elsif (config['type'] == "JS")
|
81
|
+
return "Javascript Framework"
|
82
|
+
else
|
83
|
+
return ""
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
# End Class Declaration
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require "yaml"
|
2
|
+
|
3
|
+
module Russell
|
4
|
+
module Commands
|
5
|
+
class ListFw
|
6
|
+
attr_accessor :options
|
7
|
+
def initialize(working_path, options)
|
8
|
+
#self.options = options
|
9
|
+
end
|
10
|
+
|
11
|
+
def perform
|
12
|
+
@frameworks = YAML::load(File.open("#{Russell.base_directory}/frameworks/manifest.yml"))
|
13
|
+
puts ""
|
14
|
+
@frameworks.each do |framework|
|
15
|
+
|
16
|
+
@config = YAML::load(File.open("#{Russell.base_directory}/frameworks/#{framework.chomp}.yml"))
|
17
|
+
putup = <<END
|
18
|
+
#{@config['name']}
|
19
|
+
===================
|
20
|
+
|
21
|
+
#{@config['description']}
|
22
|
+
|
23
|
+
---------------------------------------------------------------------
|
24
|
+
|
25
|
+
END
|
26
|
+
puts putup
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
# End Class Declaration
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,103 @@
|
|
1
|
+
require "yaml"
|
2
|
+
|
3
|
+
module Russell
|
4
|
+
module Commands
|
5
|
+
class NewFw
|
6
|
+
attr_accessor :options
|
7
|
+
def initialize(working_path, options)
|
8
|
+
self.options = options
|
9
|
+
end
|
10
|
+
|
11
|
+
def perform
|
12
|
+
@currentdir = Dir.pwd # Setting the Current Driectory
|
13
|
+
# CSS Installer Framework Variables
|
14
|
+
fw = {}
|
15
|
+
|
16
|
+
question = "You are going to install a new framework to russell"
|
17
|
+
#q = ask(question)
|
18
|
+
|
19
|
+
print "What would you like this framework to be named? "
|
20
|
+
fw['name'] = gets.chomp
|
21
|
+
|
22
|
+
print "Where is the base folder located? "
|
23
|
+
fw['dir'] = gets.chomp
|
24
|
+
|
25
|
+
print "What would you like the description for the project to be? "
|
26
|
+
fw['description'] = gets.chomp
|
27
|
+
|
28
|
+
print "Do you want the files to be placed in their own directory? [y/n] "
|
29
|
+
input = gets.chomp
|
30
|
+
if (input == "y")
|
31
|
+
fw['inside'] = true
|
32
|
+
else
|
33
|
+
fw['inside'] = false
|
34
|
+
end
|
35
|
+
|
36
|
+
puts "Generating Manifest"
|
37
|
+
fwdir = fw['dir']
|
38
|
+
files = []
|
39
|
+
|
40
|
+
|
41
|
+
|
42
|
+
Dir.chdir(fwdir)
|
43
|
+
Dir["**/**"].each do |file|
|
44
|
+
next if File.directory?(file)
|
45
|
+
#puts " #{file}"
|
46
|
+
files << file
|
47
|
+
end
|
48
|
+
|
49
|
+
manifest = ""
|
50
|
+
files.each do |file|
|
51
|
+
manifest = manifest + "
|
52
|
+
#{file}
|
53
|
+
"
|
54
|
+
end
|
55
|
+
|
56
|
+
mancontent = "
|
57
|
+
name:
|
58
|
+
#{fw['name']}
|
59
|
+
|
60
|
+
description:
|
61
|
+
#{fw['description']}
|
62
|
+
|
63
|
+
inside: #{fw['inside']}
|
64
|
+
|
65
|
+
manifest:
|
66
|
+
#{manifest}
|
67
|
+
|
68
|
+
"
|
69
|
+
|
70
|
+
File.open("#{Russell.base_directory}/frameworks/#{fw['name']}.yml", "w") { |f| f.write(mancontent) }
|
71
|
+
|
72
|
+
fwmanifest = YAML::load(File.open("#{Russell.base_directory}/frameworks/manifest.yml"))
|
73
|
+
fwmani = ""
|
74
|
+
fwmanifest.each do |fwn|
|
75
|
+
fwmani = fwmani + "
|
76
|
+
#{fwn}"
|
77
|
+
end
|
78
|
+
fwmani = fwmani + "
|
79
|
+
|
80
|
+
#{fw['name']}"
|
81
|
+
File.open("#{Russell.base_directory}/frameworks/manifest.yml", "w") { |f| f.write(fwmani) }
|
82
|
+
|
83
|
+
end
|
84
|
+
|
85
|
+
protected
|
86
|
+
|
87
|
+
def ask(question)
|
88
|
+
print "#{question}. Continue? [y/n] "
|
89
|
+
input = gets.chomp
|
90
|
+
if (input == "y")
|
91
|
+
return 1
|
92
|
+
elsif (input == "n")
|
93
|
+
puts "Qutting"
|
94
|
+
exit
|
95
|
+
else
|
96
|
+
puts "Error!"
|
97
|
+
exit
|
98
|
+
end
|
99
|
+
end
|
100
|
+
# End Class Declaration
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Russell
|
2
|
+
module Commands
|
3
|
+
class PrintVersion
|
4
|
+
attr_accessor :options
|
5
|
+
def initialize(working_path, options)
|
6
|
+
#self.options = options
|
7
|
+
end
|
8
|
+
|
9
|
+
def perform
|
10
|
+
# if options[:quiet]
|
11
|
+
# The quiet option may make scripting easier
|
12
|
+
# puts ::Russell.version[:string]
|
13
|
+
# else
|
14
|
+
lines = []
|
15
|
+
lines << "Russell #{::Russell.version[:string]}"
|
16
|
+
lines << "Copyright (c) 2009 Alex Coomans"
|
17
|
+
lines << "Released under the MIT License."
|
18
|
+
puts lines.join("\n")
|
19
|
+
# end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/russell/exec.rb
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
# Handles the brunt work, not not the commands.
|
2
|
+
# Sets up the option parsing and actions when
|
3
|
+
# a flag is triggered
|
4
|
+
|
5
|
+
require 'optparse'
|
6
|
+
require 'rdoc/usage'
|
7
|
+
require 'ostruct'
|
8
|
+
|
9
|
+
module Russell
|
10
|
+
module Exec
|
11
|
+
class Russell
|
12
|
+
|
13
|
+
attr_accessor :args, :options, :opts
|
14
|
+
|
15
|
+
# Takes the arugments from the command-line and sets up an empty hash. Then it continues on to parse!
|
16
|
+
def initialize(args)
|
17
|
+
self.args = args
|
18
|
+
self.options = {}
|
19
|
+
parse!
|
20
|
+
end
|
21
|
+
|
22
|
+
# Runs the entire program. Run after parse! has completed
|
23
|
+
def run!
|
24
|
+
perform!
|
25
|
+
end
|
26
|
+
|
27
|
+
protected
|
28
|
+
|
29
|
+
def perform!
|
30
|
+
if options[:command]
|
31
|
+
do_command(options[:command])
|
32
|
+
else
|
33
|
+
puts self.opts
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def parse!
|
38
|
+
self.opts = OptionParser.new(&method(:set_opts))
|
39
|
+
self.opts.parse!(self.args)
|
40
|
+
# if self.args.size > 0
|
41
|
+
# self.options[:project_name] = trim_trailing_separator(self.args.shift)
|
42
|
+
# end
|
43
|
+
if self.args.size == 0
|
44
|
+
end
|
45
|
+
self.options[:command] ||= :install_all
|
46
|
+
self.options[:environment] ||= :production
|
47
|
+
self.options[:framework] ||= :f960
|
48
|
+
self.options[:project_type] ||= :stand_alone
|
49
|
+
end
|
50
|
+
|
51
|
+
# Sets up all of the options
|
52
|
+
def set_opts(opts)
|
53
|
+
opts.banner = <<END
|
54
|
+
Usage: russell [options] [project]
|
55
|
+
|
56
|
+
Options:
|
57
|
+
END
|
58
|
+
opts.on('-c', '--config', 'Read the config file from the user\'s home directory') do
|
59
|
+
self.options[:config] = true
|
60
|
+
self.options[:command] = :install_config
|
61
|
+
end
|
62
|
+
|
63
|
+
opts.on('-f FRAMEWORK', '--framework FRAMEWORK', 'Set up a new project using the specified framework.') do |framework|
|
64
|
+
self.options[:command] = :install_one
|
65
|
+
self.options[:framework] = framework
|
66
|
+
end
|
67
|
+
|
68
|
+
opts.on('-l', '--list', 'List all available frameworks') do
|
69
|
+
self.options[:command] = :list_fw
|
70
|
+
end
|
71
|
+
|
72
|
+
opts.on('-n', '--new', 'Adds a new framework to the central system') do
|
73
|
+
self.options[:command] = :new_fw
|
74
|
+
end
|
75
|
+
|
76
|
+
opts.on_tail("-?", "-h", "--help", "Show this message") do
|
77
|
+
puts opts
|
78
|
+
exit
|
79
|
+
end
|
80
|
+
|
81
|
+
opts.on_tail("-v", "--version", "Print version") do
|
82
|
+
self.options[:command] = :print_version
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def do_command(command)
|
87
|
+
command_class_name = command.to_s.split(/_/).map{|p| p.capitalize}.join('')
|
88
|
+
command_class = eval("::Russell::Commands::#{command_class_name}")
|
89
|
+
command_class.new(Dir.getwd, options).perform
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
Dir.glob(File.join(File.dirname(__FILE__), 'commands', "*.rb")).each do |file|
|
97
|
+
require file
|
98
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
|
2
|
+
module Russell
|
3
|
+
module Version
|
4
|
+
# Returns a hash representing the version.
|
5
|
+
# The :major, :minor, and :teeny keys have their respective numbers.
|
6
|
+
# The :string key contains a human-readable string representation of the version.
|
7
|
+
# If checked out from Git,
|
8
|
+
# the :rev key will have the revision hash.
|
9
|
+
#
|
10
|
+
# This method swiped from Haml and then modified, some credit goes to Nathan Weizenbaum
|
11
|
+
# I (alex) then swiped it from Compass - so thanks there!
|
12
|
+
attr_writer :version
|
13
|
+
def version
|
14
|
+
return @version if defined?(@version)
|
15
|
+
|
16
|
+
read_version_file
|
17
|
+
parse_version
|
18
|
+
|
19
|
+
if r = revision
|
20
|
+
@version[:rev] = r
|
21
|
+
@version[:string] << " [#{r[0...7]}]"
|
22
|
+
end
|
23
|
+
|
24
|
+
@version
|
25
|
+
end
|
26
|
+
|
27
|
+
protected
|
28
|
+
|
29
|
+
def scope(file) # :nodoc:
|
30
|
+
File.join(File.dirname(__FILE__), '..', '..', file)
|
31
|
+
end
|
32
|
+
|
33
|
+
def read_version_file
|
34
|
+
@version = {
|
35
|
+
:string => File.read(scope('VERSION')).strip
|
36
|
+
}
|
37
|
+
end
|
38
|
+
|
39
|
+
def parse_version
|
40
|
+
dotted_string, @version[:label] = @version[:string].split(/-/, 2)
|
41
|
+
numbers = dotted_string.split('.').map { |n| n.to_i }
|
42
|
+
[:major, :minor, :teeny].zip(numbers).each do |attr, value|
|
43
|
+
@version[attr] = value
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def revision
|
48
|
+
revision_from_git || revision_from_file
|
49
|
+
end
|
50
|
+
|
51
|
+
def revision_from_file
|
52
|
+
if File.exists?(scope('REVISION'))
|
53
|
+
rev = File.read(scope('REVISION')).strip
|
54
|
+
rev = nil if rev !~ /[a-f0-9]+/
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def revision_from_git
|
59
|
+
if File.exists?(scope('.git/HEAD'))
|
60
|
+
rev = File.read(scope('.git/HEAD')).strip
|
61
|
+
if rev =~ /^ref: (.*)$/
|
62
|
+
rev = File.read(scope(".git/#{$1}")).strip
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
end
|
data/lib/russell.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# Sets up the basic global stuff and loads in the version.rb file
|
2
|
+
|
3
|
+
# Load the Version Module Lib file so that the arugment -v works easier
|
4
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'russell', 'version'))
|
5
|
+
|
6
|
+
module Russell
|
7
|
+
extend Russell::Version
|
8
|
+
# Defines the base russel directory. Refers to the russell
|
9
|
+
# directory above the bin and lib directories
|
10
|
+
#
|
11
|
+
def base_directory
|
12
|
+
File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
13
|
+
end
|
14
|
+
def lib_directory
|
15
|
+
File.expand_path(File.join(File.dirname(__FILE__)))
|
16
|
+
end
|
17
|
+
module_function :base_directory, :lib_directory
|
18
|
+
end
|
19
|
+
|
metadata
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: drcapulet-russell
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Alex Coomans
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-03-08 00:00:00 -08:00
|
13
|
+
default_executable: russell
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: russell is a command line utility for setting up new web projects with ease
|
17
|
+
email: alex@alexcoomans.com
|
18
|
+
executables:
|
19
|
+
- russell
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- README.rdoc
|
24
|
+
files:
|
25
|
+
- CHANGELOG.rdoc
|
26
|
+
- README.rdoc
|
27
|
+
- VERSION.yml
|
28
|
+
- bin/russell
|
29
|
+
- lib/russell
|
30
|
+
- lib/russell/commands
|
31
|
+
- lib/russell/commands/install_all.rb
|
32
|
+
- lib/russell/commands/install_config.rb
|
33
|
+
- lib/russell/commands/install_one.rb
|
34
|
+
- lib/russell/commands/list_fw.rb
|
35
|
+
- lib/russell/commands/new_fw.rb
|
36
|
+
- lib/russell/commands/print_version.rb
|
37
|
+
- lib/russell/exec.rb
|
38
|
+
- lib/russell/version.rb
|
39
|
+
- lib/russell.rb
|
40
|
+
has_rdoc: true
|
41
|
+
homepage: http://github.com/drcapulet/russell
|
42
|
+
post_install_message:
|
43
|
+
rdoc_options:
|
44
|
+
- --inline-source
|
45
|
+
- --charset=UTF-8
|
46
|
+
require_paths:
|
47
|
+
- lib
|
48
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: "0"
|
53
|
+
version:
|
54
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: "0"
|
59
|
+
version:
|
60
|
+
requirements: []
|
61
|
+
|
62
|
+
rubyforge_project:
|
63
|
+
rubygems_version: 1.2.0
|
64
|
+
signing_key:
|
65
|
+
specification_version: 2
|
66
|
+
summary: russell is a command line utility for setting up new web projects with ease
|
67
|
+
test_files: []
|
68
|
+
|