hoe 1.12.2 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/History.txt +19 -0
- data/Manifest.txt +12 -0
- data/README.txt +25 -38
- data/Rakefile +12 -19
- data/bin/sow +1 -3
- data/lib/hoe.rb +243 -940
- data/lib/hoe/clean.rb +36 -0
- data/lib/hoe/debug.rb +68 -0
- data/lib/hoe/deps.rb +169 -0
- data/lib/hoe/flay.rb +35 -0
- data/lib/hoe/flog.rb +35 -0
- data/lib/hoe/inline.rb +58 -0
- data/lib/hoe/package.rb +83 -0
- data/lib/hoe/publish.rb +182 -0
- data/lib/hoe/rake.rb +44 -0
- data/lib/hoe/rcov.rb +44 -0
- data/lib/hoe/signing.rb +119 -0
- data/lib/hoe/test.rb +140 -0
- data/template/Rakefile.erb +3 -4
- data/test/test_hoe.rb +7 -9
- metadata +33 -38
- metadata.gz.sig +0 -0
data/lib/hoe/clean.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
##
|
2
|
+
# Clean plugin for hoe.
|
3
|
+
#
|
4
|
+
# === Tasks Provided:
|
5
|
+
#
|
6
|
+
# clean:: Clean up all the extras.
|
7
|
+
|
8
|
+
module Hoe::Clean
|
9
|
+
Hoe.plugin :clean # activate globally, fine for general purpose tasks
|
10
|
+
|
11
|
+
##
|
12
|
+
# Optional: An array of file patterns to delete on clean.
|
13
|
+
|
14
|
+
attr_accessor :clean_globs
|
15
|
+
|
16
|
+
##
|
17
|
+
# Initialize variables for plugin.
|
18
|
+
|
19
|
+
def initialize_clean
|
20
|
+
self.clean_globs ||= %w(diff diff.txt email.txt ri deps .source_index
|
21
|
+
*.gem **/*~ **/.*~ **/*.rbc coverage*)
|
22
|
+
end
|
23
|
+
|
24
|
+
##
|
25
|
+
# Define tasks for plugin.
|
26
|
+
|
27
|
+
def define_clean_tasks
|
28
|
+
desc 'Clean up all the extras.'
|
29
|
+
task :clean => [ :clobber_docs, :clobber_package ] do
|
30
|
+
clean_globs.each do |pattern|
|
31
|
+
files = Dir[pattern]
|
32
|
+
rm_rf files, :verbose => true unless files.empty?
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/lib/hoe/debug.rb
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
##
|
2
|
+
# Debug plugin for hoe.
|
3
|
+
#
|
4
|
+
# === Tasks Provided:
|
5
|
+
#
|
6
|
+
# check_manifest:: Verify the manifest.
|
7
|
+
# config_hoe:: Create a fresh ~/.hoerc file.
|
8
|
+
# debug_gem:: Show information about the gem.
|
9
|
+
|
10
|
+
module Hoe::Debug
|
11
|
+
Hoe.plugin :debug
|
12
|
+
|
13
|
+
# :stopdoc:
|
14
|
+
|
15
|
+
DIFF = if Hoe::WINDOZE
|
16
|
+
'diff.exe'
|
17
|
+
else
|
18
|
+
if system("gdiff", __FILE__, __FILE__)
|
19
|
+
'gdiff' # solaris and kin suck
|
20
|
+
else
|
21
|
+
'diff'
|
22
|
+
end
|
23
|
+
end unless defined? DIFF
|
24
|
+
|
25
|
+
# :startdoc:
|
26
|
+
|
27
|
+
##
|
28
|
+
# Define tasks for plugin.
|
29
|
+
|
30
|
+
def define_debug_tasks
|
31
|
+
desc 'Create a fresh ~/.hoerc file.'
|
32
|
+
task :config_hoe do
|
33
|
+
with_config do |config, path|
|
34
|
+
File.open(path, "w") do |f|
|
35
|
+
YAML.dump(Hoe::DEFAULT_CONFIG.merge(config), f)
|
36
|
+
end
|
37
|
+
|
38
|
+
editor = ENV['EDITOR'] || 'vi'
|
39
|
+
system "#{editor} #{path}" if ENV['SHOW_EDITOR'] != 'no'
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
desc 'Verify the manifest.'
|
44
|
+
task :check_manifest => :clean do
|
45
|
+
f = "Manifest.tmp"
|
46
|
+
require 'find'
|
47
|
+
files = []
|
48
|
+
with_config do |config, _|
|
49
|
+
exclusions = config["exclude"]
|
50
|
+
abort "exclude entry missing from .hoerc. Aborting." if exclusions.nil?
|
51
|
+
Find.find '.' do |path|
|
52
|
+
next unless File.file? path
|
53
|
+
next if path =~ exclusions
|
54
|
+
files << path[2..-1]
|
55
|
+
end
|
56
|
+
files = files.sort.join "\n"
|
57
|
+
File.open f, 'w' do |fp| fp.puts files end
|
58
|
+
system "#{DIFF} -du Manifest.txt #{f}"
|
59
|
+
rm f
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
desc 'Show information about the gem.'
|
64
|
+
task :debug_gem do
|
65
|
+
puts spec.to_ruby
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
data/lib/hoe/deps.rb
ADDED
@@ -0,0 +1,169 @@
|
|
1
|
+
require 'rubygems/remote_fetcher'
|
2
|
+
|
3
|
+
##
|
4
|
+
# Deps plugin for hoe.
|
5
|
+
#
|
6
|
+
# === Tasks Provided:
|
7
|
+
#
|
8
|
+
# check_extra_deps:: Install missing dependencies.
|
9
|
+
# deps:email:: Print a contact list for gems dependent on this gem
|
10
|
+
# deps:fetch:: Fetch all the dependent gems of this gem into tarballs
|
11
|
+
# deps:list:: List all the dependent gems of this gem
|
12
|
+
|
13
|
+
module Hoe::Deps
|
14
|
+
Hoe.plugin :deps
|
15
|
+
|
16
|
+
##
|
17
|
+
# The main rubygems repository.
|
18
|
+
|
19
|
+
GEMURL = URI.parse 'http://gems.rubyforge.org'
|
20
|
+
|
21
|
+
##
|
22
|
+
# Define tasks for plugin.
|
23
|
+
|
24
|
+
def define_deps_tasks
|
25
|
+
namespace :deps do
|
26
|
+
desc "List all the dependent gems of this gem"
|
27
|
+
task :list do
|
28
|
+
gems = self.get_gems_by_name
|
29
|
+
gem = gems[self.name]
|
30
|
+
|
31
|
+
abort "Couldn't find gem: #{self.name}" unless gem
|
32
|
+
|
33
|
+
deps = self.dependent_upon self.name
|
34
|
+
max = deps.map { |s| s.full_name.size }.max
|
35
|
+
|
36
|
+
puts " dependents:"
|
37
|
+
unless deps.empty? then
|
38
|
+
deps.sort_by { |spec| spec.full_name }.each do |spec|
|
39
|
+
vers = spec.dependencies.find {|s| s.name == name }.requirement_list
|
40
|
+
puts " %-*s - %s" % [max, spec.full_name, vers.join(", ")]
|
41
|
+
end
|
42
|
+
else
|
43
|
+
puts " none"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
desc "Print a contact list for gems dependent on this gem"
|
48
|
+
task :email do
|
49
|
+
gems = self.get_gems_by_name
|
50
|
+
gem = gems[self.name]
|
51
|
+
|
52
|
+
abort "Couldn't find gem: #{self.name}" unless gem
|
53
|
+
|
54
|
+
deps = self.dependent_upon self.name
|
55
|
+
|
56
|
+
email = deps.map { |s| s.email }.flatten.sort.uniq
|
57
|
+
email = email.map { |s| s.split(/,\s*/) }.flatten.sort.uniq
|
58
|
+
|
59
|
+
email.map! { |s| # don't you people realize how easy this is?
|
60
|
+
s.gsub(/ at | _at_ |\s*(atmark|@nospam@|-at?-|@at?@|<at?>|\[at?\]|\(at?\))\s*/i, '@').gsub(/\s*(dot|\[d(ot)?\]|\.dot\.)\s*/i, '.').gsub(/\s+com$/, '.com')
|
61
|
+
}
|
62
|
+
|
63
|
+
bad, good = email.partition { |e| e !~ /^[\w.+-]+\@[\w.+-]+$/ }
|
64
|
+
|
65
|
+
warn "Rejecting #{bad.size} email. I couldn't unmunge them." unless
|
66
|
+
bad.empty?
|
67
|
+
|
68
|
+
puts good.join(", ")
|
69
|
+
end
|
70
|
+
|
71
|
+
desc "Fetch all the dependent gems of this gem into tarballs"
|
72
|
+
task :fetch do
|
73
|
+
gems = self.get_gems_by_name
|
74
|
+
gem = gems[self.name]
|
75
|
+
deps = self.dependent_upon self.name
|
76
|
+
|
77
|
+
mkdir "deps" unless File.directory? "deps"
|
78
|
+
Dir.chdir "deps" do
|
79
|
+
begin
|
80
|
+
deps.sort_by { |spec| spec.full_name }.each do |spec|
|
81
|
+
full_name = spec.full_name
|
82
|
+
tgz_name = "#{full_name}.tgz"
|
83
|
+
gem_name = "#{full_name}.gem"
|
84
|
+
|
85
|
+
next if File.exist? tgz_name
|
86
|
+
FileUtils.rm_rf [full_name, gem_name]
|
87
|
+
|
88
|
+
begin
|
89
|
+
warn "downloading #{full_name}"
|
90
|
+
Gem::RemoteFetcher.fetcher.download(spec, GEMURL, Dir.pwd)
|
91
|
+
FileUtils.mv "cache/#{gem_name}", '.'
|
92
|
+
rescue Gem::RemoteFetcher::FetchError
|
93
|
+
warn " failed"
|
94
|
+
next
|
95
|
+
end
|
96
|
+
|
97
|
+
warn "converting #{gem_name} to tarball"
|
98
|
+
|
99
|
+
system "gem unpack #{gem_name} 2> /dev/null"
|
100
|
+
system "gem spec -l #{gem_name} > #{full_name}/gemspec.rb"
|
101
|
+
system "tar zmcf #{tgz_name} #{full_name}"
|
102
|
+
FileUtils.rm_rf [full_name, gem_name, "cache"]
|
103
|
+
end
|
104
|
+
ensure
|
105
|
+
FileUtils.rm_rf "cache"
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
desc 'Install missing dependencies.'
|
112
|
+
task :check_extra_deps do
|
113
|
+
# extra_deps = [["rubyforge", ">= 1.0.0"], ["rake", ">= 0.8.1"]]
|
114
|
+
extra_deps.each do |dep|
|
115
|
+
begin
|
116
|
+
gem(*dep)
|
117
|
+
rescue Gem::LoadError
|
118
|
+
install_gem(*dep)
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
##
|
125
|
+
# Return the rubygems source index.
|
126
|
+
|
127
|
+
def get_source_index
|
128
|
+
@@index ||= nil
|
129
|
+
|
130
|
+
return @@index if @@index
|
131
|
+
|
132
|
+
dump = unless File.exist? '.source_index' then
|
133
|
+
url = GEMURL + "Marshal.#{Gem.marshal_version}.Z"
|
134
|
+
dump = Gem::RemoteFetcher.fetcher.fetch_path url
|
135
|
+
dump = Gem.inflate dump
|
136
|
+
open '.source_index', 'wb' do |io| io.write dump end
|
137
|
+
dump
|
138
|
+
else
|
139
|
+
open '.source_index', 'rb' do |io| io.read end
|
140
|
+
end
|
141
|
+
|
142
|
+
@@index = Marshal.load dump
|
143
|
+
end
|
144
|
+
|
145
|
+
##
|
146
|
+
# Return the latest rubygems.
|
147
|
+
|
148
|
+
def get_latest_gems
|
149
|
+
@@cache ||= get_source_index.latest_specs
|
150
|
+
end
|
151
|
+
|
152
|
+
##
|
153
|
+
# Return a hash of the latest rubygems keyed by name.
|
154
|
+
|
155
|
+
def get_gems_by_name
|
156
|
+
@@by_name ||= Hash[*get_latest_gems.map { |gem|
|
157
|
+
[gem.name, gem, gem.full_name, gem]
|
158
|
+
}.flatten]
|
159
|
+
end
|
160
|
+
|
161
|
+
##
|
162
|
+
# Return all the dependencies on the named rubygem.
|
163
|
+
|
164
|
+
def dependent_upon name
|
165
|
+
get_latest_gems.find_all { |gem|
|
166
|
+
gem.dependencies.any? { |dep| dep.name == name }
|
167
|
+
}
|
168
|
+
end
|
169
|
+
end
|
data/lib/hoe/flay.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
##
|
2
|
+
# Flay plugin for hoe.
|
3
|
+
#
|
4
|
+
# === Tasks Provided:
|
5
|
+
#
|
6
|
+
# flay:: Analyze for code duplication.
|
7
|
+
|
8
|
+
module Hoe::Flay
|
9
|
+
Hoe.plugin :flay
|
10
|
+
|
11
|
+
##
|
12
|
+
# Optional: flay threshold to determine threshold failure. [default: 1200-100]
|
13
|
+
|
14
|
+
attr_accessor :flay_threshold
|
15
|
+
|
16
|
+
##
|
17
|
+
# Initialize variables for plugin.
|
18
|
+
|
19
|
+
def initialize_flay
|
20
|
+
self.flay_threshold ||= timebomb 1200, 100 # 80% of average :(
|
21
|
+
end
|
22
|
+
|
23
|
+
##
|
24
|
+
# Define tasks for plugin.
|
25
|
+
|
26
|
+
def define_flay_tasks
|
27
|
+
begin
|
28
|
+
require 'flay'
|
29
|
+
require 'flay_task'
|
30
|
+
FlayTask.new :flay, self.flay_threshold
|
31
|
+
rescue Exception
|
32
|
+
# skip
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/lib/hoe/flog.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
##
|
2
|
+
# Flog plugin for hoe.
|
3
|
+
#
|
4
|
+
# === Tasks Provided:
|
5
|
+
#
|
6
|
+
# flog:: Analyze code complexity.
|
7
|
+
|
8
|
+
module Hoe::Flog
|
9
|
+
Hoe.plugin :flog
|
10
|
+
|
11
|
+
##
|
12
|
+
# Optional: flog threshold to determine threshold failure. [default: 1500-200]
|
13
|
+
|
14
|
+
attr_accessor :flog_threshold
|
15
|
+
|
16
|
+
##
|
17
|
+
# Initialize variables for plugin.
|
18
|
+
|
19
|
+
def initialize_flog
|
20
|
+
self.flog_threshold ||= timebomb 1500, 1000 # 80% of average :(
|
21
|
+
end
|
22
|
+
|
23
|
+
##
|
24
|
+
# Define tasks for plugin.
|
25
|
+
|
26
|
+
def define_flog_tasks
|
27
|
+
begin
|
28
|
+
require 'flog'
|
29
|
+
require 'flog_task'
|
30
|
+
FlogTask.new :flog, self.flog_threshold
|
31
|
+
rescue Exception
|
32
|
+
# skip
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/lib/hoe/inline.rb
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
##
|
2
|
+
# Hoe allows bundling of pre-compiled extensions in the +package+ task.
|
3
|
+
#
|
4
|
+
# To create a package for your current platform:
|
5
|
+
#
|
6
|
+
# rake package INLINE=1
|
7
|
+
#
|
8
|
+
# This will force Hoe analize your +Inline+ already compiled
|
9
|
+
# extensions and include them in your gem.
|
10
|
+
#
|
11
|
+
# If somehow you need to force a specific platform:
|
12
|
+
#
|
13
|
+
# rake package INLINE=1 FORCE_PLATFORM=mswin32
|
14
|
+
#
|
15
|
+
# This will set the +Gem::Specification+ platform to the one indicated in
|
16
|
+
# +FORCE_PLATFORM+ (instead of default Gem::Platform::CURRENT)
|
17
|
+
|
18
|
+
module Hoe::Inline
|
19
|
+
|
20
|
+
##
|
21
|
+
# Define tasks for plugin.
|
22
|
+
|
23
|
+
def define_inline_tasks
|
24
|
+
if ENV['INLINE'] then
|
25
|
+
s.platform = ENV['FORCE_PLATFORM'] || Gem::Platform::CURRENT
|
26
|
+
|
27
|
+
# Try collecting Inline extensions for +name+
|
28
|
+
if defined?(Inline) then
|
29
|
+
directory 'lib/inline'
|
30
|
+
|
31
|
+
dlext = Config::CONFIG['DLEXT']
|
32
|
+
|
33
|
+
Inline.registered_inline_classes.each do |cls|
|
34
|
+
name = cls.name # TODO: what about X::Y::Z?
|
35
|
+
# name of the extension is CamelCase
|
36
|
+
alternate_name = if name =~ /[A-Z]/ then
|
37
|
+
name.gsub(/([A-Z])/, '_\1').downcase.sub(/^_/, '')
|
38
|
+
elsif name =~ /_/ then
|
39
|
+
name.capitalize.gsub(/_([a-z])/) { $1.upcase }
|
40
|
+
end
|
41
|
+
extensions = Dir.chdir(Inline::directory) {
|
42
|
+
Dir["Inline_{#{name},#{alternate_name}}_*.#{dlext}"]
|
43
|
+
}
|
44
|
+
|
45
|
+
extensions.each do |ext|
|
46
|
+
# add the inlined extension to the spec files
|
47
|
+
s.files += ["lib/inline/#{ext}"]
|
48
|
+
|
49
|
+
# include the file in the tasks
|
50
|
+
file "lib/inline/#{ext}" => ["lib/inline"] do
|
51
|
+
cp File.join(Inline::directory, ext), "lib/inline"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
data/lib/hoe/package.rb
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
##
|
2
|
+
# Package plugin for hoe.
|
3
|
+
#
|
4
|
+
# === Tasks Provided:
|
5
|
+
#
|
6
|
+
# install_gem:: Install the package as a gem.
|
7
|
+
# release:: Package and upload the release to rubyforge.
|
8
|
+
|
9
|
+
module Hoe::Package
|
10
|
+
Hoe.plugin :package
|
11
|
+
|
12
|
+
##
|
13
|
+
# Optional: Should package create a tarball? [default: true]
|
14
|
+
|
15
|
+
attr_accessor :need_tar
|
16
|
+
|
17
|
+
##
|
18
|
+
# Optional: Should package create a zipfile? [default: false]
|
19
|
+
|
20
|
+
attr_accessor :need_zip
|
21
|
+
|
22
|
+
##
|
23
|
+
# Initialize variables for plugin.
|
24
|
+
|
25
|
+
def initialize_package
|
26
|
+
self.need_tar ||= true
|
27
|
+
self.need_zip ||= false
|
28
|
+
end
|
29
|
+
|
30
|
+
##
|
31
|
+
# Define tasks for plugin.
|
32
|
+
|
33
|
+
def define_package_tasks
|
34
|
+
Rake::GemPackageTask.new spec do |pkg|
|
35
|
+
pkg.need_tar = @need_tar
|
36
|
+
pkg.need_zip = @need_zip
|
37
|
+
end
|
38
|
+
|
39
|
+
desc 'Install the package as a gem.'
|
40
|
+
task :install_gem => [:clean, :package, :check_extra_deps] do
|
41
|
+
install_gem Dir['pkg/*.gem'].first
|
42
|
+
end
|
43
|
+
|
44
|
+
desc 'Package and upload the release to rubyforge.'
|
45
|
+
task :release => [:clean, :package] do |t|
|
46
|
+
v = ENV["VERSION"] or abort "Must supply VERSION=x.y.z"
|
47
|
+
abort "Versions don't match #{v} vs #{version}" if v != version
|
48
|
+
pkg = "pkg/#{name}-#{version}"
|
49
|
+
|
50
|
+
if $DEBUG then
|
51
|
+
puts "release_id = rf.add_release #{rubyforge_name.inspect}, #{name.inspect}, #{version.inspect}, \"#{pkg}.tgz\""
|
52
|
+
puts "rf.add_file #{rubyforge_name.inspect}, #{name.inspect}, release_id, \"#{pkg}.gem\""
|
53
|
+
end
|
54
|
+
|
55
|
+
rf = RubyForge.new.configure
|
56
|
+
puts "Logging in"
|
57
|
+
rf.login
|
58
|
+
|
59
|
+
c = rf.userconfig
|
60
|
+
c["release_notes"] = description if description
|
61
|
+
c["release_changes"] = changes if changes
|
62
|
+
c["preformatted"] = true
|
63
|
+
|
64
|
+
files = [(@need_tar ? "#{pkg}.tgz" : nil),
|
65
|
+
(@need_zip ? "#{pkg}.zip" : nil),
|
66
|
+
"#{pkg}.gem"].compact
|
67
|
+
|
68
|
+
puts "Releasing #{name} v. #{version}"
|
69
|
+
rf.add_release rubyforge_name, name, version, *files
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
##
|
74
|
+
# Install the named gem.
|
75
|
+
|
76
|
+
def install_gem name, version = nil
|
77
|
+
gem_cmd = Gem.default_exec_format % 'gem'
|
78
|
+
sudo = 'sudo ' unless Hoe::WINDOZE
|
79
|
+
local = '--local' unless version
|
80
|
+
version = "--version '#{version}'" if version
|
81
|
+
sh "#{sudo}#{gem_cmd} install #{local} #{name} #{version}"
|
82
|
+
end
|
83
|
+
end
|