<commit_before># frozen_string_literal: true
# Copyright 2016 Liqwyd Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Top level module for the core Cyclid code.
module Cyclid
  # Module for the Cyclid API
  module API
    # Module for Cyclid Job related classes
    module Job
      # Non-ActiveRecord class which holds a complete Job, complete with
      # serialised stages and the resolved sequence.
      class JobView
        attr_reader :name, :version

        def initialize(job, context, org)
          @name = job[:name]
          @version = job[:version] || '1.0.0'

          @context = context
          @organization = org.name
          @environment = job[:environment]
          @sources = job[:sources] || []
          @secrets = setec_astronomy(org, (job[:secrets] || {}))

          # Build a single unified list of StageViews
          @stages, @sequence = build_stage_collection(job, org)
        end

        # Return everything, serialized into a hash
        def to_hash
          hash = {}
          hash[:name] = @name
          hash[:version] = @version
          hash[:context] = @context
          hash[:organization] = @organization
          hash[:environment] = @environment
          hash[:sources] = @sources
          hash[:secrets] = @secrets
          hash[:stages] = @stages.each_with_object({}) do |(name, stage), h|
            h[name.to_sym] = Oj.dump(stage)
          end
          hash[:sequence] = @sequence<commit_msg>Provide an empty environment if there isn't one in the job<commit_after># frozen_string_literal: true
# Copyright 2016 Liqwyd Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Top level module for the core Cyclid code.
module Cyclid
  # Module for the Cyclid API
  module API
    # Module for Cyclid Job related classes
    module Job
      # Non-ActiveRecord class which holds a complete Job, complete with
      # serialised stages and the resolved sequence.
      class JobView
        attr_reader :name, :version

        def initialize(job, context, org)
          @name = job[:name]
          @version = job[:version] || '1.0.0'

          @context = context
          @organization = org.name
          @environment = job[:environment] || {}
          @sources = job[:sources] || []
          @secrets = setec_astronomy(org, (job[:secrets] || {}))

          # Build a single unified list of StageViews
          @stages, @sequence = build_stage_collection(job, org)
        end

        # Return everything, serialized into a hash
        def to_hash
          hash = {}
          hash[:name] = @name
          hash[:version] = @version
          hash[:context] = @context
          hash[:organization] = @organization
          hash[:environment] = @environment
          hash[:sources] = @sources
          hash[:secrets] = @secrets
          hash[:stages] = @stages.each_with_object({}) do |(name, stage), h|
            h[name.to_sym] = Oj.dump(stage)
          end
          hash[:sequence] = @sequence
{'fraction_non_alphanumeric': 0.09355405066466015, 'fraction_numerical': 0.005517933283170303, 'mean_word_length': 2.5638963360142983, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '3702655', 'n_tokens_mistral': 1078, 'n_tokens_neox': 1044, 'n_words': 401}