Skip to content

Support running ./bin/html2haml fully #41

Open
@aprescott

Description

@aprescott

To avoid going through a gem build and gem install ./html2haml-x-y.gem process, it's useful to run ./bin/html2haml and have it automatically use lib/.

First, remove any html2haml gems with gem uninstall. Then try to use ./bin/html2haml.

$ ./bin/html2haml --version

$ touch /tmp/blah.html
$ ./bin/html2haml /tmp/blah.html
/Users/adamprescott/.rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:114:in `require': cannot load such file -- html2haml/html (LoadError)
    from /Users/adamprescott/.rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:114:in `require'
    from /private/tmp/html2haml/lib/html2haml.rb:7:in `<top (required)>'
    from /Users/adamprescott/.rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:53:in `require'
    from /Users/adamprescott/.rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:53:in `require'
    from ./bin/html2haml:3:in `<main>'

If you gem install html2haml (say, version 1.0.1), ./bin/html2haml --version will incorrectly report whatever is for lib/'s version, but will instead try to generate with the version you gem install'd. To see this, note that 1.0.1 has no --ruby19-attributes flag, then:

$ cd /tmp/html2haml # git repo
$ ./bin/html2haml --version
/Users/adamprescott/.rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:114:in `require': cannot load such file -- html2haml/html (LoadError)
[...]

$ cd
$ gem install html2haml -v '1.0.1'
$ cd /tmp/html2haml # git repo
$ html2haml --version
html2haml 2.0.0.beta.2
$ ./bin/html2haml --trace --ruby19-attributes
/Users/adamprescott/.gem/ruby/2.0.0/gems/html2haml-1.0.1/lib/html2haml/exec.rb:40:in `parse': invalid option: --ruby19-attributes (OptionParser::InvalidOption)
    from /Users/adamprescott/.gem/ruby/2.0.0/gems/html2haml-1.0.1/lib/html2haml/exec.rb:22:in `parse!'
    from ./bin/html2haml:7:in `<main>'

The version is reported as 2.0.0.beta.2 from the repo's value, but it's still using ~/.gem/ruby/2.0.0/gems/html2haml-1.0.1 code.

I think the fix here is to $LOAD_PATH.unshift(...) in bin/html2haml so that it always makes lib/ available to prioritise require "..." calls.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions