Class: A::Gem
- Inherits:
-
Object
- Object
- A::Gem
- Defined in:
- lib/commands/gem.rb
Class Method Summary collapse
- .index(config) ⇒ Object
- .make_dirs(config) ⇒ Object
- .make_rakefile(config) ⇒ Object
- .make_specfile(config) ⇒ Object
Class Method Details
.index(config) ⇒ Object
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/commands/gem.rb', line 79 def index(config) dir = config[:dir] target = config[:target] self.make_dirs(config) self.make_rakefile(config) self.make_specfile(config) IO.write "lib/#{dir}.rb",'' binfile=<<-eot #!/usr/bin/env ruby puts "hello world!" eot IO.write "bin/#{dir}",binfile FileUtils.chmod "u=wrx","bin/#{dir}" rescue nil #puts gemspec end |
.make_dirs(config) ⇒ Object
5 6 7 8 9 10 11 12 13 |
# File 'lib/commands/gem.rb', line 5 def make_dirs(config) dir = config[:dir] Dir.mkdir dir rescue nil Dir.chdir dir Dir.mkdir 'lib' rescue nil Dir.mkdir 'bin' rescue nil end |
.make_rakefile(config) ⇒ Object
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 |
# File 'lib/commands/gem.rb', line 15 def make_rakefile(config) dir = config[:dir] 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 "rake install\\n" puts "then run your app with:\\n#{dir}\\n" end end task :run do puts `gem build #{dir}.gemspec` puts `gem install --local \#{latest_gem}` puts "===output===" puts `#{dir}` end task :install do puts `gem install --local \#{latest_gem}` end task :push do puts "pusing \#{latest_gem}..." puts `gem push \#{latest_gem}` if $?.success? puts "https://rubygems.org/gems/#{dir}" end end task :i=>:install eot IO.write "rakefile.rb",rakefile end |
.make_specfile(config) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/commands/gem.rb', line 58 def make_specfile(config) dir = config[:dir] 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 end |