<commit_before>
# Mecano Misc Discover
Enable Mecano.service to discover the os.
For now it only supports Centos/Redhat OS in version 6 or 7.
Store properties in the mecano store object.

    module.exports =
      system: (options) ->
        @execute
          cmd: 'cat /etc/system-release'
          shy: true
          code_skipped: 1
          , (err, status, stdout, stderr) ->
            throw err if err
            [line] = string.lines stdout
            if /CentOS/.test line
              options.store['mecano:system:type'] ?= 'centos' 
              index = line.split(' ').indexOf 'release'
              options.store['mecano:system:release'] ?= line.split(' ')[index+1]
            if /Red\sHat/.test line
              options.store['mecano:system:type'] ?= 'redhat'
              index = line.split(' ').indexOf 'release'
              options.store['mecano:system:release'] ?= line.split(' ')[index+1]
            throw Error 'Unsupported OS' unless options.store['mecano:system:type']?
      loader: (options) ->
        @execute
          shy: true
          cmd: """
          if which systemctl >/dev/null; then exit 1; fi ;
          if which service >/dev/null; then exit 2; fi ;s
          exit 3 ;
          """
          code: [1, 2]
          unless: options.loader?
          shy: true
        , (err, status, stdout, stderr, signal) ->
          throw Error "Undetected Operating System Loader" if err?.code is 3
          throw err if err
          return unless status
          options.store ?= {}
          options.loader = switch signal
            when 1 then 'systemctl'
            when 2 then 'service'
          options.store['mecano:service:loader'] = options.loader
        

## Dependencies

    string = require '../misc/string'
<commit_msg>misc/discover: refactor<commit_after>
# Mecano Misc Discover
Enable Mecano.service to discover the os.
For now it only supports Centos/Redhat OS in version 6 or 7.
Store properties in the mecano store object.

    module.exports =
      system: (options) ->
        @execute
          cmd: 'cat /etc/system-release'
          shy: true
          code_skipped: 1
        , (err, status, stdout, stderr) ->
          throw err if err
          [line] = string.lines stdout
          if /CentOS/.test line
            options.store['mecano:system:type'] ?= 'centos'
            index = line.split(' ').indexOf 'release'
            options.store['mecano:system:release'] ?= line.split(' ')[index+1]
          if /Red\sHat/.test line
            options.store['mecano:system:type'] ?= 'redhat'
            index = line.split(' ').indexOf 'release'
            options.store['mecano:system:release'] ?= line.split(' ')[index+1]
          throw Error 'Unsupported OS' unless options.store['mecano:system:type']?
      loader: (options) ->
        @execute
          shy: true
          cmd: """
          if which systemctl >/dev/null; then exit 1; fi ;
          if which service >/dev/null; then exit 2; fi ;s
          exit 3 ;
          """
          code: [1, 2]
          unless: options.loader?
          shy: true
        , (err, status, stdout, stderr, signal) ->
          throw Error "Undetected Operating System Loader" if err?.code is 3
          throw err if err
          return unless status
          options.store ?= {}
          options.loader = switch signal
            when 1 then 'systemctl'
            when 2 then 'service'
          options.store['mecano:service:loader'] = options.loader
        

## Dependencies

    string = require '../misc/string'

{'fraction_non_alphanumeric': 0.11563289362896435, 'fraction_numerical': 0.007297221442604546, 'mean_word_length': 1.8375796178343948, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '4199024', 'n_tokens_mistral': 1045, 'n_tokens_neox': 1014, 'n_words': 307}