Skip to content

Commit f9abd14

Browse files
committed
parsing Gemfile.lock
1 parent 8c8fb06 commit f9abd14

File tree

8 files changed

+64
-13
lines changed

8 files changed

+64
-13
lines changed

.rspec

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
--color
2+
--format progress

foy-ruby-parser.gemspec

+9-4
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,24 @@
11
# -*- encoding: utf-8 -*-
22
lib = File.expand_path('../lib', __FILE__)
33
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4-
require 'foy-ruby-parser/version'
4+
require 'foy_ruby_parser/version'
55

66
Gem::Specification.new do |gem|
7-
gem.name = "foy-ruby-parser"
7+
gem.name = "foy_ruby_parser"
88
gem.version = Foy::Ruby::Parser::VERSION
99
gem.authors = ["Roberto Soares"]
1010
gem.email = ["[email protected]"]
11-
gem.description = %q{TODO: Write a gem description}
12-
gem.summary = %q{TODO: Write a gem summary}
11+
gem.summary = %q{Gemfile/gemspec parser used by foy-worker}
12+
gem.description = %q{Gemfile/gemspec parser used by foy-worker}
1313
gem.homepage = ""
1414

1515
gem.files = `git ls-files`.split($/)
1616
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
1717
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
1818
gem.require_paths = ["lib"]
19+
20+
gem.add_dependency('bundler', '>= 1.3.1')
21+
22+
gem.add_development_dependency('rake', '>= 10.0.3')
23+
gem.add_development_dependency('rspec', '>= 2.13.0')
1924
end

lib/foy-ruby-parser.rb

-9
This file was deleted.

lib/foy_ruby_parser.rb

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
require "foy_ruby_parser/version"
2+
require "bundler"
3+
4+
module Foy
5+
module Ruby
6+
module Parser
7+
class << self
8+
def parse(file)
9+
Bundler::LockfileParser.new(File.open(file, 'r').read)
10+
end
11+
end
12+
end
13+
end
14+
end
File renamed without changes.

spec/fixtures/Gemfile

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Gemfile content

spec/lib/foy_ruby_parser_spec.rb

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
require 'spec_helper'
2+
3+
require 'foy_ruby_parser'
4+
5+
describe Foy::Ruby::Parser do
6+
7+
describe "#parse" do
8+
context "Gemfile.lock" do
9+
it "uses bundler parser" do
10+
Bundler::LockfileParser.should_receive(:new).with("Gemfile content\n").and_return(nil)
11+
Foy::Ruby::Parser.parse("spec/fixtures/Gemfile")
12+
end
13+
14+
it "returns current dependencies (name and version)" do
15+
Foy::Ruby::Parser.parse("spec/fixtures/Gemfile.lock").specs.collect{|d| [d.name, d.version]}
16+
end
17+
end
18+
19+
context "gemspec" #TODO
20+
end
21+
end

spec/spec_helper.rb

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# This file was generated by the `rspec --init` command. Conventionally, all
2+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3+
# Require this file using `require "spec_helper"` to ensure that it is only
4+
# loaded once.
5+
#
6+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
7+
RSpec.configure do |config|
8+
config.treat_symbols_as_metadata_keys_with_true_values = true
9+
config.run_all_when_everything_filtered = true
10+
config.filter_run :focus
11+
12+
# Run specs in random order to surface order dependencies. If you find an
13+
# order dependency and want to debug it, you can fix the order by providing
14+
# the seed, which is printed after each run.
15+
# --seed 1234
16+
config.order = 'random'
17+
end

0 commit comments

Comments
 (0)