# File lib/bones/app/git.rb, line 6
6: def self.initialize_git
7: Bones::App::Create.class_eval {
8: include ::Bones::App::Git
9:
10: option
11: option('Git Options:')
12: option('--git', 'Initialize a git repository for the project.',
13: lambda { config[:git] = true }
14: )
15: option('--github DESCRIPTION', 'Create a new GitHub project.',
16: 'Requires a project description.',
17: lambda { |desc|
18: config[:git] = true,
19: config[:github] = true,
20: config[:github_desc] = desc
21: }
22: )
23:
24: in_output_directory :initialize_git, :initialize_github
25: }
26: end
# File lib/bones/app/git.rb, line 85
85: def github_url
86: user = Git.global_config['github.user']
87: return unless user
88: "http://github.com/#{user}/#{name}"
89: end
# File lib/bones/app/git.rb, line 28
28: def initialize_git
29: return unless @config[:git]
30:
31: File.rename('.bnsignore', '.gitignore') if test ff, '.bnsignore'
32:
33: author = Git.global_config['user.name']
34: email = Git.global_config['user.email']
35:
36: if test ff, 'Rakefile'
37: lines = File.readlines 'Rakefile'
38:
39: lines.each do |line|
40: case line
41: when /^\s*authors\s+/
42: line.replace " authors '#{author}'" unless author.nil? or line !~ /FIXME/
43: when /^\s*email\s+/
44: line.replace " email '#{email}'" unless email.nil? or line !~ /FIXME/
45: when /^\s*url\s+/
46: next unless @config[:github]
47: url = github_url
48: line.replace " url '#{url}'" unless url.nil? or line !~ /FIXME/
49: when /^\s*\}\s*$/
50: line.insert 0, " ignore_file '.gitignore'\n" if test ff, '.gitignore'
51: end
52: end
53:
54: File.open('Rakefile', 'w') {|fd| fd.puts lines}
55: end
56:
57: @git = Git.init
58: @git.add
59: @git.commit "Initial commit to #{name}."
60: end
# File lib/bones/app/git.rb, line 62
62: def initialize_github
63: return unless @config[:github]
64:
65: user = Git.global_config['github.user']
66: token = Git.global_config['github.token']
67:
68: raise ::Bones::App::Error, 'A GitHub username was not found in the global configuration.' unless user
69: raise ::Bones::App::Error, 'A GitHub token was not found in the global configuration.' unless token
70:
71: Net::HTTP.post_form(
72: URI.parse('http://github.com/api/v2/yaml/repos/create'),
73: 'login' => user,
74: 'token' => token,
75: 'name' => name,
76: 'description' => @config[:github_desc]
77: )
78:
79: @git.add_remote 'origin', "git@github.com:#{user}/#{name}.git"
80: @git.config 'branch.master.remote', 'origin'
81: @git.config 'branch.master.merge', 'refs/heads/master'
82: @git.push 'origin'
83: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.