Sha256: 8775c6c61b84ac6e6f28b45cf58551ef7616601e6f04449cb60d830d218c0dd4

Contents?: true

Size: 1.92 KB

Versions: 2

Compression:

Stored size: 1.92 KB

Contents

# encoding: UTF-8

# (c) Copyright 2014 Hewlett-Packard Development Company, L.P.
#
#    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.


require 'lorj'

# Module to initialize the application
# TODO: Cleanup about Global variables used. Should be replaced by PrcLib
#       or other kind of setting.
module AppInit

   def AppInit.forj_initialize()
      # Function to create FORJ paths if missing.

      # Defining Global variables
      $FORJ_DATA_PATH = File.expand_path(File.join('~', '.forj'))
      $FORJ_ACCOUNTS_PATH = File.join($FORJ_DATA_PATH, 'accounts')
      $FORJ_KEYPAIRS_PATH = File.join($FORJ_DATA_PATH, 'keypairs')
      $FORJ_BUILD_PATH = File.join($FORJ_DATA_PATH, '.build')
      $FORJ_CREDS_PATH = File.expand_path(File.join('~', '.cache', 'forj'))

      # TODO: To move to an hpcloud object.
      $HPC_KEYPAIRS = File.expand_path(File.join('~', '.hpcloud', 'keypairs'))
      $HPC_ACCOUNTS = File.expand_path(File.join('~', '.hpcloud', 'accounts'))

      AppInit.ensure_dir_exists($FORJ_DATA_PATH)
      AppInit.ensure_dir_exists($FORJ_ACCOUNTS_PATH)
      AppInit.ensure_dir_exists($FORJ_BUILD_PATH)
      AppInit.ensure_dir_exists($FORJ_KEYPAIRS_PATH)
      FileUtils.chmod(0700, $FORJ_KEYPAIRS_PATH)
      AppInit.ensure_dir_exists($FORJ_CREDS_PATH)
   end

   def AppInit.ensure_dir_exists(path)
      if not PrcLib.dir_exists?(path)
       FileUtils.mkpath(path) if not File.directory?(path)
      end
   end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
forj-1.0.3 lib/appinit.rb
forj-1.0.2 lib/appinit.rb