brewgem 0.0.3 → 0.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 92652812c9ef3595eab6c683788b6bfe870efa85
4
- data.tar.gz: cc104ec4fc003c194cc8d469ab91537f66b73415
3
+ metadata.gz: 2029d25d2c8e8d61e3a1030e7a5644b5703242f9
4
+ data.tar.gz: 7dbd98a4455e4932982a6b121c44e1c80f28adb7
5
5
  SHA512:
6
- metadata.gz: 8494fc0031c8c36511a1ffc73cad60f69e6f0182906899b6b39d43fdf21e44b2d6e23d2263cb8c59ac439f785b56c92fef316228667170b531c24a70c2438696
7
- data.tar.gz: f8a99833b2f2cb8939c6237b7614e7735667c4dd5f4a8a2736410bb825bb342b5c25f33e791f25d11018874afdd5316b956f25d2a361d45f3c7c2752d1636876
6
+ metadata.gz: dd0cc85b65de7553801b78617c4fe0ce16b208ceb2076c8569bbda37727ab1530c4b1937838940d9dac13fd29144b105ad3055fa14f3a304c05355ae88716d9f
7
+ data.tar.gz: 9e4ad7024470390c317698a6541cf274b28d049efb78f82d81c6038bb83a204f1d21aaf6cef4231764bebcf0f568ff468e7c57743b17ca76f98cae9b313d487b
data/lib/brewgem/cli.rb CHANGED
@@ -14,19 +14,19 @@ module BrewGem
14
14
  method_option :github, type: 'string'
15
15
  method_option :verbose, :type => :boolean
16
16
  def install(gem_name = nil, version = nil)
17
- BrewGem.install(gem_name, version, options)
17
+ BrewGem.install(options.merge(name: gem_name, version: version))
18
18
  end
19
19
 
20
20
  desc 'update <gem-name>', COMMANDS[:update]
21
21
  method_option :verbose, :type => :boolean
22
22
  def update(gem_name)
23
- BrewGem.update(gem_name)
23
+ BrewGem.update(name: gem_name)
24
24
  end
25
25
 
26
26
  desc 'uninstall <gem-name>', COMMANDS[:uninstall]
27
27
  method_option :verbose, :type => :boolean
28
28
  def uninstall(gem_name)
29
- BrewGem.uninstall(gem_name)
29
+ BrewGem.uninstall(name: gem_name)
30
30
  end
31
31
  end
32
32
  end
@@ -1,3 +1,3 @@
1
1
  module BrewGem
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
data/lib/brewgem.rb CHANGED
@@ -3,16 +3,16 @@ require 'tempfile'
3
3
 
4
4
  module BrewGem
5
5
  class << self
6
- def install(name = nil, version = nil, options = {})
7
- perform(:install, name, version, options)
6
+ def install(options)
7
+ perform(:install, options)
8
8
  end
9
9
 
10
- def update(name)
11
- perform(:update, name)
10
+ def update(options)
11
+ perform(:update, options)
12
12
  end
13
13
 
14
- def uninstall(name)
15
- perform(:uninstall, name)
14
+ def uninstall(options)
15
+ perform(:uninstall, options)
16
16
  end
17
17
 
18
18
  def require_all_under(dir, recursive: true)
@@ -25,7 +25,9 @@ module BrewGem
25
25
  private
26
26
  # TODO: Refactor into several methods, and for that need to
27
27
  # run ERB from hash bindings instead of local method bindings
28
- def perform(command, name = nil, version = nil, options = {})
28
+ def perform(command, options = {})
29
+ name, version = options.values_at(:name, :version)
30
+
29
31
  ENV['HOMEBREW_VERBOSE']='true' if options[:verbose]
30
32
  if options[:local]
31
33
  local_path = File.expand_path(options[:local])
@@ -42,10 +44,11 @@ module BrewGem
42
44
  run "gem build #{gemspec_name}"
43
45
  end
44
46
 
45
- gem_name = `ls #{File.join(local_path, '*')}.gem`.chomp
47
+ gem_path = `ls #{File.join(local_path, '*')}.gem`.chomp
46
48
 
47
49
  # recursively call self to install from local gem
48
- run "#{$0} install --local=#{gem_name}", takeover: true
50
+ install(local: gem_path)
51
+ return
49
52
  end
50
53
  elsif options[:github]
51
54
  # clone from github and build gem
@@ -54,7 +57,8 @@ module BrewGem
54
57
  target_dir_name = File.join(Dir.tmpdir, "build-#{name}-#{rand(100000000)}")
55
58
  run "git clone #{github_gem_path} #{target_dir_name}"
56
59
  # recursively call self to install from local dir
57
- run "#{$0} install --local=#{target_dir_name}", takeover: true
60
+ install(local: target_dir_name)
61
+ return
58
62
  else
59
63
  # install from rubygems
60
64
  gems = `gem list --remote "^#{name}$"`.lines
@@ -75,7 +79,7 @@ module BrewGem
75
79
  f.puts template.result(binding)
76
80
  end
77
81
 
78
- system "brew #{command} #{filename}"
82
+ run "brew #{command} #{filename}"
79
83
  ensure
80
84
  File.unlink filename
81
85
  end
@@ -87,7 +91,7 @@ module BrewGem
87
91
  break unless run single_command
88
92
  end
89
93
  else
90
- puts "Executing \"#{command}\"..."
94
+ puts "[brewgem] Executing \"#{command}\"...".purple
91
95
  if options[:takeover]
92
96
  exec command # take over the process
93
97
  else
@@ -0,0 +1,30 @@
1
+ class String
2
+ # Terminal colorization (light-weight version of "colorize" gem)
3
+ def colorize(color_code)
4
+ "\e[#{color_code}m#{self}\e[0m"
5
+ end
6
+
7
+ def red
8
+ colorize(31)
9
+ end
10
+
11
+ def green
12
+ colorize(32)
13
+ end
14
+
15
+ def yellow
16
+ colorize(33)
17
+ end
18
+
19
+ def blue
20
+ colorize(34)
21
+ end
22
+
23
+ def purple
24
+ colorize(35)
25
+ end
26
+
27
+ def light_blue
28
+ colorize(36)
29
+ end
30
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brewgem
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joshua Peek
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-12-18 00:00:00.000000000 Z
13
+ date: 2015-12-19 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: thor
@@ -59,6 +59,7 @@ files:
59
59
  - lib/brewgem.rb
60
60
  - lib/brewgem/cli.rb
61
61
  - lib/brewgem/version.rb
62
+ - lib/core/string.rb
62
63
  homepage: https://github.com/gtmax/brewgem
63
64
  licenses:
64
65
  - MIT