Sha256: fde9c5ebaa0b39e168c21d2b74b60253cc3a8cbba7fa3ab701f4076b7cd75402

Contents?: true

Size: 1.25 KB

Versions: 6

Compression:

Stored size: 1.25 KB

Contents

module VagrantPlugins
  module Invade
    module Helper

      class Checksum

        attr_accessor :env, :root_path, :vagrantfile, :data

        def initialize(env)
          @env          = env
          @root_path    = Dir.pwd
          @vagrantfile  = ENV['VAGRANT_VAGRANTFILE'] ? vagrantfile_name = ENV['VAGRANT_VAGRANTFILE'] : vagrantfile_name = "Vagrantfile"
          @data         = env[:invade]['vagrantfile']
        end

        # Compare Vagrantfile <=> invade.yml with MD5 checksum
        def check()

          # Create checksum from generated data of invade.yml file
          require 'digest'
          md5_new = Digest::MD5.hexdigest(@data)

          unless (md5_new.eql? get_checksum_of_file(@vagrantfile))
            return false
          end

          true
        end

        def get_checksum_of_data(data)

          begin
            checksum = Digest::MD5.hexdigest(@data)
          rescue StandardError => e
            fail e
          end

          checksum
        end

        def get_checksum_of_file(file)

          begin
            if File.exist?(file)
              return Digest::MD5.file(file).hexdigest
            end
          rescue IOError => e
            fail e
          end

          0
        end

      end

    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
vagrant-invade-0.7.0 lib/vagrant-invade/helper/checksum.rb
vagrant-invade-0.6.4 lib/vagrant-invade/helper/checksum.rb
vagrant-invade-0.6.3 lib/vagrant-invade/helper/checksum.rb
vagrant-invade-0.6.2 lib/vagrant-invade/helper/checksum.rb
vagrant-invade-0.6.1 lib/vagrant-invade/helper/checksum.rb
vagrant-invade-0.6.0 lib/vagrant-invade/helper/checksum.rb