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
64
65
66
67
68
69
70
71
72
73
74
75
76
|
# 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 = "def latest_gem\n Dir[\"*.gem\"].sort.last\nend \n\ntask :default do\n puts `gem build \#{dir}.gemspec`\n if $?.success?\n puts \"\\\\nyou can install it with:\"\n puts \"rake install\\\\n\"\n puts \"then run your app with:\\\\n\#{dir}\\\\n\"\n\n end \nend\n\ntask :install do\n puts `gem install --local \\\#{latest_gem}`\nend\n\ntask :push do\n puts \"pusing \\\#{latest_gem}...\"\n exec \"gem push \\\#{latest_gem}\"\n if $?.success?\n puts \"https://rubygems.org/gems/\#{dir}\"\n end\nend \n\n"
gemspec = "Gem::Specification.new do |s|\n s.name = \"\#{dir}\"\n s.version = \"0.0.1\"\n s.summary = \"summary\"\n s.authors = ['authors']\n\n s.license = 'MIT'\n s.email = '[email protected]'\n s.homepage = 'https://rubygems.org/gems/a'\n\n s.files = Dir[\"lib/*.rb\"]\n s.executables = [\"\#{dir}\"]\nend\n eot\n IO.write \"\#{dir}.gemspec\",gemspec\n IO.write \"rakefile.rb\",rakefile\n IO.write \"lib/\#{dir}.rb\",''\n\n binfile=<<-eot\n#!/usr/bin/env ruby \nputs \"hello world!\"\n"
IO.write "bin/#{dir}",binfile
end
|