mspac 0.2.6 → 0.2.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/bin/mspac +3 -3
  3. data/lib/mspac.rb +23 -23
  4. data/lib/mspac/pellet.rb +62 -62
  5. metadata +7 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c0d3d32b85f604c9b5b5c88b68fc27eae2638a26
4
- data.tar.gz: 22a18b13b4009e0f956d362d2c230feb76a4929e
3
+ metadata.gz: 505169a560cee6762ad4d33918457e7e7b0fe3ee
4
+ data.tar.gz: fc80f7d307db2fcd808a5422a0ee1605da4388ca
5
5
  SHA512:
6
- metadata.gz: 001260a16b1ebcb733837d0e49d11207c3d99adeab458671d38e491bb1539177338baedf82a75dcc88d8903fcdaf6a2ad6bd7836bfb681e7ea9aed44c2035e6f
7
- data.tar.gz: 42892fb29b313a1144efe021dc9e643551bad6322b821b7db9cb238f2355f94a9702696c801d86eac48b32684fd7c32c1082c8746e31faa1366713fdeb961e84
6
+ metadata.gz: 90ed333ff3a3422630f0193d418f9442d2acfd44945722ef14f7fd0237d4e1f2f79209dadb64790cd3ebbeeba67a2c736faedf10fc47e12433120f156195a893
7
+ data.tar.gz: 976dcc5a5aa886186cf278cb5a1895621bfe18be1c2d5300abe80036c8ec8b24af05090483a69bab2f3bd0fcbe75e8f3e5fa3cd6b5f48d7def2b6d1255170189
data/bin/mspac CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require "colorize"
3
+ require "hilighter"
4
4
  require "io/wait"
5
5
  require "mspac"
6
6
  require "optparse"
@@ -162,7 +162,7 @@ def parse(args)
162
162
  end
163
163
 
164
164
  opts.on("--nocolor", "Disable colorized output") do
165
- String.disable_colorization = true
165
+ Hilighter.disable
166
166
  end
167
167
 
168
168
  opts.on(
@@ -318,7 +318,7 @@ end
318
318
  options = parse(ARGV)
319
319
 
320
320
  begin
321
- mspac = MsPac.new(!String.disable_colorization)
321
+ mspac = MsPac.new(!Hilighter.disable?)
322
322
 
323
323
  case options["operation"]
324
324
  when Operation::LIST_CACHED
@@ -1,4 +1,4 @@
1
- require "colorize"
1
+ require "hilighter"
2
2
  require "fileutils"
3
3
  require "json"
4
4
  require "pathname"
@@ -18,28 +18,11 @@ class MsPac
18
18
  # FIXME will miss pellets that get deleted by refresh
19
19
  end
20
20
 
21
- def self.colorize?
22
- @@colorize ||= false
23
- return @@colorize
24
- end
25
-
26
- def colorize_error(error)
27
- return error if (!@@colorize)
28
- return error.light_red
29
- end
30
- private :colorize_error
31
-
32
- def colorize_status(status)
33
- return status if (!@@colorize)
34
- return status.light_white
35
- end
36
- private :colorize_status
37
-
38
21
  def ensure_pellets_repo
39
22
  @pellets_dir = Pathname.new("~/.mspac/pellets").expand_path
40
23
  return if (@pellets_dir && @pellets_dir.exist?)
41
24
 
42
- puts colorize_status("Installing MsPac dependencies...")
25
+ puts hilight_status("Installing MsPac dependencies...")
43
26
  @pm.install(["git"]) if (ScoobyDoo.where_are_you("git").nil?)
44
27
  Dir.chdir(@mspac_dir) do
45
28
  @vcs.clone("https://gitlab.com/mjwhitta/pellets.git")
@@ -52,8 +35,25 @@ class MsPac
52
35
  end
53
36
  private :ensure_pellets_repo
54
37
 
55
- def initialize(colorize = false)
56
- @@colorize = colorize
38
+ def self.hilight?
39
+ @@hilight ||= false
40
+ return @@hilight
41
+ end
42
+
43
+ def hilight_error(error)
44
+ return error if (!@@hilight)
45
+ return error.light_red
46
+ end
47
+ private :hilight_error
48
+
49
+ def hilight_status(status)
50
+ return status if (!@@hilight)
51
+ return status.light_white
52
+ end
53
+ private :hilight_status
54
+
55
+ def initialize(hilight = false)
56
+ @@hilight = hilight
57
57
  FileUtils.mkdir_p(Pathname.new("~/.mspac").expand_path)
58
58
  @mspac_dir = Pathname.new("~/.mspac").expand_path
59
59
  @pm = PackageManager.new
@@ -99,7 +99,7 @@ class MsPac
99
99
  p = Pellet.new(JSON.parse(File.read(pellet)))
100
100
  @pellets[p.name] = p
101
101
  rescue JSON::ParserError => e
102
- puts colorize_error("#{pellet} is not valid JSON!")
102
+ puts hilight_error("#{pellet} is not valid JSON!")
103
103
  puts e.message.white.on_red
104
104
  rescue Exception => e
105
105
  puts e.message.white.on_red
@@ -127,7 +127,7 @@ class MsPac
127
127
  end
128
128
 
129
129
  def refresh
130
- puts colorize_status("Refreshing pellets...")
130
+ puts hilight_status("Refreshing pellets...")
131
131
  Dir.chdir(@pellets_dir) do
132
132
  @vcs.update
133
133
  end
@@ -1,64 +1,17 @@
1
- require "colorize"
1
+ require "hilighter"
2
2
  require "fileutils"
3
3
 
4
4
  class MsPac::Pellet < Hash
5
5
  @@cache_dir = Pathname("~/.mspac/cache").expand_path
6
6
  @@install_dir = Pathname("~/.mspac/installed").expand_path
7
7
 
8
- def colorize_cached(cached)
9
- if (!MsPac.colorize?)
10
- return "[cached]" if (cached)
11
- else
12
- return "[cached]".light_blue if (cached)
13
- end
14
- return ""
15
- end
16
- private :colorize_cached
17
-
18
- def colorize_error(error)
19
- return error if (!MsPac.colorize?)
20
- return error.light_red
21
- end
22
- private :colorize_error
23
-
24
- def colorize_installed(installed)
25
- if (!MsPac.colorize?)
26
- return "[installed]" if (installed)
27
- else
28
- return "[installed]".light_green if (installed)
29
- end
30
- return ""
31
- end
32
- private :colorize_installed
33
-
34
- def colorize_name(name = @name)
35
- return name if (!MsPac.colorize?)
36
- return name.light_white
37
- end
38
- private :colorize_name
39
-
40
- def colorize_status(status)
41
- return status if (!MsPac.colorize?)
42
- return status.light_white
43
- end
44
- private :colorize_status
45
-
46
- def initialize(json)
47
- json.keys.each do |key|
48
- self[key] = json[key]
49
- end
50
-
51
- @pm = MsPac::PackageManager.new
52
- @vcs = MsPac::VersionControl.new(self["vcs"])
53
- end
54
-
55
8
  def cached?
56
9
  Pathname.new("#{@@cache_dir}/#{name}").expand_path.exist?
57
10
  end
58
11
 
59
12
  def compile
60
13
  return if (self["compile"].empty?)
61
- puts colorize_status("Compiling #{name}...")
14
+ puts hilight_status("Compiling #{name}...")
62
15
  execute("compile")
63
16
  end
64
17
  private :compile
@@ -80,7 +33,7 @@ class MsPac::Pellet < Hash
80
33
 
81
34
  get_deps
82
35
 
83
- puts colorize_status("Fetching #{name}...")
36
+ puts hilight_status("Fetching #{name}...")
84
37
  if (Pathname.new("#{@@cache_dir}/#{name}").expand_path.exist?)
85
38
  Dir.chdir("#{@@cache_dir}/#{name}") do
86
39
  @vcs.update
@@ -94,7 +47,7 @@ class MsPac::Pellet < Hash
94
47
  end
95
48
 
96
49
  def get_deps
97
- puts colorize_status("Installing dependencies...")
50
+ puts hilight_status("Installing dependencies...")
98
51
  @pm.install([self["vcs"]].concat(self["deps"][@pm.pkgmgr]))
99
52
  @pm.install(self["deps"]["perl"], "perl")
100
53
  @pm.install(self["deps"]["python2"], "python2")
@@ -102,6 +55,53 @@ class MsPac::Pellet < Hash
102
55
  end
103
56
  private :get_deps
104
57
 
58
+ def hilight_cached(cached)
59
+ if (!MsPac.hilight?)
60
+ return "[cached]" if (cached)
61
+ else
62
+ return "[cached]".light_blue if (cached)
63
+ end
64
+ return ""
65
+ end
66
+ private :hilight_cached
67
+
68
+ def hilight_error(error)
69
+ return error if (!MsPac.hilight?)
70
+ return error.light_red
71
+ end
72
+ private :hilight_error
73
+
74
+ def hilight_installed(installed)
75
+ if (!MsPac.hilight?)
76
+ return "[installed]" if (installed)
77
+ else
78
+ return "[installed]".light_green if (installed)
79
+ end
80
+ return ""
81
+ end
82
+ private :hilight_installed
83
+
84
+ def hilight_name(name = @name)
85
+ return name if (!MsPac.hilight?)
86
+ return name.light_white
87
+ end
88
+ private :hilight_name
89
+
90
+ def hilight_status(status)
91
+ return status if (!MsPac.hilight?)
92
+ return status.light_white
93
+ end
94
+ private :hilight_status
95
+
96
+ def initialize(json)
97
+ json.keys.each do |key|
98
+ self[key] = json[key]
99
+ end
100
+
101
+ @pm = MsPac::PackageManager.new
102
+ @vcs = MsPac::VersionControl.new(self["vcs"])
103
+ end
104
+
105
105
  def install
106
106
  if (!cached?)
107
107
  raise MsPac::Error::PelletNotInstalledError.new(name)
@@ -110,7 +110,7 @@ class MsPac::Pellet < Hash
110
110
  link if (!installed?)
111
111
  compile
112
112
 
113
- puts colorize_status("Installing #{name}...")
113
+ puts hilight_status("Installing #{name}...")
114
114
  execute("install")
115
115
  end
116
116
 
@@ -123,7 +123,7 @@ class MsPac::Pellet < Hash
123
123
  raise MsPac::Error::PelletNotInstalledError.new(name)
124
124
  end
125
125
 
126
- puts colorize_status("Linking #{name}...")
126
+ puts hilight_status("Linking #{name}...")
127
127
  FileUtils.ln_sf(
128
128
  "#{@@cache_dir}/#{name}",
129
129
  "#{@@install_dir}/#{name}"
@@ -135,7 +135,7 @@ class MsPac::Pellet < Hash
135
135
  raise MsPac::Error::PelletNotInstalledError.new(name)
136
136
  end
137
137
 
138
- puts colorize_status("Locking #{name}...")
138
+ puts hilight_status("Locking #{name}...")
139
139
  FileUtils.touch("#{@@install_dir}/#{name}/.mspac_lock")
140
140
  end
141
141
 
@@ -148,7 +148,7 @@ class MsPac::Pellet < Hash
148
148
  raise MsPac::Error::PelletNotInstalledError.new(name)
149
149
  end
150
150
 
151
- puts colorize_status("Purging #{name}...")
151
+ puts hilight_status("Purging #{name}...")
152
152
  FileUtils.rm_rf("#{@@cache_dir}/#{name}")
153
153
  end
154
154
 
@@ -157,7 +157,7 @@ class MsPac::Pellet < Hash
157
157
  raise MsPac::Error::PelletNotInstalledError.new(name)
158
158
  end
159
159
 
160
- puts colorize_status("Removing #{name}...")
160
+ puts hilight_status("Removing #{name}...")
161
161
  execute("remove")
162
162
  unlink
163
163
  purge if (nosave)
@@ -169,8 +169,8 @@ class MsPac::Pellet < Hash
169
169
 
170
170
  def to_s
171
171
  header = [
172
- colorize_name(name),
173
- colorize_installed(installed?) || colorize_cached(cached?)
172
+ hilight_name(name),
173
+ hilight_installed(installed?) || hilight_cached(cached?)
174
174
  ].join(" ")
175
175
  return [
176
176
  header,
@@ -184,7 +184,7 @@ class MsPac::Pellet < Hash
184
184
  raise MsPac::Error::PelletNotInstalledError.new(name)
185
185
  end
186
186
 
187
- puts colorize_status("Unlinking #{name}...")
187
+ puts hilight_status("Unlinking #{name}...")
188
188
  FileUtils.rm_f("#{@@install_dir}/#{name}")
189
189
  end
190
190
 
@@ -193,7 +193,7 @@ class MsPac::Pellet < Hash
193
193
  raise MsPac::Error::PelletNotInstalledError.new(name)
194
194
  end
195
195
 
196
- puts colorize_status("Unlocking #{name}...")
196
+ puts hilight_status("Unlocking #{name}...")
197
197
  FileUtils.rm_f("#{@@install_dir}/#{name}/.mspac_lock")
198
198
  end
199
199
 
@@ -204,11 +204,11 @@ class MsPac::Pellet < Hash
204
204
 
205
205
  Dir.chdir("#{@@install_dir}/#{name}") do
206
206
  if (Pathname.new(".mspac_lock").expand_path.exist?)
207
- puts colorize_error("Locked: #{name}")
207
+ puts hilight_error("Locked: #{name}")
208
208
  return
209
209
  end
210
210
 
211
- puts colorize_status("Updating #{name}...")
211
+ puts hilight_status("Updating #{name}...")
212
212
  tip = @vcs.revision
213
213
  @vcs.update
214
214
  new_tip = @vcs.revision
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.6
4
+ version: 0.2.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: 2016-03-26 00:00:00.000000000 Z
11
+ date: 2016-04-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -31,25 +31,25 @@ dependencies:
31
31
  - !ruby/object:Gem::Version
32
32
  version: 10.5.0
33
33
  - !ruby/object:Gem::Dependency
34
- name: colorize
34
+ name: hilighter
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: '0.7'
39
+ version: '0.1'
40
40
  - - ">="
41
41
  - !ruby/object:Gem::Version
42
- version: 0.7.7
42
+ version: 0.1.0
43
43
  type: :runtime
44
44
  prerelease: false
45
45
  version_requirements: !ruby/object:Gem::Requirement
46
46
  requirements:
47
47
  - - "~>"
48
48
  - !ruby/object:Gem::Version
49
- version: '0.7'
49
+ version: '0.1'
50
50
  - - ">="
51
51
  - !ruby/object:Gem::Version
52
- version: 0.7.7
52
+ version: 0.1.0
53
53
  - !ruby/object:Gem::Dependency
54
54
  name: scoobydoo
55
55
  requirement: !ruby/object:Gem::Requirement