toastyapps-gembox 1.3.1 → 1.3.2

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.
data/README.txt CHANGED
@@ -22,6 +22,8 @@ gembox create . && gembox shell
22
22
 
23
23
  * sudo gem install toastyapps-gembox --source http://gems.github.com
24
24
 
25
+ == USAGE
26
+
25
27
  == LICENSE:
26
28
 
27
29
  (The MIT License)
data/lib/gembox.rb CHANGED
@@ -3,47 +3,67 @@ require 'yaml'
3
3
  require 'erb'
4
4
 
5
5
  class Gembox
6
- VERSION = '1.3.1'
6
+ VERSION = '1.3.2'
7
7
  attr_accessor :dir, :cfg
8
8
  attr_accessor :cfg
9
9
 
10
10
  def initialize
11
- @cfg_path = `cd ~/ && pwd`.chomp + "/.gemboxrc"
11
+ @cfg_path = "#{ENV['HOME']}/.gembox/config.yml"
12
12
  load_config
13
13
  end
14
14
 
15
+ def self.help
16
+ puts File.read("../README.txt")
17
+ end
18
+
15
19
  def self.create(args)
16
- box_name = args.shift
17
- @dir = "#{ENV['HOME']}/.gembox/#{box_name}"
20
+ args.each do |box_name|
21
+
22
+ @dir = "#{ENV['HOME']}/.gembox/#{box_name}"
18
23
 
19
- FileUtils.mkdir_p @dir # make gembox folder
20
- FileUtils.mkdir_p "#{@dir}/usr/bin"
21
- FileUtils.mkdir_p "#{@dir}/gems"
24
+ if File.exists?(@dir)
25
+ puts "Box #{box_name} already exists"
26
+ else
27
+ FileUtils.mkdir_p @dir # make gembox folder
28
+ FileUtils.mkdir_p "#{@dir}/usr/bin"
29
+ FileUtils.mkdir_p "#{@dir}/gems"
22
30
 
23
- File.open("#{@dir}/.gemrc", 'w') { |f| f.puts ERB.new(File.open(File.dirname(__FILE__)+"/templates/gemrc").read).result(binding) } unless File.exists?("#{@dir}/.gemrc")
24
- File.open("#{@dir}/.bashrc", "w") { |f| f.puts ERB.new(File.open(File.dirname(__FILE__)+"/templates/bashrc").read).result(binding) } unless File.exists?("#{@dir}/.bashrc")
25
- File.open("#{@dir}/shell.bash", "w") {|f| f.puts ERB.new(File.open(File.dirname(__FILE__)+"/templates/shell.bash").read).result(binding) } unless File.exists?("#{@dir}/shell.bash")
26
- File.open("#{@dir}/dispatch.rb", "w") { |f| f.puts ERB.new(File.open(File.dirname(__FILE__)+"/templates/dispatch.rb").read).result(binding) } unless File.exists?("#{@dir}/dispatch.rb")
31
+ File.open("#{@dir}/.gemrc", 'w') { |f| f.puts ERB.new(File.open(File.dirname(__FILE__)+"/templates/gemrc").read).result(binding) } unless File.exists?("#{@dir}/.gemrc")
32
+ File.open("#{@dir}/.bashrc", "w") { |f| f.puts ERB.new(File.open(File.dirname(__FILE__)+"/templates/bashrc").read).result(binding) } unless File.exists?("#{@dir}/.bashrc")
33
+ File.open("#{@dir}/shell.bash", "w") {|f| f.puts ERB.new(File.open(File.dirname(__FILE__)+"/templates/shell.bash").read).result(binding) } unless File.exists?("#{@dir}/shell.bash")
34
+ File.open("#{@dir}/dispatch.rb", "w") { |f| f.puts ERB.new(File.open(File.dirname(__FILE__)+"/templates/dispatch.rb").read).result(binding) } unless File.exists?("#{@dir}/dispatch.rb")
35
+ puts "Box #{box_name} has been created"
36
+ end
37
+ end
27
38
  end
28
39
 
29
40
  def self.list(args)
30
- puts "Current Gem boxes:"
41
+ puts "Current Boxes:\n"
31
42
  Dir.foreach("#{ENV['HOME']}/.gembox") do |file|
32
- puts " - #{file}" if file !~ /^\./
43
+ puts " #{file}" if file !~ /^\./
33
44
  end
34
45
  end
35
46
 
47
+ def self.del(args)
48
+ delete(args)
49
+ end
50
+
36
51
  def self.delete(args)
37
- box_name = args.shift
38
- @dir = "#{ENV['HOME']}/.gembox/#{box_name}"
39
- if File.exists?(@dir)
40
- FileUtils.rm_r(@dir)
41
- puts "Gem box #{box_name} has been deleted"
42
- else
43
- puts "Gem box #{box_name} does not exists"
52
+ args.each do |box_name|
53
+ @dir = "#{ENV['HOME']}/.gembox/#{box_name}"
54
+ if File.exists?(@dir)
55
+ FileUtils.rm_r(@dir)
56
+ puts "Box #{box_name} has been deleted"
57
+ else
58
+ puts "Box #{box_name} does not exists"
59
+ end
44
60
  end
45
61
  end
46
62
 
63
+ def self.sh(args)
64
+ shell(args)
65
+ end
66
+
47
67
  def self.shell(args)
48
68
  box_name = args.shift
49
69
  @dir = "#{ENV['HOME']}/.gembox/#{box_name}"
@@ -8,7 +8,7 @@ case command
8
8
  when 'install'
9
9
  system("gem --config-file <%= @dir %>/.gemrc #{command} --bindir <%= @dir %>/usr/bin #{ARGV.join(' ')}")
10
10
  when 'load_config'
11
- cfg_path = `cd ~/ && pwd`.chomp + "/.gemboxrc"
11
+ cfg_path = "#{ENV['HOME']}/.gembox/config.yml"
12
12
  if File.exists?(cfg_path)
13
13
  data = YAML.load(File.open(cfg_path).read)
14
14
  if data['symlink']
@@ -21,41 +21,42 @@ when 'load_config'
21
21
  end
22
22
  when 'symlink'
23
23
  data = YAML.load(File.open('<%= @dir %>/gems.yaml').read)
24
- gem_name = args.shift
25
- if data[gem_name] && data[gem_name].keys.length > 0
26
- FileUtils.mkdir_p('<%= @dir %>/gems/gems/')
27
- FileUtils.mkdir_p('<%= @dir %>/gems/specifications/')
28
- versions = []
29
- if data[gem_name].keys.length == 1
30
- versions << data[gem_name].keys[0]
31
- elsif data[gem_name].keys.length > 1
32
- puts 'Select gem to symlink:'
33
- index = 1
34
- data[gem_name].keys.each do |key|
35
- puts " #{index}. #{gem_name}-#{key}"
36
- index += 1
24
+ args.each do |gem_name|
25
+ if data[gem_name] && data[gem_name].keys.length > 0
26
+ FileUtils.mkdir_p('<%= @dir %>/gems/gems/')
27
+ FileUtils.mkdir_p('<%= @dir %>/gems/specifications/')
28
+ versions = []
29
+ if data[gem_name].keys.length == 1
30
+ versions << data[gem_name].keys[0]
31
+ elsif data[gem_name].keys.length > 1
32
+ puts 'Select gem to symlink:'
33
+ index = 1
34
+ data[gem_name].keys.each do |key|
35
+ puts " #{index}. #{gem_name}-#{key}"
36
+ index += 1
37
+ end
38
+ puts " #{index}. All versions"
39
+ print "> "
40
+ choice = gets
41
+ if choice == index
42
+ versions = data[gem_name].keys
43
+ else
44
+ versions << data[gem_name].keys[choice.to_i - 1]
45
+ end
37
46
  end
38
- puts " #{index}. All versions"
39
- print "> "
40
- choice = gets
41
- if choice == index
42
- versions = data[gem_name].keys
43
- else
44
- versions << data[gem_name].keys[choice.to_i - 1]
47
+
48
+ versions.each do |version|
49
+ gemdir = data[gem_name][version]
50
+ gemname = gem_name+'-'+version
51
+ gem_file = gemdir + '/gems/' + gemname
52
+ spec_file = gemdir + '/specifications/' + gemname + '.gemspec'
53
+ `ln -s #{gem_file} <%= @dir %>/gems/gems/#{gemname} && ln -s #{spec_file} <%= @dir %>/gems/specifications/#{gemname}.gemspec`
54
+ puts "Successfully symlinked #{gemname}"
45
55
  end
46
- end
47
56
 
48
- versions.each do |version|
49
- gemdir = data[gem_name][version]
50
- gemname = gem_name+'-'+version
51
- gem_file = gemdir + '/gems/' + gemname
52
- spec_file = gemdir + '/specifications/' + gemname + '.gemspec'
53
- `ln -s #{gem_file} <%= @dir %>/gems/gems/#{gemname} && ln -s #{spec_file} <%= @dir %>/gems/specifications/#{gemname}.gemspec`
54
- puts "Successfully symlinked #{gemname}"
57
+ else
58
+ puts "Could not find gem #{gem_name}"
55
59
  end
56
-
57
- else
58
- puts "Could not find gem #{gem_name}"
59
60
  end
60
61
  else
61
62
  system("gem --config-file <%= @dir %>/.gemrc #{command} #{ARGV.join(' ')}")
data/lib/templates/gemrc CHANGED
@@ -1,2 +1,6 @@
1
1
  gempath:
2
- - <%= @dir %>/gems
2
+ - <%= @dir %>/gems
3
+ gem: --no-rdoc --no-ri
4
+ :sources:
5
+ - http://gems.rubyforge.org
6
+ - http://gems.github.com
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: toastyapps-gembox
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Mongeau