mspac 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1b6590cb8c98b4d7b74bdec0c666a1cdf36dafae
4
- data.tar.gz: 335b53ae4914efdf3b07804ace2c4fc79a0622d2
3
+ metadata.gz: 6d5a3955b6bd3f52aeb79bcd9203ba0e18761100
4
+ data.tar.gz: 58d343c04ae9e2839dabb5ae40d50ea6a6a8d2d5
5
5
  SHA512:
6
- metadata.gz: 73325d405110ace0162e9ba368a4e686631e7864ba83b979d0d777e777c18ad0632e890fa5060c1166d47843be67cbacbfb7fb98834111ca6cd7b498ba8fe362
7
- data.tar.gz: c837b8963050a62419020d15bae674f8780a594962eefe7fd3b74a10c642f3285f5803582e1bf9b1dd94e737183debd55b31f3b7ac0afd1051feae178227f191
6
+ metadata.gz: 01cc8be8b59bb4ec74aa751b0f73235ca0d13405ca2fee19b7585d5895a4d09c5746d8dc2a9fd8a81d1ea59a3ef850e02abf20b2f43323eb80b97a28a134f7c0
7
+ data.tar.gz: e190d0e2d9ef39a93cde48d73b9e57b227c6779fa5a056755db47eb660db9c4c614e7e0b17d36b16b082622eb96dd617c125e6872bf546ec01f27d505c8e4e6d
data/bin/mspac CHANGED
@@ -26,13 +26,18 @@ end
26
26
 
27
27
  def parse(args)
28
28
  options = Hash.new
29
+ options["operation"] = nil
30
+
31
+ # Sync options
29
32
  options["clean"] = false
30
33
  options["force"] = false
31
- options["nosave"] = false
32
- options["operation"] = nil
33
34
  options["refresh"] = false
35
+ options["regex"] = false
34
36
  options["upgrade"] = false
35
37
 
38
+ # Remove options
39
+ options["nosave"] = false
40
+
36
41
  parser = OptionParser.new do |opts|
37
42
  opts.banner =
38
43
  "Usage: #{File.basename($0)} <operation> [OPTIONS] " \
@@ -101,12 +106,7 @@ def parse(args)
101
106
  "Remove pellets that are no longer installed",
102
107
  "from the cache"
103
108
  ) do
104
- if (options["operation"] == Operation::SYNC)
105
- options["clean"] = true
106
- else
107
- puts opts
108
- exit MsPacExit::INVALID_OPERATION
109
- end
109
+ options["clean"] = true
110
110
  end
111
111
 
112
112
  opts.on(
@@ -114,65 +114,30 @@ def parse(args)
114
114
  "--force",
115
115
  "Force a reinstall/recompilation of the pellet"
116
116
  ) do
117
- if (options["operation"] == Operation::SYNC)
118
- options["force"] = true
119
- else
120
- puts opts
121
- exit MsPacExit::INVALID_OPERATION
122
- end
117
+ options["force"] = true
123
118
  end
124
119
 
125
120
  opts.on(
126
121
  "-s",
127
- "--search=regex",
122
+ "--search",
128
123
  "Search each pellet for names matching the",
129
124
  "provided regex and display them"
130
- ) do |regex|
131
- if (
132
- (options["operation"] == Operation::SYNC) &&
133
- !options["upgrade"]
134
- )
135
- options["regex"] = regex
136
- else
137
- puts opts
138
- exit MsPacExit::INVALID_OPERATION
139
- end
125
+ ) do
126
+ options["regex"] = true
140
127
  end
141
128
 
142
129
  opts.on("-u", "--sysupgrade", "Upgrade all pellets") do
143
- if (
144
- (options["operation"] == Operation::SYNC) &&
145
- !options.has_key?("regex")
146
- )
147
- options["upgrade"] = true
148
- else
149
- puts opts
150
- exit MsPacExit::INVALID_OPERATION
151
- end
130
+ options["upgrade"] = true
152
131
  end
153
132
 
154
133
  opts.on("-y", "--refresh", "Refresh available pellets") do
155
- if (options["operation"] == Operation::SYNC)
156
- options["refresh"] = true
157
- else
158
- puts opts
159
- exit MsPacExit::INVALID_OPERATION
160
- end
134
+ options["refresh"] = true
161
135
  end
162
136
 
163
137
  opts.on("", "REMOVE OPTIONS")
164
138
 
165
- opts.on(
166
- "-n",
167
- "--nosave",
168
- "Completely remove pellet"
169
- ) do
170
- if (options["operation"] == Operation::REMOVE)
171
- options["nosave"] = true
172
- else
173
- puts opts
174
- exit MsPacExit::INVALID_OPERATION
175
- end
139
+ opts.on("-n", "--nosave", "Completely remove pellet") do
140
+ options["nosave"] = true
176
141
  end
177
142
  end
178
143
 
@@ -192,16 +157,126 @@ def parse(args)
192
157
  exit MsPacExit::MISSING_ARGUMENT
193
158
  end
194
159
 
195
- options["pellets"] = args
196
-
197
- if (options.has_key?("regex") && !options["pellets"].empty?)
160
+ if (!validate(options))
198
161
  puts parser
199
162
  exit MsPacExit::INVALID_OPERATION
200
163
  end
201
164
 
165
+ options["pellets"] = args
166
+
202
167
  return options
203
168
  end
204
169
 
170
+ def validate(options)
171
+ case options["operation"]
172
+ when Operation::LIST_CACHED
173
+ if (
174
+ options["clean"] ||
175
+ options["force"] ||
176
+ options["nosave"] ||
177
+ options["refresh"] ||
178
+ options["regex"] ||
179
+ options["upgrade"]
180
+ )
181
+ return false
182
+ end
183
+ when Operation::LIST_INSTALLED
184
+ if (
185
+ options["clean"] ||
186
+ options["force"] ||
187
+ options["nosave"] ||
188
+ options["refresh"] ||
189
+ options["regex"] ||
190
+ options["upgrade"]
191
+ )
192
+ return false
193
+ end
194
+ when Operation::LIST_PELLETS
195
+ if (
196
+ options["clean"] ||
197
+ options["force"] ||
198
+ options["nosave"] ||
199
+ options["refresh"] ||
200
+ options["regex"] ||
201
+ options["upgrade"]
202
+ )
203
+ return false
204
+ end
205
+ when Operation::LOCK
206
+ if (
207
+ options["clean"] ||
208
+ options["force"] ||
209
+ options["nosave"] ||
210
+ options["refresh"] ||
211
+ options["regex"] ||
212
+ options["upgrade"]
213
+ )
214
+ return false
215
+ end
216
+ when Operation::REMOVE
217
+ if (
218
+ options["clean"] ||
219
+ options["force"] ||
220
+ options["refresh"] ||
221
+ options["regex"] ||
222
+ options["upgrade"]
223
+ )
224
+ return false
225
+ end
226
+ when Operation::SYNC
227
+ return false if (options["nosave"])
228
+
229
+ if (options["clean"])
230
+ if (
231
+ options["force"] ||
232
+ options["regex"] ||
233
+ options["upgrade"]
234
+ )
235
+ return false
236
+ end
237
+ elsif (options["force"])
238
+ if (
239
+ options["clean"] ||
240
+ options["regex"] ||
241
+ options["upgrade"]
242
+ )
243
+ return false
244
+ end
245
+ elsif (options["regex"])
246
+ if (
247
+ options["clean"] ||
248
+ options["force"] ||
249
+ options["upgrade"]
250
+ )
251
+ return false
252
+ end
253
+ elsif (options["upgrade"])
254
+ if (
255
+ options["clean"] ||
256
+ options["force"] ||
257
+ options["regex"]
258
+ )
259
+ return false
260
+ end
261
+ end
262
+ when Operation::UNLOCK
263
+ if (
264
+ options["clean"] ||
265
+ options["force"] ||
266
+ options["nosave"] ||
267
+ options["refresh"] ||
268
+ options["regex"] ||
269
+ options["upgrade"]
270
+ )
271
+ return false
272
+ end
273
+ else
274
+ return false
275
+ end
276
+
277
+ return true
278
+ end
279
+
205
280
  # Parse CLI args
206
281
  options = parse(ARGV)
207
282
 
@@ -220,16 +295,17 @@ begin
220
295
  when Operation::REMOVE
221
296
  mspac.remove(options["pellets"], options["nosave"])
222
297
  when Operation::SYNC
223
- mspac.clean if (options["clean"])
224
298
  mspac.refresh if (options["refresh"])
225
299
 
226
- if (options.has_key?("regex"))
227
- mspac.search(options["regex"])
300
+ if (options["clean"])
301
+ mspac.clean
302
+ elsif (options["regex"])
303
+ mspac.search(options["pellets"].join(" "))
228
304
  elsif (options["upgrade"])
229
305
  mspac.upgrade
230
306
  else
231
307
  unless (
232
- (options["clean"] || options["refresh"]) &&
308
+ options["refresh"] &&
233
309
  (options["pellets"].nil? || options["pellets"].empty?)
234
310
  )
235
311
  mspac.install(options["pellets"], options["force"])
data/lib/mspac/pellet.rb CHANGED
@@ -50,6 +50,7 @@ class MsPac::Pellet < Hash
50
50
  else
51
51
  Dir.chdir(@@cache_dir) do
52
52
  @vcs.clone(self["repo"])
53
+ @vcs.ignore_file_perms(name)
53
54
  end
54
55
  end
55
56
  end
@@ -10,6 +10,19 @@ class MsPac::VersionControl
10
10
  end
11
11
  end
12
12
 
13
+ def ignore_file_perms(name)
14
+ Dir.chdir(name) do
15
+ case @vcs
16
+ when "git"
17
+ system("git config core.filemode false")
18
+ when "hg"
19
+ # do nothing
20
+ else
21
+ raise Error::UnsupportedVCSError.new(@vcs)
22
+ end
23
+ end
24
+ end
25
+
13
26
  def initialize(vcs)
14
27
  case vcs
15
28
  when "bzr"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mspac
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miles Whittaker
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-06 00:00:00.000000000 Z
11
+ date: 2015-12-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: scoobydoo