localport 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/localport/command.rb +59 -0
- data/localport.gemspec +2 -2
- data/spec/localport/command_spec.rb +41 -2
- metadata +83 -63
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.3
|
data/lib/localport/command.rb
CHANGED
@@ -26,6 +26,14 @@ module LocalPort
|
|
26
26
|
}
|
27
27
|
)
|
28
28
|
|
29
|
+
register_command(
|
30
|
+
:name => "update",
|
31
|
+
:args => true,
|
32
|
+
:exec => lambda {|args|
|
33
|
+
update args
|
34
|
+
}
|
35
|
+
)
|
36
|
+
|
29
37
|
register_command(
|
30
38
|
:name => "uninstall",
|
31
39
|
:args => true,
|
@@ -97,6 +105,15 @@ module LocalPort
|
|
97
105
|
end
|
98
106
|
end
|
99
107
|
|
108
|
+
def update(args)
|
109
|
+
targets = update_apps(args)
|
110
|
+
targets.each {|target|
|
111
|
+
install([installed_dir(target)])
|
112
|
+
config.installed_app() # TODO: もっとエレガントに初期化する方法を考える
|
113
|
+
activate(target)
|
114
|
+
}
|
115
|
+
end
|
116
|
+
|
100
117
|
def uninstall(args)
|
101
118
|
# 指定されたアプリケーションがactivatedされていなければ,
|
102
119
|
# そのリンクを削除する
|
@@ -204,6 +221,48 @@ module LocalPort
|
|
204
221
|
ret
|
205
222
|
}
|
206
223
|
end
|
224
|
+
|
225
|
+
# Private: [指定した]アプリケーションのバージョンをつけた文字列配列を生成する
|
226
|
+
#
|
227
|
+
# args - [String], アプリケーションの配列
|
228
|
+
#
|
229
|
+
# Examples:
|
230
|
+
#
|
231
|
+
# update_apps ["ruby"]
|
232
|
+
# #=> ["ruby-1.9.2-p130"]
|
233
|
+
#
|
234
|
+
# Returns アプリケーションのバージョンがついた文字列配列
|
235
|
+
def update_apps(args)
|
236
|
+
if args.empty?
|
237
|
+
config.installed.inject([]) {|ret, (app, versions)|
|
238
|
+
ret += versions.keys.map {|version| "#{app}-#{version}"}
|
239
|
+
ret
|
240
|
+
}
|
241
|
+
else
|
242
|
+
args.inject([]) {|ret, arg|
|
243
|
+
versions = config.installed[arg]
|
244
|
+
if versions
|
245
|
+
ret += versions.keys.map {|version| "#{arg}-#{version}"}
|
246
|
+
end
|
247
|
+
ret
|
248
|
+
}
|
249
|
+
end
|
250
|
+
end
|
251
|
+
|
252
|
+
# Private: 指定したアプリケーションがインストールされているディレクトリ名を生成する
|
253
|
+
#
|
254
|
+
# app - String, バージョン付きアプリケーション名
|
255
|
+
#
|
256
|
+
# Examples:
|
257
|
+
#
|
258
|
+
# installed_dir "ruby-1.9.3-p130"
|
259
|
+
# #=> /Users/user/local/ruby/1.9.3-p130
|
260
|
+
#
|
261
|
+
# Returns アプリケーションがインストールされているディレクトリ名
|
262
|
+
def installed_dir(appver)
|
263
|
+
app, ver = split_appver_to_app_ver(appver)
|
264
|
+
File.join(LocalPort::APPS_DIR, app, ver)
|
265
|
+
end
|
207
266
|
end
|
208
267
|
|
209
268
|
def self.command
|
data/localport.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "localport"
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.3"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["yoppi"]
|
12
|
-
s.date = "2012-04
|
12
|
+
s.date = "2012-05-04"
|
13
13
|
s.description = "localport is a local application management system"
|
14
14
|
s.email = "y.hirokazu@gmail.com"
|
15
15
|
s.executables = ["localport"]
|
@@ -5,6 +5,9 @@ require 'spec_helper'
|
|
5
5
|
|
6
6
|
require 'fileutils'
|
7
7
|
|
8
|
+
LocalPort::LINK_DIR = File.dirname(__FILE__)
|
9
|
+
LocalPort::APPS_DIR = File.dirname(__FILE__)
|
10
|
+
|
8
11
|
describe LocalPort::Command do
|
9
12
|
it "should raise CommandError in unknown command" do
|
10
13
|
expect { LocalPort.command.find("foo") }.to raise_error(
|
@@ -21,7 +24,6 @@ end
|
|
21
24
|
describe LocalPort::Command, "#install" do
|
22
25
|
|
23
26
|
let(:install) { LocalPort.command.find("install") }
|
24
|
-
LocalPort::LINK_DIR = File.dirname(__FILE__)
|
25
27
|
|
26
28
|
context "path is emtpy" do
|
27
29
|
it "should raise CommandError in no args" do
|
@@ -97,8 +99,45 @@ describe LocalPort::Command, "#deactivate" do
|
|
97
99
|
end
|
98
100
|
end
|
99
101
|
|
102
|
+
describe LocalPort::Command, "#update" do
|
103
|
+
let(:update) { LocalPort.command.find("update") }
|
104
|
+
|
105
|
+
it "should exist command" do
|
106
|
+
LocalPort.command.find("update").should_not be_nil
|
107
|
+
end
|
108
|
+
|
109
|
+
context "update one" do
|
110
|
+
let(:app) { File.join(File.dirname(__FILE__), "test/0.0.0") }
|
111
|
+
let(:bin) { File.join(File.dirname(__FILE__), "test/0.0.0/bin/a") }
|
112
|
+
let(:bin_new) { File.join(File.dirname(__FILE__), "test/0.0.0/bin/b") }
|
113
|
+
let(:symlink) { File.join(File.dirname(__FILE__), "a-0.0.0") }
|
114
|
+
let(:symlink_app) { File.join(File.dirname(__FILE__), "a") }
|
115
|
+
let(:symlink_new) { File.join(File.dirname(__FILE__), "b-0.0.0") }
|
116
|
+
let(:symlink_new_app) { File.join(File.dirname(__FILE__), "b") }
|
117
|
+
|
118
|
+
before do
|
119
|
+
FileUtils.mkdir_p(File.dirname(bin))
|
120
|
+
FileUtils.touch(bin)
|
121
|
+
File.symlink(bin, symlink)
|
122
|
+
end
|
123
|
+
|
124
|
+
it "should update specifed application" do
|
125
|
+
FileUtils.touch(bin_new)
|
126
|
+
config.installed_app()
|
127
|
+
update[:exec].call(["test"])
|
128
|
+
File.exists? symlink_new
|
129
|
+
File.exists? symlink_new_app
|
130
|
+
end
|
131
|
+
|
132
|
+
after do
|
133
|
+
FileUtils.rm_rf(File.join(File.dirname(__FILE__), "test"))
|
134
|
+
FileUtils.rm([symlink, symlink_new, symlink_app, symlink_new_app])
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
100
139
|
describe LocalPort::Command do
|
101
140
|
it "should get command list" do
|
102
|
-
LocalPort.command.list.sort.should == %w[activate deactivate install installed uninstall]
|
141
|
+
LocalPort.command.list.sort.should == %w[activate deactivate install installed uninstall update]
|
103
142
|
end
|
104
143
|
end
|
metadata
CHANGED
@@ -1,81 +1,104 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: localport
|
3
|
-
version: !ruby/object:Gem::Version
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.3
|
4
5
|
prerelease:
|
5
|
-
version: 0.0.2
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
7
|
+
authors:
|
8
8
|
- yoppi
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-05-04 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
16
15
|
name: highline
|
17
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
18
17
|
none: false
|
19
|
-
requirements:
|
20
|
-
- -
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version:
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
23
22
|
type: :runtime
|
24
23
|
prerelease: false
|
25
|
-
version_requirements:
|
26
|
-
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
27
31
|
name: rspec
|
28
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
29
33
|
none: false
|
30
|
-
requirements:
|
31
|
-
- -
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version:
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
34
38
|
type: :development
|
35
39
|
prerelease: false
|
36
|
-
version_requirements:
|
37
|
-
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
38
47
|
name: yard
|
39
|
-
requirement:
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
40
49
|
none: false
|
41
|
-
requirements:
|
42
|
-
- -
|
43
|
-
- !ruby/object:Gem::Version
|
44
|
-
version:
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
45
54
|
type: :development
|
46
55
|
prerelease: false
|
47
|
-
version_requirements:
|
48
|
-
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
49
63
|
name: bundler
|
50
|
-
requirement:
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
51
65
|
none: false
|
52
|
-
requirements:
|
53
|
-
- -
|
54
|
-
- !ruby/object:Gem::Version
|
55
|
-
version:
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
56
70
|
type: :development
|
57
71
|
prerelease: false
|
58
|
-
version_requirements:
|
59
|
-
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
60
79
|
name: jeweler
|
61
|
-
requirement:
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
62
81
|
none: false
|
63
|
-
requirements:
|
64
|
-
- -
|
65
|
-
- !ruby/object:Gem::Version
|
66
|
-
version:
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
67
86
|
type: :development
|
68
87
|
prerelease: false
|
69
|
-
version_requirements:
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
70
94
|
description: localport is a local application management system
|
71
95
|
email: y.hirokazu@gmail.com
|
72
|
-
executables:
|
96
|
+
executables:
|
73
97
|
- localport
|
74
98
|
extensions: []
|
75
|
-
|
76
|
-
extra_rdoc_files:
|
99
|
+
extra_rdoc_files:
|
77
100
|
- README.md
|
78
|
-
files:
|
101
|
+
files:
|
79
102
|
- .travis.yml
|
80
103
|
- Gemfile
|
81
104
|
- README.md
|
@@ -90,34 +113,31 @@ files:
|
|
90
113
|
- spec/localport_spec.rb
|
91
114
|
- spec/spec_helper.rb
|
92
115
|
homepage: http://github.com/yoppi/localport
|
93
|
-
licenses:
|
116
|
+
licenses:
|
94
117
|
- MIT
|
95
118
|
post_install_message:
|
96
119
|
rdoc_options: []
|
97
|
-
|
98
|
-
require_paths:
|
120
|
+
require_paths:
|
99
121
|
- lib
|
100
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
122
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
101
123
|
none: false
|
102
|
-
requirements:
|
103
|
-
- -
|
104
|
-
- !ruby/object:Gem::Version
|
105
|
-
|
106
|
-
segments:
|
124
|
+
requirements:
|
125
|
+
- - ! '>='
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
version: '0'
|
128
|
+
segments:
|
107
129
|
- 0
|
108
|
-
|
109
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
130
|
+
hash: 3928302131634072354
|
131
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
110
132
|
none: false
|
111
|
-
requirements:
|
112
|
-
- -
|
113
|
-
- !ruby/object:Gem::Version
|
114
|
-
version:
|
133
|
+
requirements:
|
134
|
+
- - ! '>='
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: '0'
|
115
137
|
requirements: []
|
116
|
-
|
117
138
|
rubyforge_project:
|
118
139
|
rubygems_version: 1.8.23
|
119
140
|
signing_key:
|
120
141
|
specification_version: 3
|
121
142
|
summary: Local Application management system
|
122
143
|
test_files: []
|
123
|
-
|