lazyatom-gem-this 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +1 -1
- data/Rakefile.erb +3 -3
- data/bin/gem-this +6 -72
- data/lib/gem_this.rb +81 -0
- data/lib/rubygems_plugin.rb +11 -3
- metadata +2 -1
data/Rakefile
CHANGED
@@ -15,7 +15,7 @@ spec = Gem::Specification.new do |s|
|
|
15
15
|
|
16
16
|
# Change these as appropriate
|
17
17
|
s.name = "gem-this"
|
18
|
-
s.version = "0.2.
|
18
|
+
s.version = "0.2.1"
|
19
19
|
s.summary = "Make existing code into a gem, without any fuss."
|
20
20
|
s.author = "James Adam"
|
21
21
|
s.email = "james@lazyatom.com"
|
data/Rakefile.erb
CHANGED
@@ -34,7 +34,7 @@ end
|
|
34
34
|
spec = Gem::Specification.new do |s|
|
35
35
|
|
36
36
|
# Change these as appropriate
|
37
|
-
s.name = "<%=
|
37
|
+
s.name = "<%= name %>"
|
38
38
|
s.version = "0.1.0"
|
39
39
|
s.summary = "What this thing does"
|
40
40
|
s.author = "<%= author_name %>"
|
@@ -74,7 +74,7 @@ spec = Gem::Specification.new do |s|
|
|
74
74
|
|
75
75
|
# If you want to publish automatically to rubyforge, you'll may need
|
76
76
|
# to tweak this, and the publishing task below too.
|
77
|
-
s.rubyforge_project = "<%=
|
77
|
+
s.rubyforge_project = "<%= name %>"
|
78
78
|
end
|
79
79
|
|
80
80
|
# This task actually builds the gem. We also regenerate a static
|
@@ -133,7 +133,7 @@ begin
|
|
133
133
|
)
|
134
134
|
|
135
135
|
host = "#{config['username']}@rubyforge.org"
|
136
|
-
remote_dir = "/var/www/gforge-projects/<%=
|
136
|
+
remote_dir = "/var/www/gforge-projects/<%= name %>/" # Should be the same as the rubyforge project name
|
137
137
|
local_dir = 'rdoc'
|
138
138
|
|
139
139
|
Rake::SshDirPublisher.new(host, remote_dir, local_dir).upload
|
data/bin/gem-this
CHANGED
@@ -1,86 +1,20 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require '
|
3
|
+
require 'gem_this'
|
4
4
|
|
5
5
|
args = ARGV.dup
|
6
6
|
|
7
7
|
if args.first =~ /-?-h/
|
8
|
-
puts
|
8
|
+
puts GemThis::SUMMARY
|
9
9
|
puts "Usage: #{__FILE__} [-d -h] [gem name]"
|
10
10
|
puts "If a gem name is not given, the name of the current directory will be used as the gem"
|
11
11
|
puts "-h help, prints out this message."
|
12
|
-
puts "-d
|
13
|
-
exit
|
12
|
+
puts "-d #{GemThis::DEBUG_MESSAGE}"
|
13
|
+
exit
|
14
14
|
end
|
15
15
|
|
16
16
|
debug = args.delete("-d")
|
17
17
|
|
18
|
-
|
18
|
+
GemThis.new(args.first || File.basename(Dir.pwd), debug).create_rakefile
|
19
19
|
|
20
|
-
|
21
|
-
Etc.getpwnam(ENV['USER']).gecos rescue ENV['USER'] # for Windows
|
22
|
-
end
|
23
|
-
|
24
|
-
def author_email
|
25
|
-
"youremail@example.com"
|
26
|
-
end
|
27
|
-
|
28
|
-
def author_url
|
29
|
-
"http://yoursite.example.com"
|
30
|
-
end
|
31
|
-
|
32
|
-
def using_rspec?
|
33
|
-
File.directory?('spec')
|
34
|
-
end
|
35
|
-
|
36
|
-
def using_test_unit?
|
37
|
-
File.directory?('test')
|
38
|
-
end
|
39
|
-
|
40
|
-
def has_executables?
|
41
|
-
File.directory?('bin')
|
42
|
-
end
|
43
|
-
|
44
|
-
def dirs_to_include
|
45
|
-
%w(bin test spec lib).select { |d| File.directory?(d) }.join(",")
|
46
|
-
end
|
47
|
-
|
48
|
-
def readme
|
49
|
-
Dir['*'].find { |f| f =~ /readme/i }
|
50
|
-
end
|
51
|
-
|
52
|
-
def files_in_root
|
53
|
-
Dir['*'].reject { |f| File.directory?(f) }.join(" ")
|
54
|
-
end
|
55
|
-
|
56
|
-
def using_git?
|
57
|
-
File.exist?(".git")
|
58
|
-
end
|
59
|
-
|
60
|
-
def add_to_gitignore
|
61
|
-
return unless File.exist?(".gitignore")
|
62
|
-
ignores = File.readlines(".gitignore")
|
63
|
-
ignores += ["pkg", "rdoc"]
|
64
|
-
File.open(".gitignore", "w") { |f| f.write ignores.map { |l| l.strip }.uniq.join("\n") }
|
65
|
-
end
|
66
|
-
|
67
|
-
require 'erb'
|
68
|
-
|
69
|
-
template = ERB.new File.read(File.join(File.dirname(__FILE__), '..', 'Rakefile.erb')), nil, '<>'
|
70
|
-
rakefile = template.result(binding)
|
71
|
-
|
72
|
-
if debug
|
73
|
-
puts rakefile
|
74
|
-
exit(0)
|
75
|
-
else
|
76
|
-
if File.exist?('Rakefile')
|
77
|
-
puts "Appended to existing Rakefile"
|
78
|
-
File.open('Rakefile', 'a') { |f| 2.times { f.puts }; f.write rakefile }
|
79
|
-
else
|
80
|
-
puts "Writing new Rakefile"
|
81
|
-
File.open('Rakefile', 'w') { |f| f.write rakefile }
|
82
|
-
end
|
83
|
-
add_to_gitignore if using_git?
|
84
|
-
end
|
85
|
-
|
86
|
-
exit(0)
|
20
|
+
exit
|
data/lib/gem_this.rb
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
require 'erb'
|
2
|
+
require 'etc'
|
3
|
+
|
4
|
+
class GemThis
|
5
|
+
SUMMARY = "Creates a Rakefile suitable for turning the current project into a gem."
|
6
|
+
DEBUG_MESSAGE = "debug, only prints out the generated Rakefile."
|
7
|
+
|
8
|
+
attr_reader :name, :debug
|
9
|
+
|
10
|
+
def initialize(name, debug)
|
11
|
+
@name = name
|
12
|
+
@debug = debug
|
13
|
+
end
|
14
|
+
|
15
|
+
def create_rakefile
|
16
|
+
template = ERB.new File.read(File.join(File.dirname(__FILE__), '..', 'Rakefile.erb')), nil, '<>'
|
17
|
+
rakefile = template.result(binding)
|
18
|
+
|
19
|
+
if debug
|
20
|
+
puts rakefile
|
21
|
+
else
|
22
|
+
if File.exist?('Rakefile')
|
23
|
+
puts "Appended to existing Rakefile"
|
24
|
+
File.open('Rakefile', 'a') { |f| 2.times { f.puts }; f.write rakefile }
|
25
|
+
else
|
26
|
+
puts "Writing new Rakefile"
|
27
|
+
File.open('Rakefile', 'w') { |f| f.write rakefile }
|
28
|
+
end
|
29
|
+
add_to_gitignore if using_git?
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def author_name
|
36
|
+
Etc.getpwnam(ENV['USER']).gecos rescue ENV['USER'] # for Windows
|
37
|
+
end
|
38
|
+
|
39
|
+
def author_email
|
40
|
+
"youremail@example.com"
|
41
|
+
end
|
42
|
+
|
43
|
+
def author_url
|
44
|
+
"http://yoursite.example.com"
|
45
|
+
end
|
46
|
+
|
47
|
+
def using_rspec?
|
48
|
+
File.directory?('spec')
|
49
|
+
end
|
50
|
+
|
51
|
+
def using_test_unit?
|
52
|
+
File.directory?('test')
|
53
|
+
end
|
54
|
+
|
55
|
+
def has_executables?
|
56
|
+
File.directory?('bin')
|
57
|
+
end
|
58
|
+
|
59
|
+
def dirs_to_include
|
60
|
+
%w(bin test spec lib).select { |d| File.directory?(d) }.join(",")
|
61
|
+
end
|
62
|
+
|
63
|
+
def readme
|
64
|
+
Dir['*'].find { |f| f =~ /readme/i }
|
65
|
+
end
|
66
|
+
|
67
|
+
def files_in_root
|
68
|
+
Dir['*'].reject { |f| File.directory?(f) }.join(" ")
|
69
|
+
end
|
70
|
+
|
71
|
+
def using_git?
|
72
|
+
File.exist?(".git")
|
73
|
+
end
|
74
|
+
|
75
|
+
def add_to_gitignore
|
76
|
+
return unless File.exist?(".gitignore")
|
77
|
+
ignores = File.readlines(".gitignore")
|
78
|
+
ignores += ["pkg", "rdoc"]
|
79
|
+
File.open(".gitignore", "w") { |f| f.write ignores.map { |l| l.strip }.uniq.join("\n") }
|
80
|
+
end
|
81
|
+
end
|
data/lib/rubygems_plugin.rb
CHANGED
@@ -1,13 +1,21 @@
|
|
1
1
|
require 'rubygems/command_manager'
|
2
2
|
require 'rubygems/command'
|
3
|
-
|
3
|
+
require 'gem_this'
|
4
|
+
|
4
5
|
class Gem::Commands::ThisCommand < Gem::Command
|
5
6
|
def initialize
|
6
|
-
super 'this',
|
7
|
+
super 'this', GemThis::SUMMARY, :debug => false
|
8
|
+
add_option('-d', '--debug', GemThis::DEBUG_MESSAGE) do |debug, options|
|
9
|
+
options[:debug] = debug
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def summary
|
14
|
+
GemThis::SUMMARY
|
7
15
|
end
|
8
16
|
|
9
17
|
def execute
|
10
|
-
|
18
|
+
GemThis.new(options[:args].first || File.basename(Dir.pwd), options[:debug]).create_rakefile
|
11
19
|
end
|
12
20
|
end
|
13
21
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lazyatom-gem-this
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Adam
|
@@ -26,6 +26,7 @@ files:
|
|
26
26
|
- Readme.markdown
|
27
27
|
- Rakefile.erb
|
28
28
|
- bin/gem-this
|
29
|
+
- lib/gem_this.rb
|
29
30
|
- lib/rubygems_plugin.rb
|
30
31
|
has_rdoc: false
|
31
32
|
homepage: http://github.com/lazyatom/gem-this
|