andy 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/andy +5 -0
- data/conf/andy.yaml +7 -0
- data/lib/andy.rb +70 -0
- metadata +64 -0
data/bin/andy
ADDED
data/conf/andy.yaml
ADDED
data/lib/andy.rb
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'git'
|
3
|
+
|
4
|
+
class Andy
|
5
|
+
|
6
|
+
ANDY_HOME=ENV['HOME'] + "/.andy"
|
7
|
+
|
8
|
+
def run
|
9
|
+
ensure_local_repo_built
|
10
|
+
siteName = ARGV[0]
|
11
|
+
if (!siteName)
|
12
|
+
puts "Usage: andy <siteName>"
|
13
|
+
return
|
14
|
+
end
|
15
|
+
|
16
|
+
directory_name = Dir::pwd + "/" + siteName
|
17
|
+
if FileTest::directory?(directory_name)
|
18
|
+
puts "That already exists, sorry"
|
19
|
+
return
|
20
|
+
end
|
21
|
+
|
22
|
+
load_config
|
23
|
+
pint = ARGV[1] || @conf['conf']['favourite']
|
24
|
+
puts "Creating a project from pint '#{pint}'"
|
25
|
+
ensure_pint_source_exists pint
|
26
|
+
pour_pint pint, directory_name
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
def pour_pint(pint, target)
|
31
|
+
|
32
|
+
pint_src = "#{ANDY_HOME}/pints/#{pint}"
|
33
|
+
FileUtils.cp_r pint_src, target
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
def ensure_pint_source_exists(pint)
|
38
|
+
root_of_pint = ANDY_HOME + "/pints/#{pint}"
|
39
|
+
if ( FileTest::directory?(root_of_pint) )
|
40
|
+
return
|
41
|
+
end
|
42
|
+
|
43
|
+
pump = @conf['pints'][pint]
|
44
|
+
begin
|
45
|
+
Git.export(pump, root_of_pint)
|
46
|
+
rescue => e
|
47
|
+
puts "Something went wrong trying to fetch pint '#{pint}' from '#{pump}' #{e}"
|
48
|
+
exit 1
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def load_config
|
53
|
+
|
54
|
+
@conf = @conf || YAML.load(File.open(ANDY_HOME + '/andy.yaml'))
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
def ensure_local_repo_built
|
59
|
+
if FileTest::directory?ANDY_HOME
|
60
|
+
return
|
61
|
+
end
|
62
|
+
Dir::mkdir(ANDY_HOME)
|
63
|
+
$LOAD_PATH.each do | dir |
|
64
|
+
if dir =~ /andy.*\/conf$/
|
65
|
+
FileUtils.cp(dir + "/andy.yaml", ANDY_HOME )
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
metadata
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: andy
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
version: 0.0.1
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- George McIntosh
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2012-11-21 00:00:00 +00:00
|
18
|
+
default_executable:
|
19
|
+
dependencies: []
|
20
|
+
|
21
|
+
description: A simple site generator gem
|
22
|
+
email: george@georgecodes.com
|
23
|
+
executables:
|
24
|
+
- andy
|
25
|
+
extensions: []
|
26
|
+
|
27
|
+
extra_rdoc_files: []
|
28
|
+
|
29
|
+
files:
|
30
|
+
- lib/andy.rb
|
31
|
+
- conf/andy.yaml
|
32
|
+
has_rdoc: true
|
33
|
+
homepage: http://rubygems.org/gems/gen
|
34
|
+
licenses: []
|
35
|
+
|
36
|
+
post_install_message:
|
37
|
+
rdoc_options: []
|
38
|
+
|
39
|
+
require_paths:
|
40
|
+
- lib
|
41
|
+
- conf
|
42
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
segments:
|
47
|
+
- 0
|
48
|
+
version: "0"
|
49
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
segments:
|
54
|
+
- 0
|
55
|
+
version: "0"
|
56
|
+
requirements: []
|
57
|
+
|
58
|
+
rubyforge_project:
|
59
|
+
rubygems_version: 1.3.6
|
60
|
+
signing_key:
|
61
|
+
specification_version: 3
|
62
|
+
summary: Site generator
|
63
|
+
test_files: []
|
64
|
+
|