toastyapps-gembox 1.3.4 → 1.3.6

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.
Files changed (3) hide show
  1. data/lib/gembox.rb +24 -3
  2. data/lib/templates/gemrc +1 -1
  3. metadata +1 -1
data/lib/gembox.rb CHANGED
@@ -3,7 +3,8 @@ require 'yaml'
3
3
  require 'erb'
4
4
 
5
5
  class Gembox
6
- VERSION = '1.3.4'
6
+ VERSION = '1.3.6'
7
+ DEFAULTS = {'nodoc' => true, 'sources' => []}
7
8
  attr_accessor :dir, :cfg, :box_name
8
9
 
9
10
  def initialize
@@ -59,6 +60,7 @@ class Gembox
59
60
  box_name = args.shift
60
61
  @dir = "#{ENV['HOME']}/.gembox/#{box_name}"
61
62
  if File.exists?(@dir)
63
+ generate_gem_yaml("#{@dir}/gem.yaml")
62
64
  generate_gems_yaml("#{@dir}/gems.yaml")
63
65
  system("sh #{@dir}/shell.bash")
64
66
  else
@@ -67,6 +69,25 @@ class Gembox
67
69
  end
68
70
 
69
71
  private
72
+
73
+ def generate_gem_yaml(file)
74
+ data = `gem env`.split("\n")
75
+ config = {'gem_paths' => []}
76
+ lines = data.strip.split("\n")
77
+ lines.each_with_index do |line, i|
78
+ if line.match(/EXECUTABLE DIRECTORY:/)
79
+ config['executable_directory'] = line.match(/:\s(.*)/).captures[0]
80
+ elsif line.match(/GEM PATHS/)
81
+ j = i + 1
82
+ while !lines[j].match(/GEM CONFIGURATION/)
83
+ config['gem_paths'] << lines[j].match(/-\s(.*)/).captures[0]
84
+ j += 1
85
+ end
86
+ break
87
+ end
88
+ end
89
+ File.open(file, "w") { |f| f.puts config.to_yaml }
90
+ end
70
91
 
71
92
  def generate_gems_yaml(file)
72
93
  data = `gem query -d`.split("\n")
@@ -98,11 +119,11 @@ class Gembox
98
119
  end
99
120
 
100
121
  def load_config
101
- @cfg = load_yaml(@cfg_path)
122
+ @cfg = DEFAULTS.merge(load_yaml(@cfg_path))
102
123
  end
103
124
 
104
125
  def load_yaml path
105
- File.exists?(path) ? YAML.load(File.open(path)) : nil
126
+ File.exists?(path) ? YAML.load(File.open(path)) : {}
106
127
  end
107
128
 
108
129
  def method_missing(method, args)
data/lib/templates/gemrc CHANGED
@@ -4,5 +4,5 @@ gempath:
4
4
  sources:
5
5
  - http://gems.rubyforge.org
6
6
  - http://gems.github.com
7
- <% (@cfg['sources'] || []).each do |source| %>- <%= source %>
7
+ <% @cfg['sources'].each do |source| %>- <%= source %>
8
8
  <% end %>
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.4
4
+ version: 1.3.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Mongeau