Alters the environment variable used to define the gem install location @param [Array] sub_argv Options passed to the gem_install command from the user input @return [Fixnum] Return status
(sub_argv)
| 1244 | # @return [Fixnum] Return status |
| 1245 | # |
| 1246 | def execute(sub_argv) |
| 1247 | require 'rubygems' |
| 1248 | |
| 1249 | $logger.info "GemList, sub_argv = #{sub_argv}" |
| 1250 | |
| 1251 | options = {} |
| 1252 | |
| 1253 | # Parse the options |
| 1254 | opts = OptionParser.new do |o| |
| 1255 | o.banner = 'Usage: openstudio gem_list' |
| 1256 | end |
| 1257 | argv = parse_options(opts, sub_argv) |
| 1258 | return 0 if argv == nil |
| 1259 | |
| 1260 | $logger.debug("GemList command: #{argv.inspect} #{options.inspect}") |
| 1261 | |
| 1262 | unless argv == [] |
| 1263 | $logger.error 'Extra arguments passed to the gem_list command. Please refer to the help documentation.' |
| 1264 | return 1 |
| 1265 | end |
| 1266 | |
| 1267 | begin |
| 1268 | embedded = [] |
| 1269 | user = [] |
| 1270 | Gem::Specification.find_all.each do |spec| |
| 1271 | if spec.gem_dir.chars.first == ':' |
| 1272 | embedded << spec |
| 1273 | else |
| 1274 | user << spec |
| 1275 | end |
| 1276 | end |
| 1277 | |
| 1278 | embedded.each do |spec| |
| 1279 | safe_puts "#{spec.name} (#{spec.version}) '#{spec.gem_dir}'" |
| 1280 | end |
| 1281 | |
| 1282 | user.each do |spec| |
| 1283 | safe_puts "#{spec.name} (#{spec.version}) '#{spec.gem_dir}'" |
| 1284 | end |
| 1285 | |
| 1286 | rescue => e |
| 1287 | $logger.error "Error listing gems: #{e.message} in #{e.backtrace.join("\n")}" |
| 1288 | exit e.exit_code |
| 1289 | end |
| 1290 | |
| 1291 | 0 |
| 1292 | end |
| 1293 | end |
| 1294 | |
| 1295 | # Class to install gems using the RubyGems functionality |