39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
# File 'lib/gemfile_arranger/cli.rb', line 39
def arrange
code = gemfile_contents(options[:gemfile])
buffer = Parser::Source::Buffer.new('(gemfile_arranger arrange)')
buffer.source = code
parser = Parser::CurrentRuby.new
ast = parser.parse(buffer)
sort_gems_in_group = Traverse::SortGemsInGroup.new
rewrited_ast = sort_gems_in_group.process(ast)
sort_priority_gems_in_group = Traverse::SortPriorityGemsInGroup.new(config['priority_gem'])
rewrited_ast = sort_priority_gems_in_group.process(rewrited_ast)
sort_block = Traverse::SortBlock.new(config['block_order'])
rewrited_ast = sort_block.process(rewrited_ast)
rewrited_gemfile = Unparser.unparse(rewrited_ast)
if options[:auto_correct]
rewrite_gemfile(rewrited_gemfile, options[:gemfile])
puts "Rewrite Gemfile compete! #{options[:gemfile]}"
else
puts rewrited_gemfile
end
end
|