bukin 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +9 -2
- data/lib/bukin/bukfile.rb +2 -2
- data/lib/bukin/cli.rb +50 -10
- data/lib/bukin/installer.rb +8 -8
- data/lib/bukin/providers/bukkit_dl.rb +0 -5
- data/lib/bukin/providers/direct_dl.rb +12 -0
- data/lib/bukin/providers/jenkins.rb +38 -0
- data/lib/bukin/utils.rb +2 -3
- data/lib/bukin/version.rb +1 -1
- metadata +4 -2
data/README.md
CHANGED
@@ -34,8 +34,15 @@ You can specify specific versions of a plugin or server to install. Craftbukkit
|
|
34
34
|
plugin 'worldedit', '5.5.5'
|
35
35
|
plugin 'worldguard', '5.7.3'
|
36
36
|
|
37
|
+
By default, bukin will try to download jar files from bukkit dev. If only zip files are available, it will automatically extract all jar files from it. If you want to specify what files are extracted from a zip file, use the `extract` option. It takes a [ruby regular expression](http://ruby-doc.org/core-1.9.3/Regexp.html) used to match file names in the zip file.
|
38
|
+
|
39
|
+
plugin 'permissionsex', '1.19.5', :extract => /PermissionsEx.*\.jar/
|
40
|
+
|
41
|
+
Plugins or servers can also be downloaded from Jenkins. Just specify the base url for Jenkins and a [ruby regular expression](http://ruby-doc.org/core-1.9.3/Regexp.html) matching the file you want to download. If no file is specified, bukin will download the first one listed.
|
42
|
+
|
43
|
+
server 'spigot', 'build-844', :jenkins => 'http://ci.md-5.net', :file => /spigot\.jar/
|
44
|
+
|
37
45
|
Need something custom? Use the `download` option. Version is optional but will display when the plugin is downloading.
|
38
46
|
|
39
|
-
|
40
|
-
plugin 'mycustomplugin', '2.4', download: 'http://example.com/My-Custom-Plugin.jar'
|
47
|
+
plugin 'mycustomplugin', '2.4', :download => 'http://example.com/My-Custom-Plugin.jar'
|
41
48
|
|
data/lib/bukin/bukfile.rb
CHANGED
@@ -30,7 +30,7 @@ class Bukin::Bukfile
|
|
30
30
|
options = args.last.is_a?(Hash) ? args.pop : {}
|
31
31
|
version = args.pop || nil
|
32
32
|
|
33
|
-
@server_info = { name
|
33
|
+
@server_info = { :name => name, :version => version }.merge(options)
|
34
34
|
end
|
35
35
|
|
36
36
|
def plugin(name, *args)
|
@@ -41,6 +41,6 @@ class Bukin::Bukfile
|
|
41
41
|
options = args.last.is_a?(Hash) ? args.pop : {}
|
42
42
|
version = args.pop || nil
|
43
43
|
|
44
|
-
@plugins_info << { name
|
44
|
+
@plugins_info << { :name => name, :version => version }.merge(options)
|
45
45
|
end
|
46
46
|
end
|
data/lib/bukin/cli.rb
CHANGED
@@ -3,6 +3,8 @@ require 'bukin/installer'
|
|
3
3
|
require 'bukin/bukfile'
|
4
4
|
require 'bukin/providers/bukget'
|
5
5
|
require 'bukin/providers/bukkit_dl'
|
6
|
+
require 'bukin/providers/direct_dl'
|
7
|
+
require 'bukin/providers/jenkins'
|
6
8
|
|
7
9
|
class Bukin::CLI < Thor
|
8
10
|
|
@@ -17,20 +19,58 @@ class Bukin::CLI < Thor
|
|
17
19
|
plugins = bukfile.plugins_info
|
18
20
|
|
19
21
|
# Grab information from the various providers
|
22
|
+
direct_dl = Bukin::DirectDl.new
|
23
|
+
jenkins = Bukin::Jenkins.new
|
20
24
|
bukkit_dl = Bukin::BukkitDl.new
|
21
25
|
bukget = Bukin::Bukget.new
|
22
26
|
|
23
|
-
|
24
|
-
|
27
|
+
# Server info
|
28
|
+
if direct_dl.usable(server)
|
29
|
+
direct_dl.resolve_info(server)
|
30
|
+
elsif jenkins.usable(server)
|
31
|
+
section "Fetching information from #{jenkins.url(server)}" do
|
32
|
+
jenkins.resolve_info(server)
|
33
|
+
end
|
34
|
+
else
|
35
|
+
section "Fetching information from #{bukkit_dl.url}" do
|
36
|
+
bukkit_dl.resolve_info(server)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
# Plugins info
|
41
|
+
direct_dl_plugins = []
|
42
|
+
jenkins_plugins = []
|
43
|
+
bukget_plugins = []
|
44
|
+
|
45
|
+
plugins.each do |plugin|
|
46
|
+
if direct_dl.usable(plugin)
|
47
|
+
direct_dl_plugins << plugin
|
48
|
+
elsif jenkins.usable(plugin)
|
49
|
+
jenkins_plugins << plugin
|
50
|
+
else
|
51
|
+
bukget_plugins << plugin
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
direct_dl_plugins.each do |plugin|
|
56
|
+
direct_dl.resolve_info(plugin)
|
57
|
+
end
|
58
|
+
|
59
|
+
jenkins_plugins.each do |plugin|
|
60
|
+
section "Fetching information from #{jenkins.url(plugin)}" do
|
61
|
+
jenkins.resolve_info(plugin)
|
62
|
+
end
|
25
63
|
end
|
26
64
|
|
27
65
|
section "Fetching information from #{bukget.url}" do
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
66
|
+
bukget_plugins.each do |plugin|
|
67
|
+
plugins.each do |plugin|
|
68
|
+
plugin[:server] ||= 'craftbukkit'
|
69
|
+
begin
|
70
|
+
bukget.resolve_info(plugin)
|
71
|
+
rescue OpenURI::HTTPError => ex
|
72
|
+
raise Bukin::BukinError, "There was an error downloading #{plugin[:name]} (#{plugin[:version]}).\n#{ex.message}"
|
73
|
+
end
|
34
74
|
end
|
35
75
|
end
|
36
76
|
end
|
@@ -39,12 +79,12 @@ class Bukin::CLI < Thor
|
|
39
79
|
installer = Bukin::Installer.new(Dir.pwd, true)
|
40
80
|
|
41
81
|
downloading server[:name], server[:display_version] do
|
42
|
-
installer.install(:server,
|
82
|
+
installer.install(:server, server)
|
43
83
|
end
|
44
84
|
|
45
85
|
plugins.each do |plugin|
|
46
86
|
downloading plugin[:name], plugin[:version] do
|
47
|
-
installer.install(:plugin,
|
87
|
+
installer.install(:plugin, plugin)
|
48
88
|
end
|
49
89
|
end
|
50
90
|
end
|
data/lib/bukin/installer.rb
CHANGED
@@ -7,10 +7,10 @@ class Bukin::Installer
|
|
7
7
|
if use_lockfile
|
8
8
|
@lockfile = Bukin::Lockfile.new
|
9
9
|
end
|
10
|
-
@paths = { server
|
10
|
+
@paths = { :server => path, :plugin => "#{path}/plugins" }
|
11
11
|
end
|
12
12
|
|
13
|
-
def install(type,
|
13
|
+
def install(type, data)
|
14
14
|
unless @paths.keys.include?(type)
|
15
15
|
raise(ArgumentError, "You must specify one of the following types to install: #{@paths.keys.to_s}")
|
16
16
|
end
|
@@ -41,12 +41,12 @@ class Bukin::Installer
|
|
41
41
|
|
42
42
|
def extract_files(file_data, path, match)
|
43
43
|
file_names = []
|
44
|
-
|
44
|
+
tempfile = Tempfile.new('bukin')
|
45
45
|
begin
|
46
|
-
|
47
|
-
|
46
|
+
tempfile.write(file_data)
|
47
|
+
tempfile.close
|
48
48
|
|
49
|
-
Zip::ZipFile.open(
|
49
|
+
Zip::ZipFile.open(tempfile.path) do |zipfile|
|
50
50
|
jars = zipfile.find_all {|file| file.name =~ match}
|
51
51
|
jars.each do |file|
|
52
52
|
file.extract(path + '/' + file.name) { true }
|
@@ -54,8 +54,8 @@ class Bukin::Installer
|
|
54
54
|
end
|
55
55
|
end
|
56
56
|
ensure
|
57
|
-
|
58
|
-
|
57
|
+
tempfile.close
|
58
|
+
tempfile.unlink
|
59
59
|
end
|
60
60
|
file_names
|
61
61
|
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
# Api for downloading from jenkins
|
4
|
+
class Bukin::Jenkins
|
5
|
+
|
6
|
+
def usable(data)
|
7
|
+
!!data[:jenkins]
|
8
|
+
end
|
9
|
+
|
10
|
+
def url(data)
|
11
|
+
data[:jenkins]
|
12
|
+
end
|
13
|
+
|
14
|
+
def resolve_info(data)
|
15
|
+
name = data[:name]
|
16
|
+
version = data[:version] || 'lastSuccessfulBuild'
|
17
|
+
|
18
|
+
if version =~ /^build-(.*)$/
|
19
|
+
base_path = "#{data[:jenkins]}/job/#{name}/#{$1}"
|
20
|
+
url = "#{base_path}/api/json"
|
21
|
+
info = JSON.parse(open(url).read)
|
22
|
+
|
23
|
+
download_info = if data[:file]
|
24
|
+
info['artifacts'].find do |artifact|
|
25
|
+
artifact['fileName'] =~ data[:file]
|
26
|
+
end
|
27
|
+
else
|
28
|
+
info['artifacts'].first
|
29
|
+
end
|
30
|
+
|
31
|
+
data[:version] = data[:display_version] = version
|
32
|
+
data[:download] = "#{base_path}/artifact/#{download_info['relativePath']}"
|
33
|
+
else
|
34
|
+
raise Bukin::InstallError, "The plugin #{name} (#{version}) has an improper version format for downloading from Jenkins. It should be in the form of 'build-<number>'"
|
35
|
+
end
|
36
|
+
data
|
37
|
+
end
|
38
|
+
end
|
data/lib/bukin/utils.rb
CHANGED
@@ -11,12 +11,11 @@ end
|
|
11
11
|
def download_file(url, content_disposition = false)
|
12
12
|
open(url, "User-Agent" => "Bukin #{Bukin::VERSION}") do |download|
|
13
13
|
file_name = if download.meta['content-disposition']
|
14
|
-
download.meta['content-disposition']
|
15
|
-
.match(/filename=(\"?)(.+)\1/)[2]
|
16
|
-
.force_encoding("UTF-8")
|
14
|
+
download.meta['content-disposition'].match(/filename=(\"?)(.+)\1/)[2]
|
17
15
|
else
|
18
16
|
File.basename(url)
|
19
17
|
end
|
18
|
+
file_name = file_name.force_encoding('UTF-8') if file_name.respond_to?(:force_encoding)
|
20
19
|
data = download.read
|
21
20
|
return data, file_name
|
22
21
|
end
|
data/lib/bukin/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bukin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-05-
|
12
|
+
date: 2013-05-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: thor
|
@@ -83,6 +83,8 @@ files:
|
|
83
83
|
- lib/bukin/lockfile.rb
|
84
84
|
- lib/bukin/providers/bukget.rb
|
85
85
|
- lib/bukin/providers/bukkit_dl.rb
|
86
|
+
- lib/bukin/providers/direct_dl.rb
|
87
|
+
- lib/bukin/providers/jenkins.rb
|
86
88
|
- lib/bukin/utils.rb
|
87
89
|
- lib/bukin/version.rb
|
88
90
|
homepage: http://github.com/Nullreff/bukin
|