<commit_before>require_relative "../instapusher"
require 'net/http'
require 'uri'

module Instapusher
  class Commands

    attr_reader :debug, :api_key, :branch_name, :project_name

    def initialize init_options = {}
      @debug = init_options[:debug]
      @quick = init_options[:quick]
      @local = init_options[:local]

      git          = Git.new
      @branch_name  = init_options[:project_name] || ENV['INSTAPUSHER_BRANCH'] || git.current_branch
      @project_name = init_options[:branch_name] || ENV['INSTAPUSHER_PROJECT'] || git.project_name
    end

    def deploy
      verify_api_key
      #SpecialInstructionForProduction.new.run if production?

      job_submission = JobSubmission.new(debug, options)
      job_submission.submit_the_job

      if job_submission.success?
        job_submission.feedback_to_user
        #TagTheRelease.new(branch_name, debug).tagit if (production? || staging?)
      else
        puts job_submission.error_message
      end
    end

    private

    def options
      @options ||= begin
        { project: project_name,
          branch:  branch_name,
          owner: Git.new.repo_owner,
          local:   @local,
          version: VERSION,
          api_key: api_key }
      end
    end

    def verify_api_key
      @api_key = ENV['API_KEY'] || Instapusher::Configuration.api_key(debug) || ""
      puts "api_key is #{@api_key}" if debug

      if @api_key.to_s.length == 0
        puts ''
        abort "No instapusher API key was found. Please execute instapusher --api-key to setup instapusher API key."
      end
    end

    def production?
      branch_name.intern == :production
    end

    def staging?
      branch_name.intern == :staging
    end

  end
end
<commit_msg>support for staging<commit_after>require_relative "../instapusher"
require 'net/http'
require 'uri'

module Instapusher
  class Commands

    attr_reader :debug, :api_key, :branch_name, :project_name, :staging

    def initialize init_options = {}
      @debug = init_options[:debug]
      @staging = init_options[:staging]

      git          = Git.new
      @branch_name  = init_options[:project_name] || ENV['INSTAPUSHER_BRANCH'] || git.current_branch
      @project_name = init_options[:branch_name] || ENV['INSTAPUSHER_PROJECT'] || git.project_name
    end

    def deploy
      verify_api_key
      #SpecialInstructionForProduction.new.run if production?

      job_submission = JobSubmission.new(debug, options)
      job_submission.submit_the_job

      if job_submission.success?
        job_submission.feedback_to_user
        #TagTheRelease.new(branch_name, debug).tagit if (production? || staging?)
      else
        puts job_submission.error_message
      end
    end

    private

    def options
      @options ||= begin
        { project: project_name,
          branch:  branch_name,
          owner: Git.new.repo_owner,
          version: VERSION,
          staging: @staging,
          api_key: api_key }
      end
    end

    def verify_api_key
      @api_key = ENV['API_KEY'] || Instapusher::Configuration.api_key(debug) || ""
      puts "api_key is #{@api_key}" if debug

      if @api_key.to_s.length == 0
        puts ''
        abort "No instapusher API key was found. Please execute instapusher --api-key to setup instapusher API key."
      end
    end

    def production?
      branch_name.intern == :production
    end

    def staging?
      branch_name.intern == :staging
    end

  end
end

{'fraction_non_alphanumeric': 0.09209006928406467, 'fraction_numerical': 0.0005773672055427252, 'mean_word_length': 2.5906735751295336, 'pattern_counts': {'":': 0, '<': 3, '<?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': '4198431', 'n_tokens_mistral': 1092, 'n_tokens_neox': 1078, 'n_words': 245}