lib/co-kamishibai/functions.rb
# load settings from json config file
load settings from json config file
load settings from json config file
def load_config(path)
  json = JSON.parse( File.binread(path) )
  $SETTINGS = {}
  $SETTINGS[:SRCS] = json['SRCS'].collect { |src| File.expand_path(src) }
  $SETTINGS[:IMG_RESIZE] = json['IMG_RESIZE']
  $SETTINGS[:USERNAME] = json['USERNAME']
  $SETTINGS[:PASSWORD] = json['PASSWORD']
  $SETTINGS[:BIND] = json['BIND']
  $SETTINGS[:PORT] = json['PORT']
  $SETTINGS[:DEFAULT_IMAGE_QUALITY] = json['DEFAULT_IMAGE_QUALITY']
  $SETTINGS[:DEFAULT_IMAGE_WIDTH] = json['DEFAULT_IMAGE_WIDTH']
  $SETTINGS[:DEFAULT_IMAGE_HEIGHT] = json['DEFAULT_IMAGE_HEIGHT']
  $SETTINGS[:BOOKMARKS_FILE] = File.expand_path( json['BOOKMARKS_FILE'] )
end
def load_config ( path ) json = JSON . parse ( File . binread ( path ) ) $SETTINGS = { } $SETTINGS [ :SRCS ] = json [ 'SRCS' ] . collect { | src | File . expand_path ( src ) } $SETTINGS [ :IMG_RESIZE ] = json [ 'IMG_RESIZE' ] $SETTINGS [ :USERNAME ] = json [ 'USERNAME' ] $SETTINGS [ :PASSWORD ] = json [ 'PASSWORD' ] $SETTINGS [ :BIND ] = json [ 'BIND' ] $SETTINGS [ :PORT ] = json [ 'PORT' ] $SETTINGS [ :DEFAULT_IMAGE_QUALITY ] = json [ 'DEFAULT_IMAGE_QUALITY' ] $SETTINGS [ :DEFAULT_IMAGE_WIDTH ] = json [ 'DEFAULT_IMAGE_WIDTH' ] $SETTINGS [ :DEFAULT_IMAGE_HEIGHT ] = json [ 'DEFAULT_IMAGE_HEIGHT' ] $SETTINGS [ :BOOKMARKS_FILE ] = File . expand_path ( json [ 'BOOKMARKS_FILE' ] ) end
load settings from json config file
load settings from json config file
path