bukkit 1.1.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1abf5468b2746310d6754a4a69fc7081762bfe4a
4
- data.tar.gz: ce882671e640baa4cd3bfe083ebc77b17c38467a
3
+ metadata.gz: f1b629fd2236d5b00287b416a0ef102b447176db
4
+ data.tar.gz: da6b41be2fb9f960e801bc9544cbe0642ab10427
5
5
  SHA512:
6
- metadata.gz: 42ac84c2efc316fef4361ad46200478e3a98f0609835f5cd43377385c2e6211190b126875bfe53b8039ff97d63c87d2a2e75bab2507f33eb5e844337392e1f9a
7
- data.tar.gz: 0a610454dfab3267ffb43efbc4a066dda0771e77e892941b09ab8897326a554a2843b0b67345f840eb17c1a3e909e452676ec44c6263bc6eb7f0f20e1a2fd60f
6
+ metadata.gz: c982ff1f02457fe724335a3ef186264bdfe6145bb149d12352ccac98429dddaf2ce8fe7102465ea172280f33369ec95a7e552d6e1a99c8c18376cc968f8e0aef
7
+ data.tar.gz: f21745c682369af6d43389054bcfcdd563e0e6b8eda67621987524b2f11d25a8afc62487492955a8d999ca7d94a71d2484cc1d4bf2162c6f102ccc91316abd37
data/.gitignore CHANGED
@@ -1,4 +1,6 @@
1
1
  .DS_Store
2
+ *.swp
3
+ *~
2
4
  *.gem
3
5
  gem/
4
- test/
6
+ my-awesome-server/
@@ -1,5 +1,4 @@
1
1
  language: ruby
2
2
  rvm:
3
3
  - 2.0.0
4
- - 1.9.3
5
- - 1.8.7
4
+ - 1.9.3
@@ -1,12 +1,13 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bukkit (1.1.0)
4
+ bukkit (2.0.0)
5
5
  archive-zip
6
6
  colorize
7
7
  commander
8
- json
8
+ curb
9
9
  launchy
10
+ multi_json
10
11
 
11
12
  GEM
12
13
  remote: https://rubygems.org/
@@ -17,11 +18,12 @@ GEM
17
18
  colorize (0.6.0)
18
19
  commander (4.1.5)
19
20
  highline (~> 1.6.11)
21
+ curb (0.8.5)
20
22
  highline (1.6.20)
21
23
  io-like (0.3.0)
22
- json (1.8.1)
23
- launchy (2.3.0)
24
+ launchy (2.4.2)
24
25
  addressable (~> 2.3)
26
+ multi_json (1.8.2)
25
27
  rake (10.1.0)
26
28
 
27
29
  PLATFORMS
data/LICENSE CHANGED
@@ -19,4 +19,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
19
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
20
  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
21
  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile CHANGED
@@ -1,40 +1,52 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- $: << File.expand_path(File.dirname(__FILE__) + "/../lib")
4
-
5
- # Lib Files
6
- require 'bukkit/version'
3
+ # Created by Jesse Herrick
4
+ # www.jessegrant.net
5
+ # jessegrantherrick@gmail.com
7
6
 
8
7
  # Gems
9
8
  require "rubygems"
10
9
  require "rake"
11
10
  require "colorize"
11
+ require "rake/testtask"
12
12
 
13
- # Tasks
14
- desc "Get version"
15
- task :version do
16
- version = Bukkit::VERSION_FULL.split
17
- puts "#{version[0].blue} #{version[1].yellow}"
13
+ # Helpers
14
+ def test(filename)
15
+ puts `ruby -I . test/test_#{filename}.rb`
18
16
  end
19
17
 
18
+ # Tasks
20
19
  desc "Default task."
21
20
  task :default do
22
- `rake version`
23
- puts "Nothing to see here... move along.".green
24
- puts "Run".yellow + " `bukkit new my-awesome-server-name` to start a new server."
21
+ puts `rake test`
22
+ puts "Gem seems to be in tip top shape!".green
23
+ puts "Run: ".yellow + "`bukkit --help` to list all commands."
24
+ end
25
+
26
+ # Run all tests.
27
+ Rake::TestTask.new do |t|
28
+ t.libs << "test"
29
+ t.libs << "bin"
30
+ t.test_files = FileList['test/test*.rb']
31
+ t.verbose = true
25
32
  end
26
33
 
27
34
  desc "Build gem."
28
35
  task :build do
29
- puts "Starting gem build...".yellow
30
- puts " Building...".yellow
31
- `gem build bukkit.gemspec`
36
+ puts "Starting gem build...".yellow
37
+ puts " Building...".yellow
38
+ `gem build bukkit.gemspec`
32
39
 
33
- version = Bukkit::VERSION
34
- puts "Bukkit-CLI successfully built! ".green + "Gem ".blue + "v" + version
40
+ puts "bukkit successfully built!".green
41
+ puts "Gems in this directory: ".yellow
42
+ Dir.glob("*.gem").each { |gem| puts "=> " + gem.yellow }
43
+ end
35
44
 
36
- gem = Dir.glob("*.gem")[0]
37
- Dir.mkdir("gem") unless Dir.exists?("gem")
38
- FileUtils.mv(gem, "gem/")
39
- puts " Gem: ".red + "#{Dir.getwd}/gem/" + gem.yellow
45
+ desc "Install the gem."
46
+ task :install do
47
+ gem = Dir.glob("*.gem").last
48
+ puts "Installing gem...".yellow
49
+ puts "From: ".yellow + gem
50
+ `gem install #{gem}`
51
+ puts "Gem successfully installed!".green
40
52
  end
data/bin/bukkit CHANGED
@@ -18,134 +18,146 @@ command :new do |c|
18
18
  c.option "--rb", "Create a new server with the recommended build."
19
19
  c.option "--beta", "Create a new server with the beta build."
20
20
  c.option "--dev", "Create a new server with the dev build."
21
- c.option "-f", "--force", "Overwrites the chosen directory if it already exists."
22
- # TODO: Those are bools, pass the t/f values to a case statement then pass that to Bukkit::new
21
+ c.option "-f", "--force", "Overwrites the chosen directory if it already exists."
22
+
23
23
  c.action do |args, options|
24
- # Make 'dir' = to first arg
25
- dir = args.shift
26
-
27
- if options.rb == true
28
- build = "rb"
29
- elsif options.beta == true
30
- build = "beta"
31
- elsif options.dev == true
32
- build = "dev"
24
+ rb = options.rb
25
+ beta = options.beta
26
+ dev = options.dev
27
+ force = options.force
28
+
29
+ name = args.shift
30
+
31
+ new_options = Hash.new
32
+
33
+ # If it doesn't have a name then just stop them right there.
34
+ abort "You didn't enter a server name.\nTry `bukkit new my-awesome-server-name`." if name.nil?
35
+
36
+ # Add the build to the new_options hash.
37
+ if rb
38
+ new_options.merge!(:build => :rb)
39
+ elsif beta
40
+ new_options.merge!(:build => :beta)
41
+ elsif dev
42
+ new_options.merge!(:build => :dev)
33
43
  else
34
- build = ask "What build would you like? (rb/beta/dev) "
35
- case build.downcase
36
- when "rb", "recommended", "r"
37
- build = "rb"
38
- when "beta", "b"
39
- build = "beta"
40
- when "dev", "d", "developer"
41
- build = "dev"
44
+ # If the user didn't give a build option then ask for it.
45
+ build = ask "Build [rb/beta/dev]: "
46
+ case build
47
+ when "rb", "recommended"
48
+ new_options.merge!(:build => :rb)
49
+ when "beta"
50
+ new_options.merge!(:build => :beta)
51
+ when "dev", "development"
52
+ new_options.merge!(:build => :dev)
42
53
  else
43
- abort "ERROR: Invalid option '#{build}'\nTry `bukkit new --help`"
54
+ abort "Invalid build option.".red
44
55
  end
45
56
  end
46
57
 
47
- if options.force == true
48
- force = true
49
- else
50
- force = nil
51
- end
52
-
53
- begin
54
- Bukkit::new(build, dir, force)
55
- rescue TypeError
56
- abort "ERROR: Server name not specified.\nTry `bukkit new my-awesome-server-name`"
57
- end
58
+ # Add the force option if it's needed. Adds the bool returned from 'force'.
59
+ force = false if force.nil?
60
+ new_options.merge!(:force => force)
61
+
62
+ # Now finally send the options to the method.
63
+ server = Bukkit::Server.new(name)
64
+ server.create(new_options)
65
+ server.start
58
66
  end
59
67
  end
68
+ alias_command :create, :new
60
69
 
61
- command :start do |c|
62
- c.syntax = "bukkit start"
63
- c.summary = "Start your server."
64
- c.description = "Start the bukkit server. (Must be in server's root)"
65
- c.example "Start your server.", "bukkit start"
66
- c.action do |args, options|
67
- puts "Starting the server...".green
68
- Bukkit::start
69
- end
70
+ command :update do |c|
71
+ c.syntax = "bukkit update [options]"
72
+ c.summary = "Download the latest CraftBukkit version."
73
+ c.description = "Download the latest CraftBukkit version from dl.bukkit.org."
74
+ c.example c.summary, "bukkit update"
75
+ c.option "--rb", "Update server with the recommended build."
76
+ c.option "--beta", "Update server with the beta build."
77
+ c.option "--dev", "Update server with the dev build."
78
+
79
+ c.action do |args, options|
80
+ rb = options.rb
81
+ beta = options.beta
82
+ dev = options.dev
83
+ force = options.force
84
+
85
+ update_options = Hash.new
86
+
87
+ # Add the build to the new_options hash.
88
+ if rb
89
+ update_options.merge!(:build => :rb)
90
+ elsif beta
91
+ update_options.merge!(:build => :beta)
92
+ elsif dev
93
+ update_options.merge!(:build => :dev)
94
+ else
95
+ # If the user didn't give a build option then ask for it.
96
+ build = ask "Build [rb/beta/dev]: "
97
+ case build
98
+ when "rb", "recommended"
99
+ update_options.merge!(:build => :rb)
100
+ when "beta"
101
+ update_options.merge!(:build => :beta)
102
+ when "dev", "development"
103
+ update_options.merge!(:build => :dev)
104
+ else
105
+ puts "Invalid build option."
106
+ end
107
+ end
108
+ # Now finally send the options to the method.
109
+ Bukkit::Server.update(update_options)
110
+ end
70
111
  end
71
112
 
72
- command :install do |c|
73
- c.syntax = "bukkit install my-favorite-plugin [options]"
74
- c.summary = "Install a new bukkit plugin."
75
- c.description = "Installs a new bukkit plugin. Must be on dev.bukkit.org. (can also be a zip!)"
76
-
77
- c.example "Installs the plugin 'my-favorite-plugin' (will ask for website when done).", "bukkit install my-favorite-plugin"
78
-
79
- c.example "Installs the plugin 'my-favorite-plugin' and doesn't ask to open it's website", "bukkit install my-favorite-plugin --nowebsite"
80
- c.option "--nowebsite", "Doesn't ask for website after install."
81
-
82
- c.action do |args, options|
83
- if args.empty?
84
- abort "ERROR: ".red + "You didn't enter an argument."
85
- else
86
- if options.nowebsite == true
87
- Bukkit::Install.normal(args.shift.downcase, true)
88
- else
89
- Bukkit::Install.normal(args.shift.downcase)
90
- end
91
- end
92
- end
113
+ command :start do |c|
114
+ c.syntax = "bukkit start"
115
+ c.summary = "Open the plugin's start in the default browser."
116
+ c.description = c.summary
117
+ c.example c.summary, "bukkit website plugin-name"
118
+ c.example "Show just the plugin's URL.", "bukkit website plugin-name --url"
119
+ c.option "--url", "Show just the plugin's URL."
120
+
121
+ c.action do |args, options|
122
+ Bukkit::Server.start
123
+ end
93
124
  end
94
125
 
95
126
  command :website do |c|
96
- c.syntax = "bukkit website my-favorite-plugin"
97
- c.summary = "Open a plugin's website."
98
- c.description = "Opens a plugin's website your default browser."
99
- c.example "Open a plugin's website.", "bukkit website my-favorite-plugin"
100
- c.option "-u", "--url", "Only show the url."
101
- c.action do |args, options|
102
- if args.empty?
103
- abort "ERROR: ".red + "You didn't enter an argument."
104
- else
105
- plugin = args.shift.downcase
106
- if options.url == true
107
- Bukkit.url(plugin)
108
- else
109
- Bukkit.website(plugin)
110
- end
111
- end
112
- end
127
+ c.syntax = "bukkit website [options]"
128
+ c.summary = "Open the plugin's website in the default browser."
129
+ c.description = c.summary
130
+ c.example c.summary, "bukkit website plugin-name"
131
+ c.example "Show just the plugin's URL.", "bukkit website plugin-name --url"
132
+ c.option "--url", "Show just the plugin's URL."
133
+
134
+ c.action do |args, options|
135
+ abort "You didn't enter a plugin name." if args.shift.nil?
136
+
137
+ plugin = Bukkit::Plugin.new(args.shift)
138
+
139
+ if options.url
140
+ puts " Website: ".yellow + plugin.website
141
+ else
142
+ plugin.view_website
143
+ end
144
+ end
113
145
  end
114
146
 
115
- command :update do |c|
116
- c.syntax = "bukkit update [options]"
117
- c.summary = "Get the latest version of bukkit."
118
- c.description = "Download the latest version of CraftBukkit."
119
- c.example "Updates your server to the latest recommended build.", "bukkit update --rb"
120
- c.option "--rb", "Get the latest recommended build."
121
- c.option "--beta", "Get the latest beta build."
122
- c.option "--dev", "Get the latest dev build."
123
- # TODO: Those are bools, pass the t/f values to a case statement then pass that to Bukkit::new
124
- c.action do |args, options|
125
- if options.rb == true
126
- build = "rb"
127
- elsif options.beta == true
128
- build = "beta"
129
- elsif options.dev == true
130
- build = "dev"
131
- else
132
- build = ask "What build would you like? (rb/beta/dev) "
133
- case build.downcase
134
- when "rb", "recommended", "r"
135
- build = "rb"
136
- when "beta", "b"
137
- build = "beta"
138
- when "dev", "d", "developer"
139
- build = "dev"
140
- else
141
- abort "ERROR:".red + " Invalid option '#{build}'\nTry `bukkit new --help`"
142
- end
143
- end
144
- # Send args & opts to Bukkit::update
145
- begin
146
- Bukkit::update(build)
147
- rescue
148
- abort "ERROR:".red + " Something bad happened!.\nTry `bukkit new --help`\n If error persists create an issue with specific details here:\n https://github.com/JesseHerrick/bukkit/issues/new"
149
- end
150
- end
147
+ command :install do |c|
148
+ c.syntax = "bukkit install my-favorite-plugin"
149
+ c.summary = "Install a plugin to your server."
150
+ c.description = c.summary
151
+ c.example c.summary, "bukkit install my-favorite-plugin"
152
+
153
+ c.action do |args, options|
154
+ name = args.shift
155
+
156
+ if name.empty?
157
+ abort "You didn't enter a plugin name."
158
+ else
159
+ plugin = Bukkit::Plugin.new(name)
160
+ plugin.install
161
+ end
162
+ end
151
163
  end
@@ -1,31 +1,31 @@
1
- # coding: utf-8
2
1
  lib = File.expand_path('../lib', __FILE__)
3
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
3
  require 'bukkit/version'
5
4
 
6
5
  Gem::Specification.new do |spec|
7
- spec.name = "bukkit"
8
- spec.version = Bukkit::VERSION
9
- spec.authors = ["Jesse Herrick"]
10
- spec.email = ["school@jessegrant.net"]
11
- spec.description = %q{A command line wrapper for CraftBukkit.}
12
- spec.summary = %q{A command line wrapper for CraftBukkit. Manage your server much easier.}
13
- spec.homepage = "https://github.com/JesseHerrick/Bukkit-CLI"
14
- spec.license = "MIT"
6
+ spec.name = "bukkit"
7
+ spec.version = Bukkit::VERSION
8
+ spec.authors = ["Jesse Herrick"]
9
+ spec.email = ["school@jessegrant.net"]
10
+ spec.description = %q{A command line wrapper for CraftBukkit.}
11
+ spec.summary = %q{A command line wrapper for CraftBukkit. Manage your server much easier.}
12
+ spec.homepage = "https://github.com/JesseHerrick/Bukkit-CLI"
13
+ spec.license = "MIT"
15
14
 
16
- spec.files = `git ls-files`.split($/)
17
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
- spec.require_paths = ["lib"]
15
+ spec.files = `git ls-files`.split($/)
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
20
19
 
21
- # Runtime Dependencies
22
- spec.add_runtime_dependency('archive-zip')
23
- spec.add_runtime_dependency('colorize')
24
- spec.add_runtime_dependency('commander')
25
- spec.add_runtime_dependency('json')
26
- spec.add_runtime_dependency('launchy')
20
+ # Runtime Dependencies
21
+ spec.add_runtime_dependency('archive-zip')
22
+ spec.add_runtime_dependency('colorize')
23
+ spec.add_runtime_dependency('commander')
24
+ spec.add_runtime_dependency('multi_json')
25
+ spec.add_runtime_dependency('launchy')
26
+ spec.add_runtime_dependency('curb')
27
27
 
28
- # Dev Dependencies
29
- spec.add_development_dependency('bundler')
30
- spec.add_development_dependency('rake')
28
+ # Dev Dependencies
29
+ spec.add_development_dependency('bundler')
30
+ spec.add_development_dependency('rake')
31
31
  end
@@ -1,11 +1,28 @@
1
1
  # Orderly and Alphabetical Require Statements
2
2
  require 'rubygems'
3
+ require 'colorize'
4
+ require 'open-uri'
5
+ require 'json'
3
6
 
4
- require 'bukkit/check'
7
+ require 'bukkit/create'
5
8
  require 'bukkit/download'
6
9
  require 'bukkit/install'
7
- require 'bukkit/new'
8
10
  require 'bukkit/start'
9
11
  require 'bukkit/update'
10
12
  require 'bukkit/version'
11
- require 'bukkit/website'
13
+ require 'bukkit/website'
14
+
15
+ module Bukkit
16
+ class Server
17
+ def initialize(name)
18
+ @name = name
19
+ end
20
+ end
21
+
22
+ class Plugin
23
+ def initialize(name)
24
+ @name = name.downcase
25
+ @plugin_api = JSON.parse(open("http://api.bukget.org/3/plugins/bukkit/#{@name}").read)
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,30 @@
1
+ module Bukkit
2
+ class Server
3
+ # Create a new server.
4
+ def create(options = {}) # Options: { :build => :rb/:beta/:dev, :force => false/true }
5
+ force = options[:force]
6
+
7
+ # If the dir already exists, fail gracefully.
8
+ if Dir.exists?(@name)
9
+ puts "'#{@name}' already exists.".red
10
+
11
+ names = %w{ minecraftyness mine-opolis mineville minetown bukkits-o-fun }
12
+ abort "Try ".yellow + "`bukkit new #{names.sample}` ".light_yellow + "or".yellow + " `bukkit new #{@name} --force`".light_blue
13
+ end
14
+
15
+ # Let the dark side of the force flow through you...
16
+ if force == true
17
+ puts "Overwriting: ".light_red + "#{@name}/"
18
+ FileUtils.rm_rf(@name)
19
+ end
20
+
21
+ # Create the server directory and cd into it.
22
+ Dir.mkdir(@name)
23
+ puts " Create: ".green + "#{@name}/"
24
+ Dir.chdir(@name)
25
+
26
+ # Download build.
27
+ Bukkit::Server.download("http://dl.bukkit.org/latest-#{options[:build].to_s}/craftbukkit.jar")
28
+ end
29
+ end
30
+ end
@@ -1,13 +1,32 @@
1
- require 'open-uri'
1
+ require 'curb'
2
2
 
3
3
  module Bukkit
4
- def self.download(filename, uri)
5
- begin
6
- File.open("#{filename}", "wb") do |file|
7
- file.write open("#{uri}").read
4
+ class Server
5
+ # Download a file from a URI.
6
+ def self.download(uri, options = {}) # Options: { :filename => "filename.ext" }
7
+ # Get the filename. If it isn't defined, derive it from the URI.
8
+ if options[:filename]
9
+ filename = options[:filename]
10
+ else
11
+ filename = uri.split("\/").last
8
12
  end
9
- rescue Errno::ENOENT
10
- abort "ERROR: No internet connection."
13
+
14
+ # Give some friendly output.
15
+ puts "Downloading: ".yellow + filename
16
+ puts " From: ".yellow + uri
17
+
18
+ # Download the file.
19
+ data = Curl::Easy.perform(uri)
20
+ data.follow_location = true
21
+ data.max_redirects = 8
22
+ data.useragent = "curb"
23
+ data.perform
24
+ File.open(filename, "wb") do |file|
25
+ file.write(data.body_str)
26
+ end
27
+ # => filename.ext
28
+
29
+ puts filename.light_green + " successfully downloaded!".green
11
30
  end
12
31
  end
13
32
  end
@@ -1,74 +1,49 @@
1
1
  require 'open-uri'
2
2
  require 'json'
3
3
  require 'archive/zip'
4
- require 'launchy'
5
- require 'colorize'
6
4
 
7
5
  module Bukkit
8
- class Install
9
- def self.normal(plugin, nowebsite = false)
10
- # Check if in root
11
- abort "ERROR:".red + " Not in server's root directory.\nTry `bukkit new my-awesome-server-name`.".yellow if Bukkit::Check.root? == false
6
+ class Plugin
7
+ # Install a new plugin.
8
+ def install
9
+ # Get server's download link.
10
+ @download_url = @plugin_api["versions"][0]["download"]
11
+ @filename = @plugin_api["versions"][0]["filename"]
12
12
 
13
- # BukGet API for Plugin Installs
14
- plugins_api = JSON.parse(open("http://api.bukget.org/3/plugins/bukkit/#{plugin}").read)
15
- # Get Plugin's Website
16
- @@website = plugins_api["website"]
17
- # Get Plugin's Download Link
18
- download = plugins_api["versions"][0]["download"]
19
- # Get Plugin's Filename
20
- filename = plugins_api["versions"][0]["filename"]
21
- # Switch to plugins dir
22
- plugin = plugin.downcase
13
+ # Fail... gracefully, if craftbukkit.jar does not exist.
14
+ abort "You're not in a server's root directory!".red unless File.exists? "craftbukkit.jar"
15
+
16
+ # Go into plugins and download the plugin.
23
17
  Dir.chdir("plugins")
24
- puts "Downloading #{plugin} from #{@@website}..."
25
- # Download File from dev.bukkit.org
26
- Bukkit::download(filename, download)
18
+ Bukkit::Server.download(@download_url, :filename => @filename)
27
19
 
28
- file_ext = File.extname(filename)
20
+ file_ext = File.extname(@filename)
29
21
 
30
22
  # Unzip if it's a zip
31
23
  case file_ext
32
24
  when ".zip"
33
25
  # Extract Zip Archive
34
- Archive::Zip.extract(filename, plugin)
35
- Dir.chdir(plugin)
26
+ Archive::Zip.extract(@filename, @name)
27
+ Dir.chdir(@name)
36
28
  jarfiles = Dir.glob("*.jar")
37
29
  # Move each jar file outside the folder.
38
30
  jarfiles.each do |jar|
39
31
  FileUtils.mv(jar, "../")
40
32
  end
33
+ puts " Unarchived: ".yellow + @filename
34
+
41
35
  Dir.chdir("../")
42
36
  # Delete the extracted folder.
43
- FileUtils.rm_r("#{plugin}/", :force => true)
37
+ FileUtils.rm_rf("#{@name}/")
44
38
  # Delete the archive.
45
- FileUtils.rm_r("filename", :force => true)
46
-
47
- puts "#{plugin.capitalize!} successfully installed!"
48
-
49
- if nowebsite == false
50
- website?
51
- end
52
- # If it's a jar... continue.
39
+ FileUtils.rm_rf(@filename)
53
40
  when ".jar"
54
- if nowebsite == true
55
- abort
56
- else
57
- website?
58
- end
59
- # If it's anything else...
41
+ nil
60
42
  else
61
- say "ERROR: ".red + "#{file_ext} is not supported at this time."
62
- end
63
- end
64
-
65
- def self.website?
66
- website_yn = agree "Would you like to visit it's website? (yes/no)"
67
-
68
- if website_yn == true
69
- puts "Launching website!"
70
- Launchy.open(@@website)
43
+ abort "Something weird happened...\nThe file extension is #{file_ext}, not '.zip' or '.jar'."
71
44
  end
45
+ puts " Installed: ".light_green + @name
46
+ puts @name.light_green + " successfully installed!".green
72
47
  end
73
48
  end
74
49
  end
@@ -1,6 +1,9 @@
1
1
  module Bukkit
2
- def self.start
3
- abort "ERROR:".red + " You aren't in your server's root directory." if Bukkit::Check.root? == false
4
- system 'java -jar craftbukkit.jar'
2
+ class Server
3
+ # Start the server.
4
+ def start
5
+ puts "Starting your CraftBukkit server.".green
6
+ system 'java -jar craftbukkit.jar'
7
+ end
5
8
  end
6
9
  end
@@ -1,19 +1,13 @@
1
1
  module Bukkit
2
- def self.update(build)
3
- # Get build url.
4
- case build
5
- when "rb"
6
- # Download the Latest Recommended Build
7
- say "Downloading Recommended Build... (this may take a while)"
8
- Bukkit::download("craftbukkit.jar", "http://cbukk.it/craftbukkit.jar")
9
- when "beta"
10
- # Download the Latest Beta Build
11
- say "Downloading Beta Build... (this may take a while)"
12
- Bukkit::download("craftbukkit.jar", "http://cbukk.it/craftbukkit-beta.jar")
13
- when "dev"
14
- # Download the Latest Developer Build
15
- say "Downloading Developer Build... (this may take a while)"
16
- Bukkit::download("craftbukkit.jar", "http://cbukk.it/craftbukkit-dev.jar")
2
+ class Server
3
+ # Download a new version of bukkit.
4
+ def self.update(options = { :build => :rb }) # Options: { :build => :rb/:beta/:dev }
5
+ Bukkit::Server.download("http://dl.bukkit.org/latest-#{options[:build].to_s}/craftbukkit.jar")
6
+ end
7
+
8
+ # Download a new version of bukkit.
9
+ def update(options = { :build => :rb }) # Options: { :build => :rb/:beta/:dev }
10
+ Bukkit::Server.download("http://dl.bukkit.org/latest-#{options[:build].to_s}/craftbukkit.jar")
17
11
  end
18
12
  end
19
13
  end
@@ -1,4 +1,4 @@
1
1
  module Bukkit
2
- VERSION = "1.1.1"
2
+ VERSION = "2.0.0"
3
3
  VERSION_FULL = "Bukkit-CLI v#{VERSION}"
4
- end
4
+ end
@@ -1,27 +1,20 @@
1
- require 'open-uri'
2
- require 'json'
3
1
  require 'launchy'
4
2
 
5
3
  module Bukkit
6
- def self.website(plugin)
7
- begin
8
- plugins_api = JSON.parse(open("http://api.bukget.org/3/plugins/bukkit/#{plugin}").read)
9
- website = plugins_api["website"]
10
- Launchy.open(website)
11
- sleep(1)
12
- puts "Opening the plugin's website in your default browser..."
13
- rescue OpenURI::HTTPError
14
- puts "ERROR: Plugin not found.\nMake sure you have the name correct.\nTry `bukkit website --help`"
15
- Bukkit::Help.website
16
- rescue
17
- puts "ERROR: Plugin name is undefined."
18
- end
19
- end
4
+ class Plugin
5
+ # Return the plugin's website URL.
6
+ def website
7
+ @website = @plugin_api["website"]
8
+ end
9
+ # => http://dev.bukkit.org/bukkit-plugins/pluginname
20
10
 
21
- def self.url(plugin)
22
- plugins_api = JSON.parse(open("http://api.bukget.org/3/plugins/bukkit/#{plugin}").read)
23
- website = plugins_api["website"]
24
- say "\n#{plugin}'s website URL is #{website}."
25
- puts ""
11
+ # Open website in default browser.
12
+ def view_website
13
+ Launchy.open(website)
14
+ puts "Opening #{@name}'s Website...".light_green
15
+ puts " Website: ".yellow + website
16
+ sleep 1.5
17
+ return website
18
+ end
26
19
  end
27
20
  end
@@ -0,0 +1,20 @@
1
+ require 'test/unit'
2
+ require 'bukkit'
3
+
4
+ class TestCreate < Test::Unit::TestCase
5
+ def test_create_rb
6
+ server = Bukkit::Server.new("my-awesome-server")
7
+ options = { :build => :rb, :force => true }
8
+ server.create(options)
9
+
10
+ def check_for_server
11
+ Dir.chdir("my-awesome-server/") if Dir.exists?("my-awesome-server")
12
+ true if File.exists?("craftbukkit.jar")
13
+ end
14
+
15
+ assert_equal(check_for_server, true)
16
+
17
+ Dir.pwd.red
18
+ Dir.chdir("../")
19
+ end
20
+ end
@@ -0,0 +1,10 @@
1
+ require 'test/unit'
2
+ require 'bukkit'
3
+
4
+ class TestDownload < Test::Unit::TestCase
5
+ def test_download
6
+ Bukkit::Server.download("http://www.jessegrant.net/humans.txt")
7
+ assert_equal(true, File.exists?("humans.txt"))
8
+ FileUtils.rm("humans.txt")
9
+ end
10
+ end
@@ -0,0 +1,22 @@
1
+ require 'test/unit'
2
+ require 'bukkit'
3
+
4
+ class TestInstall < Test::Unit::TestCase
5
+ def test_install
6
+ plugin = Bukkit::Plugin.new("WorldEdit")
7
+
8
+ # Go into server's dir.
9
+ Dir.chdir("my-awesome-server")
10
+ # Create plugins dir because it isn't generated by tests.
11
+ Dir.mkdir("plugins") unless Dir.exists?("plugins")
12
+ plugin.install
13
+
14
+ expected = File.exists?("WorldEdit.jar")
15
+ assert_equal(expected, true)
16
+ Dir.chdir("../")
17
+
18
+ # Then delete it again and cd back out.
19
+ FileUtils.rm_rf("plugins")
20
+ Dir.chdir("../")
21
+ end
22
+ end
@@ -0,0 +1,11 @@
1
+ require 'test/unit'
2
+ require 'bukkit'
3
+
4
+ class TestUpdate < Test::Unit::TestCase
5
+ def test_update_rb
6
+ Bukkit::Server.update(:build => :rb)
7
+ expected = File.exists?("craftbukkit.jar")
8
+ assert_equal(expected, true)
9
+ # FileUtils.rm("craftbukkit.jar")
10
+ end
11
+ end
@@ -0,0 +1,10 @@
1
+ require 'test/unit'
2
+ require 'bukkit'
3
+
4
+ class TestWebsite < Test::Unit::TestCase
5
+ def test_website
6
+ plugin = Bukkit::Plugin.new("WorldEdit")
7
+ expected = plugin.website
8
+ assert_equal(expected, "http://dev.bukkit.org/bukkit-plugins/worldedit")
9
+ end
10
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bukkit
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jesse Herrick
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-17 00:00:00.000000000 Z
11
+ date: 2013-12-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: archive-zip
@@ -53,7 +53,7 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: json
56
+ name: multi_json
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - '>='
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - '>='
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: curb
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: bundler
85
99
  requirement: !ruby/object:Gem::Requirement
@@ -128,14 +142,18 @@ files:
128
142
  - bin/bukkit
129
143
  - bukkit.gemspec
130
144
  - lib/bukkit.rb
131
- - lib/bukkit/check.rb
145
+ - lib/bukkit/create.rb
132
146
  - lib/bukkit/download.rb
133
147
  - lib/bukkit/install.rb
134
- - lib/bukkit/new.rb
135
148
  - lib/bukkit/start.rb
136
149
  - lib/bukkit/update.rb
137
150
  - lib/bukkit/version.rb
138
151
  - lib/bukkit/website.rb
152
+ - test/test_create.rb
153
+ - test/test_download.rb
154
+ - test/test_install.rb
155
+ - test/test_update.rb
156
+ - test/test_website.rb
139
157
  homepage: https://github.com/JesseHerrick/Bukkit-CLI
140
158
  licenses:
141
159
  - MIT
@@ -156,9 +174,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
156
174
  version: '0'
157
175
  requirements: []
158
176
  rubyforge_project:
159
- rubygems_version: 2.0.3
177
+ rubygems_version: 2.1.11
160
178
  signing_key:
161
179
  specification_version: 4
162
180
  summary: A command line wrapper for CraftBukkit. Manage your server much easier.
163
- test_files: []
164
- has_rdoc:
181
+ test_files:
182
+ - test/test_create.rb
183
+ - test/test_download.rb
184
+ - test/test_install.rb
185
+ - test/test_update.rb
186
+ - test/test_website.rb
@@ -1,11 +0,0 @@
1
- module Bukkit
2
- class Check
3
- def self.root?
4
- if File.exists? "craftbukkit.jar"
5
- true
6
- else
7
- false
8
- end
9
- end
10
- end
11
- end
@@ -1,39 +0,0 @@
1
- module Bukkit
2
- # N2K: http://cbukk.it/craftbukkit.jar http://cbukk.it/craftbukkit-beta.jar http://cbukk.it/craftbukkit-dev.jar
3
- def self.new(build, dir, force = false)
4
- # Create a Folder for the Server
5
- if Dir.exists?(dir)
6
- # Error unless forced dir overwrite.
7
- abort "ERROR:".red + " Directory already exists. Try a different name." unless force == true
8
-
9
- # If it didn't abort, overwrite the dir because it was forced.
10
- FileUtils.rm_r("#{dir}/")
11
- Dir.mkdir(dir)
12
- Dir.chdir(dir)
13
- else
14
- Dir.mkdir(dir)
15
- Dir.chdir(dir)
16
- end
17
-
18
- case build
19
- when "rb"
20
- # Download Recommended Build
21
- say "Downloading Recommended Build... (this may take a while)"
22
- Bukkit::download("craftbukkit.jar", "http://cbukk.it/craftbukkit.jar")
23
- when "beta"
24
- # Download Beta Build
25
- say "Downloading Beta Build... (this may take a while)"
26
- Bukkit::download("craftbukkit.jar", "http://cbukk.it/craftbukkit-beta.jar")
27
- when "dev"
28
- # Download Developer Build
29
- say "Downloading Developer Build... (this may take a while)"
30
- Bukkit::download("craftbukkit.jar", "http://cbukk.it/craftbukkit-dev.jar")
31
- end
32
-
33
- puts "Server built!".green
34
- puts "Dir: ".yellow + Dir.getwd
35
-
36
- # Start the Server
37
- Bukkit.start
38
- end
39
- end