clutil 2010.330.0 → 2010.331.1

Sign up to get free protection for your applications and to get access to all the features.
data/cl/util/file.rb CHANGED
@@ -134,10 +134,8 @@ class << File
134
134
  end
135
135
  end
136
136
 
137
- module ClUtilFile
138
- ALL_FILES = '*'
139
-
140
- def ClUtilFile.delTree(rootDirName, pattern=ALL_FILES)
137
+ class ClUtilFile
138
+ def ClUtilFile.delTree(rootDirName, pattern='*')
141
139
  if (rootDirName == '/') or (rootDirName.empty?)
142
140
  raise 'Cannot delete root or empty?'
143
141
  end
@@ -174,7 +172,7 @@ module ClUtilFile
174
172
  =begin
175
173
  1.8 FileUtils has cp_r in it ...
176
174
 
177
- def ClUtilFile.copyTree(fromDir, toDir, pattern=ALL_FILES)
175
+ def ClUtilFile.copyTree(fromDir, toDir, pattern='*')
178
176
  ##################################################################
179
177
  # cp_r - recursive copy
180
178
  # usage: cp_r(from,to,file_param,permissions)
data/cl/util/install.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # $Id: install.rb,v 1.7 2002/09/09 03:04:38 chrismo Exp $
2
2
  =begin
3
3
  --------------------------------------------------------------------------
4
- Copyright (c) 2002, Chris Morris
4
+ Copyright (c) 2002-2010, Chris Morris
5
5
  All rights reserved.
6
6
 
7
7
  Redistribution and use in source and binary forms, with or without modification,
@@ -36,72 +36,82 @@ require 'find'
36
36
  require 'fileutils'
37
37
  require "#{File.dirname(__FILE__)}/console"
38
38
 
39
- include Config
39
+ module CLabs
40
+ class Install
41
+ include Config
40
42
 
41
- # altered copy of rbconfig.rb -> Config::expand
42
- def custom_expand(val, conf)
43
- val.gsub!(/\$\(([^()]+)\)/) do |var|
44
- key = $1
45
- if CONFIG.key? key
46
- custom_expand(conf[key], conf)
47
- else
48
- var
43
+ attr_reader :version, :libdir, :bindir, :sitedir, :siteverdir, :archdir
44
+
45
+ def initialize
46
+ init
49
47
  end
50
- end
51
- val
52
- end
53
48
 
54
- def get_conf(customizations)
55
- conf = {}
56
- MAKEFILE_CONFIG.each{|k,v| conf[k] = v.dup}
57
- customizations.each do |k, v|
58
- conf[k] = v
59
- end
60
- conf.each_value do |val| custom_expand(val, conf) end
61
- conf
62
- end
49
+ # altered copy of rbconfig.rb -> Config::expand
50
+ def custom_expand(val, conf)
51
+ val.gsub!(/\$\(([^()]+)\)/) do |var|
52
+ key = $1
53
+ if CONFIG.key? key
54
+ custom_expand(conf[key], conf)
55
+ else
56
+ var
57
+ end
58
+ end
59
+ val
60
+ end
63
61
 
64
- def init
65
- prefixdir = get_switch('-p')
66
- customizations = {}
67
- customizations['prefix'] = prefixdir if prefixdir
68
- conf = get_conf(customizations)
69
-
70
- $version = conf["MAJOR"]+"."+conf["MINOR"]
71
- $libdir = File.join(conf["libdir"], "ruby", $version)
72
-
73
- $bindir = conf["bindir"]
74
- $sitedir = conf["sitedir"] || File.join($libdir, "site_ruby")
75
- $siteverdir = File.join($sitedir, $version)
76
- $archdir = File.join($libdir, "i586-mswin32")
77
- end
62
+ def get_conf(customizations)
63
+ conf = {}
64
+ MAKEFILE_CONFIG.each { |k, v| conf[k] = v.dup }
65
+ customizations.each do |k, v|
66
+ conf[k] = v
67
+ end
68
+ conf.each_value do |val|
69
+ custom_expand(val, conf)
70
+ end
71
+ conf
72
+ end
73
+
74
+ def init
75
+ prefixdir = get_switch('-p')
76
+ customizations = {}
77
+ customizations['prefix'] = prefixdir if prefixdir
78
+ conf = get_conf(customizations)
79
+
80
+ @version = conf["MAJOR"]+"."+conf["MINOR"]
81
+ @libdir = File.join(conf["libdir"], "ruby", @version)
82
+
83
+ @bindir = conf["bindir"]
84
+ @sitedir = conf["sitedir"] || File.join(@libdir, "site_ruby")
85
+ @siteverdir = File.join(@sitedir, @version)
86
+ @archdir = File.join(@libdir, "i586-mswin32")
87
+ end
78
88
 
79
- def install_executables(files)
80
- tmpfn = "cl_tmp"
81
- files.each do |aFile, dest|
82
- File.open(aFile) do |ip|
83
- File.open(tmpfn, "w") do |op|
84
- ruby = File.join($bindir, "ruby")
85
- op.puts "#!#{ruby}"
86
- op.write ip.read
89
+ def install_executables(files)
90
+ tmpfn = "cl_tmp"
91
+ files.each do |aFile, dest|
92
+ File.open(aFile) do |ip|
93
+ File.open(tmpfn, "w") do |op|
94
+ ruby = File.join($bindir, "ruby")
95
+ op.puts "#!#{ruby}"
96
+ op.write ip.read
97
+ end
98
+ end
99
+
100
+ File::makedirs(dest)
101
+ # 0755 I assume means read/write/execute, not needed for Windows
102
+ File::chmod(0755, dest, true)
103
+ File::install(tmpfn, File.join(dest, File.basename(aFile)), 0755, true)
104
+ File::unlink(tmpfn)
87
105
  end
88
106
  end
89
107
 
90
- File::makedirs(dest)
91
- # 0755 I assume means read/write/execute, not needed for Windows
92
- File::chmod(0755, dest, true)
93
- File::install(tmpfn, File.join(dest, File.basename(aFile)), 0755, true)
94
- File::unlink(tmpfn)
108
+ def install_lib(files)
109
+ files.each do |aFile, dest|
110
+ File::makedirs(dest)
111
+ File::install(aFile, File.join(dest, File.basename(aFile)), 0644, true)
112
+ end
113
+ end
95
114
  end
96
115
  end
97
116
 
98
- def install_lib(files)
99
- files.each do |aFile, dest|
100
- File::makedirs(dest)
101
- File::install(aFile, File.join(dest, File.basename(aFile)), 0644, true)
102
- end
103
- end
104
117
 
105
- if __FILE__ == $0
106
- init
107
- end
@@ -1,11 +1,10 @@
1
- $LOAD_PATH << '..'
2
-
3
- require 'install'
1
+ require File.expand_path(File.dirname(__FILE__) + '/../install')
4
2
  require 'test/unit'
5
3
 
6
4
  class TestInstall < Test::Unit::TestCase
7
5
  def test_set_prefix
8
- conf = get_conf({'prefix' => '/tmp/ruby'})
6
+ install = CLabs::Install.new
7
+ conf = install.get_conf({'prefix' => '/tmp/ruby'})
9
8
  assert_equal('/tmp/ruby', conf['prefix'])
10
9
  assert_equal('/tmp/ruby/lib/ruby/site_ruby', conf['sitedir'])
11
10
  end
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 2010
7
- - 330
8
- - 0
9
- version: 2010.330.0
7
+ - 331
8
+ - 1
9
+ version: 2010.331.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - chrismo
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-11-26 00:00:00 -06:00
17
+ date: 2010-11-27 00:00:00 -06:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -61,7 +61,6 @@ files:
61
61
  - cl/util/test/installtest.rb
62
62
  - cl/util/test/progresstest.rb
63
63
  - cl/util/test/stringtest.rb
64
- - cl/util/test/versiontest.rb
65
64
  - cl/util/test/wintest.rb
66
65
  has_rdoc: true
67
66
  homepage: http://clabs.org/ruby.htm
@@ -1,72 +0,0 @@
1
- $LOAD_PATH << '..'
2
-
3
- require 'test/unit'
4
- require 'version'
5
- require 'test'
6
- require 'cl/util/test'
7
-
8
- class TestVersion < TempDirTest
9
- def setup
10
- super
11
- @lineBefore = 'test line before'
12
- @lineAfter = 'test line after'
13
- end
14
-
15
- def make_sample_file(v, indent)
16
- fn = File.join(@tempDir, 'test.rb')
17
- File.open(fn, 'w+') do |f|
18
- f.puts ' ' * indent << @lineBefore
19
- f.puts ' ' * indent << CLabs::Version.header_start
20
- f.puts ' ' * indent << CLabs::Version.header_end
21
- f.puts ' ' * indent << @lineAfter
22
- end
23
- v.write_version_header(fn)
24
- fn
25
- end
26
-
27
- def do_test(indent=0)
28
- v = CLabs::Version.new(1,2,'3')
29
- fn = make_sample_file(v, indent)
30
- readlines = nil
31
- File.open(fn, 'r') do |f| readlines = f.readlines end
32
- readlines.collect! { |ln| ln.rstrip.chomp }
33
- #puts
34
- #puts readlines
35
- assert_equal(' ' * indent << @lineBefore, readlines[0])
36
- assert_equal(' ' * indent << CLabs::Version.header_start, readlines[1])
37
- assert_equal(' ' * indent << 'begin', readlines[2])
38
- assert_equal(' ' * indent << ' ' << "require 'cl/util/version'", readlines[3])
39
- assert_equal(' ' * indent << ' ' << "VERSION = CLabs::Version.new('1', '2', '3')", readlines[4])
40
- assert_equal(' ' * indent << 'rescue LoadError', readlines[5])
41
- assert_equal(' ' * indent << ' ' << "VERSION = '1.2.3'", readlines[6])
42
- assert_equal(' ' * indent << 'end', readlines[7])
43
- assert_equal(' ' * indent << CLabs::Version.header_end, readlines[8])
44
- assert_equal(' ' * indent << @lineAfter, readlines[9])
45
- end
46
-
47
- def test_write_version_header_no_indent
48
- do_test(0)
49
- end
50
-
51
- def test_write_version_header_indent
52
- do_test(2)
53
- end
54
-
55
- def test_to_s
56
- v = CLabs::Version.new(1,2,3)
57
- assert_equal('1.2.3', v.to_s)
58
-
59
- v = CLabs::Version.new(1,2,'3')
60
- assert_equal('1.2.3', v.to_s)
61
- end
62
-
63
- def test_comparison
64
- assert_equal(0, CLabs::Version.new(0,0,0) <=> CLabs::Version.new(0,0,0))
65
- assert_equal(1, CLabs::Version.new(1,0,0) <=> CLabs::Version.new(0,0,0))
66
- assert_equal(1, CLabs::Version.new(0,1,0) <=> CLabs::Version.new(0,0,0))
67
- assert_equal(1, CLabs::Version.new(0,0,1) <=> CLabs::Version.new(0,0,0))
68
- assert_equal(-1, CLabs::Version.new(0,0,0) <=> CLabs::Version.new(1,0,0))
69
- assert_equal(-1, CLabs::Version.new(0,0,0) <=> CLabs::Version.new(0,1,0))
70
- assert_equal(-1, CLabs::Version.new(0,0,0) <=> CLabs::Version.new(0,0,1))
71
- end
72
- end