derelict 0.2.0.travis.72 → 0.2.0.travis.77
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/derelict.gemspec +1 -0
- data/lib/derelict/instance.rb +6 -0
- data/lib/derelict/parser/plugin_list/invalid_format.rb +16 -0
- data/lib/derelict/parser/plugin_list.rb +47 -0
- data/lib/derelict/parser.rb +3 -2
- data/lib/derelict/plugin/manager.rb +110 -0
- data/lib/derelict/plugin/not_found.rb +14 -0
- data/lib/derelict/plugin.rb +29 -0
- data/lib/derelict.rb +1 -0
- data/spec/derelict/instance_spec.rb +6 -0
- data/spec/derelict/parser/plugin_list/invalid_format_spec.rb +16 -0
- data/spec/derelict/parser/plugin_list_spec.rb +31 -0
- data/spec/derelict/plugin/manager_spec.rb +183 -0
- data/spec/derelict/plugin/not_found_spec.rb +13 -0
- data/spec/derelict/plugin_spec.rb +37 -0
- metadata +31 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NjhhY2Y5NzUyYzBkYzhmYjAyNjcwMzRhNTcxYmNlZGM0ZTUxYWY3Yw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YTcxMzJmOGE4OGRkOGI0MzliYmI4MmM4ZTllOGU0NWRlOWExZDNmNw==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
N2RjNTJhNWRjZGY0MzY1NjgxOWIwMDdkOTlhOTY2ZDJkZmMwNzliNDNkNDFk
|
10
|
+
ZDRmNjVjZjIwY2VhNWUzODBjZTg0ODZmYjVjYjJjNjdiNTUyZGY4MDRmNmY5
|
11
|
+
NGZmMWE0N2QzYjE1ZjViOWZlM2JmNzUwYzAyN2VmZTZjMDUwYjU=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
OGNlZGZhNmYyNDI0NGUzYzc0Y2NlNDc4MTgyNDYxNjlkZTg5ZmY5NmY2NWIz
|
14
|
+
ZjRkZWM4YzdhMDQ3Nzc0ODM0NWNmMTZmZWI3ZDE2MDZlN2E2YzRmMTg5ZWRl
|
15
|
+
ZTBhY2ZiZWE2NjY4MmY3NGQxZTM1NTBhMjRmZWM5YmUxM2M5MWI=
|
data/derelict.gemspec
CHANGED
@@ -35,6 +35,7 @@ Gem::Specification.new do |spec|
|
|
35
35
|
spec.add_runtime_dependency "log4r"
|
36
36
|
spec.add_runtime_dependency "memoist"
|
37
37
|
spec.add_runtime_dependency "shell-executer"
|
38
|
+
spec.add_runtime_dependency "mime-types", "<2.0" # for coveralls 1.8
|
38
39
|
|
39
40
|
|
40
41
|
version_major = RbConfig::CONFIG["MAJOR"].to_i
|
data/lib/derelict/instance.rb
CHANGED
@@ -92,6 +92,12 @@ module Derelict
|
|
92
92
|
Derelict::Connection.new(self, path).validate!
|
93
93
|
end
|
94
94
|
|
95
|
+
# Initializes a plugin manager for use with this instance
|
96
|
+
def plugins
|
97
|
+
logger.info "Creating plugin manager for #{description}"
|
98
|
+
Derelict::Plugin::Manager.new(self)
|
99
|
+
end
|
100
|
+
|
95
101
|
# Provides a description of this Instance
|
96
102
|
#
|
97
103
|
# Mainly used for log messages.
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Derelict
|
2
|
+
class Parser
|
3
|
+
class PluginList
|
4
|
+
# The plugin list wasn't in the expected format, can't be parsed
|
5
|
+
class InvalidFormat < Derelict::Exception
|
6
|
+
include Derelict::Exception::OptionalReason
|
7
|
+
|
8
|
+
private
|
9
|
+
# Retrieves the default error message
|
10
|
+
def default_message
|
11
|
+
"Output from 'vagrant plugin list' was in an unexpected format"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module Derelict
|
2
|
+
# Parses the output of "vagrant plugin list"
|
3
|
+
class Parser::PluginList < Parser
|
4
|
+
autoload :InvalidFormat, "derelict/parser/plugin_list/invalid_format"
|
5
|
+
|
6
|
+
# Include "memoize" class method to memoize methods
|
7
|
+
extend Memoist
|
8
|
+
|
9
|
+
# Regexp to parse a plugin line into a plugin name and version
|
10
|
+
#
|
11
|
+
# Capture groups:
|
12
|
+
#
|
13
|
+
# 1. Plugin name, as listed in the output
|
14
|
+
# 2. Currently installed version (without surrounding brackets)
|
15
|
+
PARSE_PLUGIN = %r[
|
16
|
+
^(.*) # Plugin name starts at the start of the line.
|
17
|
+
\ # Version is separated by a space character,
|
18
|
+
\(([0-9\-_.]+)\) # contains version string surrounded by brackets
|
19
|
+
$ # at the end of the line.
|
20
|
+
]x # Ignore whitespace to allow these comments.
|
21
|
+
|
22
|
+
# Retrieves a Set containing all the plugins from the output
|
23
|
+
def plugins
|
24
|
+
plugin_lines.map {|l| parse_line l.match(PARSE_PLUGIN) }.to_set
|
25
|
+
end
|
26
|
+
|
27
|
+
# Provides a description of this Parser
|
28
|
+
#
|
29
|
+
# Mainly used for log messages.
|
30
|
+
def description
|
31
|
+
"Derelict::Parser::PluginList instance"
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
# Retrieves an array of the plugin lines in the output
|
36
|
+
def plugin_lines
|
37
|
+
return [] if output.match /no plugins installed/i
|
38
|
+
output.lines
|
39
|
+
end
|
40
|
+
|
41
|
+
# Parses a single line of the output into a Plugin object
|
42
|
+
def parse_line(match)
|
43
|
+
raise InvalidFormat.new "Couldn't parse plugin" if match.nil?
|
44
|
+
Derelict::Plugin.new *match.captures[0..1]
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
data/lib/derelict/parser.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
module Derelict
|
2
2
|
# Base class for parsers, which extract data from command output
|
3
3
|
class Parser
|
4
|
-
autoload :
|
5
|
-
autoload :
|
4
|
+
autoload :PluginList, "derelict/parser/plugin_list"
|
5
|
+
autoload :Status, "derelict/parser/status"
|
6
|
+
autoload :Version, "derelict/parser/version"
|
6
7
|
|
7
8
|
# Include "logger" method to get a logger for this class
|
8
9
|
include Utils::Logger
|
@@ -0,0 +1,110 @@
|
|
1
|
+
module Derelict
|
2
|
+
class Plugin
|
3
|
+
# A class that handles managing plugins for a Vagrant instance
|
4
|
+
class Manager
|
5
|
+
# Include "memoize" class method to memoize methods
|
6
|
+
extend Memoist
|
7
|
+
|
8
|
+
# Include "logger" method to get a logger for this class
|
9
|
+
include Utils::Logger
|
10
|
+
|
11
|
+
attr_reader :instance
|
12
|
+
|
13
|
+
# Initializes a Manager for use with a particular instance
|
14
|
+
#
|
15
|
+
# * instance: The Derelict::Instance which will have its
|
16
|
+
# plugins managed by this Manager
|
17
|
+
def initialize(instance)
|
18
|
+
@instance = instance
|
19
|
+
logger.debug "Successfully initialized #{description}"
|
20
|
+
end
|
21
|
+
|
22
|
+
# Retrieves the Set of currently installed plugins
|
23
|
+
def list
|
24
|
+
logger.info "Retrieving Vagrant plugin list for #{description}"
|
25
|
+
output = instance.execute!(:plugin, "list").stdout
|
26
|
+
Derelict::Parser::PluginList.new(output).plugins
|
27
|
+
end
|
28
|
+
memoize :list
|
29
|
+
|
30
|
+
# Determines whether a particular plugin is installed
|
31
|
+
#
|
32
|
+
# * plugin_name: Name of the plugin to look for (as a string)
|
33
|
+
def installed?(plugin_name)
|
34
|
+
fetch plugin_name; true
|
35
|
+
rescue Plugin::NotFound
|
36
|
+
false
|
37
|
+
end
|
38
|
+
|
39
|
+
# Installs a plugin (optionally a particular version)
|
40
|
+
#
|
41
|
+
# If no version is specified, the latest stable version is used
|
42
|
+
# by Vagrant.
|
43
|
+
#
|
44
|
+
# * plugin_name: Name of the plugin to install (as a string)
|
45
|
+
# * options: Hash of options, valid keys:
|
46
|
+
# * version: Particular version to install (optional,
|
47
|
+
# latest version will be installed if omitted)
|
48
|
+
# * log: Whether to log the output (optional, defaults
|
49
|
+
# to false)
|
50
|
+
def install(plugin_name, options = {})
|
51
|
+
options = {:log => false, :version => nil}.merge(options)
|
52
|
+
logger.info "Installing plugin '#{plugin_name}' using #{description}"
|
53
|
+
|
54
|
+
version = options[:version]
|
55
|
+
command = [:plugin, "install", plugin_name]
|
56
|
+
command.concat ["--plugin-version", version] unless version.nil?
|
57
|
+
|
58
|
+
log_block = options[:log] ? shell_log_block : nil
|
59
|
+
instance.execute! *command, &log_block
|
60
|
+
end
|
61
|
+
|
62
|
+
# Uninstalls a particular Vagrant plugin
|
63
|
+
#
|
64
|
+
# * plugin_name: Name of the plugin to uninstall (as a string)
|
65
|
+
def uninstall(plugin_name, options = {})
|
66
|
+
options = {:log => false}.merge(options)
|
67
|
+
logger.info "Uninstalling plugin '#{plugin_name}' using #{description}"
|
68
|
+
|
69
|
+
log_block = options[:log] ? shell_log_block : nil
|
70
|
+
instance.execute! :plugin, "uninstall", plugin_name, &log_block
|
71
|
+
end
|
72
|
+
|
73
|
+
# Updates a particular Vagrant plugin
|
74
|
+
#
|
75
|
+
# * plugin_name: Name of the plugin to update (as a string)
|
76
|
+
def update(plugin_name, options = {})
|
77
|
+
options = {:log => false}.merge(options)
|
78
|
+
logger.info "Updating plugin '#{plugin_name}' using #{description}"
|
79
|
+
|
80
|
+
log_block = options[:log] ? shell_log_block : nil
|
81
|
+
instance.execute! :plugin, "update", plugin_name, &log_block
|
82
|
+
end
|
83
|
+
|
84
|
+
# Retrieves a plugin with a particular name
|
85
|
+
#
|
86
|
+
# * plugin_name: Name of the plugin to look for (as a string)
|
87
|
+
def fetch(plugin_name)
|
88
|
+
list.find {|plugin| plugin.name == plugin_name}.tap do |plugin|
|
89
|
+
raise Plugin::NotFound.new plugin_name if plugin.nil?
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
# Provides a description of this Connection
|
94
|
+
#
|
95
|
+
# Mainly used for log messages.
|
96
|
+
def description
|
97
|
+
"Derelict::Plugin::Manager for #{instance.description}"
|
98
|
+
end
|
99
|
+
|
100
|
+
private
|
101
|
+
# A block that can be passed to #execute to log the output
|
102
|
+
def shell_log_block
|
103
|
+
Proc.new do |line|
|
104
|
+
logger(:type => :external).info line
|
105
|
+
end
|
106
|
+
end
|
107
|
+
memoize :shell_log_block
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Derelict
|
2
|
+
class Plugin
|
3
|
+
# A plugin that isn't currently installed has been retrieved
|
4
|
+
class NotFound < Derelict::Exception
|
5
|
+
# Initializes a new instance of this exception, for a plugin name
|
6
|
+
#
|
7
|
+
# * plugin_name: The name of the plugin that this exception
|
8
|
+
# relates to
|
9
|
+
def initialize(plugin_name)
|
10
|
+
super "Plugin '#{plugin_name}' is not currently installed"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Derelict
|
2
|
+
# Represents an individual Vagrant plugin at a particular version
|
3
|
+
class Plugin
|
4
|
+
autoload :Manager, "derelict/plugin/manager"
|
5
|
+
autoload :NotFound, "derelict/plugin/not_found"
|
6
|
+
|
7
|
+
attr_reader :name, :version
|
8
|
+
|
9
|
+
# Initializes a plugin with a particular name and version
|
10
|
+
#
|
11
|
+
# * name: The name of the plugin represented by this object
|
12
|
+
# * version: The version of the plugin represented by this object
|
13
|
+
def initialize(name, version)
|
14
|
+
@name = name
|
15
|
+
@version = version
|
16
|
+
end
|
17
|
+
|
18
|
+
# Ensure equivalent Plugins are equal to this one
|
19
|
+
def ==(other)
|
20
|
+
other.name == name and other.version == version
|
21
|
+
end
|
22
|
+
alias_method :eql?, :==
|
23
|
+
|
24
|
+
# Make equivalent Plugins hash to the same value
|
25
|
+
def hash
|
26
|
+
name.hash ^ version.hash
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/lib/derelict.rb
CHANGED
@@ -13,6 +13,7 @@ module Derelict
|
|
13
13
|
autoload :Exception, "derelict/exception"
|
14
14
|
autoload :Instance, "derelict/instance"
|
15
15
|
autoload :Parser, "derelict/parser"
|
16
|
+
autoload :Plugin, "derelict/plugin"
|
16
17
|
autoload :Utils, "derelict/utils"
|
17
18
|
autoload :VirtualMachine, "derelict/virtual_machine"
|
18
19
|
|
@@ -25,6 +25,12 @@ describe Derelict::Instance do
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
+
describe "#plugins" do
|
29
|
+
subject { instance.plugins }
|
30
|
+
it { should be_a Derelict::Plugin::Manager }
|
31
|
+
its(:instance) { should be instance }
|
32
|
+
end
|
33
|
+
|
28
34
|
context "with path parameter" do
|
29
35
|
let(:path) { "/foo/bar" }
|
30
36
|
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Derelict::Parser::PluginList::InvalidFormat do
|
4
|
+
it "is autoloaded" do
|
5
|
+
should be_a Derelict::Parser::PluginList::InvalidFormat
|
6
|
+
end
|
7
|
+
|
8
|
+
context "when using default reason" do
|
9
|
+
its(:message) { should eq "Output from 'vagrant plugin list' was in an unexpected format" }
|
10
|
+
end
|
11
|
+
|
12
|
+
context "when using custom reason" do
|
13
|
+
subject { Derelict::Parser::PluginList::InvalidFormat.new "reason" }
|
14
|
+
its(:message) { should eq "Output from 'vagrant plugin list' was in an unexpected format: reason" }
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Derelict::Parser::PluginList do
|
4
|
+
subject { Derelict::Parser::PluginList.new output }
|
5
|
+
let(:output) { nil }
|
6
|
+
|
7
|
+
it "is autoloaded" do
|
8
|
+
should be_a Derelict::Parser::PluginList
|
9
|
+
end
|
10
|
+
|
11
|
+
context "with valid output" do
|
12
|
+
let(:output) {
|
13
|
+
<<-END.gsub /^ +/, ""
|
14
|
+
foo (2.3.4)
|
15
|
+
bar (1.2.3)
|
16
|
+
END
|
17
|
+
}
|
18
|
+
|
19
|
+
describe "#plugins" do
|
20
|
+
subject { Derelict::Parser::PluginList.new(output).plugins }
|
21
|
+
let(:foo) { Derelict::Plugin.new "foo", "2.3.4" }
|
22
|
+
let(:bar) { Derelict::Plugin.new "bar", "1.2.3" }
|
23
|
+
it { should eq Set[foo, bar] }
|
24
|
+
|
25
|
+
include_context "logged messages"
|
26
|
+
let(:expected_logs) {[
|
27
|
+
"DEBUG pluginlist: Successfully initialized Derelict::Parser::PluginList instance\n",
|
28
|
+
]}
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,183 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Derelict::Plugin::Manager do
|
4
|
+
let(:instance) { double("instance", :description => "test instance") }
|
5
|
+
let(:manager) { Derelict::Plugin::Manager.new instance }
|
6
|
+
subject { manager }
|
7
|
+
|
8
|
+
it "is autoloaded" do
|
9
|
+
should be_a Derelict::Plugin::Manager
|
10
|
+
end
|
11
|
+
|
12
|
+
include_context "logged messages"
|
13
|
+
let(:expected_logs) {[
|
14
|
+
"DEBUG manager: Successfully initialized Derelict::Plugin::Manager for test instance\n"
|
15
|
+
]}
|
16
|
+
|
17
|
+
describe "#list" do
|
18
|
+
let(:stdout) { "stdout\n" }
|
19
|
+
let(:result) { double("result", :stdout => stdout) }
|
20
|
+
let(:parser) { double("parser", :plugins => plugins) }
|
21
|
+
let(:plugins) { [:foo, :bar] }
|
22
|
+
|
23
|
+
subject { manager.list }
|
24
|
+
|
25
|
+
before do
|
26
|
+
expect(instance).to receive(:execute!).with(:plugin, "list").and_return(result)
|
27
|
+
expect(Derelict::Parser::PluginList).to receive(:new).with(stdout).and_return(parser)
|
28
|
+
end
|
29
|
+
|
30
|
+
it { should be plugins }
|
31
|
+
|
32
|
+
include_context "logged messages"
|
33
|
+
let(:expected_logs) {[
|
34
|
+
"DEBUG manager: Successfully initialized Derelict::Plugin::Manager for test instance\n",
|
35
|
+
" INFO manager: Retrieving Vagrant plugin list for Derelict::Plugin::Manager for test instance\n",
|
36
|
+
]}
|
37
|
+
end
|
38
|
+
|
39
|
+
describe "#installed?" do
|
40
|
+
let(:plugin_name) { double("plugin_name") }
|
41
|
+
let(:result) { double("result") }
|
42
|
+
subject { manager.installed? plugin_name }
|
43
|
+
|
44
|
+
context "with known plugin" do
|
45
|
+
before { expect(manager).to receive(:fetch).with(plugin_name).and_return(result) }
|
46
|
+
it { should be true }
|
47
|
+
end
|
48
|
+
|
49
|
+
context "with unknown plugin" do
|
50
|
+
before { expect(manager).to receive(:fetch).with(plugin_name).and_raise(Derelict::Plugin::NotFound.new plugin_name) }
|
51
|
+
it { should be false }
|
52
|
+
end
|
53
|
+
|
54
|
+
include_context "logged messages"
|
55
|
+
let(:expected_logs) {[
|
56
|
+
"DEBUG manager: Successfully initialized Derelict::Plugin::Manager for test instance\n",
|
57
|
+
" INFO manager: Retrieving Vagrant plugin list for Derelict::Plugin::Manager for test instance\n",
|
58
|
+
]}
|
59
|
+
end
|
60
|
+
|
61
|
+
describe "#install" do
|
62
|
+
let(:log) { true }
|
63
|
+
let(:plugin_name) { double("plugin_name", :to_s => "test plugin") }
|
64
|
+
let(:version) { double("version") }
|
65
|
+
let(:result) { double("result") }
|
66
|
+
subject { manager.install plugin_name, :version => version, :log => log }
|
67
|
+
|
68
|
+
before do
|
69
|
+
expect(instance).to receive(:execute!).with(:plugin, "install", plugin_name, '--plugin-version', version).and_yield("test").and_return(result)
|
70
|
+
end
|
71
|
+
|
72
|
+
it { should be result }
|
73
|
+
|
74
|
+
context "with logging enabled" do
|
75
|
+
include_context "logged messages"
|
76
|
+
let(:expected_logs) {[
|
77
|
+
"DEBUG manager: Successfully initialized Derelict::Plugin::Manager for test instance\n",
|
78
|
+
" INFO manager: Installing plugin 'test plugin' using Derelict::Plugin::Manager for test instance\n",
|
79
|
+
" INFO external: test\n",
|
80
|
+
]}
|
81
|
+
end
|
82
|
+
|
83
|
+
context "with logging disabled" do
|
84
|
+
let(:log) { false }
|
85
|
+
include_context "logged messages"
|
86
|
+
let(:expected_logs) {[
|
87
|
+
"DEBUG manager: Successfully initialized Derelict::Plugin::Manager for test instance\n",
|
88
|
+
" INFO manager: Installing plugin 'test plugin' using Derelict::Plugin::Manager for test instance\n",
|
89
|
+
]}
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
describe "#uninstall" do
|
94
|
+
let(:log) { true }
|
95
|
+
let(:plugin_name) { double("plugin_name", :to_s => "test plugin") }
|
96
|
+
let(:result) { double("result") }
|
97
|
+
subject { manager.uninstall plugin_name, :log => log }
|
98
|
+
|
99
|
+
before do
|
100
|
+
expect(instance).to receive(:execute!).with(:plugin, "uninstall", plugin_name).and_yield("test").and_return(result)
|
101
|
+
end
|
102
|
+
|
103
|
+
it { should be result }
|
104
|
+
|
105
|
+
context "with logging enabled" do
|
106
|
+
include_context "logged messages"
|
107
|
+
let(:expected_logs) {[
|
108
|
+
"DEBUG manager: Successfully initialized Derelict::Plugin::Manager for test instance\n",
|
109
|
+
" INFO manager: Uninstalling plugin 'test plugin' using Derelict::Plugin::Manager for test instance\n",
|
110
|
+
" INFO external: test\n",
|
111
|
+
]}
|
112
|
+
end
|
113
|
+
|
114
|
+
context "with logging disabled" do
|
115
|
+
let(:log) { false }
|
116
|
+
include_context "logged messages"
|
117
|
+
let(:expected_logs) {[
|
118
|
+
"DEBUG manager: Successfully initialized Derelict::Plugin::Manager for test instance\n",
|
119
|
+
" INFO manager: Uninstalling plugin 'test plugin' using Derelict::Plugin::Manager for test instance\n",
|
120
|
+
]}
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
describe "#update" do
|
125
|
+
let(:log) { true }
|
126
|
+
let(:plugin_name) { double("plugin_name", :to_s => "test plugin") }
|
127
|
+
let(:result) { double("result") }
|
128
|
+
subject { manager.update plugin_name, :log => log }
|
129
|
+
|
130
|
+
before do
|
131
|
+
expect(instance).to receive(:execute!).with(:plugin, "update", plugin_name).and_yield("test").and_return(result)
|
132
|
+
end
|
133
|
+
|
134
|
+
it { should be result }
|
135
|
+
|
136
|
+
context "with logging enabled" do
|
137
|
+
include_context "logged messages"
|
138
|
+
let(:expected_logs) {[
|
139
|
+
"DEBUG manager: Successfully initialized Derelict::Plugin::Manager for test instance\n",
|
140
|
+
" INFO manager: Updating plugin 'test plugin' using Derelict::Plugin::Manager for test instance\n",
|
141
|
+
" INFO external: test\n",
|
142
|
+
]}
|
143
|
+
end
|
144
|
+
|
145
|
+
context "with logging disabled" do
|
146
|
+
let(:log) { false }
|
147
|
+
include_context "logged messages"
|
148
|
+
let(:expected_logs) {[
|
149
|
+
"DEBUG manager: Successfully initialized Derelict::Plugin::Manager for test instance\n",
|
150
|
+
" INFO manager: Updating plugin 'test plugin' using Derelict::Plugin::Manager for test instance\n",
|
151
|
+
]}
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
|
156
|
+
describe "#fetch" do
|
157
|
+
let(:foo) { double("foo", :name => "foo") }
|
158
|
+
let(:bar) { double("bar", :name => "bar") }
|
159
|
+
let(:plugins) { [foo, bar] }
|
160
|
+
|
161
|
+
let(:plugin_name) { double("plugin_name") }
|
162
|
+
subject { manager.fetch plugin_name }
|
163
|
+
before { expect(manager).to receive(:list).and_return(plugins) }
|
164
|
+
|
165
|
+
context "with known plugin" do
|
166
|
+
let(:plugin_name) { "foo" }
|
167
|
+
it { should be foo }
|
168
|
+
end
|
169
|
+
|
170
|
+
context "with unknown plugin" do
|
171
|
+
let(:plugin_name) { "qux" }
|
172
|
+
it "should raise NotFound" do
|
173
|
+
expect { subject }.to raise_error Derelict::Plugin::NotFound
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
include_context "logged messages"
|
178
|
+
let(:expected_logs) {[
|
179
|
+
"DEBUG manager: Successfully initialized Derelict::Plugin::Manager for test instance\n",
|
180
|
+
]}
|
181
|
+
end
|
182
|
+
|
183
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Derelict::Plugin::NotFound do
|
4
|
+
subject { Derelict::Plugin::NotFound.new "test" }
|
5
|
+
|
6
|
+
it "is autoloaded" do
|
7
|
+
should be_a Derelict::Plugin::NotFound
|
8
|
+
end
|
9
|
+
|
10
|
+
its(:message) {
|
11
|
+
should eq "Plugin 'test' is not currently installed"
|
12
|
+
}
|
13
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Derelict::Plugin do
|
4
|
+
let(:name) { double("name") }
|
5
|
+
let(:version) { double("version") }
|
6
|
+
let(:plugin) { Derelict::Plugin.new name, version }
|
7
|
+
subject { plugin }
|
8
|
+
|
9
|
+
it "is autoloaded" do
|
10
|
+
should be_a Derelict::Plugin
|
11
|
+
end
|
12
|
+
|
13
|
+
its(:name) { should be name }
|
14
|
+
its(:version) { should be version }
|
15
|
+
|
16
|
+
context "when comparing to an equivalent" do
|
17
|
+
let(:other) { plugin.dup }
|
18
|
+
|
19
|
+
it { should eq other }
|
20
|
+
its(:hash) { should eq other.hash }
|
21
|
+
|
22
|
+
specify "#eql?(other) should be true" do
|
23
|
+
expect(subject.eql? other).to be true
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context "when comparing to a non-equivalent" do
|
28
|
+
let(:other) { plugin.class.new "not_foo", "1.0" }
|
29
|
+
|
30
|
+
it { should_not eq other }
|
31
|
+
its(:hash) { should_not eq other.hash }
|
32
|
+
|
33
|
+
specify "#eql?(other) should be false" do
|
34
|
+
expect(subject.eql? other).to be false
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: derelict
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.0.travis.
|
4
|
+
version: 0.2.0.travis.77
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brad Feehan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-10-
|
11
|
+
date: 2013-10-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: log4r
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - ! '>='
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: mime-types
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - <
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2.0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - <
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '2.0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: bundler
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -188,10 +202,15 @@ files:
|
|
188
202
|
- lib/derelict/instance/non_directory.rb
|
189
203
|
- lib/derelict/instance/not_found.rb
|
190
204
|
- lib/derelict/parser.rb
|
205
|
+
- lib/derelict/parser/plugin_list.rb
|
206
|
+
- lib/derelict/parser/plugin_list/invalid_format.rb
|
191
207
|
- lib/derelict/parser/status.rb
|
192
208
|
- lib/derelict/parser/status/invalid_format.rb
|
193
209
|
- lib/derelict/parser/version.rb
|
194
210
|
- lib/derelict/parser/version/invalid_format.rb
|
211
|
+
- lib/derelict/plugin.rb
|
212
|
+
- lib/derelict/plugin/manager.rb
|
213
|
+
- lib/derelict/plugin/not_found.rb
|
195
214
|
- lib/derelict/utils.rb
|
196
215
|
- lib/derelict/utils/logger.rb
|
197
216
|
- lib/derelict/utils/logger/array_outputter.rb
|
@@ -213,11 +232,16 @@ files:
|
|
213
232
|
- spec/derelict/instance/non_directory_spec.rb
|
214
233
|
- spec/derelict/instance/not_found_spec.rb
|
215
234
|
- spec/derelict/instance_spec.rb
|
235
|
+
- spec/derelict/parser/plugin_list/invalid_format_spec.rb
|
236
|
+
- spec/derelict/parser/plugin_list_spec.rb
|
216
237
|
- spec/derelict/parser/status/invalid_format_spec.rb
|
217
238
|
- spec/derelict/parser/status_spec.rb
|
218
239
|
- spec/derelict/parser/version/invalid_format_spec.rb
|
219
240
|
- spec/derelict/parser/version_spec.rb
|
220
241
|
- spec/derelict/parser_spec.rb
|
242
|
+
- spec/derelict/plugin/manager_spec.rb
|
243
|
+
- spec/derelict/plugin/not_found_spec.rb
|
244
|
+
- spec/derelict/plugin_spec.rb
|
221
245
|
- spec/derelict/utils/logger/array_outputter_spec.rb
|
222
246
|
- spec/derelict/utils/logger/invalid_type_spec.rb
|
223
247
|
- spec/derelict/utils/logger/raw_formatter_spec.rb
|
@@ -265,11 +289,16 @@ test_files:
|
|
265
289
|
- spec/derelict/instance/non_directory_spec.rb
|
266
290
|
- spec/derelict/instance/not_found_spec.rb
|
267
291
|
- spec/derelict/instance_spec.rb
|
292
|
+
- spec/derelict/parser/plugin_list/invalid_format_spec.rb
|
293
|
+
- spec/derelict/parser/plugin_list_spec.rb
|
268
294
|
- spec/derelict/parser/status/invalid_format_spec.rb
|
269
295
|
- spec/derelict/parser/status_spec.rb
|
270
296
|
- spec/derelict/parser/version/invalid_format_spec.rb
|
271
297
|
- spec/derelict/parser/version_spec.rb
|
272
298
|
- spec/derelict/parser_spec.rb
|
299
|
+
- spec/derelict/plugin/manager_spec.rb
|
300
|
+
- spec/derelict/plugin/not_found_spec.rb
|
301
|
+
- spec/derelict/plugin_spec.rb
|
273
302
|
- spec/derelict/utils/logger/array_outputter_spec.rb
|
274
303
|
- spec/derelict/utils/logger/invalid_type_spec.rb
|
275
304
|
- spec/derelict/utils/logger/raw_formatter_spec.rb
|