4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
# File 'lib/commands/gem.rb', line 4
def index(config)
dir = config[:dir]
target = config[:target]
Dir.mkdir dir rescue nil
Dir.chdir dir
Dir.mkdir 'lib' rescue nil
Dir.mkdir 'bin' rescue nil
rakefile = <<-eot
def latest_gem
Dir["*.gem"].sort.last
end
task :default do
puts `gem build #{dir}.gemspec`
if $?.success?
puts "\\nyou can install it with:"
puts "gem install --local \#{latest_gem}\\n"
puts "run your app with:\\n#{dir}\\n"
end
end
eot
gemspec = <<-eot
Gem::Specification.new do |s|
s.name = "#{dir}"
s.version = "0.0.1"
s.summary = "summary"
s.authors = ['authors']
s.license = 'MIT'
s.email = '[email protected]'
s.homepage = 'https://rubygems.org/gems/a'
s.files = Dir["lib/*.rb"]
s.executables = ["#{dir}"]
end
eot
IO.write "#{dir}.gemspec",gemspec
IO.write "rakefile.rb",rakefile
IO.write "lib/#{dir}.rb",''
binfile=<<-eot
#!/usr/bin/env ruby
puts "hello world!"
eot
IO.write "bin/#{dir}",binfile
end
|