Skip to content

Commit

Permalink
Merge pull request #20 from FundingCircle/fix-dependencies
Browse files Browse the repository at this point in the history
Fix bundler dependency
  • Loading branch information
bliof authored Feb 6, 2018
2 parents 3a38c82 + 3490126 commit fc86ba1
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 23 deletions.
23 changes: 4 additions & 19 deletions bin/hellgrid
Original file line number Diff line number Diff line change
@@ -1,28 +1,13 @@
#!/usr/bin/env ruby

require 'pathname'
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', Pathname.new(__FILE__).realpath)
# XXX: BUNDLE_GEMFILE should be provided because the internals of bundler require a 'Gemfile' or '.bundle' to
# work properly. Without this the script will fail if there isn't a Gemfile somewhere up the directory chain
ENV['BUNDLE_GEMFILE'] ||= File.join(File.expand_path('../..', Pathname.new(__FILE__).realpath), 'Gemfile')

require 'rubygems'
require 'bundler/setup'
require 'find'

require 'hellgrid'

recursive_search = !!(ARGV.delete('-r'))
folders = ARGV.empty? ? [Dir.pwd] : ARGV

folders.each do |folder|
matrix = Hellgrid::Matrix.new

Find.find(folder) do |path|
if File.directory?(path) && File.exists?(File.join(path, 'Gemfile.lock'))
matrix.add_project(Hellgrid::Project.new(folder, path))
Find.prune unless recursive_search
end
end

view = Hellgrid::Views::Console.new(matrix.sorted_by_most_used)

view.render
end
Hellgrid::CLI.start
7 changes: 7 additions & 0 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ jobs:
paths:
- vendor/bundle
- run: bundle exec rspec spec --format progress
- run:
name: Make sure that the gem runs when installed
command: |
set -e
gem build 'hellgrid.gemspec'
gem install $(ls -t1 hellgrid-*.gem | head -1)
cd ~ && hellgrid
deploy:
<<: *defaults
steps:
Expand Down
10 changes: 10 additions & 0 deletions exe/hellgrid
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env ruby

require 'pathname'
# XXX: BUNDLE_GEMFILE should be provided because the internals of bundler require a 'Gemfile' or '.bundle' to
# work properly. Without this the script will fail if there isn't a Gemfile somewhere up the directory chain
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', Pathname.new(__FILE__).realpath)

require 'hellgrid'

Hellgrid::CLI.start
8 changes: 5 additions & 3 deletions hellgrid.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ Gem::Specification.new do |s|
s.summary = 'Gem version dependency matrix'
s.authors = ['Deyan Dobrinov', 'Aleksandar Ivanov']
s.email = ['[email protected]']
s.files = Dir.chdir(project_root) { Dir['lib/**/*.rb'] + Dir['bin/*'] + Dir['spec/**/*.rb'] + %w(Gemfile Gemfile.lock README.md hellgrid.gemspec) }
s.executables = s.files.grep(/^bin\//) { |f| File.basename(f) }
s.files = Dir.chdir(project_root) { Dir['lib/**/*.rb'] + Dir['bin/*'] + Dir['exe/*'] + Dir['spec/**/*.rb'] + %w(Gemfile Gemfile.lock README.md hellgrid.gemspec) }
s.bindir = 'exe'
s.executables = s.files.grep(/^exe\//) { |f| File.basename(f) }
s.test_files = s.files.grep(/^spec\//)
s.require_paths = ['lib']
s.homepage = 'https://github.com/FundingCircle/hellgrid'
s.license = 'BSD-3-Clause'

s.add_runtime_dependency 'bundler', ['>= 1.11.0', '< 1.17']

s.add_development_dependency 'rspec', '~> 3.4', '>= 3.4.0'
s.add_development_dependency 'bundler', '~> 1.11', '>= 1.11.0'
end
3 changes: 3 additions & 0 deletions lib/hellgrid.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
require 'bundler'
require 'find'
require 'hellgrid/project'
require 'hellgrid/matrix'
require 'hellgrid/views/console'
require 'hellgrid/cli'

module Hellgrid
end
33 changes: 33 additions & 0 deletions lib/hellgrid/cli.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
module Hellgrid
class CLI
def self.start(argv = ARGV)
new(argv).start
end

def initialize(argv = ARGV)
@argv = argv
end

attr_reader :argv

def start
recursive_search = !!(argv.delete('-r'))
folders = argv.empty? ? [Dir.pwd] : argv

folders.each do |folder|
matrix = Hellgrid::Matrix.new

Find.find(folder) do |path|
if File.directory?(path) && File.exists?(File.join(path, 'Gemfile.lock'))
matrix.add_project(Hellgrid::Project.new(folder, path))
Find.prune unless recursive_search
end
end

view = Hellgrid::Views::Console.new(matrix.sorted_by_most_used)

view.render
end
end
end
end
2 changes: 1 addition & 1 deletion lib/hellgrid/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Hellgrid
VERSION = '0.3.0'
VERSION = '0.3.1'
end

0 comments on commit fc86ba1

Please sign in to comment.