bukin 0.7.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  Bukin
2
2
  =====
3
3
 
4
- Plugin and server installer for Minecraft similar to [Bundler](http://gembundler.com/). Still a work in progress...
4
+ Plugin and server installer for Minecraft similar to [Bundler](http://gembundler.com/).
5
5
 
6
6
  [![Build Status](https://travis-ci.org/Nullreff/bukin.png)](https://travis-ci.org/Nullreff/bukin)
7
7
  [![Dependency Status](https://gemnasium.com/Nullreff/bukin.png)](https://gemnasium.com/Nullreff/bukin)
@@ -11,40 +11,131 @@ Plugin and server installer for Minecraft similar to [Bundler](http://gembundler
11
11
  Installation
12
12
  ------------
13
13
 
14
- Install [rubygems](http://docs.rubygems.org/read/chapter/3) then:
14
+ Bukin requires Ruby 1.9 or greater.
15
15
 
16
- gem install bukin
16
+ ### Debian/Ubuntu
17
17
 
18
+ apt-get install ruby
19
+ gem install bukin --no-ri --no-rdoc
18
20
 
21
+ ### CentOS/RHEL
22
+
23
+ CentOS 6.x comes with Ruby 1.8 which is incompatable with Bukin. You'll need to [download and install](http://www.ruby-lang.org/en/downloads/) a newer version. After that just run
24
+
25
+ gem install bukin --no-ri --no-rdoc
26
+
27
+ Features
28
+ --------
29
+
30
+ Bukin is still a work in progress and is far from feature complete. Currently it supports:
31
+
32
+ * Resource installation from
33
+ * [dev.bukkit.org](http://dev.bukkit.org/)
34
+ * [dl.bukkit.org](http://dl.bukkit.org/)
35
+ * [Jenkins](http://jenkins-ci.org/)
36
+ * Direct download
37
+ * Versioning
38
+ * Specific versions
39
+ * Categories (ex: latest test build)
40
+ * Auto selection if none specified
41
+ * Automatic or user specified filtering of downloaded files
42
+ * Automatic or user specified extraction of zip files
43
+ * Installation groups
44
+
45
+ Eventually, I'd like to add some of the following:
46
+
47
+ * A lockfile that tracks exactly what versions are installed
48
+ * Automatic detection of already installed plugins
49
+ * Dependency tracking and resolution
50
+ * More complex version selectors
51
+ * Modpack support
52
+ * Resource installation from git
53
+ * Top level 'source' directives
54
+ * More commands for viewing information and updating plugins
55
+
56
+ If you have features you'd like to see, pull request are welcome.
57
+
19
58
  Usage
20
59
  -----
21
60
 
22
61
  Bukin works by reading a list of dependencies from a `Bukfile`. The most basic usage would be:
23
62
 
24
- echo "server 'craftbukkit'" > Bukfile
25
- bukin install
63
+ ```bash
64
+ echo "server 'craftbukkit'" > Bukfile
65
+ bukin install
66
+ ```
67
+
68
+ Specify a server using the `server` keyword and a plugin using the `plugin` keyword.
26
69
 
27
- Currently only [Craftbukkit](http://bukkit.org/) is available as a server and [BukkitDev](http://dev.bukkit.org/) is the only plugin api supported. Specify a server using the `server` keyword and a plugin using the `plugin` keyword.
70
+ ```ruby
71
+ server 'craftbukkit'
72
+ plugin 'worldedit'
73
+ plugin 'worldguard'
74
+ ```
28
75
 
29
- server 'craftbukkit'
30
- plugin 'worldedit'
31
- plugin 'worldguard'
76
+ You can specify groups that resources should be placed in. This allows you to only install specific plugins depending on your environment or server setup.
77
+
78
+ ```ruby
79
+ # Will not be installed if the group 'test' is excluded
80
+ plugin 'worldedit', group: :test
81
+
82
+ group :test do
83
+ plugin 'worldguard'
84
+ plugin 'worldedit'
85
+ end
86
+
87
+ # Will not be installed if both the groups 'test' and 'development' are excluded
88
+ plugin 'worldedit', group: [:test, :development]
89
+
90
+ group :test, :development do
91
+ plugin 'worldguard'
92
+ plugin 'worldedit'
93
+ end
94
+
95
+ # Will be installed regardless of what groups are specified
96
+ plugin 'worldguard'
97
+ ```
98
+
99
+ When installing, resources that exist only in excluded groups will not be installed.
100
+
101
+ ```bash
102
+ bukin install --without development test
103
+ ```
32
104
 
33
105
  You can specify specific versions of a plugin or server to install. Craftbukkit uses its own [special version naming](http://dl.bukkit.org/about/) (artifact slugs).
34
106
 
35
- server 'craftbukkit', 'build-2754'
36
- plugin 'worldedit', '5.5.5'
37
- plugin 'worldguard', '5.7.3'
107
+ ```ruby
108
+ server 'craftbukkit', 'build-2754'
109
+ plugin 'worldedit', '5.5.5'
110
+ plugin 'worldguard', '5.7.3'
111
+ ```
38
112
 
39
113
  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 string or [ruby regular expression](http://ruby-doc.org/core-1.9.3/Regexp.html) used to match file names in the zip file.
40
114
 
41
- plugin 'permissionsex', '1.19.5', extract: /PermissionsEx.*\.jar/
115
+ ```ruby
116
+ plugin 'permissionsex', '1.19.5', extract: /PermissionsEx.*\.jar/
117
+ ```
42
118
 
43
119
  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.
44
120
 
45
- server 'spigot', 'build-844', jenkins: 'http://ci.md-5.net', file: /spigot\.jar/
121
+ ```ruby
122
+ server 'spigot', 'build-844', jenkins: 'http://ci.md-5.net', file: /spigot\.jar/
123
+ ```
46
124
 
47
125
  Need something custom? Use the `download` option. Version is optional but will display when the plugin is downloading.
48
126
 
49
- plugin 'mycustomplugin', '2.4', download: 'http://example.com/My-Custom-Plugin.jar'
127
+ ```ruby
128
+ plugin 'mycustomplugin', '2.4', download: 'http://example.com/My-Custom-Plugin.jar'
129
+ ```
130
+
131
+ When installing, the entire Bukfile is evaluated as ruby code. This means that you can do just about anything with it. For instance, if you wanted to conditionally install spigot if the file `spigot.yml` exists, you could do
132
+
133
+ ```ruby
134
+ if File.exist? 'spigot.yml'
135
+ server 'spigot', jenkins: 'http://ci.md-5.net'
136
+ else
137
+ server 'craftbukkit'
138
+ end
139
+ ```
50
140
 
141
+ Just make sure that you read and trust any Bukfile you download before running `bukin install`.
@@ -4,7 +4,15 @@ require 'socket'
4
4
 
5
5
  module Bukin
6
6
  class BukinError < StandardError; end
7
- class BukfileError < BukinError; end
7
+ class BukfileError < BukinError
8
+ def self.not_symbol(group)
9
+ BukfileError.new("The group name '#{group}' must be a Symbol")
10
+ end
11
+
12
+ def self.nested_groups
13
+ BukfileError.new("Nesing 'group' statements is not supported")
14
+ end
15
+ end
8
16
  class InstallError < BukinError; end
9
17
 
10
18
  class VersionError < BukinError
@@ -6,6 +6,8 @@ module Bukin
6
6
  def initialize(path = nil, &block)
7
7
  @resources = []
8
8
  @path = path || File.join(Dir.pwd, FILE_NAME)
9
+ @groups = []
10
+
9
11
  if block
10
12
  instance_eval(&block)
11
13
  else
@@ -21,6 +23,17 @@ module Bukin
21
23
  add_resource name, :plugin, args
22
24
  end
23
25
 
26
+ def group(*groups)
27
+ raise BukfileError.nested_groups unless @groups.empty?
28
+ groups.each do |group|
29
+ raise BukfileError.not_symbol(group) unless group.is_a?(Symbol)
30
+ end
31
+
32
+ @groups = groups
33
+ yield
34
+ @groups = []
35
+ end
36
+
24
37
  def to_s
25
38
  @reources.map do |resource|
26
39
  result = "#{resource[:name]}"
@@ -46,6 +59,8 @@ module Bukin
46
59
  :version => version
47
60
  }.merge(options)
48
61
 
62
+ resource[:group] = build_groups(resource[:group])
63
+
49
64
  @resources << resource
50
65
  end
51
66
 
@@ -54,5 +69,18 @@ module Bukin
54
69
  resource[:name] == name && resource[:type] == type
55
70
  end
56
71
  end
72
+
73
+ def build_groups(group)
74
+ case group
75
+ when nil
76
+ @groups.uniq
77
+ when Symbol
78
+ [group] | @groups
79
+ when Array
80
+ group | @groups
81
+ else
82
+ raise BukfileError.not_symbol(group)
83
+ end
84
+ end
57
85
  end
58
86
  end
@@ -13,8 +13,10 @@ module Bukin
13
13
  desc 'install [NAMES]', "Download and install the resources specified in a "\
14
14
  "Bukfile.\nOptionally specify the names of specific "\
15
15
  "plugins to install."
16
+ option :without, type: :array, default: [], desc: 'Groups to exclude when installing'
16
17
  def install(*names) # Parse in the Bukfile
17
- raw_resources = parse_resources(names)
18
+ without = options[:without].map(&:to_sym)
19
+ raw_resources = parse_resources(names, without)
18
20
 
19
21
  # Get all the informatin needed to install
20
22
  resources = prepare_resources(raw_resources)
@@ -29,11 +31,18 @@ module Bukin
29
31
  end
30
32
 
31
33
  private
32
- def parse_resources(names)
34
+ def parse_resources(names, without)
33
35
  resources = section('Parsing Bukfile') {Bukin::Bukfile.new.resources}
34
36
 
35
37
  # If name are specified, only install resources with those names
36
38
  resources.select! {|resource| names.include?(resource[:name])} if names.any?
39
+
40
+ # Skip any resources that only exist in excluded groups
41
+ if without.any?
42
+ resources.select! do |resource|
43
+ resource[:group].empty? || (resource[:group] - without).any?
44
+ end
45
+ end
37
46
  raise Bukin::BukinError, "Nothing to install" if resources.empty?
38
47
 
39
48
  resources
@@ -1,3 +1,3 @@
1
1
  module Bukin
2
- VERSION = '0.7.0'
2
+ VERSION = '0.8.0'
3
3
  end
@@ -3,7 +3,6 @@ require 'bukin'
3
3
 
4
4
  describe Bukin::Bukfile do
5
5
  [:server, :plugin].each do |type|
6
-
7
6
  it "adds a #{type} by method" do
8
7
  bukfile = Bukin::Bukfile.new{}
9
8
  bukfile.resources.size.should == 0
@@ -88,4 +87,128 @@ describe Bukin::Bukfile do
88
87
  bukfile.resources.size.should == 0
89
88
  bukfile.resources.find{|resource| resource[:name] == 'missing_plugin'}.should be_nil
90
89
  end
90
+
91
+ it 'attaches a single group to a resource' do
92
+ bukfile = Bukin::Bukfile.new do
93
+ plugin 'test', group: :test
94
+ end
95
+
96
+ bukfile.resources.first[:group].should == [:test]
97
+ end
98
+
99
+ it 'attaches multiple groups to a resource' do
100
+ bukfile = Bukin::Bukfile.new do
101
+ plugin 'test', group: [:test, :development]
102
+ end
103
+
104
+ bukfile.resources.first[:group].should == [:test, :development]
105
+ end
106
+
107
+ it 'attaches a single group to multiple resources' do
108
+ bukfile = Bukin::Bukfile.new do
109
+ group :test do
110
+ plugin 'test1'
111
+ plugin 'test2'
112
+ end
113
+ end
114
+
115
+ bukfile.resources[0][:group].should == [:test]
116
+ bukfile.resources[1][:group].should == [:test]
117
+ end
118
+
119
+ it 'attaches multiple groups to multiple resources' do
120
+ bukfile = Bukin::Bukfile.new do
121
+ group :test, :development do
122
+ plugin 'test1'
123
+ plugin 'test2'
124
+ end
125
+ end
126
+
127
+ bukfile.resources[0][:group].should == [:test, :development]
128
+ bukfile.resources[1][:group].should == [:test, :development]
129
+ end
130
+
131
+ it 'attaches groups to multiple resources' do
132
+ bukfile = Bukin::Bukfile.new do
133
+ group :test do
134
+ plugin 'test1', group: :development
135
+ plugin 'test2'
136
+ end
137
+ end
138
+
139
+ bukfile.resources[0][:group].should =~ [:test, :development]
140
+ bukfile.resources[1][:group].should == [:test]
141
+ end
142
+
143
+ it 'combines duplicate groups' do
144
+ bukfile = Bukin::Bukfile.new do
145
+ group :test do
146
+ plugin 'test1', group: [:development, :test]
147
+ plugin 'test2', group: :test
148
+ end
149
+ end
150
+
151
+ bukfile.resources[0][:group].should =~ [:test, :development]
152
+ bukfile.resources[1][:group].should == [:test]
153
+ end
154
+
155
+ it 'combines duplicate method groups' do
156
+ bukfile = Bukin::Bukfile.new do
157
+ group :test, :test do
158
+ plugin 'test'
159
+ end
160
+ end
161
+
162
+ bukfile.resources.first[:group].should == [:test]
163
+ end
164
+
165
+ it 'combines duplicate resource groups' do
166
+ bukfile = Bukin::Bukfile.new do
167
+ plugin 'test', group: [:test, :test]
168
+ end
169
+
170
+ bukfile.resources.first[:group].should == [:test]
171
+ end
172
+
173
+ it 'only adds groups inside a block' do
174
+ bukfile = Bukin::Bukfile.new do
175
+ group :development do
176
+ plugin 'test1'
177
+ end
178
+ plugin 'test2'
179
+ end
180
+
181
+ bukfile.resources[0][:group].should == [:development]
182
+ bukfile.resources[1][:group].should == []
183
+ end
184
+
185
+ it 'throws an error when groups are nested' do
186
+ expect do
187
+ Bukin::Bukfile.new do
188
+ group :test do
189
+ group :development do
190
+ plugin 'test'
191
+ end
192
+ end
193
+ end
194
+ end.to raise_error(Bukin::BukfileError)
195
+ end
196
+
197
+ it 'throws an error when group is not a symbol' do
198
+ expect do
199
+ Bukin::Bukfile.new do
200
+ group 'test' do
201
+ plugin 'test'
202
+ end
203
+ end
204
+ end.to raise_error(Bukin::BukfileError)
205
+ end
206
+
207
+ it 'throws an error when resource group is not a symbol' do
208
+ expect do
209
+ Bukin::Bukfile.new do
210
+ plugin 'test', group: 'test'
211
+ end
212
+ end.to raise_error(Bukin::BukfileError)
213
+ end
91
214
  end
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.7.0
4
+ version: 0.8.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: 2014-01-19 00:00:00.000000000 Z
12
+ date: 2014-01-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thor