Sha256: 4114c5fec55146787cc6cbfa046a85520779cf778e451e6f80a54825d0c5a6e3

Contents?: true

Size: 1.35 KB

Versions: 25

Compression:

Stored size: 1.35 KB

Contents

module Approvals
  module Reporters
    module Launcher

      class << self
        REPORTERS = [:opendiff, :diffmerge, :vimdiff, :tortoisediff, :filelauncher]

        def memoized(instance_variable)
          unless self.instance_variable_get(instance_variable)
            value = yield
            self.instance_variable_set(instance_variable, value)
          end
          self.instance_variable_get(instance_variable)
        end

        REPORTERS.each do |name|
          define_method name do
            memoized(:"@#{name}") do
              lambda {|received, approved|
                self.send("#{name}_command".to_sym, received, approved)
              }
            end
          end
        end

        def opendiff_command(received, approved)
          "opendiff #{received} #{approved}"
        end

        def diffmerge_command(received, approved)
          "/Applications/DiffMerge.app/Contents/MacOS/DiffMerge --nosplash \"#{received}\" \"#{approved}\""
        end

        def vimdiff_command(received, approved)
          "vimdiff #{received} #{approved}"
        end

        def tortoisediff_command(received, approved)
          "C:\\Program Files\\TortoiseSVN\\bin\\TortoiseMerge.exe #{received} #{approved}"
        end

        def filelauncher_command(received, approved)
          "open #{received}"
        end
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 2 rubygems

Version Path
approvals-0.0.26 lib/approvals/reporters/launcher.rb
approvals-0.0.25 lib/approvals/reporters/launcher.rb
approvals-0.0.24 lib/approvals/reporters/launcher.rb
br-approvals-0.0.22 lib/approvals/reporters/launcher.rb
approvals-0.0.22 lib/approvals/reporters/launcher.rb
approvals-0.0.21 lib/approvals/reporters/launcher.rb
approvals-0.0.20 lib/approvals/reporters/launcher.rb
approvals-0.0.19 lib/approvals/reporters/launcher.rb
approvals-0.0.18 lib/approvals/reporters/launcher.rb
approvals-0.0.17 lib/approvals/reporters/launcher.rb
approvals-0.0.16 lib/approvals/reporters/launcher.rb
approvals-0.0.15 lib/approvals/reporters/launcher.rb
approvals-0.0.14 lib/approvals/reporters/launcher.rb
approvals-0.0.13 lib/approvals/reporters/launcher.rb
approvals-0.0.12 lib/approvals/reporters/launcher.rb
approvals-0.0.11 lib/approvals/reporters/launcher.rb
approvals-0.0.10 lib/approvals/reporters/launcher.rb
approvals-0.0.9 lib/approvals/reporters/launcher.rb
approvals-0.0.8 lib/approvals/reporters/launcher.rb
approvals-0.0.7 lib/approvals/reporters/launcher.rb