Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: opal/opal
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 7ed0538191d4
Choose a base ref
...
head repository: opal/opal
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: b1dfcd23c1a4
Choose a head ref
  • 3 commits
  • 2 files changed
  • 2 contributors

Commits on May 14, 2015

  1. Allow PathReader to deal with absolute and ./ and ../ relative paths

    This allows you do do things like:
    
      Opal::Builder.build('/path/to/file.rb')
      Opal::Builder.build('./path/to/file.rb')
      Opal::Builder.build('../path/to/file.rb')
    
    Previously, you couldn't build a file without adding a directory
    containing the file to the paths to examine.  This makes Opal::Builder
    operate more like ruby itself.
    
    Note that this does not let you use absolute and ./ and ../ relative
    paths in require, that requires additional changes, probably to
    Builder#process_require.
    jeremyevans committed May 14, 2015
    Copy the full SHA
    d7ae195 View commit details

Commits on May 15, 2015

  1. Fix regexp

    jeremyevans committed May 15, 2015
    Copy the full SHA
    7069629 View commit details
  2. Merge pull request #855 from jeremyevans/path_reader_abs_rel

    Allow PathReader to deal with absolute and ./ and ../ relative paths
    elia committed May 15, 2015

    Unverified

    This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
    Copy the full SHA
    b1dfcd2 View commit details
Showing with 17 additions and 1 deletion.
  1. +5 −1 lib/opal/path_reader.rb
  2. +12 −0 spec/lib/path_reader_spec.rb
6 changes: 5 additions & 1 deletion lib/opal/path_reader.rb
Original file line number Diff line number Diff line change
@@ -13,7 +13,11 @@ def read(path)
end

def expand(path)
file_finder.find(path)
if Pathname.new(path).absolute? || path =~ %r{\A\.?\.#{File::SEPARATOR}}
path
else
file_finder.find(path)
end
end

def paths
12 changes: 12 additions & 0 deletions spec/lib/path_reader_spec.rb
Original file line number Diff line number Diff line change
@@ -20,5 +20,17 @@
include_examples :path_finder
include_examples :path_reader do
let(:path_reader) { file_reader }

it 'works with absolute paths' do
expect(path_reader.read(File.expand_path(__FILE__))).not_to be_nil
end

it 'works with relative paths starting with ./' do
expect(path_reader.read('./spec/lib/shared/path_reader_shared.rb')).not_to be_nil
end

it 'works with absolute paths' do
expect(path_reader.read("../#{File.basename(Dir.pwd)}/spec/lib/shared/path_reader_shared.rb")).not_to be_nil
end
end
end