Class: Gem::Commands::BootstrapCommand
- Inherits:
-
Gem::Command
- Object
- Gem::Command
- Gem::Commands::BootstrapCommand
- Includes:
- CommandOptions, Gem::Commands, GemRelease, Helpers
- Defined in:
- lib/rubygems/commands/bootstrap_command.rb
Constant Summary collapse
- OPTIONS =
{ :gemspec => true, :strategy => 'git', :scaffold => false, :github => false }
Constants included from GemRelease
Instance Attribute Summary collapse
-
#arguments ⇒ Object
readonly
Returns the value of attribute arguments.
-
#usage ⇒ Object
readonly
Returns the value of attribute usage.
Instance Method Summary collapse
- #create_repo ⇒ Object
- #execute ⇒ Object
-
#initialize ⇒ BootstrapCommand
constructor
A new instance of BootstrapCommand.
- #write_gemspec ⇒ Object
- #write_rakefile ⇒ Object
- #write_scaffold ⇒ Object
- #write_version ⇒ Object
Constructor Details
#initialize ⇒ BootstrapCommand
Returns a new instance of BootstrapCommand.
12 13 14 15 16 17 18 19 |
# File 'lib/rubygems/commands/bootstrap_command.rb', line 12 def initialize super 'bootstrap', 'Bootstrap a new gem source repository', OPTIONS option :gemspec, '-g', 'Generate a .gemspec' option :strategy, '-f', 'Strategy for collecting files [glob|git] in .gemspec' option :scaffold, '-s', 'Scaffold lib/[gem_name]/version.rb README test/' option :github, '-h', 'Bootstrap a git repo, create on github and push' end |
Instance Attribute Details
#arguments ⇒ Object (readonly)
Returns the value of attribute arguments.
10 11 12 |
# File 'lib/rubygems/commands/bootstrap_command.rb', line 10 def arguments @arguments end |
#usage ⇒ Object (readonly)
Returns the value of attribute usage.
10 11 12 |
# File 'lib/rubygems/commands/bootstrap_command.rb', line 10 def usage @usage end |
Instance Method Details
#create_repo ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/rubygems/commands/bootstrap_command.rb', line 69 def create_repo = { :login => github_user, :token => github_token, :name => gem_name } = .map { |name, value| "-F '#{name}=#{value}'" }.join(' ') say 'Bootstrapializing git repository' `git init` say 'Staging files' `git add .` say 'Creating initial commit' `git commit -m 'initial commit'` say "Adding remote origin [email protected]:#{github_user}/#{gem_name}.git" `git remote add origin [email protected]:#{github_user}/#{gem_name}.git` say 'Creating repository on Github' silence { `curl #{} http://github.com/api/v2/yaml/repos/create` } say 'Pushing to Github' `git push origin master` end |
#execute ⇒ Object
21 22 23 24 25 |
# File 'lib/rubygems/commands/bootstrap_command.rb', line 21 def execute write_gemspec if [:gemspec] write_scaffold if [:scaffold] create_repo if [:github] end |
#write_gemspec ⇒ Object
27 28 29 |
# File 'lib/rubygems/commands/bootstrap_command.rb', line 27 def write_gemspec GemspecCommand.new.invoke end |
#write_rakefile ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/rubygems/commands/bootstrap_command.rb', line 49 def write_rakefile if File.exists?('Rakefile') say "Skipping Rakefile: already exists" else rakefile = <<RAKEFILE require 'rake' require 'rake/testtask' Rake::TestTask.new do |t| t.libs << 'lib' t.pattern = 'test/**/*_test.rb' t.verbose = false end task :default => :test RAKEFILE File.open('Rakefile', 'w').write(rakefile) end end |
#write_scaffold ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/rubygems/commands/bootstrap_command.rb', line 31 def write_scaffold say 'scaffolding lib/ README test/' `mkdir lib test` `touch README` write_version write_rakefile end |
#write_version ⇒ Object
39 40 41 42 43 44 45 46 47 |
# File 'lib/rubygems/commands/bootstrap_command.rb', line 39 def write_version version = Version.new() if File.exists?("#{version.filename}") say "Skipping #{version.filename}: already exists" else say "Creating #{version.filename}" version.write end end |