Giter Club home page Giter Club logo

gemnasium-parser's Introduction

Gemnasium::Parser

Gem Version Build Status Dependency Status

The Gemnasium parser determines gem dependencies from gemfiles and gemspecs, without evaluating the Ruby.

Why?

Bundler is wonderful. It takes your gemfile and your gemspec (both just Ruby) and evaluates them, determining your gem dependencies. This works great locally and even on your production server… but only because you can be trusted!

An untrustworthy character could put some pretty nasty stuff in a gemfile. If Gemnasium were to blindly evaluate that Ruby on its servers, havoc would ensue.

Solution #1

If evaluating Ruby is so dangerous, just sandbox it! Travis CI runs its builds inside isolated environments built with Vagrant. That way, if anything goes awry, it’s in a controlled environment.

This is entirely possible with Gemnasium, but it’s impractical. Gemfiles often require other files in the repository. So to evaluate a gemfile, Gemnasium needs to clone the entire repo. That’s an expensive operation when only a couple files determine the dependencies.

Solution #2

Parse Ruby like Ruby parses Ruby.

Ruby 1.9 includes a library called Ripper. Ripper is a Ruby parsing library that can break down a gemfile or gemspec into bite-sized chunks, without evaluating the source. Then it can be searched for just the methods that matter.

The problem is that it’s hard to make heads or tails from Ripper’s output, at least for me. I could see the Gemnasium parser one day moving to this strategy. But not today.

Third try’s the charm

If we can’t evaluate the Ruby and Ripper’s output is unmanageable, how else can we find patterns in a gemfile or gemspec and get usable output?

Regular expressions!

The Gemnasium parser, for both gemfiles and gemspecs, is based on a number of Ruby regular expressions. These patterns match gem method calls in gemfiles and add_dependency calls in gemspecs.

For a more comprehensive list of its abilities, see the specs.

Contributing

  1. Fork it
  2. Create your branch (git checkout -b my-bugfix)
  3. Commit your changes (git commit -am "Fix my bug")
  4. Push your branch (git push origin my-bugfix)
  5. Send a pull request

Problems?

If you have a gemfile or gemspec that the Gemnasium parser screws up…

  1. Boil it down to its simplest problematic form
  2. Write a failing spec
  3. See Contributing

gemnasium-parser's People

Contributors

gonzoyumo avatar laserlemon avatar remomueller avatar sferik avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gemnasium-parser's Issues

Included spec fail?

Ruby newbie here but I was playing with this gem and couldn't get it to work via running these commands from the cemnasium-parser top-level directory:

$ sudo bundle install
Using rake (0.9.2.2)
Using diff-lcs (1.1.3)
Using gemnasium-parser (0.1.6) from source at .
Using rspec-core (2.11.1)
Using rspec-expectations (2.11.2)
Using rspec-mocks (2.11.1)
Using rspec (2.11.0)
Using bundler (1.1.5)
Your bundle is complete! Use bundle show [gemname] to see where a bundled gem is installed.

$ sudo bundle exec rake build
gemnasium-parser 0.1.6 built to pkg/gemnasium-parser-0.1.6.gem

$ sudo bundle exec rake install
gemnasium-parser 0.1.6 built to pkg/gemnasium-parser-0.1.6.gem
gemnasium-parser (0.1.6) installed

$ sudo bundle exec rake spec
** Invoke spec (first_time)
** Execute spec
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -S rspec ./spec/gemnasium/parser/gemfile_spec.rb ./spec/gemnasium/parser/gemspec_spec.rb ./spec/gemnasium/parser_spec.rb
/Users/rgehring/installed/gemnasium-parser/lib/gemnasium/parser/gemfile.rb:2:in `require': /Users/rgehring/installed/gemnasium-parser/lib/gemnasium/parser/patterns.rb:30: undefined (?...) sequence: /^(?[ \t])git[ (][^\n]?do[ \t]?\n(?.?)\n^\kend[ \t]$/ (SyntaxError)
/Users/rgehring/installed/gemnasium-parser/lib/gemnasium/parser/patterns.rb:32: undefined (?...) sequence: /^(?[ \t]
)path[ (][^\n]?do[ \t]?\n(?.?)\n^\kend[ \t]$/

Is this an issue with the gem or my newbiness? Help appreciated!

Unexpected results for pry/pry

Pry should have 6 dependencies, from its gemspec:

  • coderay ~> 1.0.5
  • slop < 3, >= 2.4.1
  • method_source ~> 0.7
  • bacon ~> 1.1
  • open4 ~> 1.3
  • rake ~> 0.9

Dependency on Bundler not stated

gemnasium-parser depends on Bundler::Dependency, but the dependency is not stated in .gemfile. Could we delete the dependency on Bundler altogether and use Gem::Dependency instead? Given the fact that Gem::Dependency comes with RubyGems and that the Bundler features are slowly moving to RubyGems it would make sense to me. Otherwise/in the meantime let's fix this by stating the dependency on Bundler.

Unexpected results for gitkeeper/valet

Hi guys,

I've just deployed a skeleton application, which I wired with Gemnasium for the first time. Now I wonder, why the overall status doesn't turn to green, because all individual gem dependencies are up-to-date and show as green.

Also the status picture shows "Dependency Status: Unknown".

Can you help me get that issue straight?

Thank you for your awesome service,

Alex

Unexpected results for AlexParamonov/ap-project

Hi!
I've even added Gemfile.lock to github, but gemnasium.dont see this dep:

DEPENDENCIES
cells
coffee-rails (> 3.2.1)
factory_girl
guard
guard-bundler
guard-rspec
guard-shell
haml-rails
jquery-rails
kameleon (
> 0.2.0.alpha)
libnotify
rails (> 3.2.2.rc1)
rb-inotify
routing-filter
rspec-cells
rspec-rails (
> 2.6)
sass-rails (~> 3.2.3)
therubyracer
uglifier (>= 1.0.3)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.