Class: RUGS::Client
- Inherits:
-
Object
- Object
- RUGS::Client
- Extended by:
- Commandable
- Defined in:
- lib/rugs/client.rb
Instance Method Summary collapse
- #create(repo_name, *remote) ⇒ Object
- #default_remotes ⇒ Object
- #defaults ⇒ Object
- #remote_add(remote, url_path, default = false) ⇒ Object
- #remote_list ⇒ Object
- #remote_remove(remote) ⇒ Object
- #remotes ⇒ Object
- #set_default(remote, is_default = true) ⇒ Object
- #unset_default(remote) ⇒ Object
Instance Method Details
#create(repo_name, *remote) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/rugs/client.rb', line 29 def create(repo_name, *remote) just_name = repo_name.split("/").last make_local_repo(repo_name) add_defaults(repo_name) make_hooks(repo_name) FileUtils.cd repo_name unless remote.empty? make_remote_repo(just_name, remote.last) end "Created #{just_name} locally#{" and on remote #{remote.last}" unless remote.empty?}" end |
#default_remotes ⇒ Object
83 84 85 86 87 |
# File 'lib/rugs/client.rb', line 83 def default_remotes @default_remotes ||= remote_list.select do |remote, keys| keys[:default] end end |
#defaults ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/rugs/client.rb', line 19 def defaults default_remotes.collect do |remote, keys| url = keys[:url] path = keys[:path] default = keys[:default] "#{remote}: #{url}#{":#{path}" if path}; default? #{default}" end.insert(0, "Default remotes:") end |
#remote_add(remote, url_path, default = false) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/rugs/client.rb', line 46 def remote_add(remote, url_path, default=false) url, path = url_path.split(":") default = (remote == 'origin' || default == 'default') remote_list.merge!(remote => {url: url, path: path, default: default}) Config.save("remotes", remote_list) puts "Added remote #{remote}." remotes end |
#remote_list ⇒ Object
89 90 91 |
# File 'lib/rugs/client.rb', line 89 def remote_list @remote_list ||= Config.load("remotes") end |
#remote_remove(remote) ⇒ Object
59 60 61 62 63 64 65 |
# File 'lib/rugs/client.rb', line 59 def remote_remove(remote) remote_list.delete(remote) Config.save("remotes", remote_list) puts "Removed remote #{remote}." remotes end |
#remotes ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'lib/rugs/client.rb', line 9 def remotes remote_list.collect do |remote, keys| url = keys[:url] path = keys[:path] default = keys[:default] "#{remote}: #{url}#{":#{path}" if path}; default? #{default}" end.insert(0, "All remotes:") end |
#set_default(remote, is_default = true) ⇒ Object
68 69 70 71 72 73 74 75 76 |
# File 'lib/rugs/client.rb', line 68 def set_default(remote, is_default=true) remote_list[remote][:default] = is_default if is_default "Set #{remote} as a default" else "Removed #{remote} from defaults" end remotes end |
#unset_default(remote) ⇒ Object
79 80 81 |
# File 'lib/rugs/client.rb', line 79 def unset_default(remote) set_default remote, false end |