pixii 0.1.4 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +4 -2
- data/lib/pixii.rb +23 -21
- metadata +2 -2
data/README.md
CHANGED
@@ -64,14 +64,16 @@ I understand that three spells may not be enough for the more advanced wizards o
|
|
64
64
|
class Pixii
|
65
65
|
def git_clone(repo, dest)
|
66
66
|
step "Cloning #{repo}..." do
|
67
|
-
`git clone #{repo} #{dest}`
|
67
|
+
`git clone #{repo} #{inside(:dest,dest)}`
|
68
68
|
end
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
72
72
|
Just place that at the top of your script. Pretty simple! The only new thing that you have to get is the `step` method. That basically just defines a step to run. The `"Cloning ..."` passed in at the start is just a string describing what you are doing. You don't have to pass anything there and `step do` is perfectly acceptable.
|
73
73
|
|
74
|
-
|
74
|
+
The `inside(:dest, ...)` method basically scopes a path to the destination directory. `inside` can take `:dest`, `:templates` or `:src`.
|
75
|
+
|
76
|
+
You can now use `git_clone` in your potion:
|
75
77
|
|
76
78
|
make.git_clone 'git://github.com/chrislloyd/gravtastic.git', 'vendor/gems/gravtastic'
|
77
79
|
|
data/lib/pixii.rb
CHANGED
@@ -24,7 +24,7 @@ class Pixii
|
|
24
24
|
attr_accessor :name, :steps
|
25
25
|
|
26
26
|
def self.defaults
|
27
|
-
@@defaults ||= {:project => ARGV.first
|
27
|
+
@@defaults ||= {:project => ARGV.first}
|
28
28
|
end
|
29
29
|
|
30
30
|
def self.defaults=(hsh); @@defaults = hsh; end
|
@@ -44,10 +44,10 @@ class Pixii
|
|
44
44
|
end
|
45
45
|
|
46
46
|
def normalize_opts!
|
47
|
-
# TODO
|
48
|
-
opts.src_dir
|
49
|
-
opts.
|
50
|
-
opts.dest_dir
|
47
|
+
# TODO fix caller[1] hack
|
48
|
+
opts.src_dir ||= File.expand_path(File.dirname(caller[1].split(':').first))
|
49
|
+
opts.templates_dir = opts.templates || inside(:src, '..', 'templates')
|
50
|
+
opts.dest_dir ||= File.expand_path(File.join(Dir.pwd, opts.project))
|
51
51
|
end
|
52
52
|
|
53
53
|
def step(msg=nil, &blk)
|
@@ -57,48 +57,50 @@ class Pixii
|
|
57
57
|
def dir(*dirs)
|
58
58
|
dirs.each do |d|
|
59
59
|
step do
|
60
|
-
FileUtils.mkdir_p(d)
|
60
|
+
FileUtils.mkdir_p inside(:dest, d)
|
61
61
|
end
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
65
65
|
def clone(src, dest)
|
66
66
|
step do
|
67
|
-
src =
|
67
|
+
src = inside(:templates, src) if URI::parse(src).scheme.nil?
|
68
68
|
open(src) do |sf|
|
69
|
-
File.open(dest,'wb') do |f|
|
69
|
+
File.open(inside(:dest, dest), 'wb') do |f|
|
70
70
|
f.write(sf.read)
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
71
|
+
end # down
|
72
|
+
end # down
|
73
|
+
end # to
|
74
|
+
end # funkytown
|
75
75
|
|
76
76
|
def template(src_tmpl, dest, env={})
|
77
77
|
step do
|
78
|
-
src_tmpl =
|
78
|
+
src_tmpl = inside(:templates, src_tmpl)
|
79
79
|
tmpl = File.open(src_tmpl){|f| f.read }
|
80
80
|
|
81
81
|
env = env.merge!(opts).to_mash
|
82
|
-
File.open(dest,'w') do |f|
|
82
|
+
File.open(inside(:dest, dest), 'w') do |f|
|
83
83
|
f.write(ERB.new(tmpl).result(env.binding))
|
84
84
|
end
|
85
85
|
end
|
86
86
|
end
|
87
87
|
|
88
88
|
def magic!
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
end
|
89
|
+
make_dest
|
90
|
+
steps.each do |step|
|
91
|
+
puts step.first unless step.first.nil?
|
92
|
+
step.last.call
|
94
93
|
end
|
95
94
|
end
|
96
95
|
|
97
96
|
# private
|
98
97
|
|
99
|
-
def
|
98
|
+
def inside(dir, *file)
|
99
|
+
File.join(opts.send("#{dir}_dir"), *file)
|
100
|
+
end
|
101
|
+
|
102
|
+
def make_dest
|
100
103
|
FileUtils.mkdir_p opts.dest_dir
|
101
|
-
Dir.chdir(opts.dest_dir, &blk)
|
102
104
|
end
|
103
105
|
|
104
106
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pixii
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Lloyd
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-08-
|
12
|
+
date: 2009-08-10 00:00:00 +10:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|