Class: Bashy::Pull
- Inherits:
-
Object
- Object
- Bashy::Pull
- Defined in:
- lib/bashy.rb
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Pull
constructor
A new instance of Pull.
Constructor Details
#initialize(options = {}) ⇒ Pull
Returns a new instance of Pull.
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
# File 'lib/bashy.rb', line 126 def initialize( = {}) # Check that our directories are in tact. Bashy::check_and_load_config_directory # http://gist.github.com/547224 if([:url] =~ /http:\/\/gist\.github\.com\/([0-9]+)/) id = [:url].match(/http:\/\/gist\.github\.com\/([0-9]+)/)[1] unless id.nil? response = get_url('http://gist.github.com/api/v1/yaml/' + id) if response && response.code == "200" yaml = YAML::load(response.body) filename = yaml['gists'][0][:files][0] response = get_url('http://gist.github.com/raw/' + id + '/' + filename) if response && response.code == "200" [:snippet] = response.body else end Add.new() else raise(GistFetchError.new('The Gist you requested could not be fetched from GitHib successfully.')) end else raise(ArgumentError) end else raise(ArgumentError.new('Make sure you pass a valid URL to a GitHub gist.')) end end |