Created
August 8, 2013 16:11
-
-
Save artemeff/6186013 to your computer and use it in GitHub Desktop.
Code extracted from https://github.com/rubyperu/ready4rails4/blob/master/lib/gemfile_parser.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class GemfileParser | |
attr_reader :gemfile | |
EXCLUDED = ["rails"] | |
def self.gems_status gemfile | |
new(gemfile).gems_status | |
end | |
def initialize gemfile | |
@gemfile = gemfile | |
end | |
def gems_status | |
excluded = gem_names - EXCLUDED | |
registered = Rubygem.alphabetical.where name: excluded | |
unregistered = excluded - registered.map(&:name) | |
[registered, unregistered] | |
end | |
private | |
def gem_names | |
gemfile.scan(/gem\s+['"](\S+)['"]/).flatten | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment