<commit_before>require 'inch_ci/worker/build_json/task'

module InchCI
  module Worker
    module BuildJSON
      def self.json(filename)
        JSONDump.new(filename)
      end

      class JSONDump
        attr_reader :language, :branch_name, :revision, :nwo, :url

        def initialize(filename)
          contents = File.read(filename, :encoding => 'utf-8')
          @json = JSON[contents]
          @language    = @json['language']
          @branch_name = @json['branch_name'] || @json['travis_branch']
          @revision    = @json['revision'] || @json['travis_commit']
          @nwo         = @json['nwo'] || @json['travis_repo_slug']
          @url         = @json['git_repo_url']
        end

        def circleci?
          !@json['circleci'].nil?
        end

        def travis?
          !@json['travis'].nil?
        end

        def to_h(include_objects: true)
          h = @json.dup
          h.delete('objects') unless include_objects
          h
        end
      end
    end
  end
end<commit_msg>Add 'shell' trigger to Build JSONs<commit_after>require 'inch_ci/worker/build_json/task'

module InchCI
  module Worker
    module BuildJSON
      def self.json(filename)
        JSONDump.new(filename)
      end

      class JSONDump
        attr_reader :language, :branch_name, :revision, :nwo, :url

        def initialize(filename)
          contents = File.read(filename, :encoding => 'utf-8')
          @json = JSON[contents]
          @language    = @json['language']
          @branch_name = @json['branch_name'] || @json['travis_branch']
          @revision    = @json['revision'] || @json['travis_commit']
          @nwo         = @json['nwo'] || @json['travis_repo_slug']
          @url         = @json['git_repo_url']
        end

        def shell?
          !@json['shell'].nil?
        end

        def circleci?
          !@json['circleci'].nil?
        end

        def travis?
          !@json['travis'].nil?
        end

        def to_h(include_objects: true)
          h = @json.dup
          h.delete('objects') unless include_objects
          h
        end
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.12253521126760564, 'fraction_numerical': 0.0009389671361502347, 'mean_word_length': 1.8875338753387534, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '2625164', 'n_tokens_mistral': 660, 'n_tokens_neox': 658, 'n_words': 136}