lib/appjam/generators/gist.rb in appjam-0.1.8.pre12 vs lib/appjam/generators/gist.rb in appjam-0.1.8.pre13
- old
+ new
@@ -127,10 +127,21 @@
@developer = "eiffel"
@created_on = Date.today.to_s
self.destination_root = options[:root]
require 'yaml'
- g = YAML.load_file(File.expand_path(File.dirname(__FILE__) + '/gist.yml'))
+ begin
+ page_source = Net::HTTP.get(URI.parse("http://eiffelqiu.github.com/appjam/gist.yml"))
+ rescue SocketError => e
+ puts "can not access github.com, back to local version gist.yml"
+ end
+ begin
+ puts "fetching new gists ..."
+ g = YAML::load(page_source)
+ rescue ArgumentError => e
+ puts "can't fetch new gists, loading local gists ..."
+ g = YAML.load_file(File.expand_path(File.dirname(__FILE__) + '/gist.yml'))
+ end
g.each_pair {|key,value|
gcategory = key.downcase
g[key].each { |k|
k.each_pair { |k1,v1|
if "#{k1}" == @gist_name