<commit_before>require 'travis/build/script/addons/deploy'

module Travis
  module Build
    class Script
      module Addons
        class CloudFoundry < Deploy
          def self.new(script, config)
            return super if self < CloudFoundry
            version  = config.to_hash[:version] if config.respond_to? :version
            subclass = version.to_i == 1 ? V1 : V2
            subclass.new(script, config)
          end

          class V1 < CloudFoundry
            private
              def tool_name
                "vmc"
              end
          end

          class V2 < CloudFoundry
            private
              def tool_name
                "cf"
              end
          end

          private
            def deploy
              cf "target #{option(:target)}"
              silent { cf "login --email #{option(:email)} --password #{option(:password)}" }
              cf "push #{app}"
            end

            def tools
              `gem install #{tool_name}`
            end

            def cf(cmd)
              `#{tool_name} #{cmd}`
            end
        end
      end
    end
  end
end<commit_msg>simplify cloud foundry addon, make CLI tool configurable (many providers have their own fork)<commit_after>require 'travis/build/script/addons/deploy'

module Travis
  module Build
    class Script
      module Addons
        class CloudFoundry < Deploy
          private
            def cli_tool
              config.fetch(:cli_tool) { config[:version].to_i == 1 ? 'cf' : 'vmc' }
            end

            def deploy
              cf "target #{option(:target)}"
              silent { cf "login --email #{option(:email)} --password #{option(:password)}" }
              cf "push #{app}"
            end

            def tools
              `gem install #{cli_tool}`
            end

            def cf(cmd)
              `#{cli_tool} #{cmd}`
            end
        end
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.08539094650205761, 'fraction_numerical': 0.0030864197530864196, 'mean_word_length': 1.2990543735224587, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5146337', 'n_tokens_mistral': 517, 'n_tokens_neox': 507, 'n_words': 151}