Sha256: 3257e0cf1c466822c0b2bea83c88fb3e8645c24ed13c80e688bed5cdfd9122d1
Contents?: true
Size: 1.24 KB
Versions: 1
Compression:
Stored size: 1.24 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 #{@branch} --name-only`.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.1 | lib/bamboo_rat/diff.rb |