localport 0.0.0 → 0.0.2
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.
- data/.travis.yml +6 -0
- data/Gemfile +4 -5
- data/README.md +93 -0
- data/Rakefile +0 -5
- data/VERSION +1 -1
- data/bin/localport +0 -0
- data/lib/localport/command.rb +33 -23
- data/lib/localport/config.rb +6 -6
- data/lib/localport.rb +20 -12
- data/localport.gemspec +29 -29
- data/spec/localport/command_spec.rb +104 -0
- data/spec/localport_spec.rb +12 -0
- data/spec/spec_helper.rb +25 -1
- metadata +16 -24
- data/README +0 -78
data/.travis.yml
ADDED
data/Gemfile
CHANGED
@@ -7,9 +7,8 @@ gem "highline"
|
|
7
7
|
# Add dependencies to develop your gem here.
|
8
8
|
# Include everything needed to run rake, tests, features, etc.
|
9
9
|
group :development do
|
10
|
-
gem "rspec"
|
11
|
-
gem "yard"
|
12
|
-
gem "bundler"
|
13
|
-
gem "jeweler"
|
14
|
-
gem "rcov", ">= 0"
|
10
|
+
gem "rspec"
|
11
|
+
gem "yard"
|
12
|
+
gem "bundler"
|
13
|
+
gem "jeweler"
|
15
14
|
end
|
data/README.md
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
# Local Application Port System
|
2
|
+
Local Application Management system. This application just like MacPorts on Mac
|
3
|
+
OS X.
|
4
|
+
An application has some versioned. But we use various version case by case.
|
5
|
+
For example Ruby application is now moving from 1.8 to 1.9.
|
6
|
+
So we must build Ruby 1.8 and Ruby 1.9 environment.
|
7
|
+
And so, we use many many middle ware, memcached, redis, MySQL, Varnish...
|
8
|
+
localport make us build multiversion environment easyly.
|
9
|
+
|
10
|
+
## Install
|
11
|
+
Just easy. Just type,
|
12
|
+
|
13
|
+
$ gem install localport
|
14
|
+
|
15
|
+
## How to use
|
16
|
+
There is some restrictions, following:
|
17
|
+
|
18
|
+
* When you install some application, you must specify one directory.
|
19
|
+
This directory is called "application directory" on system.
|
20
|
+
Like this,
|
21
|
+
|
22
|
+
~/apps
|
23
|
+
|
24
|
+
* And, you must specify execute directory.
|
25
|
+
This directory is called "executional directory"
|
26
|
+
Like this,
|
27
|
+
|
28
|
+
~/local/bin
|
29
|
+
|
30
|
+
Ok, Let's control Ruby-1.8.7.-p160 with localport.
|
31
|
+
|
32
|
+
1. Build, and Install Ruby-1.8.7-p160 to "application directory".
|
33
|
+
|
34
|
+
$ tar zxvf ruby-1.8.7-p160.tar.gz
|
35
|
+
$ cd ruby-1.8.7-p160
|
36
|
+
$ ./configure --prefix=$HOME/apps/ruby/ruby-1.8.7-p160
|
37
|
+
|
38
|
+
2. Install that to "execution directory"
|
39
|
+
|
40
|
+
$ localport install ~/apps/ruby/ruby-1.8.7-p160
|
41
|
+
|
42
|
+
This command make symbolic links that are Ruby applications in
|
43
|
+
|
44
|
+
~/apps/ruby/ruby-1.8.7-p160/bin/*
|
45
|
+
|
46
|
+
3. Then, Activate that.
|
47
|
+
|
48
|
+
$ localport activate ruby-1.8.7-p160
|
49
|
+
|
50
|
+
This command make installed symbolic ruby-1.8.7-p160 point symbolic link.
|
51
|
+
|
52
|
+
$ ls -l ~/local/bin/ruby -> ~/local/bin/ruby-1.8.7-p160
|
53
|
+
$ ls -l ~/local/bin/ruby-1.8.7-p160 -> ~/apps/ruby/ruby-1.8.7-p160/bin/ruby
|
54
|
+
|
55
|
+
4. Deactivate that.
|
56
|
+
If you want to execute another Ruby version with no specified version command, 'ruby'.
|
57
|
+
|
58
|
+
$ locaport deactivate ruby-1.8.7-p160
|
59
|
+
|
60
|
+
This command remove symbolic link 'local/bin/ruby'.
|
61
|
+
|
62
|
+
## Commands
|
63
|
+
This application provide some commands. Like MacPorts.
|
64
|
+
|
65
|
+
- install
|
66
|
+
- installed
|
67
|
+
- activate
|
68
|
+
- deactivate
|
69
|
+
|
70
|
+
### install
|
71
|
+
|
72
|
+
To specify an application path.
|
73
|
+
|
74
|
+
$ localport install {app}
|
75
|
+
|
76
|
+
### installed
|
77
|
+
|
78
|
+
To list up installed applications.
|
79
|
+
|
80
|
+
$ localport installed [app]
|
81
|
+
|
82
|
+
### activate
|
83
|
+
|
84
|
+
To activate installed application.
|
85
|
+
|
86
|
+
$ localport activate {app}
|
87
|
+
|
88
|
+
### deactivate
|
89
|
+
|
90
|
+
To deactivate installed application.
|
91
|
+
Delete internal symbolic link.
|
92
|
+
|
93
|
+
$ localport deactivate {app}
|
data/Rakefile
CHANGED
@@ -31,11 +31,6 @@ RSpec::Core::RakeTask.new(:spec) do |spec|
|
|
31
31
|
spec.pattern = FileList['spec/**/*_spec.rb']
|
32
32
|
end
|
33
33
|
|
34
|
-
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
35
|
-
spec.pattern = 'spec/**/*_spec.rb'
|
36
|
-
spec.rcov = true
|
37
|
-
end
|
38
|
-
|
39
34
|
task :default => :spec
|
40
35
|
|
41
36
|
require 'yard'
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.2
|
data/bin/localport
CHANGED
File without changes
|
data/lib/localport/command.rb
CHANGED
@@ -5,6 +5,7 @@
|
|
5
5
|
require 'localport/config'
|
6
6
|
|
7
7
|
module LocalPort
|
8
|
+
class CommandError < ::StandardError; end
|
8
9
|
class Command
|
9
10
|
attr_reader :commands
|
10
11
|
|
@@ -18,6 +19,9 @@ module LocalPort
|
|
18
19
|
:name => "install",
|
19
20
|
:args => true,
|
20
21
|
:exec => lambda {|args|
|
22
|
+
if args.empty?
|
23
|
+
raise LocalPort::CommandError, "must specify to installed application path."
|
24
|
+
end
|
21
25
|
install args
|
22
26
|
}
|
23
27
|
)
|
@@ -38,7 +42,7 @@ module LocalPort
|
|
38
42
|
args.each do |app|
|
39
43
|
puts "#{app}:"
|
40
44
|
config.installed[app].keys.each {|ver|
|
41
|
-
puts_version(app, ver)
|
45
|
+
puts_version(app, ver)
|
42
46
|
}
|
43
47
|
end
|
44
48
|
else
|
@@ -56,11 +60,10 @@ module LocalPort
|
|
56
60
|
:name => "activate",
|
57
61
|
:args => true,
|
58
62
|
:exec => lambda {|args|
|
59
|
-
if args.
|
60
|
-
|
61
|
-
else
|
62
|
-
raise ArgumentError, "must specify verbose application name"
|
63
|
+
if args.empty?
|
64
|
+
raise LocalPort::CommandError, "must specify verbose application name. {app}-{version}"
|
63
65
|
end
|
66
|
+
args.each {|app| activate app }
|
64
67
|
}
|
65
68
|
)
|
66
69
|
|
@@ -68,11 +71,10 @@ module LocalPort
|
|
68
71
|
:name => "deactivate",
|
69
72
|
:args => true,
|
70
73
|
:exec => lambda {|args|
|
71
|
-
if args
|
72
|
-
|
73
|
-
else
|
74
|
-
raise ArgumentError, "must specify verbose application name"
|
74
|
+
if args.empty?
|
75
|
+
raise LocalPort::CommandError, "must specify verbose application name. {app}-{version}"
|
75
76
|
end
|
77
|
+
args.each {|app| deactivate app }
|
76
78
|
}
|
77
79
|
)
|
78
80
|
end
|
@@ -82,22 +84,16 @@ module LocalPort
|
|
82
84
|
puts " %s #{ver}" % status
|
83
85
|
end
|
84
86
|
|
85
|
-
def
|
86
|
-
|
87
|
-
|
88
|
-
end
|
87
|
+
def list
|
88
|
+
@commands.keys
|
89
|
+
end
|
89
90
|
|
91
|
+
def install(paths=[])
|
90
92
|
paths.each do |path|
|
91
|
-
bins = Dir[sanitize(path) + "/bin/*"]
|
92
|
-
bins.each
|
93
|
-
# e.g. /Users/user/apps/vim/vim-7.2/bin/vim
|
94
|
-
bin_app = bin.split('/')[-4] # => vim
|
95
|
-
bin_app_version = bin.split('/')[-3] # => vim-7.2
|
96
|
-
bin_version = bin_app_version.gsub(/^#{bin_app}/, '') # => -7.2
|
97
|
-
bin_name = File.basename bin # => vim
|
98
|
-
link = LocalPort::LINK_DIR + "/" + bin_name + bin_version
|
93
|
+
bins = Dir[sanitize(path) + "/bin/*", sanitize(path) + "/sbin/*"]
|
94
|
+
symlinks(bins).each {|bin, link|
|
99
95
|
File.symlink(bin, link) unless File.exist? link
|
100
|
-
|
96
|
+
}
|
101
97
|
end
|
102
98
|
end
|
103
99
|
|
@@ -131,7 +127,7 @@ module LocalPort
|
|
131
127
|
# 違うバージョンのときのみにエラーを吐く
|
132
128
|
app, ver = split_appver_to_app_ver(appver)
|
133
129
|
if activated_ver = config.activated[app]
|
134
|
-
if activated_ver != ver
|
130
|
+
if activated_ver != ver
|
135
131
|
raise ArgumentError, "already activated *#{app}-#{activated_ver}*\nplease deactivate first"
|
136
132
|
end
|
137
133
|
end
|
@@ -166,6 +162,7 @@ module LocalPort
|
|
166
162
|
end
|
167
163
|
|
168
164
|
def find(name)
|
165
|
+
raise LocalPort::CommandError, "'#{name}' is not a localport command." unless @commands.key? name
|
169
166
|
@commands[name]
|
170
167
|
end
|
171
168
|
|
@@ -194,6 +191,19 @@ module LocalPort
|
|
194
191
|
end
|
195
192
|
path
|
196
193
|
end
|
194
|
+
|
195
|
+
def symlinks(bins)
|
196
|
+
bins.inject({}) {|ret, bin|
|
197
|
+
bin_app = bin.split('/')[-4] # => vim
|
198
|
+
bin_version = bin.split('/')[-3] # => 7.2
|
199
|
+
bin_name = File.basename bin # => vim
|
200
|
+
bin_ext = File.extname bin
|
201
|
+
link = File.join(LocalPort::LINK_DIR,
|
202
|
+
(bin_name.gsub(bin_ext, '') + "-"+ bin_version + bin_ext))
|
203
|
+
ret[bin] = link
|
204
|
+
ret
|
205
|
+
}
|
206
|
+
end
|
197
207
|
end
|
198
208
|
|
199
209
|
def self.command
|
data/lib/localport/config.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
#
|
3
3
|
# Cofigure localport
|
4
|
-
#
|
4
|
+
#
|
5
5
|
require 'rubygems' if RUBY_VERSION < "1.9"
|
6
6
|
require 'highline'
|
7
7
|
|
@@ -11,7 +11,7 @@ module LocalPort
|
|
11
11
|
LocalPort::CONF_FILE = LocalPort::CONF_DIR + "/config"
|
12
12
|
|
13
13
|
class Config
|
14
|
-
|
14
|
+
|
15
15
|
attr_reader :installed, :activated
|
16
16
|
|
17
17
|
def self.instance
|
@@ -27,7 +27,7 @@ module LocalPort
|
|
27
27
|
ui = HighLine.new
|
28
28
|
apps_dir = ui.ask("Where is your applications directory: ")
|
29
29
|
link_dir = ui.ask("Where is your link directory: ")
|
30
|
-
config = template(apps_dir, link_dir)
|
30
|
+
config = template(apps_dir, link_dir)
|
31
31
|
Dir.mkdir(LocalPort::CONF_DIR) unless File.exist? LocalPort::CONF_DIR
|
32
32
|
File.open(LocalPort::CONF_FILE, 'w') {|io|
|
33
33
|
io << config
|
@@ -44,7 +44,7 @@ LocalPort::LINK_DIR = '%s'" % [apps_dir, link_dir]
|
|
44
44
|
symlinks = Dir["#{dir}/*"]
|
45
45
|
symlinks.each do |symlink|
|
46
46
|
next unless File.symlink? symlink
|
47
|
-
|
47
|
+
|
48
48
|
src = File.readlink symlink
|
49
49
|
same_dir_p = same_dir?(src, symlink)
|
50
50
|
if same_dir_p
|
@@ -71,7 +71,7 @@ LocalPort::LINK_DIR = '%s'" % [apps_dir, link_dir]
|
|
71
71
|
add_activated(app, version)
|
72
72
|
next
|
73
73
|
end
|
74
|
-
|
74
|
+
|
75
75
|
@installed[app] ||= {}
|
76
76
|
app_versions = @installed[app]
|
77
77
|
app_versions[version] ||= []
|
@@ -85,7 +85,7 @@ LocalPort::LINK_DIR = '%s'" % [apps_dir, link_dir]
|
|
85
85
|
end
|
86
86
|
|
87
87
|
def add_activated(app, version)
|
88
|
-
@activated[app] = version unless @activated[app]
|
88
|
+
@activated[app] = version unless @activated[app]
|
89
89
|
end
|
90
90
|
end
|
91
91
|
end
|
data/lib/localport.rb
CHANGED
@@ -17,21 +17,23 @@ module LocalPort
|
|
17
17
|
|
18
18
|
class << self
|
19
19
|
def invoke(argv)
|
20
|
-
load_config() # to set location of applications
|
21
|
-
correct_installed_app() # correct installed applications
|
22
|
-
|
23
|
-
command, args = parse_args(argv)
|
24
|
-
command = find_command(command)
|
25
|
-
|
26
20
|
begin
|
21
|
+
load_config() # to set location of applications
|
22
|
+
correct_installed_app() # correct installed applications
|
23
|
+
|
24
|
+
command, args = parse_args(argv)
|
25
|
+
command = find_command(command)
|
26
|
+
|
27
27
|
command[:exec].call args
|
28
|
+
rescue LocalPort::CommandError => e
|
29
|
+
puts "localport: #{e.message}"
|
28
30
|
rescue => e
|
29
31
|
raise e
|
30
32
|
end
|
31
33
|
end
|
32
34
|
|
33
35
|
def load_config
|
34
|
-
unless File.exist? LocalPort::CONF_FILE
|
36
|
+
unless File.exist? LocalPort::CONF_FILE
|
35
37
|
config.setup
|
36
38
|
end
|
37
39
|
load LocalPort::CONF_FILE
|
@@ -42,21 +44,27 @@ module LocalPort
|
|
42
44
|
end
|
43
45
|
|
44
46
|
def parse_args(args)
|
45
|
-
if args.
|
46
|
-
|
47
|
+
if args.empty?
|
48
|
+
puts usage()
|
49
|
+
exit 1
|
47
50
|
end
|
48
51
|
command = args.shift
|
49
52
|
[command, args]
|
50
53
|
end
|
51
54
|
|
52
55
|
def find_command(name)
|
53
|
-
command.find name
|
56
|
+
command.find name
|
57
|
+
end
|
58
|
+
|
59
|
+
def list_command
|
60
|
+
command.list
|
54
61
|
end
|
55
62
|
|
56
63
|
def usage
|
57
64
|
<<-"USAGE"
|
58
|
-
|
59
|
-
|
65
|
+
Usage: #{File.basename $0} <command> [app]
|
66
|
+
command list:
|
67
|
+
#{list_command.join("\n ")}
|
60
68
|
USAGE
|
61
69
|
end
|
62
70
|
end
|
data/localport.gemspec
CHANGED
@@ -4,21 +4,22 @@
|
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
|
-
s.name =
|
8
|
-
s.version = "0.0.
|
7
|
+
s.name = "localport"
|
8
|
+
s.version = "0.0.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = [
|
12
|
-
s.date =
|
13
|
-
s.description =
|
14
|
-
s.email =
|
15
|
-
s.executables = [
|
11
|
+
s.authors = ["yoppi"]
|
12
|
+
s.date = "2012-04-29"
|
13
|
+
s.description = "localport is a local application management system"
|
14
|
+
s.email = "y.hirokazu@gmail.com"
|
15
|
+
s.executables = ["localport"]
|
16
16
|
s.extra_rdoc_files = [
|
17
|
-
"README"
|
17
|
+
"README.md"
|
18
18
|
]
|
19
19
|
s.files = [
|
20
|
+
".travis.yml",
|
20
21
|
"Gemfile",
|
21
|
-
"README",
|
22
|
+
"README.md",
|
22
23
|
"Rakefile",
|
23
24
|
"VERSION",
|
24
25
|
"bin/localport",
|
@@ -26,39 +27,38 @@ Gem::Specification.new do |s|
|
|
26
27
|
"lib/localport/command.rb",
|
27
28
|
"lib/localport/config.rb",
|
28
29
|
"localport.gemspec",
|
30
|
+
"spec/localport/command_spec.rb",
|
31
|
+
"spec/localport_spec.rb",
|
29
32
|
"spec/spec_helper.rb"
|
30
33
|
]
|
31
|
-
s.homepage =
|
32
|
-
s.licenses = [
|
33
|
-
s.require_paths = [
|
34
|
-
s.rubygems_version =
|
35
|
-
s.summary =
|
34
|
+
s.homepage = "http://github.com/yoppi/localport"
|
35
|
+
s.licenses = ["MIT"]
|
36
|
+
s.require_paths = ["lib"]
|
37
|
+
s.rubygems_version = "1.8.23"
|
38
|
+
s.summary = "Local Application management system"
|
36
39
|
|
37
40
|
if s.respond_to? :specification_version then
|
38
41
|
s.specification_version = 3
|
39
42
|
|
40
43
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
41
44
|
s.add_runtime_dependency(%q<highline>, [">= 0"])
|
42
|
-
s.add_development_dependency(%q<rspec>, ["
|
43
|
-
s.add_development_dependency(%q<yard>, ["
|
44
|
-
s.add_development_dependency(%q<bundler>, ["
|
45
|
-
s.add_development_dependency(%q<jeweler>, ["
|
46
|
-
s.add_development_dependency(%q<rcov>, [">= 0"])
|
45
|
+
s.add_development_dependency(%q<rspec>, [">= 0"])
|
46
|
+
s.add_development_dependency(%q<yard>, [">= 0"])
|
47
|
+
s.add_development_dependency(%q<bundler>, [">= 0"])
|
48
|
+
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
47
49
|
else
|
48
50
|
s.add_dependency(%q<highline>, [">= 0"])
|
49
|
-
s.add_dependency(%q<rspec>, ["
|
50
|
-
s.add_dependency(%q<yard>, ["
|
51
|
-
s.add_dependency(%q<bundler>, ["
|
52
|
-
s.add_dependency(%q<jeweler>, ["
|
53
|
-
s.add_dependency(%q<rcov>, [">= 0"])
|
51
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
52
|
+
s.add_dependency(%q<yard>, [">= 0"])
|
53
|
+
s.add_dependency(%q<bundler>, [">= 0"])
|
54
|
+
s.add_dependency(%q<jeweler>, [">= 0"])
|
54
55
|
end
|
55
56
|
else
|
56
57
|
s.add_dependency(%q<highline>, [">= 0"])
|
57
|
-
s.add_dependency(%q<rspec>, ["
|
58
|
-
s.add_dependency(%q<yard>, ["
|
59
|
-
s.add_dependency(%q<bundler>, ["
|
60
|
-
s.add_dependency(%q<jeweler>, ["
|
61
|
-
s.add_dependency(%q<rcov>, [">= 0"])
|
58
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
59
|
+
s.add_dependency(%q<yard>, [">= 0"])
|
60
|
+
s.add_dependency(%q<bundler>, [">= 0"])
|
61
|
+
s.add_dependency(%q<jeweler>, [">= 0"])
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
@@ -0,0 +1,104 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
$:.unshift(File.join(File.dirname(__FILE__), '..'))
|
4
|
+
require 'spec_helper'
|
5
|
+
|
6
|
+
require 'fileutils'
|
7
|
+
|
8
|
+
describe LocalPort::Command do
|
9
|
+
it "should raise CommandError in unknown command" do
|
10
|
+
expect { LocalPort.command.find("foo") }.to raise_error(
|
11
|
+
LocalPort::CommandError
|
12
|
+
)
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should return command hash in provided command" do
|
16
|
+
command = LocalPort.command.find("install")
|
17
|
+
command[:name].should == 'install'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe LocalPort::Command, "#install" do
|
22
|
+
|
23
|
+
let(:install) { LocalPort.command.find("install") }
|
24
|
+
LocalPort::LINK_DIR = File.dirname(__FILE__)
|
25
|
+
|
26
|
+
context "path is emtpy" do
|
27
|
+
it "should raise CommandError in no args" do
|
28
|
+
command = LocalPort.command.find("install")
|
29
|
+
expect { command[:exec].call([]) }.to raise_error(
|
30
|
+
LocalPort::CommandError
|
31
|
+
)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
context "install .exe file in cygwin" do
|
36
|
+
let(:bin) { File.join(File.dirname(__FILE__), "test/0.0.0/bin/test.exe") }
|
37
|
+
let(:app) { File.join(File.dirname(__FILE__), "test/0.0.0") }
|
38
|
+
let(:symlink) { File.join(File.dirname(__FILE__), "test-0.0.0.exe") }
|
39
|
+
|
40
|
+
before do
|
41
|
+
FileUtils.mkdir_p(File.dirname(bin))
|
42
|
+
FileUtils.touch(bin)
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should have .exe in symbolic" do
|
46
|
+
install[:exec].call([app])
|
47
|
+
File.exist?(symlink).should be_true
|
48
|
+
end
|
49
|
+
|
50
|
+
after do
|
51
|
+
FileUtils.rm_rf(File.join(File.dirname(__FILE__), "test"))
|
52
|
+
FileUtils.rm(symlink)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
context "install has *sbin* directory application" do
|
57
|
+
let(:sbin) { File.join(File.dirname(__FILE__), "test/0.0.0/sbin/a") }
|
58
|
+
let(:app) { File.join(File.dirname(__FILE__), "test/0.0.0") }
|
59
|
+
let(:symlink) { File.join(File.dirname(__FILE__), "a-0.0.0") }
|
60
|
+
|
61
|
+
before do
|
62
|
+
FileUtils.mkdir_p(File.dirname(sbin))
|
63
|
+
FileUtils.touch(sbin)
|
64
|
+
end
|
65
|
+
|
66
|
+
it "should install sbin file" do
|
67
|
+
install[:exec].call([app])
|
68
|
+
File.exist?(symlink).should be_true
|
69
|
+
end
|
70
|
+
|
71
|
+
after do
|
72
|
+
FileUtils.rm_rf(File.join(File.dirname(__FILE__), "test"))
|
73
|
+
FileUtils.rm(symlink)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
describe LocalPort::Command, "#activate" do
|
79
|
+
context "activate with no app" do
|
80
|
+
it "should raise CommandError" do
|
81
|
+
command = LocalPort.command.find("activate")
|
82
|
+
expect { command[:exec].call([]) }.to raise_error(
|
83
|
+
LocalPort::CommandError
|
84
|
+
)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
describe LocalPort::Command, "#deactivate" do
|
90
|
+
context "deactivate with no args" do
|
91
|
+
it "should raise CommandError" do
|
92
|
+
command = LocalPort.command.find("deactivate")
|
93
|
+
expect { command[:exec].call([]) }.to raise_error(
|
94
|
+
LocalPort::CommandError
|
95
|
+
)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
describe LocalPort::Command do
|
101
|
+
it "should get command list" do
|
102
|
+
LocalPort.command.list.sort.should == %w[activate deactivate install installed uninstall]
|
103
|
+
end
|
104
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
$:.unshift(File.dirname(__FILE__))
|
4
|
+
require 'spec_helper'
|
5
|
+
|
6
|
+
describe LocalPort do
|
7
|
+
context "executed in no args" do
|
8
|
+
it "should show usage and exit status is 1" do
|
9
|
+
expect { LocalPort.parse_args([]) }.to exit_with_code(1)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -7,6 +7,30 @@ require 'localport'
|
|
7
7
|
# in ./support/ and its subdirectories.
|
8
8
|
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
9
9
|
|
10
|
+
RSpec::Matchers.define :exit_with_code do |code|
|
11
|
+
actual = nil
|
12
|
+
match do |block|
|
13
|
+
begin
|
14
|
+
block.call
|
15
|
+
rescue SystemExit => e
|
16
|
+
actual = e.status
|
17
|
+
end
|
18
|
+
actual && actual == code
|
19
|
+
end
|
20
|
+
|
21
|
+
failure_message_for_should do |block|
|
22
|
+
"expected block to call exit(#{code}) but exit" + (actual.nil? ? " not called" : "(#{actual}) was called" )
|
23
|
+
end
|
24
|
+
|
25
|
+
failure_message_for_should_not do |block|
|
26
|
+
"expected block not to call exit(#{code})"
|
27
|
+
end
|
28
|
+
|
29
|
+
description do
|
30
|
+
"expect block to call exit(#{code})"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
10
34
|
RSpec.configure do |config|
|
11
|
-
|
35
|
+
|
12
36
|
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: localport
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.2
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- yoppi
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date:
|
13
|
+
date: 2012-04-29 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: highline
|
@@ -28,9 +28,9 @@ dependencies:
|
|
28
28
|
requirement: &id002 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: "0"
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: *id002
|
@@ -39,9 +39,9 @@ dependencies:
|
|
39
39
|
requirement: &id003 !ruby/object:Gem::Requirement
|
40
40
|
none: false
|
41
41
|
requirements:
|
42
|
-
- -
|
42
|
+
- - ">="
|
43
43
|
- !ruby/object:Gem::Version
|
44
|
-
version: 0
|
44
|
+
version: "0"
|
45
45
|
type: :development
|
46
46
|
prerelease: false
|
47
47
|
version_requirements: *id003
|
@@ -50,26 +50,15 @@ dependencies:
|
|
50
50
|
requirement: &id004 !ruby/object:Gem::Requirement
|
51
51
|
none: false
|
52
52
|
requirements:
|
53
|
-
- -
|
53
|
+
- - ">="
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version:
|
55
|
+
version: "0"
|
56
56
|
type: :development
|
57
57
|
prerelease: false
|
58
58
|
version_requirements: *id004
|
59
59
|
- !ruby/object:Gem::Dependency
|
60
60
|
name: jeweler
|
61
61
|
requirement: &id005 !ruby/object:Gem::Requirement
|
62
|
-
none: false
|
63
|
-
requirements:
|
64
|
-
- - ~>
|
65
|
-
- !ruby/object:Gem::Version
|
66
|
-
version: 1.6.2
|
67
|
-
type: :development
|
68
|
-
prerelease: false
|
69
|
-
version_requirements: *id005
|
70
|
-
- !ruby/object:Gem::Dependency
|
71
|
-
name: rcov
|
72
|
-
requirement: &id006 !ruby/object:Gem::Requirement
|
73
62
|
none: false
|
74
63
|
requirements:
|
75
64
|
- - ">="
|
@@ -77,7 +66,7 @@ dependencies:
|
|
77
66
|
version: "0"
|
78
67
|
type: :development
|
79
68
|
prerelease: false
|
80
|
-
version_requirements: *
|
69
|
+
version_requirements: *id005
|
81
70
|
description: localport is a local application management system
|
82
71
|
email: y.hirokazu@gmail.com
|
83
72
|
executables:
|
@@ -85,10 +74,11 @@ executables:
|
|
85
74
|
extensions: []
|
86
75
|
|
87
76
|
extra_rdoc_files:
|
88
|
-
- README
|
77
|
+
- README.md
|
89
78
|
files:
|
79
|
+
- .travis.yml
|
90
80
|
- Gemfile
|
91
|
-
- README
|
81
|
+
- README.md
|
92
82
|
- Rakefile
|
93
83
|
- VERSION
|
94
84
|
- bin/localport
|
@@ -96,6 +86,8 @@ files:
|
|
96
86
|
- lib/localport/command.rb
|
97
87
|
- lib/localport/config.rb
|
98
88
|
- localport.gemspec
|
89
|
+
- spec/localport/command_spec.rb
|
90
|
+
- spec/localport_spec.rb
|
99
91
|
- spec/spec_helper.rb
|
100
92
|
homepage: http://github.com/yoppi/localport
|
101
93
|
licenses:
|
@@ -110,7 +102,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
110
102
|
requirements:
|
111
103
|
- - ">="
|
112
104
|
- !ruby/object:Gem::Version
|
113
|
-
hash:
|
105
|
+
hash: -267058066276211359
|
114
106
|
segments:
|
115
107
|
- 0
|
116
108
|
version: "0"
|
@@ -123,7 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
123
115
|
requirements: []
|
124
116
|
|
125
117
|
rubyforge_project:
|
126
|
-
rubygems_version: 1.8.
|
118
|
+
rubygems_version: 1.8.23
|
127
119
|
signing_key:
|
128
120
|
specification_version: 3
|
129
121
|
summary: Local Application management system
|
data/README
DELETED
@@ -1,78 +0,0 @@
|
|
1
|
-
== Local Application Port system
|
2
|
-
|
3
|
-
Local Application Management system. This application just like MacPorts on Mac
|
4
|
-
OS X.
|
5
|
-
An application has some versioned. But we use various version case by case.
|
6
|
-
For example Ruby application is now moving from 1.8 to 1.9.
|
7
|
-
So we must build Ruby 1.8 and Ruby 1.9 environment.
|
8
|
-
localport make us build multiversion environment easyly.
|
9
|
-
But there is some restrictions, following:
|
10
|
-
|
11
|
-
* When you install some application, you must specify one directory.
|
12
|
-
Like this,
|
13
|
-
/Users/user/apps
|
14
|
-
This directory is called "application directory".
|
15
|
-
|
16
|
-
* And, you must specify execute directory. Like this,
|
17
|
-
/Users/user/local/bin
|
18
|
-
This directory is called "executional directory"
|
19
|
-
|
20
|
-
Fox example, let's control Ruby-1.8.7.-p160 with localport.
|
21
|
-
|
22
|
-
1) Build, and Install Ruby-1.8.7-p160 to "application directory".
|
23
|
-
% tar zxvf ruby-1.8.7-p160.tar.gz
|
24
|
-
% cd ruby-1.8.7-p160
|
25
|
-
% ./configure --prefix=/Users/user/apps/ruby/ruby-1.8.7-p160
|
26
|
-
|
27
|
-
2) Install that to "execution directory"
|
28
|
-
% localport install /Users/user/apps/ruby/ruby-1.8.7-p160
|
29
|
-
This command make symbolic links that are Ruby applications in
|
30
|
-
/Users/user/apps/ruby/ruby-1.8.7-p160/bin.
|
31
|
-
|
32
|
-
3) Activate that.
|
33
|
-
% localport activate ruby-1.8.7-p160
|
34
|
-
This command make installed symbolic ruby-1.8.7-p160 point symbolic link.
|
35
|
-
apps/ruby/ruby-1.8.7-p160/bin/ruby
|
36
|
-
<- local/bin/ruby-1.8.7-p160
|
37
|
-
<- local/bin/ruby
|
38
|
-
|
39
|
-
4) Deactivate that.
|
40
|
-
If you want to execute another Ruby version with no specified version
|
41
|
-
command, 'ruby'.
|
42
|
-
% locaport deactivate ruby-1.8.7-p160
|
43
|
-
This command remove symbolic link 'local/bin/ruby'.
|
44
|
-
|
45
|
-
== Install
|
46
|
-
|
47
|
-
Just easy. Just run rake.
|
48
|
-
|
49
|
-
% Rake
|
50
|
-
|
51
|
-
== Usage
|
52
|
-
|
53
|
-
This application provide some commands. Like MacPorts.
|
54
|
-
|
55
|
-
= install
|
56
|
-
|
57
|
-
To specify an application path.
|
58
|
-
|
59
|
-
% localport install {app}
|
60
|
-
|
61
|
-
= installed
|
62
|
-
|
63
|
-
To list up installed applications.
|
64
|
-
|
65
|
-
% localport installed [app]
|
66
|
-
|
67
|
-
= activate
|
68
|
-
|
69
|
-
To activate installed application.
|
70
|
-
|
71
|
-
% localport activate {app}
|
72
|
-
|
73
|
-
= deactivate
|
74
|
-
|
75
|
-
To deactivate installed application.
|
76
|
-
Delete internal symbolic link.
|
77
|
-
|
78
|
-
% localport deactivate {app}
|