Created
June 4, 2017 14:55
-
-
Save sue445/538c7339ccfb35decdb3463511acf21e to your computer and use it in GitHub Desktop.
Gemfile中のgemの名前だけ取り出して標準出力に書き出す
This file contains 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
# Gemfile中のgemの名前だけ取り出して標準出力に書き出す | |
# | |
# 使い方 | |
# ruby parse_gemfile.rb /path/to/gemfile | |
# | |
# 複数のgemfileから被ってるのが多い順に表示する | |
# ruby parse_gemfile.rb *.gemfile | sort | uniq -c | sort -nr | |
# rails newした時にデフォルトで入ってるgemは除外する | |
EXCLUDE_GEMS = %w( | |
rails | |
sqlite3 | |
puma | |
sass-rails | |
uglifier | |
therubyracer | |
coffee-rails | |
turbolinks | |
jbuilder | |
redis | |
bcrypt | |
capistrano-rails | |
byebug | |
capybara | |
selenium-webdriver | |
web-console | |
listen | |
spring | |
spring-watcher-listen | |
tzinfo-data | |
mysql2 | |
) | |
ARGV.each do |source_file| | |
File.read(source_file).each_line do |line| | |
match_data = line.match(/^\s*gem\s*+["'](.+?)["']/) | |
next unless match_data | |
gem_name = match_data[1] | |
next if EXCLUDE_GEMS.include?(gem_name) | |
puts gem_name | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment