p4ruby 2012.2.beta → 2012.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/install.rb +430 -434
  2. data/p4ruby.gemspec +1 -1
  3. metadata +7 -10
data/install.rb CHANGED
@@ -11,213 +11,213 @@ require 'pathname'
11
11
  require 'rubygems'
12
12
 
13
13
  class Installer
14
- include FileUtils
15
-
16
- CONFIG = Config::CONFIG
17
- BIT64 = (1.size == 8)
18
-
19
- RB_BASENAME = Pathname.new "P4.rb"
20
- SO_BASENAME = Pathname.new "P4.#{CONFIG['DLEXT']}"
21
-
22
- RAW_INSTALL_FILES = [
23
- Pathname.new(CONFIG["sitelibdir"]) + RB_BASENAME,
24
- Pathname.new(CONFIG["sitearchdir"]) + SO_BASENAME,
25
- ]
26
-
27
- GEM_INSTALL_FILES = [
28
- Pathname.new("lib") + RB_BASENAME,
29
- Pathname.new("ext") + SO_BASENAME,
30
- ]
31
-
32
- SERVER = "ftp.perforce.com"
33
- SERVER_TOP_DIR = Pathname.new "perforce"
34
-
35
- # Mysterious "ghost" releases which lack files
36
- HOSED_VERSIONS = %w[09.3 11.1]
37
-
38
- P4API_REMOTE_BASENAME = Pathname.new "p4api.tgz"
39
- P4RUBY_REMOTE_BASENAME = Pathname.new "p4ruby.tgz"
40
-
41
- WORK_DIR = Pathname.new "work"
42
- DISTFILES_DIR = WORK_DIR + "distfiles"
43
- BUILD_DIR = WORK_DIR + "build"
44
-
45
- def parse_command_line
46
- OptionParser.new("Usage: ruby install.rb [options]", 24, "") {
47
- |parser|
48
- parser.on(
49
- "--version NN.N",
50
- "Version to download, e.g. 08.1. Default finds latest.") {
51
- |version|
52
- @s.version = version
53
- }
54
- parser.on(
55
- "--list-versions",
56
- "List available versions.") {
57
- @s.list_versions = true
58
- }
59
- parser.on(
60
- "--platform PLATFORM",
61
- "Perforce-named platform to download. Default guesses.") {
62
- |platform|
63
- @s.platform = platform
64
- }
65
- parser.on(
66
- "--list-platforms",
67
- "List available platforms for the given version.") {
68
- @s.list_platforms = true
69
- }
70
- parser.on(
71
- "--gem",
72
- "Gem configuration (for the gem installer).") {
73
- @s.gem_config = true
74
- }
75
- parser.on(
76
- "--uninstall",
77
- "Uninstall.") {
78
- @s.uninstall = true
79
- }
80
- parser.on(
81
- "--local",
82
- "Use the files in work/distfiles (manual download).") {
83
- @s.local = true
84
- }
85
- parser.parse(ARGV)
86
- }
14
+ include FileUtils
15
+
16
+ CONFIG = Config::CONFIG
17
+ BIT64 = (1.size == 8)
18
+
19
+ RB_BASENAME = Pathname.new "P4.rb"
20
+ SO_BASENAME = Pathname.new "P4.#{CONFIG['DLEXT']}"
21
+
22
+ RAW_INSTALL_FILES = [
23
+ Pathname.new(CONFIG["sitelibdir"]) + RB_BASENAME,
24
+ Pathname.new(CONFIG["sitearchdir"]) + SO_BASENAME,
25
+ ]
26
+
27
+ GEM_INSTALL_FILES = [
28
+ Pathname.new("lib") + RB_BASENAME,
29
+ Pathname.new("ext") + SO_BASENAME,
30
+ ]
31
+
32
+ SERVER = "ftp.perforce.com"
33
+ SERVER_TOP_DIR = Pathname.new "perforce"
34
+
35
+ # Mysterious "ghost" releases which lack files
36
+ HOSED_VERSIONS = %w[09.3 11.1]
37
+
38
+ P4API_REMOTE_BASENAME = Pathname.new "p4api.tgz"
39
+ P4RUBY_REMOTE_BASENAME = Pathname.new "p4ruby.tgz"
40
+
41
+ WORK_DIR = Pathname.new "work"
42
+ DISTFILES_DIR = WORK_DIR + "distfiles"
43
+ BUILD_DIR = WORK_DIR + "build"
44
+
45
+ def parse_command_line
46
+ OptionParser.new("Usage: ruby install.rb [options]", 24, "") {
47
+ |parser|
48
+ parser.on(
49
+ "--version NN.N",
50
+ "Version to download, e.g. 08.1. Default finds latest.") {
51
+ |version|
52
+ @s.version = version
53
+ }
54
+ parser.on(
55
+ "--list-versions",
56
+ "List available versions.") {
57
+ @s.list_versions = true
58
+ }
59
+ parser.on(
60
+ "--platform PLATFORM",
61
+ "Perforce-named platform to download. Default guesses.") {
62
+ |platform|
63
+ @s.platform = platform
64
+ }
65
+ parser.on(
66
+ "--list-platforms",
67
+ "List available platforms for the given version.") {
68
+ @s.list_platforms = true
69
+ }
70
+ parser.on(
71
+ "--gem",
72
+ "Gem configuration (for the gem installer).") {
73
+ @s.gem_config = true
74
+ }
75
+ parser.on(
76
+ "--uninstall",
77
+ "Uninstall.") {
78
+ @s.uninstall = true
79
+ }
80
+ parser.on(
81
+ "--local",
82
+ "Use the files in work/distfiles (manual download).") {
83
+ @s.local = true
84
+ }
85
+ parser.parse(ARGV)
86
+ }
87
+ end
88
+
89
+ def run
90
+ @s = LazyStruct.new
91
+ parse_command_line
92
+ config
93
+ if @s.uninstall
94
+ uninstall
95
+ elsif @s.list_platforms
96
+ puts platforms
97
+ elsif @s.list_versions
98
+ puts versions
99
+ elsif @s.platform.nil?
100
+ platform_fail
101
+ elsif @s.platform =~ %r!\Ant!
102
+ windows_install
103
+ else
104
+ fetch
105
+ build
106
+ install
107
+ verify_install
87
108
  end
109
+ end
88
110
 
89
- def run
90
- @s = LazyStruct.new
91
- parse_command_line
92
- config
93
- if @s.uninstall
94
- uninstall
95
- elsif @s.list_platforms
96
- puts platforms
97
- elsif @s.list_versions
98
- puts versions
99
- elsif @s.platform.nil?
100
- platform_fail
101
- elsif @s.platform =~ %r!\Ant!
102
- windows_install
103
- else
104
- fetch
105
- build
106
- install
107
- verify_install
108
- end
111
+ def config
112
+ if CONFIG["LIBRUBYARG_SHARED"].empty?
113
+ raise "error: ruby must be configured with --enable-shared"
109
114
  end
110
115
 
111
- def config
112
- if CONFIG["LIBRUBYARG_SHARED"].empty?
113
- raise "error: ruby must be configured with --enable-shared"
114
- end
115
-
116
- @s.ftp = Net::FTP.new(SERVER).tap { |t|
117
- t.passive = true
118
- t.login
119
- }
120
-
121
- @s.p4api = LazyStruct.new.tap { |t|
122
- t.basename = P4API_REMOTE_BASENAME
123
- }
124
-
125
- @s.p4ruby = LazyStruct.new.tap { |t|
126
- t.basename = P4RUBY_REMOTE_BASENAME
127
- }
128
-
129
- @s.specs = [@s.p4ruby, @s.p4api]
130
- @s.specs.each { |spec|
131
- spec.local = DISTFILES_DIR + spec.basename
132
- }
133
-
134
- unless @s.version
135
- @s.version = latest_version
136
- end
116
+ @s.ftp = Net::FTP.new(SERVER).tap { |t|
117
+ t.passive = true
118
+ t.login
119
+ }
137
120
 
138
- @s.version_dir = SERVER_TOP_DIR + "r#{@s.version}"
121
+ @s.p4api = LazyStruct.new.tap { |t|
122
+ t.basename = P4API_REMOTE_BASENAME
123
+ }
139
124
 
140
- unless @s.platform
141
- @s.platform = guess_platform
142
- end
125
+ @s.p4ruby = LazyStruct.new.tap { |t|
126
+ t.basename = P4RUBY_REMOTE_BASENAME
127
+ }
143
128
 
144
- if @s.platform =~ /nt/
145
- @s.p4api.remote = @s.version_dir + "bin.#{@s.platform}"
146
- else
147
- @s.p4api.remote = @s.version_dir + "bin.#{@s.platform}" + @s.p4api.basename
148
- @s.p4ruby.remote = @s.version_dir + "bin.tools" + @s.p4ruby.basename
149
- end
129
+ @s.specs = [ @s.p4ruby, @s.p4api ]
130
+ @s.specs.each { |spec|
131
+ spec.local = DISTFILES_DIR + spec.basename
132
+ }
133
+
134
+ unless @s.version
135
+ @s.version = latest_version
136
+ end
150
137
 
138
+ @s.version_dir = SERVER_TOP_DIR + "r#{@s.version}"
151
139
 
140
+ unless @s.platform
141
+ @s.platform = guess_platform
152
142
  end
153
143
 
154
- def guess_cpu
155
- if CONFIG["target_os"] =~ /darwin/i
156
- if CONFIG["build"] =~ /i686|x86_64/
157
- "x86_64"
158
- else
159
- "x86"
160
- end
161
- else
162
- case CONFIG["target_cpu"]
163
- when %r!ia!i
164
- "ia64"
165
- when %r!86!
166
- # note: with '_'
167
- "x86" + (BIT64 ? "_64" : "")
168
- when %r!(ppc|sparc)!i
169
- # note: without '_'
170
- $1 + (BIT64 ? "64" : "")
171
- else
172
- ""
173
- end
174
- end
144
+ if @s.platform =~ /nt/
145
+ @s.p4api.remote = @s.version_dir + "bin.#{@s.platform}"
146
+ else
147
+ @s.p4api.remote = @s.version_dir + "bin.#{@s.platform}" + @s.p4api.basename
148
+ @s.p4ruby.remote = @s.version_dir + "bin.tools" + @s.p4ruby.basename
175
149
  end
176
150
 
177
- def guess_version(os)
178
- if match = `uname -a`.match(%r!#{os}\s+\S+\s+(\d+)\.(\d+)!i)
179
- version = match.captures.join
180
- cpu = guess_cpu
181
- platforms = self.platforms
182
- built_platforms = (0..version.to_i).map { |n|
183
- [os, n.to_s, cpu].join
184
- }.select { |platform|
185
- platforms.include? platform
186
- }
187
- if os =~ /darwin/
188
- built_platforms.last
189
- else
190
- built_platforms.last
191
- end
192
- else
193
- nil
194
- end
195
- end
196
151
 
197
- def guess_platform(opts = { })
198
- config_os = CONFIG["target_os"].downcase
199
- windows_cpu = BIT64 ? "x64" : "x86"
200
-
201
- if config_os =~ %r!cygwin!i
202
- "cygwin" + windows_cpu
203
- elsif config_os =~ %r!(mswin|mingw)!i
204
- "nt" + windows_cpu
205
- elsif @s.local
206
- "<local>"
207
- else
208
- if match = config_os.match(%r!\A\D+!)
209
- guess_version(match[0])
210
- else
211
- nil
212
- end
213
- end
152
+ end
153
+
154
+ def guess_cpu
155
+ if CONFIG["target_os"] =~ /darwin/i
156
+ if CONFIG["build"] =~ /i686|x86_64/
157
+ "x86_64"
158
+ else
159
+ "x86"
160
+ end
161
+ else
162
+ case CONFIG["target_cpu"]
163
+ when %r!ia!i
164
+ "ia64"
165
+ when %r!86!
166
+ # note: with '_'
167
+ "x86" + (BIT64 ? "_64" : "")
168
+ when %r!(ppc|sparc)!i
169
+ # note: without '_'
170
+ $1 + (BIT64 ? "64" : "")
171
+ else
172
+ ""
173
+ end
174
+ end
175
+ end
176
+
177
+ def guess_version(os)
178
+ if match = `uname -a`.match(%r!#{os}\s+\S+\s+(\d+)\.(\d+)!i)
179
+ version = match.captures.join
180
+ cpu = guess_cpu
181
+ platforms = self.platforms
182
+ built_platforms = (0..version.to_i).map { |n|
183
+ [os, n.to_s, cpu].join
184
+ }.select { |platform|
185
+ platforms.include? platform
186
+ }
187
+ if os =~ /darwin/
188
+ built_platforms.last
189
+ else
190
+ built_platforms.last
191
+ end
192
+ else
193
+ nil
194
+ end
195
+ end
196
+
197
+ def guess_platform(opts = {})
198
+ config_os = CONFIG["target_os"].downcase
199
+ windows_cpu = BIT64 ? "x64" : "x86"
200
+
201
+ if config_os =~ %r!cygwin!i
202
+ "cygwin" + windows_cpu
203
+ elsif config_os =~ %r!(mswin|mingw)!i
204
+ "nt" + windows_cpu
205
+ elsif @s.local
206
+ "<local>"
207
+ else
208
+ if match = config_os.match(%r!\A\D+!)
209
+ guess_version(match[0])
210
+ else
211
+ nil
212
+ end
214
213
  end
214
+ end
215
215
 
216
- def platform_fail
217
- install_fail {
218
- @s.version = "<version>"
219
- @s.platform = "<platform>"
220
- message = %Q{
216
+ def platform_fail
217
+ install_fail {
218
+ @s.version = "<version>"
219
+ @s.platform = "<platform>"
220
+ message = %Q{
221
221
  Auto-fetch not yet handled for this platform. Run:
222
222
 
223
223
  \truby install.rb --list-platforms
@@ -234,278 +234,274 @@ class Installer
234
234
 
235
235
  Copy it to #{@s.p4api.local} and run install.rb --local.
236
236
  }.gsub(%r!^ +(?=\S)!, "")
237
-
238
- mkdir_p(DISTFILES_DIR)
239
- puts message
240
- }
241
- end
242
-
243
- def install_fail
244
- yield
245
- exit(1)
246
- end
247
-
248
- def sys(*args)
249
- system(*args).tap { |result|
250
- unless result
251
- raise "system() failed: #{args.join(" ")}"
252
- end
253
- }
237
+
238
+ mkdir_p(DISTFILES_DIR)
239
+ puts message
240
+ }
241
+ end
242
+
243
+ def install_fail
244
+ yield
245
+ exit(1)
246
+ end
247
+
248
+ def sys(*args)
249
+ system(*args).tap { |result|
250
+ unless result
251
+ raise "system() failed: #{args.join(" ")}"
252
+ end
253
+ }
254
+ end
255
+
256
+ def unpack(distfile, target_dir)
257
+ sys("tar", "zxvf", distfile.to_s, "-C", target_dir.to_s)
258
+ end
259
+
260
+ def fetch_spec(spec)
261
+ unless @s.local
262
+ mkdir_p(spec.local.dirname)
263
+ puts "downloading ftp://#{SERVER}/#{spec.remote} ..."
264
+ @s.ftp.getbinaryfile(spec.remote.to_s, spec.local.to_s)
254
265
  end
255
-
256
- def unpack(distfile, target_dir)
257
- sys("tar", "zxvf", distfile.to_s, "-C", target_dir.to_s)
258
- end
259
-
260
- def fetch_spec(spec)
261
- unless @s.local
262
- mkdir_p(spec.local.dirname)
263
- puts "downloading ftp://#{SERVER}/#{spec.remote} ..."
264
- @s.ftp.getbinaryfile(spec.remote.to_s, spec.local.to_s)
266
+ end
267
+
268
+ def fetch
269
+ @s.specs.each { |spec|
270
+ fetch_spec(spec)
271
+ }
272
+ end
273
+
274
+ def remote_files_matching(dir, regex)
275
+ @s.ftp.ls(dir.to_s).map { |entry|
276
+ if match = entry.match(regex)
277
+ yield match
278
+ else
279
+ nil
280
+ end
281
+ }.reject { |entry|
282
+ entry.nil?
283
+ }
284
+ end
285
+
286
+ def platforms
287
+ remote_files_matching(@s.version_dir, %r!bin\.(\w+)!) { |match|
288
+ match.captures.first
289
+ }.reject { |platform|
290
+ platform =~ %r!java!
291
+ }.sort
292
+ end
293
+
294
+ def versions
295
+ remote_files_matching(SERVER_TOP_DIR, %r!r([0-8]\d\.\d)!) { |match|
296
+ match.captures.first
297
+ }.reject { |version|
298
+ HOSED_VERSIONS.include? version
299
+ }.sort
300
+ end
301
+
302
+ def latest_version
303
+ versions.reverse_each{ |v|
304
+ begin
305
+ remote_files_matching("#{SERVER_TOP_DIR}/r#{v}/bin.tools",/p4ruby/) do
306
+ return v
265
307
  end
308
+ rescue
309
+ next
310
+ end
311
+ }
312
+ end
313
+
314
+ def make(*args)
315
+ sys("make", *args)
316
+ end
317
+
318
+ def ruby(*args)
319
+ exe = Pathname.new(CONFIG["bindir"]) + CONFIG["RUBY_INSTALL_NAME"]
320
+ sys(exe.to_s, *args)
321
+ end
322
+
323
+ def build
324
+ puts "building..."
325
+ rm_rf(BUILD_DIR)
326
+ mkdir_p(BUILD_DIR)
327
+
328
+ @s.specs.each { |spec|
329
+ unpack(spec.local, BUILD_DIR)
330
+ }
331
+
332
+ Dir.chdir(BUILD_DIR) {
333
+ api_dir = Pathname.glob("p4api*").last
334
+ p4ruby_dir = Pathname.glob("p4ruby*").last
335
+ Dir.chdir(p4ruby_dir) {
336
+ ruby("p4conf.rb", "--apidir", "../#{api_dir}")
337
+ make
338
+ }
339
+ @s.p4ruby_build_dir = BUILD_DIR + p4ruby_dir
340
+ }
341
+ end
342
+
343
+ def raw_install_to_gem_install
344
+ RAW_INSTALL_FILES.zip(GEM_INSTALL_FILES) { |source, dest|
345
+ mkdir_p(dest.dirname)
346
+ puts "move #{source} --> #{dest}"
347
+ mv(source, dest)
348
+ }
349
+ end
350
+
351
+ def install
352
+ puts "installing..."
353
+ Dir.chdir(@s.p4ruby_build_dir) {
354
+ make("install")
355
+ }
356
+ if @s.gem_config
357
+ raw_install_to_gem_install
266
358
  end
267
-
268
- def fetch
269
- @s.specs.each { |spec|
270
- fetch_spec(spec)
271
- }
359
+ end
360
+
361
+ def verify_install(on_error = nil)
362
+ puts "verifying..."
363
+ files =
364
+ if @s.gem_config
365
+ GEM_INSTALL_FILES
366
+ else
367
+ RAW_INSTALL_FILES
368
+ end.map { |t| t.expand_path }
369
+
370
+ if files.all? { |t| t.exist? }
371
+ puts "Installed files:"
372
+ puts files
373
+ elsif on_error
374
+ install_fail(&on_error)
375
+ else
376
+ install_fail {
377
+ puts "These files were supposed to be installed, but were not:"
378
+ puts files
379
+ puts "Install failed!"
380
+ }
272
381
  end
382
+ end
273
383
 
274
- def remote_files_matching(dir, regex)
275
- @s.ftp.ls(dir.to_s).map { |entry|
276
- if match = entry.match(regex)
277
- yield match
278
- else
279
- nil
280
- end
281
- }.reject { |entry|
282
- entry.nil?
283
- }
284
- end
285
-
286
- def platforms
287
- remote_files_matching(@s.version_dir, %r!bin\.(\w+)!) { |match|
288
- match.captures.first
289
- }.reject { |platform|
290
- platform =~ %r!java!
291
- }.sort
292
- end
293
-
294
- def versions
295
- remote_files_matching(SERVER_TOP_DIR, %r!r([0-8]\d\.\d)!) { |match|
296
- match.captures.first
297
- }.reject { |version|
298
- HOSED_VERSIONS.include? version
299
- }.sort
300
- end
301
-
302
- def latest_version
303
- versions.reverse_each { |v|
304
- begin
305
- remote_files_matching("#{SERVER_TOP_DIR}/r#{v}/bin.tools", /p4ruby/) do
306
- return v
307
- end
308
- rescue
309
- next
310
- end
311
- }
312
- end
384
+ def find_ruby_version(spec)
385
+ remote_files_matching(spec.remote, /p4ruby\d\d.exe/) {|r_ver|
313
386
 
314
- def make(*args)
315
- sys("make", *args)
316
- end
387
+ #Find the latest version of p4ruby for this version of ruby
388
+ v_max = CONFIG["MAJOR"]
389
+ v_min = CONFIG["MINOR"]
390
+ version = [v_max, v_min].join
391
+ if r_ver.to_s =~ /p4ruby#{version}.exe/
392
+ return "p4ruby#{version}.exe"
393
+ end
317
394
 
318
- def ruby(*args)
319
- exe = Pathname.new(CONFIG["bindir"]) + CONFIG["RUBY_INSTALL_NAME"]
320
- sys(exe.to_s, *args)
321
- end
322
-
323
- def build
324
- puts "building..."
325
- rm_rf(BUILD_DIR)
326
- mkdir_p(BUILD_DIR)
327
-
328
- @s.specs.each { |spec|
329
- unpack(spec.local, BUILD_DIR)
330
- }
395
+ }
396
+ nil
397
+ end
331
398
 
332
- Dir.chdir(BUILD_DIR) {
333
- api_dir = Pathname.glob("p4api*").last
334
- p4ruby_dir = Pathname.glob("p4ruby*").last
335
- Dir.chdir(p4ruby_dir) {
336
- ruby("p4conf.rb", "--apidir", "../#{api_dir}")
337
- make
338
- }
339
- @s.p4ruby_build_dir = BUILD_DIR + p4ruby_dir
340
- }
341
- end
342
-
343
- def raw_install_to_gem_install
344
- RAW_INSTALL_FILES.zip(GEM_INSTALL_FILES) { |source, dest|
345
- mkdir_p(dest.dirname)
346
- puts "move #{source} --> #{dest}"
347
- mv(source, dest)
348
- }
349
- end
350
-
351
- def install
352
- puts "installing..."
353
- Dir.chdir(@s.p4ruby_build_dir) {
354
- make("install")
355
- }
356
- if @s.gem_config
357
- raw_install_to_gem_install
358
- end
359
- end
360
-
361
- def verify_install(on_error = nil)
362
- puts "verifying..."
363
- files =
364
- if @s.gem_config
365
- GEM_INSTALL_FILES
366
- else
367
- RAW_INSTALL_FILES
368
- end.map { |t| t.expand_path }
369
-
370
- if files.all? { |t| t.exist? }
371
- puts "Installed files:"
372
- puts files
373
- elsif on_error
374
- install_fail(&on_error)
375
- else
376
- install_fail {
377
- puts "These files were supposed to be installed, but were not:"
378
- puts files
379
- puts "Install failed!"
380
- }
381
- end
382
- end
383
-
384
- def find_ruby_version(spec)
385
- remote_files_matching(spec.remote, /p4ruby\d\d.exe/) { |r_ver|
386
-
387
- #Find the latest version of p4ruby for this version of ruby
388
- v_max = CONFIG["MAJOR"]
389
- v_min = CONFIG["MINOR"]
390
- version = [v_max, v_min].join
391
- if r_ver.to_s =~ /p4ruby#{version}.exe/
392
- return "p4ruby#{version}.exe"
393
- end
394
-
395
- }
396
- nil
399
+ def windows_install
400
+ #
401
+ # For Windows, p4ruby is located in the p4api directory on the
402
+ # perforce server -- switcharoo --
403
+ #
404
+ spec = @s.p4api
405
+
406
+ p4ruby_exe = find_ruby_version(spec)
407
+ if p4ruby_exe && !(spec.remote.to_s =~ /p4ruby/)
408
+ spec.remote += p4ruby_exe.to_s
409
+ else
410
+ abort("Failed to find a suitable p4ruby executable for ruby #{CONFIG["MAJOR"]}.#{CONFIG["MINOR"]}")
397
411
  end
398
-
399
- def windows_install
400
- #
401
- # For Windows, p4ruby is located in the p4api directory on the
402
- # perforce server -- switcharoo --
403
- #
404
- spec = @s.p4api
405
-
406
- p4ruby_exe = find_ruby_version(spec)
407
- if p4ruby_exe && !(spec.remote.to_s =~ /p4ruby/)
408
- spec.remote += p4ruby_exe.to_s
409
- spec.local = 'p4ruby18.exe'
410
- else
411
- abort("Failed to find a suitable p4ruby executable for ruby #{CONFIG["MAJOR"]}.#{CONFIG["MINOR"]}")
412
- end
413
- fetch_spec(spec)
414
-
415
- error = lambda {
416
- puts "The Perforce P4Ruby Windows installer failed!"
417
- puts "You may re-run it manually here:"
418
- puts spec.local.expand_path
419
- }
420
-
421
- puts "running Perforce P4Ruby Windows installer..."
422
- if system(spec.local.to_s, "/S", "/v/qn")
423
- if @s.gem_config
424
- sleep(1)
425
- raw_install_to_gem_install
426
- sleep(1)
427
- unless system(spec.local, "/V", "/x", "/S", "/v/qn")
428
- # We don't much care if this fails; just write to the log
429
- puts "Note: the Perforce P4Ruby Windows uninstaller failed."
430
- end
431
- end
432
- verify_install(error)
433
- else
434
- install_fail(&error)
412
+ fetch_spec(spec)
413
+
414
+ error = lambda {
415
+ puts "The Perforce P4Ruby Windows installer failed!"
416
+ puts "You may re-run it manually here:"
417
+ puts spec.local.expand_path
418
+ }
419
+
420
+ puts "running Perforce P4Ruby Windows installer..."
421
+ if system(spec.local.to_s, "/S", "/v/qn")
422
+ if @s.gem_config
423
+ sleep(1)
424
+ raw_install_to_gem_install
425
+ sleep(1)
426
+ unless system(spec.local, "/V", "/x", "/S", "/v/qn")
427
+ # We don't much care if this fails; just write to the log
428
+ puts "Note: the Perforce P4Ruby Windows uninstaller failed."
435
429
  end
430
+ end
431
+ verify_install(error)
432
+ else
433
+ install_fail(&error)
436
434
  end
437
-
438
- def uninstall
439
- RAW_INSTALL_FILES.each { |file|
440
- if file.exist?
441
- puts "delete #{file}"
442
- rm_f(file)
443
- end
444
- }
445
- end
435
+ end
436
+
437
+ def uninstall
438
+ RAW_INSTALL_FILES.each { |file|
439
+ if file.exist?
440
+ puts "delete #{file}"
441
+ rm_f(file)
442
+ end
443
+ }
444
+ end
446
445
  end
447
446
 
448
447
  #
449
448
  # An OpenStruct with optional lazy-evaluated fields.
450
449
  #
451
450
  class LazyStruct < OpenStruct
451
+ #
452
+ # For mixing into an existing OpenStruct instance singleton class.
453
+ #
454
+ module Mixin
452
455
  #
453
- # For mixing into an existing OpenStruct instance singleton class.
456
+ # &block is evaluated when this attribute is requested. The
457
+ # same result is returned for subsquent calls, until the field
458
+ # is assigned a different value.
454
459
  #
455
- module Mixin
460
+ def attribute(reader, &block)
461
+ singleton = (class << self ; self ; end)
462
+ singleton.instance_eval {
456
463
  #
457
- # &block is evaluated when this attribute is requested. The
458
- # same result is returned for subsquent calls, until the field
459
- # is assigned a different value.
464
+ # Define a special reader method in the singleton class.
460
465
  #
461
- def attribute(reader, &block)
462
- singleton = (
463
- class << self;
464
- self;
465
- end)
466
+ define_method(reader) {
467
+ block.call.tap { |value|
468
+ #
469
+ # The value has been computed. Replace this method with a
470
+ # one-liner giving the value.
471
+ #
466
472
  singleton.instance_eval {
467
- #
468
- # Define a special reader method in the singleton class.
469
- #
470
- define_method(reader) {
471
- block.call.tap { |value|
472
- #
473
- # The value has been computed. Replace this method with a
474
- # one-liner giving the value.
475
- #
476
- singleton.instance_eval {
477
- remove_method(reader)
478
- define_method(reader) { value }
479
- }
480
- }
481
- }
482
-
483
- #
484
- # Revert to the old OpenStruct behavior when the writer is called.
485
- #
486
- writer = "#{reader}=".to_sym
487
- define_method(writer) { |value|
488
- singleton.instance_eval {
489
- remove_method(reader)
490
- remove_method(writer)
491
- }
492
- method_missing(writer, value)
493
- }
473
+ remove_method(reader)
474
+ define_method(reader) { value }
494
475
  }
495
- end
476
+ }
477
+ }
478
+
479
+ #
480
+ # Revert to the old OpenStruct behavior when the writer is called.
481
+ #
482
+ writer = "#{reader}=".to_sym
483
+ define_method(writer) { |value|
484
+ singleton.instance_eval {
485
+ remove_method(reader)
486
+ remove_method(writer)
487
+ }
488
+ method_missing(writer, value)
489
+ }
490
+ }
496
491
  end
497
-
498
- include Mixin
492
+ end
493
+
494
+ include Mixin
499
495
  end
500
496
 
501
497
  # version < 1.8.7 compatibility
502
498
  module Kernel
503
- unless respond_to? :tap
504
- def tap
505
- yield self
506
- self
507
- end
499
+ unless respond_to? :tap
500
+ def tap
501
+ yield self
502
+ self
508
503
  end
504
+ end
509
505
  end
510
506
 
511
507
  Installer.new.run
data/p4ruby.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
 
2
2
  Gem::Specification.new { |t|
3
3
  t.name = "p4ruby"
4
- t.version = "2012.2.beta"
4
+ t.version = "2012.2"
5
5
  t.summary = "Ruby interface to the Perforce API"
6
6
  t.description = t.summary + "."
7
7
  t.author = "Perforce Software (ruby gem by James M. Lawrence)"
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: p4ruby
3
3
  version: !ruby/object:Gem::Version
4
- hash: -711907940
5
- prerelease: 7
4
+ hash: 8063
5
+ prerelease:
6
6
  segments:
7
7
  - 2012
8
8
  - 2
9
- - beta
10
- version: 2012.2.beta
9
+ version: "2012.2"
11
10
  platform: ruby
12
11
  authors:
13
12
  - Perforce Software (ruby gem by James M. Lawrence)
@@ -91,14 +90,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
91
90
  required_rubygems_version: !ruby/object:Gem::Requirement
92
91
  none: false
93
92
  requirements:
94
- - - ">"
93
+ - - ">="
95
94
  - !ruby/object:Gem::Version
96
- hash: 25
95
+ hash: 3
97
96
  segments:
98
- - 1
99
- - 3
100
- - 1
101
- version: 1.3.1
97
+ - 0
98
+ version: "0"
102
99
  requirements: []
103
100
 
104
101
  rubyforge_project: p4ruby