rag 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. data/.gitignore +5 -0
  2. data/.rspec +1 -0
  3. data/.yardopts +5 -0
  4. data/Gemfile +13 -0
  5. data/Gemfile.lock +30 -0
  6. data/LICENSE +20 -0
  7. data/README.md +102 -0
  8. data/Rakefile +35 -0
  9. data/bin/rag +20 -0
  10. data/data/header/apache.erb +13 -0
  11. data/data/header/common.erb +3 -0
  12. data/data/header/gpl.erb +14 -0
  13. data/data/header/lgpl.erb +14 -0
  14. data/data/home_config/_ragrc +8 -0
  15. data/data/license/apache +174 -0
  16. data/data/license/bsd.erb +10 -0
  17. data/data/license/gpl +619 -0
  18. data/data/license/lgpl +165 -0
  19. data/data/license/mit.erb +21 -0
  20. data/data/template/default/.gitignore +1 -0
  21. data/data/template/default/.rspec +1 -0
  22. data/data/template/default/Gemfile +7 -0
  23. data/data/template/default/LICENSE.erb +20 -0
  24. data/data/template/default/README.md.erb +38 -0
  25. data/data/template/default/Ragfile +5 -0
  26. data/data/template/default/__project__.gemspec.erb +20 -0
  27. data/data/template/default/__project__.watchr +22 -0
  28. data/data/template/default/lib/__project__.rb +0 -0
  29. data/data/template/default/spec/spec_helper.rb.erb +0 -0
  30. data/data/template/default/version.rb.erb +9 -0
  31. data/data/template/default.readme +26 -0
  32. data/data/template/test/file_name.erb +1 -0
  33. data/docs/OverView.md +11 -0
  34. data/lib/rag/doc.rb +6 -0
  35. data/lib/rag/gem.rb +17 -0
  36. data/lib/rag/new/project.rb +142 -0
  37. data/lib/rag/new.rb +39 -0
  38. data/lib/rag/rc.rb +21 -0
  39. data/lib/rag/test.rb +21 -0
  40. data/lib/rag.rb +8 -0
  41. data/rag.gemspec +22 -0
  42. data/rag.watchr +22 -0
  43. data/spec/rag/new/project_spec.rb +27 -0
  44. data/spec/rag/new_spec.rb +10 -0
  45. data/spec/spec_helper.rb +15 -0
  46. data/version.rb +9 -0
  47. metadata +179 -0
data/data/license/lgpl ADDED
@@ -0,0 +1,165 @@
1
+ GNU LESSER GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+
9
+ This version of the GNU Lesser General Public License incorporates
10
+ the terms and conditions of version 3 of the GNU General Public
11
+ License, supplemented by the additional permissions listed below.
12
+
13
+ 0. Additional Definitions.
14
+
15
+ As used herein, "this License" refers to version 3 of the GNU Lesser
16
+ General Public License, and the "GNU GPL" refers to version 3 of the GNU
17
+ General Public License.
18
+
19
+ "The Library" refers to a covered work governed by this License,
20
+ other than an Application or a Combined Work as defined below.
21
+
22
+ An "Application" is any work that makes use of an interface provided
23
+ by the Library, but which is not otherwise based on the Library.
24
+ Defining a subclass of a class defined by the Library is deemed a mode
25
+ of using an interface provided by the Library.
26
+
27
+ A "Combined Work" is a work produced by combining or linking an
28
+ Application with the Library. The particular version of the Library
29
+ with which the Combined Work was made is also called the "Linked
30
+ Version".
31
+
32
+ The "Minimal Corresponding Source" for a Combined Work means the
33
+ Corresponding Source for the Combined Work, excluding any source code
34
+ for portions of the Combined Work that, considered in isolation, are
35
+ based on the Application, and not on the Linked Version.
36
+
37
+ The "Corresponding Application Code" for a Combined Work means the
38
+ object code and/or source code for the Application, including any data
39
+ and utility programs needed for reproducing the Combined Work from the
40
+ Application, but excluding the System Libraries of the Combined Work.
41
+
42
+ 1. Exception to Section 3 of the GNU GPL.
43
+
44
+ You may convey a covered work under sections 3 and 4 of this License
45
+ without being bound by section 3 of the GNU GPL.
46
+
47
+ 2. Conveying Modified Versions.
48
+
49
+ If you modify a copy of the Library, and, in your modifications, a
50
+ facility refers to a function or data to be supplied by an Application
51
+ that uses the facility (other than as an argument passed when the
52
+ facility is invoked), then you may convey a copy of the modified
53
+ version:
54
+
55
+ a) under this License, provided that you make a good faith effort to
56
+ ensure that, in the event an Application does not supply the
57
+ function or data, the facility still operates, and performs
58
+ whatever part of its purpose remains meaningful, or
59
+
60
+ b) under the GNU GPL, with none of the additional permissions of
61
+ this License applicable to that copy.
62
+
63
+ 3. Object Code Incorporating Material from Library Header Files.
64
+
65
+ The object code form of an Application may incorporate material from
66
+ a header file that is part of the Library. You may convey such object
67
+ code under terms of your choice, provided that, if the incorporated
68
+ material is not limited to numerical parameters, data structure
69
+ layouts and accessors, or small macros, inline functions and templates
70
+ (ten or fewer lines in length), you do both of the following:
71
+
72
+ a) Give prominent notice with each copy of the object code that the
73
+ Library is used in it and that the Library and its use are
74
+ covered by this License.
75
+
76
+ b) Accompany the object code with a copy of the GNU GPL and this license
77
+ document.
78
+
79
+ 4. Combined Works.
80
+
81
+ You may convey a Combined Work under terms of your choice that,
82
+ taken together, effectively do not restrict modification of the
83
+ portions of the Library contained in the Combined Work and reverse
84
+ engineering for debugging such modifications, if you also do each of
85
+ the following:
86
+
87
+ a) Give prominent notice with each copy of the Combined Work that
88
+ the Library is used in it and that the Library and its use are
89
+ covered by this License.
90
+
91
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
92
+ document.
93
+
94
+ c) For a Combined Work that displays copyright notices during
95
+ execution, include the copyright notice for the Library among
96
+ these notices, as well as a reference directing the user to the
97
+ copies of the GNU GPL and this license document.
98
+
99
+ d) Do one of the following:
100
+
101
+ 0) Convey the Minimal Corresponding Source under the terms of this
102
+ License, and the Corresponding Application Code in a form
103
+ suitable for, and under terms that permit, the user to
104
+ recombine or relink the Application with a modified version of
105
+ the Linked Version to produce a modified Combined Work, in the
106
+ manner specified by section 6 of the GNU GPL for conveying
107
+ Corresponding Source.
108
+
109
+ 1) Use a suitable shared library mechanism for linking with the
110
+ Library. A suitable mechanism is one that (a) uses at run time
111
+ a copy of the Library already present on the user's computer
112
+ system, and (b) will operate properly with a modified version
113
+ of the Library that is interface-compatible with the Linked
114
+ Version.
115
+
116
+ e) Provide Installation Information, but only if you would otherwise
117
+ be required to provide such information under section 6 of the
118
+ GNU GPL, and only to the extent that such information is
119
+ necessary to install and execute a modified version of the
120
+ Combined Work produced by recombining or relinking the
121
+ Application with a modified version of the Linked Version. (If
122
+ you use option 4d0, the Installation Information must accompany
123
+ the Minimal Corresponding Source and Corresponding Application
124
+ Code. If you use option 4d1, you must provide the Installation
125
+ Information in the manner specified by section 6 of the GNU GPL
126
+ for conveying Corresponding Source.)
127
+
128
+ 5. Combined Libraries.
129
+
130
+ You may place library facilities that are a work based on the
131
+ Library side by side in a single library together with other library
132
+ facilities that are not Applications and are not covered by this
133
+ License, and convey such a combined library under terms of your
134
+ choice, if you do both of the following:
135
+
136
+ a) Accompany the combined library with a copy of the same work based
137
+ on the Library, uncombined with any other library facilities,
138
+ conveyed under the terms of this License.
139
+
140
+ b) Give prominent notice with the combined library that part of it
141
+ is a work based on the Library, and explaining where to find the
142
+ accompanying uncombined form of the same work.
143
+
144
+ 6. Revised Versions of the GNU Lesser General Public License.
145
+
146
+ The Free Software Foundation may publish revised and/or new versions
147
+ of the GNU Lesser General Public License from time to time. Such new
148
+ versions will be similar in spirit to the present version, but may
149
+ differ in detail to address new problems or concerns.
150
+
151
+ Each version is given a distinguishing version number. If the
152
+ Library as you received it specifies that a certain numbered version
153
+ of the GNU Lesser General Public License "or any later version"
154
+ applies to it, you have the option of following the terms and
155
+ conditions either of that published version or of any later version
156
+ published by the Free Software Foundation. If the Library as you
157
+ received it does not specify a version number of the GNU Lesser
158
+ General Public License, you may choose any version of the GNU Lesser
159
+ General Public License ever published by the Free Software Foundation.
160
+
161
+ If the Library as you received it specifies that a proxy can decide
162
+ whether future versions of the GNU Lesser General Public License shall
163
+ apply, that proxy's public statement of acceptance of any version is
164
+ permanent authorization for you to choose that version for the
165
+ Library.
@@ -0,0 +1,21 @@
1
+ The MIT License
2
+
3
+ Copyright (c) <%=year%> <%=author%>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1 @@
1
+ *~
@@ -0,0 +1 @@
1
+ --color
@@ -0,0 +1,7 @@
1
+ source :rubygems
2
+
3
+ group :development do
4
+
5
+ end
6
+
7
+ gemspec
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 <%=author%>
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ 'Software'), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,38 @@
1
+ Foo, a very good library
2
+ ========================
3
+
4
+ **Homepage**: [https://github.com/<%=github.username%>/<%=project%>](https://github.com/<%=github.username%>/<%=project%>) <br/>
5
+ **Author**: <%=author%> <br/>
6
+ **License**: <%=license%> <br/>
7
+ **Documentation**: [http://rubydoc.info/gems/<%=project%>/frames](http://rubydoc.info/gems/<%=project%>/frames) <br/>
8
+ **Issue Tracker**: [https://github.com/<%=github.username%>/<%=project%>/issues](https://github.com/<%=github.username%>/<%=project%>/issues) <br/>
9
+
10
+ Overview
11
+ --------
12
+
13
+ descripe your prjoect here.
14
+
15
+ Features
16
+ --------
17
+
18
+ a clearly list of features.
19
+
20
+ Usage
21
+ -----
22
+
23
+ how to use
24
+
25
+ Install
26
+ ----------
27
+
28
+ install method
29
+
30
+ Resources
31
+ ---------
32
+
33
+ some related resources to help each other.
34
+
35
+
36
+ Copyright
37
+ ---------
38
+ Copyright &copy; 2011 by <%=author%>. this library released under <%=license%>, See {file:LICENSE} for futher details.
@@ -0,0 +1,5 @@
1
+ # add your own task in Ragfile or in tasks/*.rag
2
+ class Rag < Thor
3
+ end
4
+
5
+ # vim: filetype=ruby
@@ -0,0 +1,20 @@
1
+ $: << "."
2
+ require "version"
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = "<%=project%>"
6
+ s.version = <%=project.capitalize%>::VERSION::IS
7
+ s.summary = "a good lib"
8
+ s.description = <<-EOF
9
+ a good lib
10
+ EOF
11
+
12
+ s.author = "<%=author%>"
13
+ s.email = "<%=email%>"
14
+ s.homepage = "http://github.com/<%=github.username%>/<%=project%>"
15
+ s.rubyforge_project = "xx"
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+
19
+ s.add_dependency "x"
20
+ end
@@ -0,0 +1,22 @@
1
+ # lib/**/*.rb
2
+ watch %r~lib/(.*)\.rb~ do |m|
3
+ test "spec/#{m[1]}_spec.rb"
4
+ end
5
+
6
+ # spec/**/*_spec.rb
7
+ watch %r~spec/.*_spec\.rb~ do |m|
8
+ test m[0]
9
+ end
10
+
11
+ # Ctrl-\
12
+ Signal.trap('QUIT') do
13
+ puts "--- Running all tests ---\n\n"
14
+ test "spec"
15
+ end
16
+
17
+ def test path
18
+ cmd = "rspec #{path}"
19
+ puts cmd
20
+ system cmd
21
+ end
22
+
File without changes
File without changes
@@ -0,0 +1,9 @@
1
+ module <%=project.capitalize%>
2
+ module VERSION
3
+ MAJOR = 0
4
+ MINOR = 1
5
+ PATCH = 0
6
+
7
+ IS = [MAJOR, MINOR, PATCH].join(".")
8
+ end
9
+ end
@@ -0,0 +1,26 @@
1
+
2
+ file layout
3
+
4
+ bin/
5
+
6
+ lib/
7
+ \__project__/
8
+ ...
9
+ \__project__.rb
10
+
11
+ spec/
12
+ spec_helper.rb
13
+ \__project__
14
+ ...
15
+ \__project__.watchr
16
+
17
+ Gemfile
18
+ Ragfile
19
+ \__project__.gemspec
20
+ version.rb
21
+
22
+ LICENSE
23
+ README
24
+
25
+
26
+ # vim: filetype=markdown
@@ -0,0 +1 @@
1
+ <%=author%>
data/docs/OverView.md ADDED
@@ -0,0 +1,11 @@
1
+
2
+ see template/default/README
3
+
4
+
5
+ Template
6
+ --------
7
+
8
+ filename:
9
+ subsitute '__project__' to your 'project-name'
10
+
11
+
data/lib/rag/doc.rb ADDED
@@ -0,0 +1,6 @@
1
+ class Rag < Thor
2
+ desc "doc", "test documentation with yard server --reload"
3
+ def doc
4
+ system "yard server --reload", :verbose
5
+ end
6
+ end
data/lib/rag/gem.rb ADDED
@@ -0,0 +1,17 @@
1
+ class Rag < Thor
2
+
3
+ desc "release", "release this gem to RubyGems.org"
4
+ def release
5
+ system "gem build #{Rc.o.project}.gemspec", :verbose
6
+ system "gem push #{Rc.o.project}-#{Rc.o.version}.gem", :verbose
7
+ Pa.rm "#{Rc.o.project}-#{Rc.o.version}.gem", :verbose
8
+ end
9
+
10
+ desc "install", "install this gem to your system"
11
+ def install
12
+ system "gem build #{Rc.o.project}.gemspec", :verbose
13
+ system "gem install #{Rc.o.project}-#{Rc.o.version}.gem", :verbose
14
+ Pa.rm "#{Rc.o.project}-#{Rc.o.version}.gem", :verbose
15
+ end
16
+
17
+ end
@@ -0,0 +1,142 @@
1
+ require "tagen/yaml"
2
+ require "tagen/erb"
3
+
4
+ class Rag
5
+ =begin
6
+
7
+ == ERB support variables
8
+ * project # the name of your project, provided by `rag new <project_name>'
9
+ * others from .ragrc
10
+
11
+ == Configrauton
12
+
13
+ + ~/.ragrc
14
+ + APP/.ragrc
15
+ + from cmdline
16
+
17
+ you can use arbitrary name in .ragrc, then you can use then in template file.
18
+
19
+ =end
20
+ class Project
21
+ module ClassMethods
22
+ def create name, o={}
23
+ Project.new(name, o).create
24
+ end
25
+
26
+ # find templates
27
+ def templates
28
+ templates = []
29
+ templates << Rc.pa.template.ls - %w(test)
30
+ home_template_pa = Pa('~/.rag/tempalte' )
31
+ templates << home_template_pa.ls if home_tempate_pa.exists?
32
+ end
33
+
34
+ # call by `rag new -l'
35
+ def list_templates
36
+ puts self.templates.join('\n')
37
+ end
38
+
39
+ end
40
+ extend ClassMethods
41
+
42
+ attr_reader :options, :name, :project
43
+ def initialize name, o={}
44
+ @name = name
45
+ @options = o
46
+ @project = name=="." ? (o["name"] || Pa.pwd2.base) : name
47
+ @dest = Pa(@name)
48
+ end
49
+
50
+ def create
51
+ create_project_directory
52
+ if name=="."
53
+ copy_files
54
+ else
55
+ copy_files :overwrite => true
56
+ end
57
+ end
58
+
59
+ def create_project_directory
60
+ if @name=="."
61
+ return
62
+ elsif @dest.exists?
63
+ puts "dest directory `#{@name}' already existing"
64
+ exit
65
+ else
66
+ @dest.mkdir
67
+ end
68
+ end
69
+
70
+ def copy_files o={}
71
+ Pa.each_r Rc.pa.template.join(options[:template]) do |pa, relative, e|
72
+ # skip *~
73
+ next if pa.b =~ /~$/
74
+
75
+ # convert __project__ to @name
76
+ dest = @dest.join(relative.gsub(/__project__/, project))
77
+ path_msg = relative.gsub(/__project__/,project).gsub(/\.erb$/,'')
78
+
79
+ # skip directory not file
80
+ next if dest.exists? and dest.directory?
81
+
82
+ if not o[:overwrite] and (dest.exists? or dest.sub(/\.erb$/, '').exists?)
83
+ print "Overwrite #{path_msg}? [yna] "
84
+ case $stdin.gets.rstrip
85
+ when "y"
86
+ puts "[overwrite] #{path_msg}"
87
+ copy_file pa, dest, o
88
+ when "a"
89
+ puts "[overwrite] #{path_msg}"
90
+ o[:overwrite] = true
91
+ copy_file pa, dest, o
92
+ when "q"
93
+ exit
94
+ else
95
+ puts "[skip] #{path_msg}"
96
+ next
97
+ end
98
+ elsif o[:overwrite] and dest.exists?
99
+ puts "[overwrite] #{path_msg}"
100
+ copy_file pa, dest, o
101
+ else
102
+ # classify: file dir/
103
+ puts "[create] #{path_msg}" + (dest.directory? ? '/' : '')
104
+ copy_file pa, dest, o
105
+ end
106
+
107
+ end
108
+ end
109
+
110
+ # not rescurive copy
111
+ def copy_file src, dest, o
112
+ if src.e=='erb'
113
+ copy_erb_file src, dest.sub(/\.erb$/,'')
114
+ else
115
+ Pa.cp src, dest, o.merge(special: true)
116
+ end
117
+ end
118
+
119
+ def copy_erb_file src, dest
120
+ content = ERB.new(File.read(src.p)).result(nil, get_erb_config)
121
+ File.write dest.p, content
122
+ dest.chmod(src.stat.mode)
123
+ end
124
+
125
+ def get_erb_config
126
+ # ~/.ragrc
127
+ home_config = YAML.load(Rc.pa.config)
128
+ # APP/.ragrc
129
+ app_config = Rc.pa.app_config.exists? ? YAML.load(Rc.pa.app_config) : {}
130
+ # cli
131
+ cli_config = options
132
+
133
+ config = home_config.merge(app_config).merge(cli_config)
134
+ config["project"] = project
135
+
136
+ o = OpenOption.new(config)
137
+ o
138
+ end
139
+
140
+
141
+ end
142
+ end
data/lib/rag/new.rb ADDED
@@ -0,0 +1,39 @@
1
+ require_relative "new/project"
2
+
3
+ class Rag < Thor
4
+ desc "new <project_name> or new .", "create a new project or use current directory"
5
+ method_option "author", type: :string, banner: "NAME", desc: "the project's author name"
6
+ method_option "email", type: :string, desc: "author's email address"
7
+ method_option "template", type: :string, default: "default", banner: "NAME", desc: "which template to use"
8
+ method_option "name", type: :string, banner: "NAME", desc: "rag new . [--name hello] default from File.basename(cur_path)"
9
+ method_option "list", type: :boolean, desc: "list templates", aliaes: %w(-l)
10
+ def new name
11
+ if options.list?
12
+ Project.list_templates
13
+ end
14
+
15
+ check_first_time
16
+
17
+ Project.create name, options
18
+ end
19
+
20
+ private
21
+ def check_first_time
22
+ return unless first_time?
23
+
24
+ puts "first time run rag"
25
+ (Rc.pa.data+'/home_config').each do |src|
26
+ dest = '~/' + src.b.sub(/^_/, '.')
27
+ puts "[create] #{dest.short}"
28
+ Pa.cp src, dest
29
+ end
30
+ puts "exit."
31
+ puts "please edit ~/.ragrc config file, then run rag again"
32
+ exit
33
+ end
34
+
35
+ def first_time?
36
+ Rc.pa.config.exists? ? false : true
37
+ end
38
+
39
+ end
data/lib/rag/rc.rb ADDED
@@ -0,0 +1,21 @@
1
+ class Rag
2
+ Rc = OpenOption.new
3
+ Rc.pa = OpenOption.new
4
+ Rc.pa.config = Pa(ENV['HOME']).join('.ragrc')
5
+ Rc.pa.app = Pa(__FILE__).dir2.parent(2)
6
+ Rc.pa.app_config = Rc.pa.app.join('.ragrc')
7
+ Rc.pa.data = Rc.pa.app.join('data')
8
+ Rc.pa.template = Rc.pa.data.join('template')
9
+ Rc.pa.home_config = Rc.pa.data.join('home_config')
10
+ Rc.pa.header = Rc.pa.data.join('header')
11
+ Rc.pa.license = Rc.pa.data.join('license')
12
+
13
+ Rc.o = OpenOption.new
14
+ gemspec_file = Dir['*.gemspec'][0]
15
+ if gemspec_file
16
+ gemspec = Gem::Specification.load gemspec_file
17
+ Rc.o.project = gemspec.name
18
+ Rc.o.version = gemspec.version
19
+ end
20
+
21
+ end
data/lib/rag/test.rb ADDED
@@ -0,0 +1,21 @@
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
data/lib/rag.rb ADDED
@@ -0,0 +1,8 @@
1
+ require "bundler/setup"
2
+ require "thor"
3
+ require "tagen/core"
4
+
5
+ class Rag < Thor
6
+ end
7
+
8
+ require_relative "rag/rc"
data/rag.gemspec ADDED
@@ -0,0 +1,22 @@
1
+ $: << "."
2
+ require "version"
3
+ require "bundler"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "rag"
7
+ s.version = Rag::VERSION::IS
8
+ s.summary = "a project helper, include create, developing, testing, release"
9
+ s.description = <<-EOF
10
+ a project helper, include create, develop, test, release
11
+ EOF
12
+
13
+ s.author = "Guten"
14
+ s.email = "ywzhaifei@gmail.com"
15
+ s.homepage = "http://github.com/GutenLinux/rag"
16
+ s.rubyforge_project = "xx"
17
+
18
+ s.files = `git ls-files`.split("\n")
19
+ s.executables = %w(rag)
20
+
21
+ s.add_bundler_dependencies
22
+ end
data/rag.watchr ADDED
@@ -0,0 +1,22 @@
1
+ # lib/**/*.rb
2
+ watch %r~lib/(.*)\.rb~ do |m|
3
+ test "spec/#{m[1]}_spec.rb"
4
+ end
5
+
6
+ # spec/**/*_spec.rb
7
+ watch %r~spec/.*_spec\.rb~ do |m|
8
+ test m[0]
9
+ end
10
+
11
+ # Ctrl-\
12
+ Signal.trap('QUIT') do
13
+ puts "--- Running all tests ---\n\n"
14
+ test "spec"
15
+ end
16
+
17
+ def test path
18
+ cmd = "rspec --color #{path}"
19
+ puts cmd
20
+ system cmd
21
+ end
22
+