rag 1.2.1 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/.travis.yml +4 -0
- data/Gemfile +6 -3
- data/Gemfile.lock +26 -16
- data/README.md +5 -2
- data/Rakefile +14 -11
- data/bin/1rag +6 -0
- data/hello/hello +1 -0
- data/lib/rag.rb +58 -24
- data/lib/rag/aur.rb +5 -0
- data/lib/rag/ext.rb +50 -0
- data/lib/rag/new.rb +81 -36
- data/lib/rag/ruby.rb +21 -0
- data/lib/rag/{doc.rb → ruby/doc.rb} +1 -1
- data/lib/rag/{gem.rb → ruby/gem.rb} +3 -1
- data/lib/rag/ruby/test.rb +21 -0
- data/lib/rag/version.rb +1 -1
- data/rag.gemspec +5 -4
- data/rag.watchr +1 -2
- data/spec/data/home/ruby.app/Buildfile +3 -0
- data/spec/data/home/ruby.app/template/hello.tt +1 -0
- data/spec/rag/new_spec.rb +5 -10
- data/spec/rag_spec.rb +17 -0
- data/spec/spec_helper.rb +75 -3
- data/spec/tmp/.gitkeep +0 -0
- metadata +78 -22
- data/data/home_config/_ragrc +0 -8
- data/data/template/test/file_name.erb +0 -1
- data/lib/rag/test.rb +0 -21
- data/spec/data/_rag/default/hello.erb +0 -1
- data/spec/data/homerc +0 -8
- data/spec/data/systemrc +0 -9
- data/spec/rag/rag_spec.rb +0 -6
data/.gitignore
CHANGED
data/.travis.yml
ADDED
data/Gemfile
CHANGED
@@ -1,9 +1,12 @@
|
|
1
1
|
source :rubygems
|
2
|
+
#source "http://ruby.taobao.org"
|
2
3
|
|
3
|
-
gem "tagen", "~>1.1.0"
|
4
|
-
gem "
|
5
|
-
gem "
|
4
|
+
gem "tagen", "~>1.1.0"
|
5
|
+
gem "pd"
|
6
|
+
gem "pa", "~>1.3.0"
|
7
|
+
gem "optimism", "~>3.2.0"
|
6
8
|
gem "thor"
|
9
|
+
gem "tilt"
|
7
10
|
|
8
11
|
group :development do
|
9
12
|
gem "rspec"
|
data/Gemfile.lock
CHANGED
@@ -1,25 +1,33 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
-
activesupport (3.1.
|
4
|
+
activesupport (3.1.4)
|
5
5
|
multi_json (~> 1.0)
|
6
|
+
awesome_print (1.0.2)
|
6
7
|
diff-lcs (1.1.3)
|
7
8
|
hike (1.2.1)
|
8
|
-
|
9
|
-
|
9
|
+
i18n (0.6.0)
|
10
|
+
multi_json (1.3.5)
|
11
|
+
optimism (3.2.0)
|
10
12
|
hike (~> 1.2.0)
|
11
|
-
pa (1.
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
rspec-
|
20
|
-
|
13
|
+
pa (1.3.0)
|
14
|
+
pd
|
15
|
+
pd (1.0.5)
|
16
|
+
awesome_print
|
17
|
+
rspec (2.10.0)
|
18
|
+
rspec-core (~> 2.10.0)
|
19
|
+
rspec-expectations (~> 2.10.0)
|
20
|
+
rspec-mocks (~> 2.10.0)
|
21
|
+
rspec-core (2.10.0)
|
22
|
+
rspec-expectations (2.10.0)
|
23
|
+
diff-lcs (~> 1.1.3)
|
24
|
+
rspec-mocks (2.10.1)
|
25
|
+
tagen (1.1.7)
|
21
26
|
activesupport (~> 3.1.0)
|
22
|
-
|
27
|
+
i18n
|
28
|
+
pd
|
29
|
+
thor (0.15.4)
|
30
|
+
tilt (1.3.3)
|
23
31
|
watchr (0.7)
|
24
32
|
yard (0.7.5)
|
25
33
|
|
@@ -27,10 +35,12 @@ PLATFORMS
|
|
27
35
|
ruby
|
28
36
|
|
29
37
|
DEPENDENCIES
|
30
|
-
optimism (~> 3.
|
31
|
-
pa (~> 1.
|
38
|
+
optimism (~> 3.2.0)
|
39
|
+
pa (~> 1.3.0)
|
40
|
+
pd
|
32
41
|
rspec
|
33
42
|
tagen (~> 1.1.0)
|
34
43
|
thor
|
44
|
+
tilt
|
35
45
|
watchr
|
36
46
|
yard
|
data/README.md
CHANGED
@@ -1,5 +1,4 @@
|
|
1
|
-
Rag, a project helper
|
2
|
-
=====================
|
1
|
+
# Rag, a project helper [![Build Status](https://secure.travis-ci.org/GutenYe/rag.png)](http://travis-ci.org/GutenYe/rag)
|
3
2
|
|
4
3
|
| Homepage: | https://github.com/GutenYe/rag |
|
5
4
|
|----------------|---------------------------------------|
|
@@ -106,6 +105,10 @@ Resources
|
|
106
105
|
* [gem.vim](https://github.com/GutenYe/gem.vim): a project helper for ruby gem/library development
|
107
106
|
* [Hoe](https://github.com/seattlerb/hoe): a rake/rubygems helper for project
|
108
107
|
|
108
|
+
Requirements
|
109
|
+
------------
|
110
|
+
|
111
|
+
* ruby 1.9.3
|
109
112
|
|
110
113
|
Copyright
|
111
114
|
---------
|
data/Rakefile
CHANGED
@@ -1,40 +1,43 @@
|
|
1
|
+
sudo = Process.pid==0 ? "" : "sudo"
|
2
|
+
|
1
3
|
desc "build a gem file"
|
2
4
|
task :release do
|
3
|
-
|
4
|
-
|
5
|
-
|
5
|
+
run "gem build rag.gemspec"
|
6
|
+
run "gem push *.gem"
|
7
|
+
run "#{sudo} gem install *.gem"
|
8
|
+
run "rm *.gem"
|
6
9
|
end
|
7
10
|
|
8
11
|
desc "install a gem file"
|
9
12
|
task :install do
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
+
run "gem build rag.gemspec"
|
14
|
+
run "#{sudo} gem install *.gem"
|
15
|
+
run "rm *.gem"
|
13
16
|
end
|
14
17
|
|
15
18
|
desc "autotest with watchr"
|
16
19
|
task :test do
|
17
|
-
|
20
|
+
run "watchr rag.watchr"
|
18
21
|
end
|
19
22
|
|
20
23
|
desc "testing the libraray"
|
21
24
|
namespace :test do
|
22
25
|
task :all do
|
23
|
-
|
26
|
+
run "rspec spec"
|
24
27
|
end
|
25
28
|
end
|
26
29
|
|
27
30
|
desc "run yard server --reload"
|
28
31
|
task :doc do
|
29
|
-
|
32
|
+
run "yard server --reload"
|
30
33
|
end
|
31
34
|
|
32
35
|
desc "clean up"
|
33
36
|
task :clean do
|
34
|
-
|
37
|
+
run "rm *.gem"
|
35
38
|
end
|
36
39
|
|
37
|
-
def
|
40
|
+
def run cmd
|
38
41
|
puts cmd
|
39
42
|
system cmd
|
40
43
|
end
|
data/bin/1rag
ADDED
data/hello/hello
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
hello
|
data/lib/rag.rb
CHANGED
@@ -1,18 +1,21 @@
|
|
1
|
-
|
2
|
-
require "bundler/setup"
|
3
|
-
Bundler.require
|
1
|
+
libdir = File.dirname(__FILE__); $LOAD_PATH.unshift(libdir) unless $LOAD_PATH.include?(libdir)
|
4
2
|
|
5
|
-
|
6
|
-
|
3
|
+
#require "tagen/core"
|
4
|
+
require "tagen/core/array/extract_options"
|
5
|
+
require "active_support/core_ext/string/inflections"
|
6
|
+
require "pd"
|
7
|
+
require "pa"
|
8
|
+
require "optimism"
|
9
|
+
require "thor"
|
7
10
|
|
8
11
|
class Rag < Thor
|
9
|
-
Error = Class.new Exception
|
10
|
-
RagError = Class.new Exception
|
11
|
-
|
12
12
|
autoload :VERSION, "rag/version"
|
13
13
|
autoload :UI, "rag/ui"
|
14
14
|
autoload :Util, "rag/util"
|
15
15
|
|
16
|
+
Error = Class.new Exception
|
17
|
+
ENoTemplate = Class.new Error
|
18
|
+
RagError = Class.new Exception
|
16
19
|
Rc = Optimism.require "rag/rc", "~/.ragrc"
|
17
20
|
|
18
21
|
include Thor::Actions
|
@@ -28,23 +31,54 @@ class Rag < Thor
|
|
28
31
|
end
|
29
32
|
end
|
30
33
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
# generate Rc.o
|
38
|
-
o = Rc.o = OpenOption.new
|
39
|
-
if gemspec_file=Dir["*.gemspec"][0]
|
40
|
-
gemspec = Gem::Specification.load(gemspec_file)
|
41
|
-
o.project = gemspec.name
|
42
|
-
o.version = gemspec.version
|
34
|
+
chainable = Module.new do
|
35
|
+
def initialize(*)
|
36
|
+
super
|
37
|
+
the_shell = (options["no-color"] ? Thor::Shell::Basic.new : shell)
|
38
|
+
Rag.ui = UI::Shell.new(the_shell)
|
39
|
+
Rag.ui.debug! if options["verbose"]
|
43
40
|
end
|
44
41
|
end
|
42
|
+
include chainable
|
45
43
|
end
|
46
44
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
45
|
+
# new
|
46
|
+
class Rag
|
47
|
+
desc "new <template_name> <app_path>", "create a new project"
|
48
|
+
method_option "name", :aliases => "-n", :type => :string, :banner => "NAME", :desc => "new project name"
|
49
|
+
method_option "klass", :aliases => "-k", :type => :string, :banner => "CLASS_NAME", :desc => "new class name"
|
50
|
+
method_option "dir", :aliases => "-d", :type => :string, :banner => "DIR", :desc => "template directory"
|
51
|
+
def new(template_name, app_path)
|
52
|
+
o = options.dup
|
53
|
+
template_name = template_name.dup
|
54
|
+
app_path = Pa(app_path.dup)
|
55
|
+
require "rag/new"
|
56
|
+
|
57
|
+
template_name, *exts = template_name.split(".")
|
58
|
+
template_dir = o[:dir] || Rc.p.home
|
59
|
+
exts = exts.empty? ? ["default"] : exts
|
60
|
+
root = Pa("#{template_dir}/#{template_name}").a
|
61
|
+
raise ENoTemplate, "can't find '#{template_name}' at #{template_dir}" unless root.exists?
|
62
|
+
|
63
|
+
app_path = Pa.absolute(app_path)
|
64
|
+
o["name"] ||= app_path.fname
|
65
|
+
o["klass"] ||= o["name"].classify
|
66
|
+
Rc << {
|
67
|
+
template_name: template_name,
|
68
|
+
app_path: app_path,
|
69
|
+
project: o["name"],
|
70
|
+
klass: o["klass"],
|
71
|
+
exts: exts,
|
72
|
+
ext: exts[0]
|
73
|
+
}
|
74
|
+
|
75
|
+
Pa.mkdir(app_path)
|
76
|
+
Pa.cd(app_path)
|
77
|
+
|
78
|
+
source = File.read("#{root}/Buildfile")
|
79
|
+
DSL.source_root root.p
|
80
|
+
dsl = DSL.new(template_name, app_path, o)
|
81
|
+
dsl.destination_root = ""
|
82
|
+
dsl.instance_eval source
|
83
|
+
end
|
84
|
+
end
|
data/lib/rag/aur.rb
ADDED
data/lib/rag/ext.rb
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
class Thor
|
2
|
+
module Actions
|
3
|
+
def directory2(source, *args, &block)
|
4
|
+
config = args.last.is_a?(Hash) ? args.pop : {}
|
5
|
+
destination = args.first || source
|
6
|
+
action Directory2.new(self, source, destination || source, config, &block)
|
7
|
+
end
|
8
|
+
|
9
|
+
# use tilt
|
10
|
+
# :scope => nil
|
11
|
+
# :locals => {}
|
12
|
+
# &block is for yield.
|
13
|
+
def template2(source, *args, &block)
|
14
|
+
config = args.last.is_a?(Hash) ? args.pop : {}
|
15
|
+
destination = args.first || source.sub(/\.tt$/, '')
|
16
|
+
template_options = {source_root: self.class.source_root}
|
17
|
+
|
18
|
+
source = File.expand_path(find_in_source_paths(source.to_s))
|
19
|
+
|
20
|
+
create_file destination, nil, config do
|
21
|
+
Rag::Template.render(source, template_options, &block)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
class Directory2 < Directory #:nodoc:
|
26
|
+
protected
|
27
|
+
def execute!
|
28
|
+
lookup = config[:recursive] ? File.join(source, '**') : source
|
29
|
+
lookup = File.join(lookup, '{*,.[a-z]*}')
|
30
|
+
|
31
|
+
Dir[lookup].sort.each do |file_source|
|
32
|
+
next if File.directory?(file_source)
|
33
|
+
file_destination = File.join(given_destination, file_source.gsub(source, '.'))
|
34
|
+
file_destination.gsub!('/./', '/')
|
35
|
+
|
36
|
+
case file_source
|
37
|
+
when /\.empty_directory$/
|
38
|
+
dirname = File.dirname(file_destination).gsub(/\/\.$/, '')
|
39
|
+
next if dirname == given_destination
|
40
|
+
base.empty_directory(dirname, config)
|
41
|
+
when /\.tt$/
|
42
|
+
destination = base.template2(file_source, file_destination[0..-4], config, &@block)
|
43
|
+
else
|
44
|
+
destination = base.copy_file(file_source, file_destination, config, &@block)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
data/lib/rag/new.rb
CHANGED
@@ -1,4 +1,7 @@
|
|
1
|
-
|
1
|
+
require "tilt"
|
2
|
+
require "rag/ext"
|
3
|
+
|
4
|
+
class Rag # Project Template DSL
|
2
5
|
=begin
|
3
6
|
|
4
7
|
== ERB support variables
|
@@ -52,20 +55,20 @@ you can use arbitrary name in .ragrc, then you can use then in template file.
|
|
52
55
|
end
|
53
56
|
|
54
57
|
def template_path
|
55
|
-
|
56
|
-
return
|
58
|
+
p = Pa("#{Rc.p.home}/#{template}")
|
59
|
+
return p.p if p.exists?
|
57
60
|
|
58
61
|
raise Error, "can't find template -- #{template}"
|
59
62
|
end
|
60
63
|
|
61
64
|
def copy_files(o={})
|
62
|
-
Pa.each_r template_path do |pa,
|
65
|
+
Pa.each_r template_path do |pa, abs, rel|
|
63
66
|
# skip *~
|
64
67
|
next if pa.fn2 =~ /~$/
|
65
68
|
|
66
69
|
# convert __project__ to options["name"]
|
67
|
-
dest = app_path.join(
|
68
|
-
path_msg =
|
70
|
+
dest = app_path.join(rel.gsub(/__project__/, options["name"]))
|
71
|
+
path_msg = rel.gsub(/__project__/, options["name"]).gsub(/\.erb$/,"")
|
69
72
|
|
70
73
|
# skip directory not file
|
71
74
|
next if dest.exists? and dest.directory?
|
@@ -122,35 +125,77 @@ you can use arbitrary name in .ragrc, then you can use then in template file.
|
|
122
125
|
config._data
|
123
126
|
end
|
124
127
|
end
|
125
|
-
end
|
126
128
|
|
127
|
-
class
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
129
|
+
class Template
|
130
|
+
Rc = Rag::Rc # used in hello.tt
|
131
|
+
|
132
|
+
# @param [Hash] o options pass to initialize
|
133
|
+
def self.render(source, o={}, &blk)
|
134
|
+
scope = Template.new(o)
|
135
|
+
|
136
|
+
Tilt["erb"].new(source).render(scope, scope.locals, &blk)
|
137
|
+
end
|
138
|
+
|
139
|
+
attr_reader :source_root
|
140
|
+
|
141
|
+
# @param [Hash] o options
|
142
|
+
# @option o [String] :source_root ("")
|
143
|
+
def initialize(o={})
|
144
|
+
@source_root = o[:source_root] || ""
|
145
|
+
end
|
146
|
+
|
147
|
+
# path absolute or relative.
|
148
|
+
def render(path)
|
149
|
+
path = Pa(Pa.absolute?(path) ? path : Pa.join(source_root, path))
|
150
|
+
path = path.build(fname: (path.base[0]=="_" ? "" : "_")+path.base)
|
151
|
+
|
152
|
+
Tilt::ERBTemplate.new(path.p).render(self, locals)
|
153
|
+
end
|
154
|
+
|
155
|
+
def have_ext(ext)
|
156
|
+
Rc.exts.include? ext
|
157
|
+
end
|
158
|
+
|
159
|
+
# for tilt
|
160
|
+
def locals
|
161
|
+
Rc._to_hash
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
class DSL < Thor
|
166
|
+
include Thor::Actions
|
167
|
+
attr_reader :options, :template_name, :app_path
|
168
|
+
|
169
|
+
def initialize(template_name, app_path, o={})
|
170
|
+
@template_name = template_name
|
171
|
+
@app_path = app_path
|
172
|
+
@options = o
|
173
|
+
end
|
174
|
+
|
175
|
+
no_tasks do
|
176
|
+
|
177
|
+
def project
|
178
|
+
Rc.project
|
179
|
+
end
|
180
|
+
|
181
|
+
def have_ext(ext)
|
182
|
+
Rc.exts.include? ext
|
183
|
+
end
|
184
|
+
|
185
|
+
# a shortcut for
|
186
|
+
# directory2 "template", Rc.app_path
|
187
|
+
# directory2 "template.daemon", Rc.app_path if have_ext("daemon")
|
188
|
+
# ...
|
189
|
+
def copy_template(dir)
|
190
|
+
directory2 dir, Rc.app_path
|
191
|
+
|
192
|
+
Rc.exts.each {|ext|
|
193
|
+
newdir = "#{dir}.#{ext}"
|
194
|
+
if Pa.exists?(newdir)
|
195
|
+
directory2 newdir, Rc.app_path
|
196
|
+
end
|
197
|
+
}
|
198
|
+
end
|
199
|
+
end
|
200
|
+
end
|
156
201
|
end
|
data/lib/rag/ruby.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
class Rag
|
2
|
+
chainable = Module.new do
|
3
|
+
def initialize(*)
|
4
|
+
super
|
5
|
+
|
6
|
+
# generate Rc.o
|
7
|
+
o = Rc.o = Optimism.new
|
8
|
+
if gemspec_file=Dir["*.gemspec"][0]
|
9
|
+
gemspec = Gem::Specification.load(gemspec_file)
|
10
|
+
o.project = gemspec.name
|
11
|
+
o.version = gemspec.version
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
include chainable
|
17
|
+
end
|
18
|
+
|
19
|
+
require "rag/ruby/gem"
|
20
|
+
require "rag/ruby/test"
|
21
|
+
require "rag/ruby/doc"
|
@@ -1,8 +1,10 @@
|
|
1
|
-
class Rag
|
1
|
+
class Rag
|
2
2
|
desc "release", "release this gem to RubyGems.org"
|
3
3
|
def release
|
4
|
+
sudo = Process.uid == 0 ? "" : "sudo"
|
4
5
|
system "gem build #{Rc.o.project}.gemspec", :verbose => true
|
5
6
|
system "gem push #{Rc.o.project}-#{Rc.o.version}.gem", :verbose => true
|
7
|
+
system "#{sudo} gem install #{Rc.o.project}-#{Rc.o.version}.gem", :verbose => true
|
6
8
|
Pa.rm "#{Rc.o.project}-#{Rc.o.version}.gem", :verbose => true
|
7
9
|
end
|
8
10
|
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Ragen
|
2
|
+
class Test < Thor
|
3
|
+
default_task :default
|
4
|
+
|
5
|
+
desc "default", "begin auto test", hide: true
|
6
|
+
def default
|
7
|
+
system "watchr #{Rag::Rc.o.project}.watchr", :verbose => true
|
8
|
+
end
|
9
|
+
|
10
|
+
desc "all", "test all"
|
11
|
+
def all
|
12
|
+
system "bundle exec rspec --color spec", :verbose => true
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
class Rag < Thor
|
19
|
+
desc "test", "run test"
|
20
|
+
subcommand "test", Ragen::Test
|
21
|
+
end
|
data/lib/rag/version.rb
CHANGED
data/rag.gemspec
CHANGED
@@ -1,5 +1,4 @@
|
|
1
|
-
|
2
|
-
require "rag/version"
|
1
|
+
Kernel.load File.expand_path("../lib/rag/version.rb", __FILE__)
|
3
2
|
|
4
3
|
Gem::Specification.new do |s|
|
5
4
|
s.name = "rag"
|
@@ -17,8 +16,10 @@ A project helper, include create, develop, test, release helper.
|
|
17
16
|
s.files = `git ls-files`.split("\n")
|
18
17
|
s.executables = %w(rag)
|
19
18
|
|
19
|
+
s.add_dependency "pd"
|
20
20
|
s.add_dependency "tagen", "~>1.1.0"
|
21
|
-
s.add_dependency "pa", "~>1.
|
22
|
-
s.add_dependency "optimism", "~>3.
|
21
|
+
s.add_dependency "pa", "~>1.3.0"
|
22
|
+
s.add_dependency "optimism", "~>3.2.0"
|
23
23
|
s.add_dependency "thor"
|
24
|
+
s.add_dependency "tilt"
|
24
25
|
end
|
data/rag.watchr
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
<%=project%>
|
data/spec/rag/new_spec.rb
CHANGED
@@ -1,9 +1,12 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
require "fileutils"
|
3
3
|
require "tmpdir"
|
4
|
+
require "rag/new"
|
5
|
+
require "rag/ext"
|
4
6
|
|
5
7
|
Project = Rag::Project
|
6
8
|
|
9
|
+
=begin
|
7
10
|
describe Project do
|
8
11
|
before :all do
|
9
12
|
@curdir = Dir.pwd
|
@@ -18,16 +21,8 @@ describe Project do
|
|
18
21
|
|
19
22
|
describe ".create" do
|
20
23
|
it "runs ok" do
|
21
|
-
Project.create "
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
describe Rag do
|
27
|
-
describe ".new" do
|
28
|
-
it "first time create ragrc in $HOME" do
|
29
|
-
#pd Rc.pa.config
|
30
|
-
#Rag::Rc.pa.config.should be_exists
|
24
|
+
Project.create "rb.app", "guten"
|
31
25
|
end
|
32
26
|
end
|
33
27
|
end
|
28
|
+
=end
|
data/spec/rag_spec.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Rag do
|
4
|
+
describe "#new" do
|
5
|
+
it "works" do
|
6
|
+
chdir $spec_tmp, :empty => true do
|
7
|
+
Rag.new.invoke(:new, ["ruby.app.bar", "myapp"])
|
8
|
+
|
9
|
+
File.read("myapp/hello").should == "hello"
|
10
|
+
Rc.template.should == "ruby"
|
11
|
+
Rc.exts.should == %w[app bar]
|
12
|
+
Rc.ext.should == "app" # main ext
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
data/spec/spec_helper.rb
CHANGED
@@ -1,7 +1,79 @@
|
|
1
|
+
require "bundler/setup"
|
2
|
+
require "stringio"
|
3
|
+
require "fileutils"
|
4
|
+
require "pd"
|
1
5
|
require "rag"
|
2
6
|
|
3
|
-
$spec_dir =
|
7
|
+
$spec_dir = File.expand_path("..", __FILE__)
|
8
|
+
$spec_data = File.expand_path("../data", __FILE__)
|
9
|
+
$spec_tmp = File.expand_path("../tmp", __FILE__)
|
4
10
|
|
5
|
-
|
11
|
+
Rc = Rag::Rc
|
12
|
+
Rc._merge! <<EOF
|
13
|
+
p:
|
14
|
+
root = nil
|
15
|
+
home = Pa("#{$spec_data}/home")
|
16
|
+
homerc = Pa("#{$spec_data}/ragrc")
|
17
|
+
apprc = Pa("#{$spec_data}/apprc")
|
18
|
+
data = nil
|
6
19
|
|
7
|
-
|
20
|
+
author = "Test"
|
21
|
+
email = "test@test.com"
|
22
|
+
license = "TEST-LICENSE"
|
23
|
+
|
24
|
+
github:
|
25
|
+
username = "TestYe"
|
26
|
+
EOF
|
27
|
+
|
28
|
+
RSpec.configure do |config|
|
29
|
+
def capture(stream)
|
30
|
+
begin
|
31
|
+
stream = stream.to_s
|
32
|
+
eval "$#{stream} = StringIO.new"
|
33
|
+
yield
|
34
|
+
result = eval("$#{stream}").string
|
35
|
+
ensure
|
36
|
+
eval("$#{stream} = #{stream.upcase}")
|
37
|
+
end
|
38
|
+
|
39
|
+
result
|
40
|
+
end
|
41
|
+
alias :silence :capture
|
42
|
+
|
43
|
+
def chdir(dir, o={}, &blk)
|
44
|
+
begin
|
45
|
+
cwd = Dir.pwd
|
46
|
+
Dir.chdir(dir)
|
47
|
+
ensure
|
48
|
+
Dir.chdir(cwd)
|
49
|
+
if o[:empty]
|
50
|
+
FileUtils.rm_r Dir.entries(dir).tap{|v| v.delete("."); v.delete(".."); v.delete(".gitkeep")}
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
module Kernel
|
58
|
+
private
|
59
|
+
|
60
|
+
def xdescribe(*args, &blk)
|
61
|
+
describe *args do
|
62
|
+
pending "xxxxxxxxx"
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def xcontext(*args, &blk)
|
67
|
+
context *args do
|
68
|
+
pending "xxxxxxxxx"
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def xit(*args, &blk)
|
73
|
+
it *args do
|
74
|
+
pending "xxxxxxxx"
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
# vim: ft=ruby
|
data/spec/tmp/.gitkeep
ADDED
File without changes
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rag
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,27 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-08-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: pd
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
14
30
|
- !ruby/object:Gem::Dependency
|
15
31
|
name: tagen
|
16
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
17
33
|
none: false
|
18
34
|
requirements:
|
19
35
|
- - ~>
|
@@ -21,32 +37,63 @@ dependencies:
|
|
21
37
|
version: 1.1.0
|
22
38
|
type: :runtime
|
23
39
|
prerelease: false
|
24
|
-
version_requirements:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 1.1.0
|
25
46
|
- !ruby/object:Gem::Dependency
|
26
47
|
name: pa
|
27
|
-
requirement:
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
28
49
|
none: false
|
29
50
|
requirements:
|
30
51
|
- - ~>
|
31
52
|
- !ruby/object:Gem::Version
|
32
|
-
version: 1.
|
53
|
+
version: 1.3.0
|
33
54
|
type: :runtime
|
34
55
|
prerelease: false
|
35
|
-
version_requirements:
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.3.0
|
36
62
|
- !ruby/object:Gem::Dependency
|
37
63
|
name: optimism
|
38
|
-
requirement:
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
39
65
|
none: false
|
40
66
|
requirements:
|
41
67
|
- - ~>
|
42
68
|
- !ruby/object:Gem::Version
|
43
|
-
version: 3.
|
69
|
+
version: 3.2.0
|
44
70
|
type: :runtime
|
45
71
|
prerelease: false
|
46
|
-
version_requirements:
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 3.2.0
|
47
78
|
- !ruby/object:Gem::Dependency
|
48
79
|
name: thor
|
49
|
-
requirement:
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :runtime
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: tilt
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
50
97
|
none: false
|
51
98
|
requirements:
|
52
99
|
- - ! '>='
|
@@ -54,7 +101,12 @@ dependencies:
|
|
54
101
|
version: '0'
|
55
102
|
type: :runtime
|
56
103
|
prerelease: false
|
57
|
-
version_requirements:
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
58
110
|
description: ! "A project helper, include create, develop, test, release helper. \n"
|
59
111
|
email: ywzhaifei@gmail.com
|
60
112
|
executables:
|
@@ -64,42 +116,46 @@ extra_rdoc_files: []
|
|
64
116
|
files:
|
65
117
|
- .gitignore
|
66
118
|
- .rspec
|
119
|
+
- .travis.yml
|
67
120
|
- .yardopts
|
68
121
|
- Gemfile
|
69
122
|
- Gemfile.lock
|
70
123
|
- README.md
|
71
124
|
- Rakefile
|
125
|
+
- bin/1rag
|
72
126
|
- bin/rag
|
73
127
|
- data/header/apache.erb
|
74
128
|
- data/header/common.erb
|
75
129
|
- data/header/gpl.erb
|
76
130
|
- data/header/lgpl.erb
|
77
|
-
- data/home_config/_ragrc
|
78
131
|
- data/license/apache
|
79
132
|
- data/license/bsd.erb
|
80
133
|
- data/license/gpl
|
81
134
|
- data/license/lgpl
|
82
135
|
- data/license/mit.erb
|
83
|
-
- data/template/test/file_name.erb
|
84
136
|
- docs/OverView.md
|
137
|
+
- hello/hello
|
85
138
|
- lib/rag.rb
|
86
|
-
- lib/rag/
|
87
|
-
- lib/rag/
|
139
|
+
- lib/rag/aur.rb
|
140
|
+
- lib/rag/ext.rb
|
88
141
|
- lib/rag/new.rb
|
89
142
|
- lib/rag/rc.rb
|
90
|
-
- lib/rag/
|
143
|
+
- lib/rag/ruby.rb
|
144
|
+
- lib/rag/ruby/doc.rb
|
145
|
+
- lib/rag/ruby/gem.rb
|
146
|
+
- lib/rag/ruby/test.rb
|
91
147
|
- lib/rag/ui.rb
|
92
148
|
- lib/rag/util.rb
|
93
149
|
- lib/rag/util/erb.rb
|
94
150
|
- lib/rag/version.rb
|
95
151
|
- rag.gemspec
|
96
152
|
- rag.watchr
|
97
|
-
- spec/data/
|
98
|
-
- spec/data/
|
99
|
-
- spec/data/systemrc
|
153
|
+
- spec/data/home/ruby.app/Buildfile
|
154
|
+
- spec/data/home/ruby.app/template/hello.tt
|
100
155
|
- spec/rag/new_spec.rb
|
101
|
-
- spec/
|
156
|
+
- spec/rag_spec.rb
|
102
157
|
- spec/spec_helper.rb
|
158
|
+
- spec/tmp/.gitkeep
|
103
159
|
- tags
|
104
160
|
homepage: http://github.com/GutenYe/rag
|
105
161
|
licenses: []
|
@@ -121,7 +177,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
121
177
|
version: '0'
|
122
178
|
requirements: []
|
123
179
|
rubyforge_project: xx
|
124
|
-
rubygems_version: 1.8.
|
180
|
+
rubygems_version: 1.8.24
|
125
181
|
signing_key:
|
126
182
|
specification_version: 3
|
127
183
|
summary: A project helper, include create, developing, testing, release
|
data/data/home_config/_ragrc
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
<%=author%>
|
data/lib/rag/test.rb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
module Ragen
|
2
|
-
class Test < Thor
|
3
|
-
default_task :default
|
4
|
-
|
5
|
-
desc "default", "default", hide: true
|
6
|
-
def default
|
7
|
-
system "watchr #{Rag::Rc.o.project}.watchr", :verbose
|
8
|
-
end
|
9
|
-
|
10
|
-
desc "test [all]", "auto test with watchr"
|
11
|
-
def all
|
12
|
-
system "rspec --color spec", :verbose
|
13
|
-
end
|
14
|
-
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
class Rag < Thor
|
19
|
-
desc "test", "run test"
|
20
|
-
subcommand "test", Ragen::Test
|
21
|
-
end
|
@@ -1 +0,0 @@
|
|
1
|
-
<%=author%>
|
data/spec/data/homerc
DELETED
data/spec/data/systemrc
DELETED