mspac 0.2.7 → 0.3.0

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: 505169a560cee6762ad4d33918457e7e7b0fe3ee
4
- data.tar.gz: fc80f7d307db2fcd808a5422a0ee1605da4388ca
3
+ metadata.gz: bc9b4c5cf07936d804430a524e80596432812d75
4
+ data.tar.gz: d5b8fd7f13e87f73ee15f9fb6e22899dc3daf565
5
5
  SHA512:
6
- metadata.gz: 90ed333ff3a3422630f0193d418f9442d2acfd44945722ef14f7fd0237d4e1f2f79209dadb64790cd3ebbeeba67a2c736faedf10fc47e12433120f156195a893
7
- data.tar.gz: 976dcc5a5aa886186cf278cb5a1895621bfe18be1c2d5300abe80036c8ec8b24af05090483a69bab2f3bd0fcbe75e8f3e5fa3cd6b5f48d7def2b6d1255170189
6
+ metadata.gz: 3cd180a86cf6980c36ba81d70684e9e4856208322aeb46896a5b66105c531d44a8a54e088f5e0a20a15c51ae06cee30d6700902761e5f32dd59b0f90175957ab
7
+ data.tar.gz: 45ab1681fdca5555b13cb8a6abfa38f76bf24e7d558d15523137b82f2f9fc07d3d71ad48ee7e35c8abe4adcaccad5ce202560422e386c04cb52d6e78acf8345b
@@ -6,8 +6,8 @@ require "scoobydoo"
6
6
 
7
7
  class MsPac
8
8
  def cached
9
- return @pellets.keys.sort.delete_if do |name|
10
- !@pellets[name].cached?
9
+ return @pellets.keys.sort.keep_if do |name|
10
+ @pellets[name].cached?
11
11
  end
12
12
  end
13
13
 
@@ -30,7 +30,7 @@ class MsPac
30
30
 
31
31
  @pellets_dir = Pathname.new("~/.mspac/pellets").expand_path
32
32
  if (@pellets_dir.nil? || !@pellets_dir.exist?)
33
- raise Error::PelletRepoError.new
33
+ raise Error::PelletRepo.new
34
34
  end
35
35
  end
36
36
  private :ensure_pellets_repo
@@ -56,14 +56,14 @@ class MsPac
56
56
  @@hilight = hilight
57
57
  FileUtils.mkdir_p(Pathname.new("~/.mspac").expand_path)
58
58
  @mspac_dir = Pathname.new("~/.mspac").expand_path
59
- @pm = PackageManager.new
59
+ @pm = PackageManager.new(self)
60
60
  @vcs = VersionControl.new("git")
61
61
  load_pellets
62
62
  end
63
63
 
64
64
  def install(pellets, force = false)
65
65
  if (pellets.nil? || pellets.empty?)
66
- raise Error::MissingPelletError.new
66
+ raise Error::MissingPellet.new
67
67
  end
68
68
 
69
69
  pellets.each do |name|
@@ -79,7 +79,7 @@ class MsPac
79
79
  pellet.install
80
80
  end
81
81
  else
82
- raise Error::MissingPelletError.new(name)
82
+ raise Error::MissingPellet.new(name)
83
83
  end
84
84
  end
85
85
  end
@@ -96,7 +96,7 @@ class MsPac
96
96
  @pellets = Hash.new
97
97
  Dir["#{@pellets_dir}/*.pellet"].each do |pellet|
98
98
  begin
99
- p = Pellet.new(JSON.parse(File.read(pellet)))
99
+ p = Pellet.new(JSON.parse(File.read(pellet)), @pm)
100
100
  @pellets[p.name] = p
101
101
  rescue JSON::ParserError => e
102
102
  puts hilight_error("#{pellet} is not valid JSON!")
@@ -110,14 +110,14 @@ class MsPac
110
110
 
111
111
  def lock(pellets)
112
112
  if (pellets.nil? || pellets.empty?)
113
- raise Error::MissingPelletError.new
113
+ raise Error::MissingPellet.new
114
114
  end
115
115
 
116
116
  pellets.each do |name|
117
117
  if (@pellets.has_key?(name))
118
118
  @pellets[name].lock
119
119
  else
120
- raise Error::MissingPelletError.new(name)
120
+ raise Error::MissingPellet.new(name)
121
121
  end
122
122
  end
123
123
  end
@@ -135,14 +135,14 @@ class MsPac
135
135
 
136
136
  def remove(pellets, nosave)
137
137
  if (pellets.nil? || pellets.empty?)
138
- raise Error::MissingPelletError.new
138
+ raise Error::MissingPellet.new
139
139
  end
140
140
 
141
141
  pellets.each do |name|
142
142
  if (@pellets.has_key?(name))
143
143
  @pellets[name].remove(nosave)
144
144
  else
145
- raise Error::MissingPelletError.new(name)
145
+ raise Error::MissingPellet.new(name)
146
146
  end
147
147
  end
148
148
  end
@@ -158,14 +158,14 @@ class MsPac
158
158
 
159
159
  def unlock(pellets)
160
160
  if (pellets.nil? || pellets.empty?)
161
- raise Error::MissingPelletError.new
161
+ raise Error::MissingPellet.new
162
162
  end
163
163
 
164
164
  pellets.each do |name|
165
165
  if (@pellets.has_key?(name))
166
166
  @pellets[name].unlock
167
167
  else
168
- raise Error::MissingPelletError.new(name)
168
+ raise Error::MissingPellet.new(name)
169
169
  end
170
170
  end
171
171
  end
@@ -1,8 +1,8 @@
1
1
  class MsPac::Error < RuntimeError
2
2
  end
3
3
 
4
- require "mspac/error/missing_pellet_error"
5
- require "mspac/error/pellet_not_installed_error"
6
- require "mspac/error/pellet_repo_error"
7
- require "mspac/error/unsupported_package_manager_error"
8
- require "mspac/error/unsupported_vcs_error"
4
+ require "mspac/error/missing_pellet"
5
+ require "mspac/error/pellet_not_installed"
6
+ require "mspac/error/pellet_repo"
7
+ require "mspac/error/unsupported_package_manager"
8
+ require "mspac/error/unsupported_vcs"
@@ -1,4 +1,4 @@
1
- class MsPac::Error::MissingPelletError < MsPac::Error
1
+ class MsPac::Error::MissingPellet < MsPac::Error
2
2
  def initialize(pellet = nil)
3
3
  if (pellet)
4
4
  super("Pellet not found: #{pellet}")
@@ -1,4 +1,4 @@
1
- class MsPac::Error::PelletNotInstalledError < MsPac::Error
1
+ class MsPac::Error::PelletNotInstalled < MsPac::Error
2
2
  def initialize(pellet = "unknown")
3
3
  super("Pellet not installed: #{pellet}")
4
4
  end
@@ -1,4 +1,4 @@
1
- class MsPac::Error::PelletRepoError < MsPac::Error
1
+ class MsPac::Error::PelletRepo < MsPac::Error
2
2
  def initialize
3
3
  super("Could not update pellet repo")
4
4
  end
@@ -1,4 +1,4 @@
1
- class MsPac::Error::UnsupportedPackageManagerError < MsPac::Error
1
+ class MsPac::Error::UnsupportedPackageManager < MsPac::Error
2
2
  def initialize(pkg_mgr = "unknown")
3
3
  super("Unsupported package manager: #{pkg_mgr}")
4
4
  end
@@ -1,4 +1,4 @@
1
- class MsPac::Error::UnsupportedVCSError < MsPac::Error
1
+ class MsPac::Error::UnsupportedVCS < MsPac::Error
2
2
  def initialize(vcs = "unknown")
3
3
  super("Unsupported version control system: #{vcs}")
4
4
  end
@@ -1,6 +1,7 @@
1
1
  require "scoobydoo"
2
2
 
3
3
  class MsPac::PackageManager
4
+ attr_reader :mspac
4
5
  attr_reader :pkgmgr
5
6
 
6
7
  def alt_install(packages, pkgmgr = @pkgmgr)
@@ -10,25 +11,27 @@ class MsPac::PackageManager
10
11
  end
11
12
  end
12
13
 
13
- def initialize
14
+ def initialize(mspac)
15
+ @mspac = mspac
16
+
14
17
  if (ScoobyDoo.where_are_you("apt-get"))
15
18
  @pkgmgr = "apt-get"
16
19
  elsif (ScoobyDoo.where_are_you("brew"))
17
- raise MsPac::Error::UnsupportedPackageManagerError.new(
20
+ raise MsPac::Error::UnsupportedPackageManager.new(
18
21
  "brew"
19
22
  )
20
23
  elsif (ScoobyDoo.where_are_you("pacman"))
21
24
  @pkgmgr = "pacman"
22
25
  elsif (ScoobyDoo.where_are_you("yum"))
23
- raise MsPac::Error::UnsupportedPackageManagerError.new(
26
+ raise MsPac::Error::UnsupportedPackageManager.new(
24
27
  "yum"
25
28
  )
26
29
  elsif (ScoobyDoo.where_are_you("zipper"))
27
- raise MsPac::Error::UnsupportedPackageManagerError.new(
30
+ raise MsPac::Error::UnsupportedPackageManager.new(
28
31
  "zipper"
29
32
  )
30
33
  else
31
- raise MsPac::Error::UnsupportedPackageManagerError.new
34
+ raise MsPac::Error::UnsupportedPackageManager.new
32
35
  end
33
36
  end
34
37
 
@@ -42,9 +45,11 @@ class MsPac::PackageManager
42
45
  when "apt-get"
43
46
  system("sudo apt-get install -y #{pkgs}")
44
47
  when "brew"
45
- raise MsPac::Error::UnsupportedPackageManagerError.new(
48
+ raise MsPac::Error::UnsupportedPackageManager.new(
46
49
  "brew"
47
50
  )
51
+ when "mspac"
52
+ @mspac.install(pkgs.split(" "))
48
53
  when "pacman"
49
54
  system("sudo pacman --needed --noconfirm -S #{pkgs}")
50
55
  when "perl"
@@ -54,15 +59,15 @@ class MsPac::PackageManager
54
59
  when "python3"
55
60
  system("umask 022 && sudo python3 -m pip install #{pkgs}")
56
61
  when "yum"
57
- raise MsPac::Error::UnsupportedPackageManagerError.new(
62
+ raise MsPac::Error::UnsupportedPackageManager.new(
58
63
  "yum"
59
64
  )
60
65
  when "zipper"
61
- raise MsPac::Error::UnsupportedPackageManagerError.new(
66
+ raise MsPac::Error::UnsupportedPackageManager.new(
62
67
  "zipper"
63
68
  )
64
69
  else
65
- raise MsPac::Error::UnsupportedPackageManagerError.new
70
+ raise MsPac::Error::UnsupportedPackageManager.new
66
71
  end
67
72
  end
68
73
  private :pkgmgr_install
@@ -21,9 +21,19 @@ class MsPac::Pellet < Hash
21
21
  end
22
22
 
23
23
  def execute(operation)
24
- Dir.chdir("#{@@install_dir}/#{name}") do
25
- system(["umask 022"].concat(self[operation]).join("; "))
26
- end if (!self[operation].empty?)
24
+ if (self["vcs"] != "powerpellet")
25
+ Dir.chdir("#{@@install_dir}/#{name}") do
26
+ system(
27
+ ["umask 022"].concat(self[operation]).join("; ")
28
+ )
29
+ end if (!self[operation].empty?)
30
+ else
31
+ if (!self[operation].empty?)
32
+ system(
33
+ ["umask 022"].concat(self[operation]).join("; ")
34
+ )
35
+ end
36
+ end
27
37
  end
28
38
  private :execute
29
39
 
@@ -47,8 +57,12 @@ class MsPac::Pellet < Hash
47
57
  end
48
58
 
49
59
  def get_deps
50
- puts hilight_status("Installing dependencies...")
51
- @pm.install([self["vcs"]].concat(self["deps"][@pm.pkgmgr]))
60
+ puts hilight_status("Installing dependencies for #{name}...")
61
+ deps = Array.new
62
+ deps.push(self["vcs"]) if (self["vcs"] != "powerpellet")
63
+ deps.push(self["deps"][@pm.pkgmgr])
64
+ @pm.install(deps)
65
+ @pm.install(self["deps"]["mspac"], "mspac")
52
66
  @pm.install(self["deps"]["perl"], "perl")
53
67
  @pm.install(self["deps"]["python2"], "python2")
54
68
  @pm.install(self["deps"]["python3"], "python3")
@@ -81,7 +95,7 @@ class MsPac::Pellet < Hash
81
95
  end
82
96
  private :hilight_installed
83
97
 
84
- def hilight_name(name = @name)
98
+ def hilight_name(name)
85
99
  return name if (!MsPac.hilight?)
86
100
  return name.light_white
87
101
  end
@@ -93,18 +107,18 @@ class MsPac::Pellet < Hash
93
107
  end
94
108
  private :hilight_status
95
109
 
96
- def initialize(json)
110
+ def initialize(json, pm)
97
111
  json.keys.each do |key|
98
112
  self[key] = json[key]
99
113
  end
100
114
 
101
- @pm = MsPac::PackageManager.new
115
+ @pm = pm
102
116
  @vcs = MsPac::VersionControl.new(self["vcs"])
103
117
  end
104
118
 
105
119
  def install
106
- if (!cached?)
107
- raise MsPac::Error::PelletNotInstalledError.new(name)
120
+ if (!cached? && (self["vcs"] != "powerpellet"))
121
+ raise MsPac::Error::PelletNotInstalled.new(name)
108
122
  end
109
123
 
110
124
  link if (!installed?)
@@ -119,10 +133,12 @@ class MsPac::Pellet < Hash
119
133
  end
120
134
 
121
135
  def link
122
- if (!cached?)
123
- raise MsPac::Error::PelletNotInstalledError.new(name)
136
+ if (!cached? && (self["vcs"] != "powerpellet"))
137
+ raise MsPac::Error::PelletNotInstalled.new(name)
124
138
  end
125
139
 
140
+ return if (self["vcs"] == "powerpellet")
141
+
126
142
  puts hilight_status("Linking #{name}...")
127
143
  FileUtils.ln_sf(
128
144
  "#{@@cache_dir}/#{name}",
@@ -132,7 +148,7 @@ class MsPac::Pellet < Hash
132
148
 
133
149
  def lock
134
150
  if (!installed?)
135
- raise MsPac::Error::PelletNotInstalledError.new(name)
151
+ raise MsPac::Error::PelletNotInstalled.new(name)
136
152
  end
137
153
 
138
154
  puts hilight_status("Locking #{name}...")
@@ -144,17 +160,19 @@ class MsPac::Pellet < Hash
144
160
  end
145
161
 
146
162
  def purge
147
- if (!cached?)
148
- raise MsPac::Error::PelletNotInstalledError.new(name)
163
+ if (!cached? && (self["vcs"] != "powerpellet"))
164
+ raise MsPac::Error::PelletNotInstalled.new(name)
149
165
  end
150
166
 
167
+ return if (self["vcs"] == "powerpellet")
168
+
151
169
  puts hilight_status("Purging #{name}...")
152
170
  FileUtils.rm_rf("#{@@cache_dir}/#{name}")
153
171
  end
154
172
 
155
173
  def remove(nosave = false)
156
174
  if (!installed?)
157
- raise MsPac::Error::PelletNotInstalledError.new(name)
175
+ raise MsPac::Error::PelletNotInstalled.new(name)
158
176
  end
159
177
 
160
178
  puts hilight_status("Removing #{name}...")
@@ -181,7 +199,7 @@ class MsPac::Pellet < Hash
181
199
 
182
200
  def unlink
183
201
  if (!installed?)
184
- raise MsPac::Error::PelletNotInstalledError.new(name)
202
+ raise MsPac::Error::PelletNotInstalled.new(name)
185
203
  end
186
204
 
187
205
  puts hilight_status("Unlinking #{name}...")
@@ -190,7 +208,7 @@ class MsPac::Pellet < Hash
190
208
 
191
209
  def unlock
192
210
  if (!installed?)
193
- raise MsPac::Error::PelletNotInstalledError.new(name)
211
+ raise MsPac::Error::PelletNotInstalled.new(name)
194
212
  end
195
213
 
196
214
  puts hilight_status("Unlocking #{name}...")
@@ -199,9 +217,11 @@ class MsPac::Pellet < Hash
199
217
 
200
218
  def update(force = false)
201
219
  if (!installed?)
202
- raise MsPac::Error::PelletNotInstalledError.new(name)
220
+ raise MsPac::Error::PelletNotInstalled.new(name)
203
221
  end
204
222
 
223
+ return if (self["vcs"] == "powerpellet")
224
+
205
225
  Dir.chdir("#{@@install_dir}/#{name}") do
206
226
  if (Pathname.new(".mspac_lock").expand_path.exist?)
207
227
  puts hilight_error("Locked: #{name}")
@@ -5,47 +5,51 @@ class MsPac::VersionControl
5
5
  case @vcs
6
6
  when "git", "hg"
7
7
  system("#{@vcs} clone #{repo}")
8
+ when "powerpellet"
9
+ # do nothing
8
10
  else
9
- raise Error::UnsupportedVCSError.new(@vcs)
11
+ raise MsPac::Error::UnsupportedVCS.new(@vcs)
10
12
  end
11
13
  end
12
14
 
13
15
  def ignore_file_perms(name)
14
- Dir.chdir(name) do
15
- case @vcs
16
- when "git"
16
+ case @vcs
17
+ when "git"
18
+ Dir.chdir(name) do
17
19
  system("git config core.filemode false")
18
- when "hg"
19
- # do nothing
20
- else
21
- raise Error::UnsupportedVCSError.new(@vcs)
22
20
  end
21
+ when "hg", "powerpellet"
22
+ # do nothing
23
+ else
24
+ raise MsPac::Error::UnsupportedVCS.new(@vcs)
23
25
  end
24
26
  end
25
27
 
26
28
  def initialize(vcs)
27
29
  case vcs
28
30
  when "bzr"
29
- raise Error::UnsupportedVCSError.new(vcs)
30
- when "git"
31
- @vcs = vcs
32
- when "hg"
31
+ raise MsPac::Error::UnsupportedVCS.new(vcs)
32
+ when "git", "hg", "powerpellet"
33
33
  @vcs = vcs
34
34
  when "svn"
35
- raise Error::UnsupportedVCSError.new(vcs)
35
+ raise MsPac::Error::UnsupportedVCS.new(vcs)
36
36
  else
37
- raise Error::UnsupportedVCSError.new
37
+ raise MsPac::Error::UnsupportedVCS.new
38
38
  end
39
39
  end
40
40
 
41
41
  def revision
42
42
  case @vcs
43
43
  when "git"
44
- %x(git log --oneline | head -n 1 | awk '{print $1}')
44
+ return %x(
45
+ git log --oneline | head -n 1 | awk '{print $1}'
46
+ )
45
47
  when "hg"
46
- %(hg tip --template "{node}")
48
+ return %(hg tip --template "{node}")
49
+ when "powerpellet"
50
+ return "powerpellet"
47
51
  else
48
- raise Error::UnsupportedVCSError.new(@vcs)
52
+ raise MsPac::Error::UnsupportedVCS.new(@vcs)
49
53
  end
50
54
  end
51
55
 
@@ -55,8 +59,10 @@ class MsPac::VersionControl
55
59
  system("git reset && git pull")
56
60
  when "hg"
57
61
  system("hg pull && hg update")
62
+ when "powerpellet"
63
+ # do nothing
58
64
  else
59
- raise Error::UnsupportedVCSError.new(@vcs)
65
+ raise MsPac::Error::UnsupportedVCS.new(@vcs)
60
66
  end
61
67
  end
62
68
  end
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.2.7
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miles Whittaker
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-24 00:00:00.000000000 Z
11
+ date: 2016-06-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -39,7 +39,7 @@ dependencies:
39
39
  version: '0.1'
40
40
  - - ">="
41
41
  - !ruby/object:Gem::Version
42
- version: 0.1.0
42
+ version: 0.1.3
43
43
  type: :runtime
44
44
  prerelease: false
45
45
  version_requirements: !ruby/object:Gem::Requirement
@@ -49,7 +49,7 @@ dependencies:
49
49
  version: '0.1'
50
50
  - - ">="
51
51
  - !ruby/object:Gem::Version
52
- version: 0.1.0
52
+ version: 0.1.3
53
53
  - !ruby/object:Gem::Dependency
54
54
  name: scoobydoo
55
55
  requirement: !ruby/object:Gem::Requirement
@@ -84,11 +84,11 @@ files:
84
84
  - bin/mspac
85
85
  - lib/mspac.rb
86
86
  - lib/mspac/error.rb
87
- - lib/mspac/error/missing_pellet_error.rb
88
- - lib/mspac/error/pellet_not_installed_error.rb
89
- - lib/mspac/error/pellet_repo_error.rb
90
- - lib/mspac/error/unsupported_package_manager_error.rb
91
- - lib/mspac/error/unsupported_vcs_error.rb
87
+ - lib/mspac/error/missing_pellet.rb
88
+ - lib/mspac/error/pellet_not_installed.rb
89
+ - lib/mspac/error/pellet_repo.rb
90
+ - lib/mspac/error/unsupported_package_manager.rb
91
+ - lib/mspac/error/unsupported_vcs.rb
92
92
  - lib/mspac/package_manager.rb
93
93
  - lib/mspac/pellet.rb
94
94
  - lib/mspac/version_control.rb