copernicium 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/pushpull.rb +38 -37
- data/lib/ui.rb +10 -8
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7a5ffa814cbc75d8cef5aa496ae365e64055544f
|
4
|
+
data.tar.gz: dcdc64d513fc8d4ab767ca371446fd04897984a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dfa00b3ba05c58cb3c7f5fe99c7c910bc3e3ea09500d1473adaccd50640a11e0c8e554d234d14fb9e3609f09f7e58feb7bbca4d6813500b33c9c7ec37fe2d927
|
7
|
+
data.tar.gz: 2c29c875e7dcc63d6e0698e4c6ff414b1fb7806d277ce66718cb2e5a6f7bf7d300d0a8a73b72b2defa9888522894cbdb535489228597e3dfd4bba6f6f1bab1ce
|
data/lib/pushpull.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# Frank Tamburrino
|
2
|
-
# CSC
|
2
|
+
# CSC 254
|
3
3
|
# PushPull Module
|
4
|
-
# November
|
4
|
+
# November 7, 2015
|
5
5
|
#
|
6
6
|
# How to use for Push, Pull and Clone:
|
7
7
|
# Push - cn push <user> <repo.host:/dir/of/repo> <branch-name>
|
@@ -11,7 +11,6 @@
|
|
11
11
|
|
12
12
|
|
13
13
|
module Copernicium
|
14
|
-
include Workspace
|
15
14
|
module PushPull
|
16
15
|
def PushPull.UICommandParser(comm)
|
17
16
|
# handle parsing out remote info
|
@@ -32,11 +31,11 @@ module Copernicium
|
|
32
31
|
@@user = comm.opts
|
33
32
|
case comm.command
|
34
33
|
when "clone"
|
35
|
-
|
34
|
+
PushPull.pclone
|
36
35
|
when "push"
|
37
|
-
|
36
|
+
PushPull.ppush
|
38
37
|
when "pull"
|
39
|
-
|
38
|
+
PushPull.ppull
|
40
39
|
when 'test'
|
41
40
|
# avoid error while doing unit testing
|
42
41
|
else
|
@@ -45,9 +44,11 @@ module Copernicium
|
|
45
44
|
end
|
46
45
|
|
47
46
|
# tell user to set up their ssh keys
|
48
|
-
def PushPull.connection_failure(str = '')
|
47
|
+
def PushPull.connection_failure(str = '', err = '')
|
48
|
+
puts "Make sure SSH keys are setup to the host server.".grn
|
49
49
|
puts "Connection error while: ".red + str
|
50
|
-
puts "
|
50
|
+
puts "Error: ".red + err.to_s
|
51
|
+
puts "Backtrace:\n\t".red + "#{err.backtrace.join("\n\t")}"
|
51
52
|
puts "User: ".yel + @@user
|
52
53
|
puts "Host: ".yel + @@host
|
53
54
|
puts "Path: ".yel + @@path
|
@@ -63,8 +64,8 @@ module Copernicium
|
|
63
64
|
begin
|
64
65
|
Net::SSH.start(@@host, @@user) { |ssh| yield ssh }
|
65
66
|
true
|
66
|
-
rescue
|
67
|
-
connection_failure 'trying to execute a command'
|
67
|
+
rescue => error
|
68
|
+
connection_failure 'trying to execute a command', error
|
68
69
|
end
|
69
70
|
end
|
70
71
|
|
@@ -73,11 +74,11 @@ module Copernicium
|
|
73
74
|
#
|
74
75
|
# Description:
|
75
76
|
# Grabs a repository from a remote server
|
76
|
-
def PushPull.
|
77
|
+
def PushPull.pclone
|
77
78
|
begin
|
78
79
|
PushPull.fetch
|
79
|
-
rescue
|
80
|
-
connection_failure 'trying to clone a repo'
|
80
|
+
rescue => error
|
81
|
+
connection_failure 'trying to clone a repo', error
|
81
82
|
end
|
82
83
|
end
|
83
84
|
|
@@ -90,8 +91,8 @@ module Copernicium
|
|
90
91
|
begin
|
91
92
|
Net::SCP.start(@@host, @@user) { |scp| yield scp }
|
92
93
|
true
|
93
|
-
rescue
|
94
|
-
connection_failure 'trying to upload a file'
|
94
|
+
rescue => error
|
95
|
+
connection_failure 'trying to upload a file', error
|
95
96
|
end
|
96
97
|
end
|
97
98
|
|
@@ -102,34 +103,34 @@ module Copernicium
|
|
102
103
|
# a net/scp wrapper to copy from server, can take a block or do a one-off copy without one
|
103
104
|
#
|
104
105
|
# local: where we want to put the file, not needed for blocked calls
|
105
|
-
def PushPull.fetch
|
106
|
-
if
|
106
|
+
def PushPull.fetch
|
107
|
+
if block_given? # fetch more than one file or folder
|
107
108
|
begin
|
108
|
-
Net::SCP.start(@@host, @@user)
|
109
|
-
|
110
|
-
|
111
|
-
rescue # no ssh keys are setup, die
|
112
|
-
connection_failure 'trying to copy a file'
|
109
|
+
Net::SCP.start(@@host, @@user) { |scp| yield scp }
|
110
|
+
rescue => error
|
111
|
+
connection_failure "trying to fetch files", error
|
113
112
|
end
|
114
113
|
|
115
|
-
else #
|
114
|
+
else # no block given, clone the repo
|
116
115
|
begin
|
117
|
-
Net::SCP.start(@@host, @@user)
|
118
|
-
|
119
|
-
|
116
|
+
Net::SCP.start(@@host, @@user) do |scp|
|
117
|
+
scp.download!(@@path, Dir.pwd, :recursive => true)
|
118
|
+
end
|
119
|
+
rescue => error
|
120
|
+
connection_failure 'trying to clone a repo', error
|
120
121
|
end
|
121
122
|
end
|
122
123
|
true
|
123
124
|
end
|
124
125
|
|
125
126
|
|
126
|
-
# Function:
|
127
|
+
# Function: ppush()
|
127
128
|
#
|
128
129
|
# Description:
|
129
130
|
# pushes local changes on the current branch to a remote branch
|
130
|
-
def PushPull.
|
131
|
+
def PushPull.ppush
|
131
132
|
begin
|
132
|
-
transfer do |ssh|
|
133
|
+
PushPull.transfer do |ssh|
|
133
134
|
# uploading our history to remote
|
134
135
|
ssh.upload!("#{Dir.pwd}/.cn/history",
|
135
136
|
"#{@@path}/.cn/merging_#{@@user}")
|
@@ -142,25 +143,25 @@ module Copernicium
|
|
142
143
|
end
|
143
144
|
end # ssh
|
144
145
|
|
145
|
-
connect do |ssh|
|
146
|
+
PushPull.connect do |ssh|
|
146
147
|
ssh.exec! "cd #{@@path}"
|
147
148
|
puts ssh.exec! "cn update #{@@user}"
|
148
149
|
end
|
149
|
-
rescue
|
150
|
-
connection_failure "trying to push files"
|
150
|
+
rescue => error
|
151
|
+
connection_failure "trying to push files", error
|
151
152
|
end
|
152
153
|
true
|
153
154
|
end
|
154
155
|
|
155
156
|
|
156
|
-
# Function:
|
157
|
+
# Function: ppull()
|
157
158
|
#
|
158
159
|
# Description:
|
159
160
|
# pulls remote changes to the current branch from remote branch
|
160
161
|
#
|
161
|
-
def PushPull.
|
162
|
+
def PushPull.ppull
|
162
163
|
begin
|
163
|
-
fetch do |session|
|
164
|
+
PushPull.fetch do |session|
|
164
165
|
# uploading our history to remote
|
165
166
|
session.download!("#{@@path}/.cn/merging_#{@@user}",
|
166
167
|
"#{Dir.pwd}/.cn/history")
|
@@ -174,8 +175,8 @@ module Copernicium
|
|
174
175
|
end
|
175
176
|
system "cn update", @@user
|
176
177
|
puts "Remote pulled: ".grn + @@host + @@path
|
177
|
-
rescue
|
178
|
-
connection_failure "trying to pull files"
|
178
|
+
rescue => error
|
179
|
+
connection_failure "trying to pull files", error
|
179
180
|
end
|
180
181
|
true
|
181
182
|
end
|
data/lib/ui.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
# user interface module - parse and execute commands
|
2
2
|
# integrates all modules, central module
|
3
3
|
|
4
|
-
VERSION = "0.1.
|
4
|
+
VERSION = "0.1.4"
|
5
|
+
|
6
|
+
include Copernicium::PushPull
|
5
7
|
|
6
8
|
module Copernicium
|
7
9
|
# Communication object that will pass commands to backend modules
|
@@ -21,10 +23,10 @@ module Copernicium
|
|
21
23
|
end
|
22
24
|
end
|
23
25
|
|
24
|
-
# todo - consider refactoring some UIComm usage
|
25
26
|
# main driver for the command line user interface
|
26
27
|
module Driver
|
27
28
|
include Workspace # needed for most high level commands
|
29
|
+
include PushPull # needed for most high level commands
|
28
30
|
# Executes the required action for a given user command.
|
29
31
|
#
|
30
32
|
# Parameters:
|
@@ -53,7 +55,7 @@ module Copernicium
|
|
53
55
|
if cmd == 'init'
|
54
56
|
noroot?? init(args) : puts(IN_REPO_WARNING.yel, getroot)
|
55
57
|
elsif cmd == 'clone' # allow cloning a new repo
|
56
|
-
|
58
|
+
clonecn args
|
57
59
|
elsif noroot? # if not in a repo, warn them, tell how to create
|
58
60
|
puts NO_REPO_WARNING.yel
|
59
61
|
else # now, assume we are in a copernicum project
|
@@ -172,12 +174,12 @@ module Copernicium
|
|
172
174
|
end
|
173
175
|
end
|
174
176
|
|
175
|
-
def
|
177
|
+
def clonecn(args)
|
176
178
|
user = args.first
|
177
179
|
host = args.last
|
178
180
|
user = get "username for push" if user.nil?
|
179
181
|
host = get "host path (<host:/dir/of/repo>)" if host.nil? || user == host
|
180
|
-
comm = UIComm.new(command: 'clone',
|
182
|
+
comm = UIComm.new(command: 'clone', repo: host, opts: user)
|
181
183
|
PushPull.UICommandParser(comm)
|
182
184
|
return comm
|
183
185
|
end
|
@@ -187,7 +189,7 @@ module Copernicium
|
|
187
189
|
host = args.last
|
188
190
|
user = get "username for push" if user.nil?
|
189
191
|
host = get "host path (<host:/dir/of/repo>)" if host.nil? || user == host
|
190
|
-
comm = UIComm.new(command: 'push',
|
192
|
+
comm = UIComm.new(command: 'push', repo: host, opts: user)
|
191
193
|
PushPull.UICommandParser(comm)
|
192
194
|
return comm
|
193
195
|
end
|
@@ -197,7 +199,7 @@ module Copernicium
|
|
197
199
|
host = args.last
|
198
200
|
user = get "username for push" if user.nil?
|
199
201
|
host = get "host path (<host:/dir/of/repo>)" if host.nil? || user == host
|
200
|
-
comm = UIComm.new(command: 'pull',
|
202
|
+
comm = UIComm.new(command: 'pull', repo: host, opts: user)
|
201
203
|
PushPull.UICommandParser(comm)
|
202
204
|
return comm
|
203
205
|
end
|
@@ -282,7 +284,7 @@ module Copernicium
|
|
282
284
|
else
|
283
285
|
username = args.first
|
284
286
|
end
|
285
|
-
Repos.update(UIComm.new(command: 'update',
|
287
|
+
Repos.update(UIComm.new(command: 'update', opts: username))
|
286
288
|
end
|
287
289
|
end # Driver
|
288
290
|
end # Copernicium
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: copernicium
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Team Copernicium
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-12-
|
11
|
+
date: 2015-12-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: diffy
|