root/lang/ruby/cutagem/templates/command/Rakefile @ 426

Revision 426, 3.3 kB (checked in by cho45, 7 years ago)

lang/ruby/cutagem/templates/default/Rakefile,
lang/ruby/cutagem/templates/command/Rakefile:

デフォルトのテンプレートを多少マシに

Line 
1require 'rubygems'
2require 'rake'
3require 'rake/clean'
4require 'rake/testtask'
5require 'rake/packagetask'
6require 'rake/gempackagetask'
7require 'rake/rdoctask'
8require 'rake/contrib/rubyforgepublisher'
9require 'fileutils'
10include FileUtils
11
12NAME              = "<%=gemname%>"
13AUTHOR            = "<%=author%>"
14EMAIL             = "<%=email%>"
15DESCRIPTION       = "<%=description%>"
16RUBYFORGE_PROJECT = "<%=config['meta_project'] || gemid%>"
17HOMEPATH          = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
18BIN_FILES         = %w( <%=gemname%> )
19VERS              = "0.0.1"
20
21
22REV = File.read(".svn/entries")[/committed-rev="(d+)"/, 1] rescue nil
23CLEAN.include ['**/.*.sw?', '*.gem', '.config']
24RDOC_OPTS = [
25        '--title', "#{NAME} documentation",
26        "--charset", "utf-8",
27        "--opname", "index.html",
28        "--line-numbers",
29        "--main", "README",
30        "--inline-source",
31]
32
33task :default => [:test]
34task :package => [:clean]
35
36Rake::TestTask.new("test") do |t|
37        t.libs   << "test"
38        t.pattern = "test/**/*_test.rb"
39        t.verbose = true
40end
41
42spec = Gem::Specification.new do |s|
43        s.name              = NAME
44        s.version           = VERS
45        s.platform          = Gem::Platform::RUBY
46        s.has_rdoc          = true
47        s.extra_rdoc_files  = ["README", "ChangeLog"]
48        s.rdoc_options     += RDOC_OPTS + ['--exclude', '^(examples|extras)/']
49        s.summary           = DESCRIPTION
50        s.description       = DESCRIPTION
51        s.author            = AUTHOR
52        s.email             = EMAIL
53        s.homepage          = HOMEPATH
54        s.executables       = BIN_FILES
55        s.rubyforge_project = RUBYFORGE_PROJECT
56        s.bindir            = "bin"
57        s.require_path      = "lib"
58        s.autorequire       = ""
59        s.test_files        = Dir["test/test_*.rb"]
60
61        #s.add_dependency('activesupport', '>=1.3.1')
62        #s.required_ruby_version = '>= 1.8.2'
63
64        s.files = %w(README ChangeLog Rakefile) +
65                Dir.glob("{bin,doc,test,lib,templates,generator,extras,website,script}/**/*") +
66                Dir.glob("ext/**/*.{h,c,rb}") +
67                Dir.glob("examples/**/*.rb") +
68                Dir.glob("tools/*.rb")
69
70        s.extensions = FileList["ext/**/extconf.rb"].to_a
71end
72
73Rake::GemPackageTask.new(spec) do |p|
74        p.need_tar = true
75        p.gem_spec = spec
76end
77
78task :install do
79        name = "#{NAME}-#{VERS}.gem"
80        sh %{rake package}
81        sh %{sudo gem install pkg/#{name}}
82end
83
84task :uninstall => [:clean] do
85        sh %{sudo gem uninstall #{NAME}}
86end
87
88
89Rake::RDocTask.new do |rdoc|
90        rdoc.rdoc_dir = 'html'
91        rdoc.options += RDOC_OPTS
92        rdoc.template = "resh"
93        #rdoc.template = "#{ENV['template']}.rb" if ENV['template']
94        if ENV['DOC_FILES']
95                rdoc.rdoc_files.include(ENV['DOC_FILES'].split(/,\s*/))
96        else
97                rdoc.rdoc_files.include('README', 'ChangeLog')
98                rdoc.rdoc_files.include('lib/**/*.rb')
99                rdoc.rdoc_files.include('ext/**/*.c')
100        end
101end
102
103desc "Publish to RubyForge"
104task :rubyforge => [:rdoc, :package] do
105        Rake::RubyForgePublisher.new(RUBYFORGE_PROJECT, '<%=ENV['USER']%>').upload
106end
107
108desc 'Package and upload the release to rubyforge.'
109task :release => [:clean, :package] do |t|
110        v = ENV["VERSION"] or abort "Must supply VERSION=x.y.z"
111        abort "Versions don't match #{v} vs #{VERS}" unless v == VERS
112        pkg = "pkg/#{NAME}-#{VERS}"
113
114        rf = RubyForge.new
115        puts "Logging in"
116        rf.login
117
118        c = rf.userconfig
119#       c["release_notes"] = description if description
120#       c["release_changes"] = changes if changes
121        c["preformatted"] = true
122
123        files = [
124                "#{pkg}.tgz",
125                "#{pkg}.gem"
126        ].compact
127
128        puts "Releasing #{NAME} v. #{VERS}"
129        rf.add_release RUBYFORGE_PROJECT, NAME, VERS, *files
130end
Note: See TracBrowser for help on using the browser.