rbx-require-relative 0.0.4-universal-rubinius-1.2 → 0.0.5-universal-rubinius-1.2

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog CHANGED
@@ -1,3 +1,41 @@
1
+ 2011-06-11 rocky <rockyb@rubyforge.org>
2
+
3
+ * .gemspec, Rakefile: Package name needs the kind of Ruby in it.
4
+ Sigh
5
+
6
+ 2011-06-11 rocky <rockyb@rubyforge.org>
7
+
8
+ * .gemspec, ChangeLog, NEWS, lib/require_relative.rb: Tolerance for
9
+ unpatched 1.9.2
10
+
11
+ 2011-05-26 rocky <rockyb@rubyforge.org>
12
+
13
+ * .gemspec, Rakefile, lib/version.rb: Package versioning for MRI
14
+ 1.8.7 was wrong.
15
+
16
+ 2011-05-26 rocky <rockyb@rubyforge.org>
17
+
18
+ * .gemspec, README.textile, Rakefile, lib/require_relative.rb,
19
+ lib/version.rb, test/test-rr.rb: Handle MRI 1.8
20
+
21
+ 2011-04-22 rocky <rockyb@rubyforge.org>
22
+
23
+ * NEWS, lib/version.rb: Update for release.
24
+
25
+ 2011-04-22 rocky <rockyb@rubyforge.org>
26
+
27
+ * lib/require_relative.rb: Don't use
28
+ Rubinius::StaticScope#data_path, but mirror the logic for that until
29
+ an API is created that works like RequireRelative#abs_file. Also use
30
+ Rubinius::StaticScope.of_sender rather than backtrace. Thanks to
31
+ Evan Phoenix for advice on all of this.
32
+
33
+ 2011-02-14 rocky <rockyb@rubyforge.org>
34
+
35
+ * .gemspec, ChangeLog, NEWS, Rakefile, lib/require_relative.rb,
36
+ lib/version.rb: Allow this to be build on 1.9.2-nframe as mostly a
37
+ no-op.
38
+
1
39
  2010-09-23 rocky <rockyb@rubyforge.org>
2
40
 
3
41
  * .gemspec: Need symbol in defined?
data/NEWS CHANGED
@@ -1,3 +1,13 @@
1
+ 0.0.5 (06-12-11) Fleetwood release
2
+
3
+ Allow this to work on Ruby MRI 1.8 and 1.9. On 1.9 we don't do
4
+ anything for require_relative, but in 1.9.2+thread_frame we add a
5
+ relible abs_path. This package is provided on 1.9 is there for
6
+ compatibility and for abs_path for a threadframe-enabled 1.9.2.
7
+
8
+ On MRI abs_path may be unreliable in the face of Dir.chdir.
9
+
10
+
1
11
  0.0.4 (04-22-11)
2
12
 
3
13
  - Using an undocumented API has changed in Rubinius 1.2.4dev. Down
data/README.textile CHANGED
@@ -1,4 +1,4 @@
1
- h2. Ruby 1.9's relative_relative for Rubinus 1.0.1 .. 1.1
1
+ h2. Ruby 1.9's relative_relative for Rubinus and MRI 1.8
2
2
 
3
3
  Here we add in Module RequireRelative method: *require_relative*, and *abs_file*. Example:
4
4
 
data/Rakefile CHANGED
@@ -1,11 +1,14 @@
1
1
  #!/usr/bin/env rake
2
2
  # -*- Ruby -*-
3
- # Are we rubinius? We'll test by checking the specific function we need.
3
+ # Are we rubinius or MRI 1.8?
4
4
  raise RuntimeError, 'This package is for rubinius or 1.9.2-nframe only!' unless
5
5
  (Object.constants.include?('Rubinius') &&
6
6
  Rubinius.constants.include?('VM') &&
7
7
  Rubinius::VM.respond_to?(:backtrace)) ||
8
- (defined? RUBY_DESCRIPTION && RUBY_DESCRIPTION.start_with?('ruby 1.9.2frame'))
8
+ (defined? RUBY_DESCRIPTION &&
9
+ RUBY_DESCRIPTION.start_with?('ruby 1.9.2frame')) ||
10
+ (RUBY_VERSION.start_with?('1.8') &&
11
+ RUBY_COPYRIGHT.end_with?('Yukihiro Matsumoto'))
9
12
 
10
13
  # begin
11
14
  # require_relative 'lib/version'
@@ -15,8 +18,8 @@ raise RuntimeError, 'This package is for rubinius or 1.9.2-nframe only!' unless
15
18
  # end
16
19
 
17
20
  require 'rubygems'
18
- require 'rake/gempackagetask'
19
- require 'rake/rdoctask'
21
+ require 'rubygems/package_task'
22
+ require 'rdoc/task'
20
23
  require 'rake/testtask'
21
24
  require 'fileutils'
22
25
 
@@ -86,9 +89,6 @@ task :ChangeLog do
86
89
  system('git log --pretty --numstat --summary | git2cl > ChangeLog')
87
90
  end
88
91
 
89
- desc "Remove built files"
90
- task :clean => [:clobber_package, :clobber_rdoc]
91
-
92
92
  desc "Generate the gemspec"
93
93
  task :generate do
94
94
  puts gemspec.to_ruby
@@ -99,6 +99,20 @@ task :gemspec do
99
99
  gemspec.validate
100
100
  end
101
101
 
102
+ desc 'Remove residue from running patch'
103
+ task :rm_patch_residue do
104
+ FileUtils.rm_rf FileList['**/*.{rej,orig}'].to_a, :verbose => true
105
+ end
106
+
107
+ desc 'Remove ~ backup files'
108
+ task :rm_tilde_backups do
109
+ FileUtils.rm_rf Dir.glob('**/*~'), :verbose => true
110
+ FileUtils.rm_rf Dir.glob('**/*.rbc'), :verbose => true
111
+ end
112
+
113
+ desc "Remove built files"
114
+ task :clean => [:clobber_package, :clobber_rdoc, :rm_patch_residue, :rm_tilde_backups]
115
+
102
116
  task :clobber_package do
103
117
  FileUtils.rm_rf File.join(ROOT_DIR, 'pkg')
104
118
  end
@@ -1,6 +1,6 @@
1
1
  # Ruby 1.9's require_relative.
2
2
 
3
- if defined?(RubyVM)
3
+ if defined?(RubyVM) && RUBY_DESCRIPTION.start_with?('ruby 1.9.2frame')
4
4
  require 'thread_frame'
5
5
  end
6
6
 
@@ -16,14 +16,20 @@ module RequireRelative
16
16
  else
17
17
  nil
18
18
  end
19
+ else
20
+ file = caller.first.split(/:\d/,2).first
21
+ if /\A\((.*)\)/ =~ file # eval, etc.
22
+ nil
23
+ end
24
+ File.expand_path(file)
19
25
  end
20
26
  end
21
27
  module_function :abs_file
22
28
  end
23
29
 
24
- # On platforms other than Rubinius for 1.8.7
25
- # don't do anything.
26
- if defined?(Rubinius) && "1.8.7" == RUBY_VERSION
30
+ if RUBY_VERSION.start_with?('1.9')
31
+ # On 1.9.2 platforms we don't do anything.
32
+ elsif defined?(Rubinius) && '1.8.7' == RUBY_VERSION
27
33
  module Kernel
28
34
  def require_relative(suffix)
29
35
  # Rubinius::Location#file stores relative file names while
@@ -41,6 +47,15 @@ if defined?(Rubinius) && "1.8.7" == RUBY_VERSION
41
47
  end
42
48
  end
43
49
  end
50
+ elsif (RUBY_VERSION.start_with?('1.8') &&
51
+ RUBY_COPYRIGHT.end_with?('Yukihiro Matsumoto'))
52
+ def require_relative(suffix)
53
+ file = caller.first.split(/:\d/,2).first
54
+ if /\A\((.*)\)/ =~ file # eval, etc.
55
+ raise LoadError, "require_relative is called in #{$1}"
56
+ end
57
+ require File.join(File.dirname(file), suffix)
58
+ end
44
59
  end
45
60
 
46
61
  # demo
@@ -48,7 +63,15 @@ if __FILE__ == $0
48
63
  file = RequireRelative.abs_file
49
64
  puts file
50
65
  require 'tmpdir'
51
- Dir.chdir(Dir.tmpdir) do
66
+ dir =
67
+ if RUBY_VERSION.start_with?('1.8') &&
68
+ RUBY_COPYRIGHT.end_with?('Yukihiro Matsumoto')
69
+ puts "Note: require_relative doesn't work with Dir.chdir as it does on Rubinius or 1.9"
70
+ '.'
71
+ else
72
+ Dir.tmpdir
73
+ end
74
+ Dir.chdir(dir) do
52
75
  rel_file = File.basename(file)
53
76
  cur_dir = File.basename(File.dirname(file))
54
77
  ['./', "../#{cur_dir}/"].each do |prefix|
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module RequireRelative
2
- VERSION = '0.0.4'
2
+ VERSION = '0.0.5'
3
3
  end
data/test/test-rr.rb CHANGED
@@ -9,9 +9,18 @@ require file
9
9
  class TestRR < Test::Unit::TestCase
10
10
  require 'tmpdir'
11
11
  def test_basic
12
- # The chdir is to make things harder.
12
+ dir =
13
+ if RUBY_VERSION.start_with?('1.8') &&
14
+ RUBY_COPYRIGHT.end_with?('Yukihiro Matsumoto')
15
+ puts "Note: require_relative doesn't work with Dir.chdir as it does on Rubinius or 1.9"
16
+ '.'
17
+ else
18
+ Dir.tmpdir
19
+ end
13
20
  abs_file = RequireRelative.abs_file
14
- Dir.chdir(Dir.tmpdir) do
21
+ # The chdir is to make things harder for those platforms that
22
+ # truly support require_relative.
23
+ Dir.chdir(dir) do
15
24
  cur_dir = File.basename(File.expand_path(File.dirname(abs_file)))
16
25
  ['./foo', "../#{cur_dir}/bar"].each_with_index do |suffix, i|
17
26
  assert_equal(true, require_relative(suffix),
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbx-require-relative
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 4
10
- version: 0.0.4
9
+ - 5
10
+ version: 0.0.5
11
11
  platform: universal-rubinius-1.2
12
12
  authors:
13
13
  - R. Bernstein
@@ -15,25 +15,12 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-04-22 00:00:00 -04:00
18
+ date: 2011-06-11 00:00:00 -04:00
19
19
  default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
22
- name: diff-lcs
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- hash: 3
30
- segments:
31
- - 0
32
- version: "0"
33
- type: :runtime
34
- version_requirements: *id001
20
+ dependencies: []
21
+
35
22
  description: |
36
- Ruby 1.9's require_relative for Rubinius.
23
+ Ruby 1.9's require_relative for Rubinius and MRI 1.8.
37
24
 
38
25
  We also add abs_path which is like __FILE__ but __FILE__ can be fooled
39
26
  by a sneaky "chdir" while abs_path can't.
@@ -67,10 +54,8 @@ licenses:
67
54
  - MIT
68
55
  post_install_message:
69
56
  rdoc_options:
70
- - --main
71
- - README
72
57
  - --title
73
- - require_relative 0.0.4 Documentation
58
+ - require_relative 0.0.5 Documentation
74
59
  require_paths:
75
60
  - lib
76
61
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -99,6 +84,6 @@ rubyforge_project:
99
84
  rubygems_version: 1.5.2
100
85
  signing_key:
101
86
  specification_version: 3
102
- summary: Ruby 1.9's require_relative for Rubinius. We also add abs_path which is like __FILE__ but __FILE__ can be fooled by a sneaky "chdir" while abs_path can't. If you are running on Ruby 1.9.2, require_relative is the pre-defined version. The benefit we provide in this situation by this package is the ability to write the same require_relative sequence in Rubinius 1.8 and Ruby 1.9.
87
+ summary: Ruby 1.9's require_relative for Rubinius and MRI 1.8. We also add abs_path which is like __FILE__ but __FILE__ can be fooled by a sneaky "chdir" while abs_path can't. If you are running on Ruby 1.9.2, require_relative is the pre-defined version. The benefit we provide in this situation by this package is the ability to write the same require_relative sequence in Rubinius 1.8 and Ruby 1.9.
103
88
  test_files: []
104
89