<commit_before>#
# Copyright (C) 2010-2016 dtk contributors
#
# This file is part of the dtk project.
#
# 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.
#
#
# Classes that encapsulate information for each module or moulde branch where is its location clone and where is its remotes
#
module DTK
  class ModuleBranch
    class Augmented < self
      subclass_model :module_branch_augmented, :module_branch, print_form: 'module_branch'

      def version
        self[:version]
      end
      
      def component_module?
        self[:component_module]
      end
      def component_module
        component_module? || raise_unexpected_nil('component_module?')
      end

      def component_module_name?
        if component_module = component_module?
          component_module.get_field?(:display_name)
        end
      end
      def component_module_name
        component_module_name? || raise_unexpected_nil('component_module_name?') 
      end

      def component_module
        component_module? || raise_unexpected_nil('component_module?')
      end

      def module_name 
        self[:module_name] || raise_unexpected_nil('self[:module_name]')
      end

      def repo
        self[:repo] || raise_unexpected_nil('self[:repo]')
      end

      def current_sha
        self[:current_sha] || raise_unexpected_nil('self[:current_sha]')
      end
      
      def branch_name
        self[:branch]  || raise_unexpected_nil('self[:branch]')
      end
      
      def namespace
        self[:namespace]  || raise_unexpected_nil('self[:namespace]')
      end

      def frozen
        has_key?(:frozen) ? self[:frozen] : raise_unexpected_nil('self[:frozen]')
      end
      
      def implementation
        @implementation ||= get_implementation
      end

      def self.augmented_module_branch(module_branch)
        sp_hash = {
          cols: [:display_name, :augmented_branch_info, :namespace]
        }
        module_branch_id = module_branch.id
        module_obj = module_branch.get_module.get_objs(sp_hash).find { |r| r[:module_branch][:id] == module_branch_id }
        aug_module_branch = module_obj[:module_branch].merge(repo: module_obj[:repo], module_name: module_obj[:display_name], module_namespace: module_obj[:namespace][:display_name])
        aug_module_branch.create_as_subclass_object(self)
      end

      # opts can have keys:
      #   :filter
      #   :donot_raise_error
      #   :include_repo_remotes
      def self.get_augmented_module_branch(parent_module, opts = {})
        ret = nil
        version       = (opts[:filter] || {})[:version] #version can be nil
        version_field = ModuleBranch.version_field(version) <commit_msg>Fixed small bug in application/model/module/branch/augmented.rb<commit_after>#
# Copyright (C) 2010-2016 dtk contributors
#
# This file is part of the dtk project.
#
# 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.
#
#
# Classes that encapsulate information for each module or moulde branch where is its location clone and where is its remotes
#
module DTK
  class ModuleBranch
    class Augmented < self
      subclass_model :module_branch_augmented, :module_branch, print_form: 'module_branch'

      def version
        self[:version]
      end
      
      def component_module?
        self[:component_module]
      end
      def component_module
        component_module? || raise_unexpected_nil('component_module?')
      end

      def component_module_name?
        if component_module = component_module?
          component_module.get_field?(:display_name)
        end
      end
      def component_module_name
        component_module_name? || raise_unexpected_nil('component_module_name?') 
      end

      def component_module
        component_module? || raise_unexpected_nil('component_module?')
      end

      def module_name 
        self[:module_name] || raise_unexpected_nil('self[:module_name]')
      end

      def repo
        self[:repo] || raise_unexpected_nil('self[:repo]')
      end

      def current_sha
        self[:current_sha] || raise_unexpected_nil('self[:current_sha]')
      end
      
      def branch_name
        self[:branch]  || raise_unexpected_nil('self[:branch]')
      end
      
      # namespace object
      def module_namespace
        self[:module_namespace]  || raise_unexpected_nil('self[:module_namespace]')
      end

      def frozen
        has_key?(:frozen) ? self[:frozen] : raise_unexpected_nil('self[:frozen]')
      end
      
      def implementation
        @implementation ||= get_implementation
      end

      def self.augmented_module_branch(module_branch)
        sp_hash = {
          cols: [:display_name, :augmented_branch_info, :namespace]
        }
        module_branch_id = module_branch.id
        module_obj = module_branch.get_module.get_objs(sp_hash).find { |r| r[:module_branch][:id] == module_branch_id }
        aug_module_branch = module_obj[:module_branch].merge(repo: module_obj[:repo], module_name: module_obj[:display_name], module_namespace: module_obj[:namespace])
        aug_module_branch.create_as_subclass_object(self)
      end

      # opts can have keys:
      #   :filter
      #   :donot_raise_error
      #   :include_repo_remotes
      def self.get_augmented_module_branch(parent_module, opts = {})
        ret = nil
        version       = (opts[:filter] || {})[:version] #version can be nil
        version_field = ModuleBranch.version_field(version) 
{'fraction_non_alphanumeric': 0.0855007008254166, 'fraction_numerical': 0.003737735555209469, 'mean_word_length': 3.0826446280991737, 'pattern_counts': {'":': 0, '<': 5, '<?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': '1680580', 'n_tokens_mistral': 1860, 'n_tokens_neox': 1800, 'n_words': 476}