[![Build Status](https://travis-ci.org/repotag/cutting_edge.svg?branch=master)](https://travis-ci.org/repotag/cutting_edge) [![Coverage Status](https://coveralls.io/repos/github/repotag/cutting_edge/badge.svg?branch=master)](https://coveralls.io/github/repotag/cutting_edge?branch=master) # CuttingEdge ## Sinatra App * start the app with `bundle exec ruby lib/app.rb` * Runs on http://localhost:4567 * Routes under `/source/org/name` * For example: http://localhost:4567/github/gollum/gollum/info ## DependencyWorker The DependencyWorker currently performs the following actions: * Fetch gemfile and gemspec for a given Gem * Currently, the `GithubGem` class specifies the needed information for a gem hosted on github, ditto for the `GitlabGem` class for gitlab. * These are subclasses of `RepositoryGem`. * Parse both files for dependency requirements * Does not bork if either of the files could not be retrieved. * Determine the latest version for each required gem * By querying rubygems for a version of the gem `>= 0`. * Generate a Hash of results of the following form: ```ruby {:gemspec=> {:outdated_major=> [{:name=>"kramdown", :required=>"~> 1.9.0", :latest=>"2.1.0", :type=>:runtime}, {:name=>"sinatra", :required=>"~> 1.4, >= 1.4.4", :latest=>"2.0.8.1", :type=>:runtime}, {:name=>"mustache", :required=>">= 0.99.5, < 1.0.0", :latest=>"1.1.1", :type=>:runtime}, {:name=>"gemojione", :required=>"~> 3.2", :latest=>"4.3.2", :type=>:runtime}], :outdated_minor=>[], :outdated_bump=>[], :ok=> [{:name=>"gollum-lib", :required=>"~> 4.2, >= 4.2.10", :latest=>"4.2.10", :type=>:runtime}, {:name=>"useragent", :required=>"~> 0.16.2", :latest=>"0.16.10", :type=>:runtime}], :unknown=>[]}, :gemfile=> {:outdated_major=> [{:name=>"rake", :required=>"~> 10.4", :latest=>"13.0.1", :type=>:runtime}], :outdated_minor=>[], :outdated_bump=>[], :ok=>[], :unknown=>[]}} ``` * These results are stored in a Moneta store under a key generated by `RepositoryGem#identifier` (for e.g. a `GithubGem`, the identifier will be of the form `'github/org/name'`). * The Moneta store used by the Worker is provided by the Sinatra app Class: `::CuttingEdge::App.store`. * So we must do e.g. `CuttingEdge::App.set(:store, Moneta.new(:Memory))` to set the `#store` method on the `CuttingEdge` Class. ### Example use of the DependencyWorker and Gem API See `test.rb` for a basic example (without Sinatra) of how the setup works. Run it with `bundle exec ruby test.rb`. ```ruby require 'redis-objects' gem = GithubGem.new('gollum', 'gollum') Redis::Objects.redis = Redis.new gem_dependencies = Redis::Value.new(gem.identifier) puts gem_dependencies.value # Currently nil DependencyWorker.perform_async(gem.identifier, gem.gemspec_location, gem.gemfile_location) # Fire up a Sidekiq job # Sleep 5 puts gem_dependencies.value # The JSON results hash ``` ## License This work is licensed under the terms of the [GNU GPLv3.0](LICENSE).