evm 0.6.1 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +278 -0
- data/bin/evm +12 -0
- data/lib/evm.rb +7 -28
- data/lib/evm/builder.rb +18 -17
- data/lib/evm/cli.rb +43 -18
- data/lib/evm/command.rb +2 -1
- data/lib/evm/command/bin.rb +2 -2
- data/lib/evm/command/config.rb +19 -0
- data/lib/evm/command/disuse.rb +15 -0
- data/lib/evm/command/install.rb +3 -1
- data/lib/evm/command/list.rb +1 -1
- data/lib/evm/command/uninstall.rb +3 -1
- data/lib/evm/command/use.rb +3 -1
- data/lib/evm/config.rb +43 -0
- data/lib/evm/git.rb +1 -1
- data/lib/evm/package.rb +26 -11
- data/lib/evm/remote_file.rb +9 -55
- data/lib/evm/tar_file.rb +1 -1
- data/spec/evm/builder_spec.rb +209 -0
- data/spec/evm/cli_spec.rb +53 -0
- data/spec/evm/command/bin_spec.rb +32 -0
- data/spec/evm/command/config_spec.rb +34 -0
- data/spec/evm/command/disuse_spec.rb +19 -0
- data/spec/evm/command/install_spec.rb +103 -0
- data/spec/evm/command/list_spec.rb +36 -0
- data/spec/evm/command/uninstall_spec.rb +35 -0
- data/spec/evm/command/use_spec.rb +32 -0
- data/spec/evm/config_spec.rb +36 -0
- data/spec/evm/evm_spec.rb +11 -0
- data/spec/evm/git_spec.rb +39 -0
- data/spec/evm/os_spec.rb +47 -0
- data/spec/evm/package_spec.rb +274 -0
- data/spec/evm/recipe_spec.rb +47 -0
- data/spec/evm/remote_file_spec.rb +47 -0
- data/spec/evm/system_spec.rb +36 -0
- data/spec/evm/tar_file_spec.rb +21 -0
- data/spec/spec_helper.rb +13 -0
- metadata +29 -17
- data/lib/evm/exception.rb +0 -4
- data/lib/evm/progress_bar.rb +0 -37
- data/recipes/emacs-23.4-bin.rb +0 -7
- data/recipes/emacs-23.4.rb +0 -27
- data/recipes/emacs-24.1-bin.rb +0 -7
- data/recipes/emacs-24.1.rb +0 -24
- data/recipes/emacs-24.2-bin.rb +0 -7
- data/recipes/emacs-24.2.rb +0 -24
- data/recipes/emacs-24.3-bin.rb +0 -7
- data/recipes/emacs-24.3.rb +0 -24
- data/recipes/emacs-24.4-bin.rb +0 -7
- data/recipes/emacs-24.4.rb +0 -24
- data/recipes/emacs-git-snapshot.rb +0 -25
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Evm::Cli do
|
4
|
+
let :foo do
|
5
|
+
double('Foo')
|
6
|
+
end
|
7
|
+
|
8
|
+
before do
|
9
|
+
stub_const('Evm::Command::Foo', foo)
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'should initialize class without argument or option' do
|
13
|
+
expect(foo).to receive(:new).with([], {})
|
14
|
+
|
15
|
+
Evm::Cli.parse(['foo'])
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'should initialize class with argument' do
|
19
|
+
expect(foo).to receive(:new).with(['bar'], {})
|
20
|
+
|
21
|
+
Evm::Cli.parse(['foo', 'bar'])
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should initialize class with option' do
|
25
|
+
expect(foo).to receive(:new).with([], :force => true)
|
26
|
+
|
27
|
+
Evm::Cli.parse(['foo', '--force'])
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'should support force option' do
|
31
|
+
expect(foo).to receive(:new).with(['bar'], :force => true)
|
32
|
+
|
33
|
+
Evm::Cli.parse(['foo', 'bar', '--force'])
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'should support use option' do
|
37
|
+
expect(foo).to receive(:new).with(['bar'], :use => true)
|
38
|
+
|
39
|
+
Evm::Cli.parse(['foo', 'bar', '--use'])
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'should support skip option' do
|
43
|
+
expect(foo).to receive(:new).with(['bar'], :skip => true)
|
44
|
+
|
45
|
+
Evm::Cli.parse(['foo', 'bar', '--skip'])
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'should print message and exit if command not found' do
|
49
|
+
expect {
|
50
|
+
Evm::Cli.parse(['bar'])
|
51
|
+
}.to raise_error('No such command: bar')
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Evm::Command::Bin do
|
4
|
+
it 'should print current bin when not specified' do
|
5
|
+
allow(Evm::Package).to receive(:current) do |package_name, options|
|
6
|
+
double('package', :bin => 'BIN')
|
7
|
+
end
|
8
|
+
|
9
|
+
expect(STDOUT).to receive(:puts).with('BIN')
|
10
|
+
|
11
|
+
Evm::Command::Bin.new([])
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should print specified bin when specified' do
|
15
|
+
allow(Evm::Package).to receive(:find) do |package_name, options|
|
16
|
+
double('package', :bin => 'BIN')
|
17
|
+
end
|
18
|
+
|
19
|
+
expect(STDOUT).to receive(:puts).with('BIN')
|
20
|
+
|
21
|
+
Evm::Command::Bin.new(['foo'])
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should raise exception when no current and no specified' do
|
25
|
+
allow(Evm::Package).to receive(:find)
|
26
|
+
allow(Evm::Package).to receive(:current)
|
27
|
+
|
28
|
+
expect {
|
29
|
+
Evm::Command::Bin.new([])
|
30
|
+
}.to raise_error('No current selected')
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Evm::Command::Config do
|
4
|
+
let :config do
|
5
|
+
{}
|
6
|
+
end
|
7
|
+
|
8
|
+
before do
|
9
|
+
allow(Evm).to receive(:config).and_return(config)
|
10
|
+
stub_const('Evm::CONFIG_TYPES', [:foo])
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'raises exception unless valid type' do
|
14
|
+
expect {
|
15
|
+
described_class.new(['bar'])
|
16
|
+
}.to raise_error('Invalid config type: bar')
|
17
|
+
end
|
18
|
+
|
19
|
+
context 'get' do
|
20
|
+
it 'prints type value' do
|
21
|
+
config['foo'] = 'FOO'
|
22
|
+
expect(STDOUT).to receive(:puts).with('FOO')
|
23
|
+
described_class.new(['foo'])
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context 'set' do
|
28
|
+
it 'sets type to value and prints value' do
|
29
|
+
expect(STDOUT).to receive(:puts).with('BAR')
|
30
|
+
described_class.new(['foo', 'BAR'])
|
31
|
+
expect(config['foo']).to eq('BAR')
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Evm::Command::Disuse do
|
4
|
+
it 'should disuse package name if package selected' do
|
5
|
+
allow(Evm::Package).to receive(:current) do
|
6
|
+
package = double('package')
|
7
|
+
expect(package).to receive(:disuse!)
|
8
|
+
package
|
9
|
+
end
|
10
|
+
|
11
|
+
Evm::Command::Disuse.new([])
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should raise exception if no package selected' do
|
15
|
+
expect {
|
16
|
+
Evm::Command::Disuse.new([])
|
17
|
+
}.to raise_error('No package currently selected')
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,103 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Evm::Command::Install do
|
4
|
+
it 'should install if package and not installed' do
|
5
|
+
allow(Evm::Package).to receive(:find) do |package_name|
|
6
|
+
package = double('package')
|
7
|
+
expect(package).to receive(:install!)
|
8
|
+
allow(package).to receive(:installed?).and_return(false)
|
9
|
+
package
|
10
|
+
end
|
11
|
+
|
12
|
+
expect(STDOUT).to receive(:puts).with('Successfully installed foo')
|
13
|
+
|
14
|
+
Evm::Command::Install.new(['foo'])
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should uninstall first if force option' do
|
18
|
+
allow(Evm::Package).to receive(:find) do |package_name|
|
19
|
+
package = double('package')
|
20
|
+
expect(package).to receive(:install!)
|
21
|
+
expect(package).to receive(:uninstall!)
|
22
|
+
allow(package).to receive(:installed?).and_return(false)
|
23
|
+
package
|
24
|
+
end
|
25
|
+
|
26
|
+
expect(STDOUT).to receive(:puts).with('Successfully installed foo')
|
27
|
+
|
28
|
+
Evm::Command::Install.new(['foo'], :force => true)
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'should install when installed if force' do
|
32
|
+
allow(Evm::Package).to receive(:find) do |package_name|
|
33
|
+
package = double('package')
|
34
|
+
expect(package).to receive(:install!)
|
35
|
+
allow(package).to receive(:uninstall!) {
|
36
|
+
allow(package).to receive(:installed?).and_return(false)
|
37
|
+
}
|
38
|
+
allow(package).to receive(:installed?).and_return(true)
|
39
|
+
package
|
40
|
+
end
|
41
|
+
|
42
|
+
expect(STDOUT).to receive(:puts).with('Successfully installed foo')
|
43
|
+
|
44
|
+
Evm::Command::Install.new(['foo'], :force => true)
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'should install and use if --use option' do
|
48
|
+
allow(Evm::Package).to receive(:find) do |package_name|
|
49
|
+
package = double('package')
|
50
|
+
expect(package).to receive(:use!)
|
51
|
+
expect(package).to receive(:install!)
|
52
|
+
allow(package).to receive(:installed?).and_return(false)
|
53
|
+
package
|
54
|
+
end
|
55
|
+
|
56
|
+
expect(STDOUT).to receive(:puts).with('Successfully installed foo')
|
57
|
+
|
58
|
+
Evm::Command::Install.new(['foo'], :use => true)
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'should raise exception if already installed' do
|
62
|
+
allow(Evm::Package).to receive(:find) do |package_name|
|
63
|
+
package = double('package')
|
64
|
+
expect(package).not_to receive(:install!)
|
65
|
+
allow(package).to receive(:installed?).and_return(true)
|
66
|
+
package
|
67
|
+
end
|
68
|
+
|
69
|
+
expect {
|
70
|
+
Evm::Command::Install.new(['foo'])
|
71
|
+
}.to raise_error('Already installed foo')
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'should raise exception if no package name' do
|
75
|
+
expect {
|
76
|
+
Evm::Command::Install.new([nil])
|
77
|
+
}.to raise_error('The install command requires an argument')
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'should not install if already installed and --skip option' do
|
81
|
+
allow(Evm::Package).to receive(:find) do |package_name|
|
82
|
+
package = double('package')
|
83
|
+
expect(package).not_to receive(:install!)
|
84
|
+
allow(package).to receive(:installed?).and_return(true)
|
85
|
+
package
|
86
|
+
end
|
87
|
+
|
88
|
+
Evm::Command::Install.new(['foo'], :skip => true)
|
89
|
+
end
|
90
|
+
|
91
|
+
it 'should install if not already installed and --skip option' do
|
92
|
+
allow(Evm::Package).to receive(:find) do |package_name|
|
93
|
+
package = double('package')
|
94
|
+
expect(package).to receive(:install!)
|
95
|
+
allow(package).to receive(:installed?).and_return(false)
|
96
|
+
package
|
97
|
+
end
|
98
|
+
|
99
|
+
expect(STDOUT).to receive(:puts).with('Successfully installed foo')
|
100
|
+
|
101
|
+
Evm::Command::Install.new(['foo'], :skip => true)
|
102
|
+
end
|
103
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Evm::Command::List do
|
4
|
+
it 'should print list of packages' do
|
5
|
+
allow(Evm::Package).to receive(:all) do
|
6
|
+
foo = double('foo')
|
7
|
+
allow(foo).to receive(:current?).and_return(true)
|
8
|
+
allow(foo).to receive(:installed?).and_return(true)
|
9
|
+
allow(foo).to receive(:to_s).and_return('foo')
|
10
|
+
|
11
|
+
bar = double('bar')
|
12
|
+
allow(bar).to receive(:current?).and_return(false)
|
13
|
+
allow(bar).to receive(:installed?).and_return(false)
|
14
|
+
allow(bar).to receive(:to_s).and_return('bar')
|
15
|
+
|
16
|
+
baz = double('baz')
|
17
|
+
allow(baz).to receive(:current?).and_return(false)
|
18
|
+
allow(baz).to receive(:installed?).and_return(true)
|
19
|
+
allow(baz).to receive(:to_s).and_return('baz')
|
20
|
+
|
21
|
+
[foo, bar, baz]
|
22
|
+
end
|
23
|
+
|
24
|
+
output = []
|
25
|
+
allow(STDOUT).to receive(:puts) { |*args|
|
26
|
+
output << args.first.to_s + "\n"
|
27
|
+
}
|
28
|
+
allow(STDOUT).to receive(:print) { |*args|
|
29
|
+
output << args.first.to_s
|
30
|
+
}
|
31
|
+
|
32
|
+
Evm::Command::List.new()
|
33
|
+
|
34
|
+
expect(output.join).to eq("* foo [I]\nbar\nbaz [I]\n")
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Evm::Command::Uninstall do
|
4
|
+
it 'should uninstall if installed' do
|
5
|
+
allow(Evm::Package).to receive(:find) do |package_name|
|
6
|
+
package = double('package')
|
7
|
+
expect(package).to receive((:uninstall!))
|
8
|
+
allow(package).to receive(:installed?).and_return(true)
|
9
|
+
package
|
10
|
+
end
|
11
|
+
|
12
|
+
expect(STDOUT).to receive(:puts).with('Successfully uninstalled foo')
|
13
|
+
|
14
|
+
Evm::Command::Uninstall.new(['foo'])
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should raise exception if not installed' do
|
18
|
+
allow(Evm::Package).to receive(:find) do |package_name|
|
19
|
+
package = double('package')
|
20
|
+
expect(package).not_to receive(:uninstall!)
|
21
|
+
allow(package).to receive(:installed?).and_return(false)
|
22
|
+
package
|
23
|
+
end
|
24
|
+
|
25
|
+
expect {
|
26
|
+
Evm::Command::Uninstall.new(['foo'])
|
27
|
+
}.to raise_error('Not installed foo')
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'should raise exception if no package name' do
|
31
|
+
expect {
|
32
|
+
Evm::Command::Uninstall.new([])
|
33
|
+
}.to raise_error('The uninstall command requires an argument')
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Evm::Command::Use do
|
4
|
+
it 'should use package name if installed' do
|
5
|
+
allow(Evm::Package).to receive(:find) do |package_name|
|
6
|
+
package = double('package')
|
7
|
+
allow(package).to receive(:installed?).and_return(true)
|
8
|
+
expect(package).to receive(:use!)
|
9
|
+
package
|
10
|
+
end
|
11
|
+
|
12
|
+
Evm::Command::Use.new(['foo'])
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'should raise exception if package is not installed' do
|
16
|
+
allow(Evm::Package).to receive(:find) do |package_name|
|
17
|
+
package = double('package')
|
18
|
+
allow(package).to receive(:installed?).and_return(false)
|
19
|
+
package
|
20
|
+
end
|
21
|
+
|
22
|
+
expect {
|
23
|
+
Evm::Command::Use.new(['foo'])
|
24
|
+
}.to raise_error('Package not installed: foo')
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'should raise exception if no package name' do
|
28
|
+
expect {
|
29
|
+
Evm::Command::Use.new([])
|
30
|
+
}.to raise_error('The use command requires an argument')
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'tempfile'
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe Evm::Config do
|
5
|
+
let :config_file do
|
6
|
+
Tempfile.new('foo')
|
7
|
+
end
|
8
|
+
|
9
|
+
let :defaults do
|
10
|
+
{ baz: 'qux' }
|
11
|
+
end
|
12
|
+
|
13
|
+
subject do
|
14
|
+
described_class.new(config_file, defaults)
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'can set type to value and get value' do
|
18
|
+
subject[:foo] = 'bar'
|
19
|
+
expect(subject[:foo]).to eq('bar')
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'supports both string and symbol type' do
|
23
|
+
subject[:foo] = 'bar'
|
24
|
+
expect(subject['foo']).to eq('bar')
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'returns nil unless type is set to a value' do
|
28
|
+
expect(subject[:foo]).to be_nil
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'returns default value if any and type not set' do
|
32
|
+
expect(subject[:baz]).to eq('qux')
|
33
|
+
subject[:baz] = 'QUX'
|
34
|
+
expect(subject[:baz]).to eq('QUX')
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Evm do
|
4
|
+
it 'should return correct root directory' do
|
5
|
+
expect(Evm::ROOT_PATH).to eq(File.expand_path('../..', File.dirname(__FILE__)))
|
6
|
+
end
|
7
|
+
|
8
|
+
it 'should return correct local directory' do
|
9
|
+
expect(Evm::LOCAL_PATH).to eq('/usr/local/evm')
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Evm::Git do
|
4
|
+
before do
|
5
|
+
@path = '/path/to/git'
|
6
|
+
|
7
|
+
@git = Evm::Git.new(@path)
|
8
|
+
end
|
9
|
+
|
10
|
+
describe 'exist?' do
|
11
|
+
it 'should exist when path does exist' do
|
12
|
+
allow(File).to receive(:exist?).and_return(false)
|
13
|
+
|
14
|
+
expect(@git.exist?).to be false
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should not exist when path does not exist' do
|
18
|
+
allow(File).to receive(:exist?).and_return(true)
|
19
|
+
|
20
|
+
expect(@git.exist?).to be true
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe 'clone' do
|
25
|
+
it 'should clone url to path' do
|
26
|
+
expect(@git).to receive(:git).with('clone', 'URL', @path)
|
27
|
+
@git.clone('URL')
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe 'pull' do
|
32
|
+
it 'should pull in path' do
|
33
|
+
expect(Dir).to receive(:chdir).with(@path).and_yield
|
34
|
+
|
35
|
+
expect(@git).to receive(:git).with('pull')
|
36
|
+
@git.pull
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/spec/evm/os_spec.rb
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Evm::Os do
|
4
|
+
describe '.osx?' do
|
5
|
+
it 'should be osx when osx' do
|
6
|
+
stub_const('RUBY_PLATFORM', 'x86_64-darwin12.3.0')
|
7
|
+
|
8
|
+
expect(Evm::Os.osx?).to be_truthy
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'should not be osx when linux' do
|
12
|
+
stub_const('RUBY_PLATFORM', 'x86_64-linux')
|
13
|
+
|
14
|
+
expect(Evm::Os.osx?).to be_falsy
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '.linux?' do
|
19
|
+
it 'should be linux when linux' do
|
20
|
+
stub_const('RUBY_PLATFORM', 'x86_64-linux')
|
21
|
+
|
22
|
+
expect(Evm::Os.linux?).to be_truthy
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'should not be linux when osx' do
|
26
|
+
stub_const('RUBY_PLATFORM', 'x86_64-darwin12.3.0')
|
27
|
+
|
28
|
+
expect(Evm::Os.linux?).to be_falsy
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe '.platform_name' do
|
33
|
+
it 'should be osx when osx' do
|
34
|
+
allow(Evm::Os).to receive(:osx?).and_return(true)
|
35
|
+
allow(Evm::Os).to receive(:linux?).and_return(false)
|
36
|
+
|
37
|
+
expect(Evm::Os.platform_name).to eq(:osx)
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'should be linux when linux' do
|
41
|
+
allow(Evm::Os).to receive(:osx?).and_return(false)
|
42
|
+
allow(Evm::Os).to receive(:linux?).and_return(true)
|
43
|
+
|
44
|
+
expect(Evm::Os.platform_name).to eq(:linux)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|