Class: Nucleon::Project::Github
- Defined in:
- lib/nucleon/project/github.rb
Class Method Summary collapse
-
.expand_url(path, editable = false) ⇒ Object
—————————————————————————– Utilities.
Instance Method Summary collapse
-
#client ⇒ Object
—————————————————————————– Property accessor / modifiers.
-
#init_auth ⇒ Object
—————————————————————————– Project operations.
-
#normalize(reload) ⇒ Object
—————————————————————————– Project plugin interface.
-
#set_connection ⇒ Object
—.
Methods inherited from Git
#add_remote_url, #add_subproject, #can_persist?, #checkout, #cli, #commit, #config, #delete_config, #delete_remote, #delete_subproject, #ignore, #init_cache, #init_remotes, #load_revision, #load_subprojects, #new?, #project_directory?, #pull, #push, #remote, #set_config, #set_location, #set_remote, #subproject?, #subproject_config, #synchronize, #top?, #translate_edit_url, #translate_url, #update_subprojects
Class Method Details
.expand_url(path, editable = false) ⇒ Object
Utilities
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/nucleon/project/github.rb', line 82 def self.(path, editable = false) if path =~ /^[a-zA-Z0-9_\-\/]+(.git)?$/ path = path.gsub('.git', '') if editable protocol = 'git@' separator = ':' else protocol = 'https://' separator = '/' end url = "#{protocol}github.com#{separator}" + path + '.git' else url = path end url end |
Instance Method Details
#client ⇒ Object
Property accessor / modifiers
37 38 39 40 |
# File 'lib/nucleon/project/github.rb', line 37 def client set_connection unless @client @client end |
#init_auth ⇒ Object
Project operations
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 77 |
# File 'lib/nucleon/project/github.rb', line 45 def init_auth super do external_ip = get(:external_ip, Nucleon.ip_address) internal_ip = get(:internal_ip, nil) if internal_ip && internal_ip.to_s != external_ip location = "#{external_ip}[#{internal_ip}]" else location = external_ip end key_id = ENV['USER'] + '@' + location ssh_key = public_key_str if private_key && ssh_key deploy_keys = client.deploy_keys(plugin_name) github_id = nil keys_match = true deploy_keys.each do |key_resource| if key_resource.title == key_id github_id = key_resource.id keys_match = false if key_resource.key != ssh_key break end end client.remove_deploy_key(myself.plugin_name, github_id) if github_id && ! keys_match client.add_deploy_key(myself.plugin_name, key_id, ssh_key) verify_key end end end |
#normalize(reload) ⇒ Object
Project plugin interface
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/nucleon/project/github.rb', line 13 def normalize(reload) if reference = delete(:reference, nil) myself.plugin_name = normalize_reference(reference) else if url = get(:url, nil) myself.plugin_name = url set(:url, myself.class.(url, get(:ssh, false))) end end super end |
#set_connection ⇒ Object
27 28 29 30 31 32 |
# File 'lib/nucleon/project/github.rb', line 27 def set_connection require 'octokit' @client = Octokit::Client.new :netrc => true @client.login end |