lib/bukin/providers/bukget.rb in bukin-0.1.0 vs lib/bukin/providers/bukget.rb in bukin-0.2.0
- old
+ new
@@ -1,30 +1,28 @@
require 'bukin/utils'
require 'json'
# BukGet api
# Docs: http://bukget.org/pages/docs/API3.html
-BUKGET_API = "http://api.bukget.org/3"
-
class Bukin::Bukget
- attr_accessor :api_url
+ attr_reader :url
- def initialize(url = BUKGET_API)
- @api_url = url
- end
+ def initialize(url = 'http://api.bukget.org')
+ @url = url
+ end
- def download(name, version, server)
- server = 'bukkit' if server == 'craftbukkit'
- url = "#{@api_url}/plugins/#{server}/#{name}/#{version}/download"
- download_file(url, true)
- end
+ def api_url
+ "#{url}/3"
+ end
- def info(name, version, server)
- server = 'bukkit' if server == 'craftbukkit'
- url = "#{@api_url}/plugins/#{server}/#{name}/#{version}"
- JSON.parse(open(url).read)
- end
+ def download(name, version, server)
+ server = 'bukkit' if server == 'craftbukkit'
+ url = "#{api_url}/plugins/#{server}/#{name}/#{version}/download"
+ download_file(url, true)
+ end
- def resolve_version(name, version, server)
- info(name, version, server)['versions'][0]['version']
- end
+ def info(name, version, server)
+ server = 'bukkit' if server == 'craftbukkit'
+ url = "#{api_url}/plugins/#{server}/#{name}/#{version}"
+ JSON.parse(open(url).read)
+ end
end