Sha256: 2fba3c1e63e687b3679ac8619c5dd5e8a9f15c2f80ce550132b834740507f3da
Contents?: true
Size: 1.25 KB
Versions: 1
Compression:
Stored size: 1.25 KB
Contents
require 'json' module BambooRat class Diff def initialize(tree, path, branch, format) @tree = tree @path = path @branch = branch @format = format @diff_components = diff_components self end def formatted_data return { diff: @diff_components }.to_json if @format == 'simple' return @diff_components[:js].join(',') if @format == 'js' return @diff_components[:ruby].join(',') if @format == 'ruby' { js_components: @tree.js_components.map(&:path), ruby_components: @tree.ruby_components.map(&:path), diff: @diff_components, components: @tree.components.map(&:path) } end def diff_components files = `git diff --name-only origin/#{@branch}`.split /\n/ component_hash = { js: Set.new, ruby: Set.new } files.each do |file| @tree.components.each do |component| reg = Regexp.new "^#{component.path}" key = component.name == 'Ruby' ? :ruby : :js component_hash[key] << component.path if reg.match("#{@path}#{file}") end end component_hash[:js] = component_hash[:js].to_a component_hash[:ruby] = component_hash[:ruby].to_a component_hash end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
bamboo_rat-0.1.4 | lib/bamboo_rat/diff.rb |