Sha256: dfe3b5e1df68e56c85e1968a38799ae60108e01ea4b6f647e0e51aa9101c0d7d

Contents?: true

Size: 777 Bytes

Versions: 2

Compression:

Stored size: 777 Bytes

Contents

module Travis
  class Keychain
    include Cli::Helper

    attr_reader :app, :shell, :dir

    def initialize(app, shell, dir = '../travis-keychain')
      @app = app
      @shell = shell
      @dir = File.expand_path(dir)
    end

    def fetch
      chdir { pull }
      read
    end

    protected

      def pull
        error 'There are unstaged changes in your travis-keychain working directory.' unless clean?
        say 'Fetching the keychain ...'
        run 'git pull'
      end

      def read
        File.read(File.join(dir, "config/travis.#{app}.yml")) || ''
      end

      def chdir(&block)
        FileUtils.mkdir_p(dir)
        Dir.chdir(dir, &block)
      end

      def clean?
        `git status`.include?('working directory clean')
      end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
travis-cli-0.0.2 lib/travis/keychain.rb
travis-cli-0.0.1 lib/travis/keychain.rb