class Bim::Action::Fw

Fw class uses by Bim::Subcommands::Fw

Constants

DETAIL_CONF
FW_PATH
FW_URI

Public Class Methods

detail(name) click to toggle source
# File lib/bim/action/fw.rb, line 41
def detail(name)
  start_uri = URI(sub_localhost(specify_link_by_name(FW_URI, name)))
  detail_depth(start_uri, DETAIL_CONF).to_json
end
detail_depth(uri, conf) click to toggle source
# File lib/bim/action/fw.rb, line 46
def detail_depth(uri, conf)
  datas = JSON.parse(get_body(uri))
  if conf[:items]
    datas['items'].map do |data|
      detail_proc.call(data, conf, true)
    end
  else
    detail_proc.call(datas, conf)
  end
end
detail_proc() click to toggle source
# File lib/bim/action/fw.rb, line 57
def detail_proc
  proc do |data, conf, map = false|
    d = {}
    conf[:attrs].each { |attr| d[attr] = data[attr] }

    (map ? (next d) : (return d)) unless data.key?(conf[:under_key])
    next_uri = URI(sub_localhost(data[conf[:under_key]]['link']))
    d[conf[:under_key]] = detail_depth(next_uri, conf[:under_layer])
    d
  end
end
ls() click to toggle source
# File lib/bim/action/fw.rb, line 35
def ls
  map(FW_URI) do |item|
    { 'item' => item['name'], 'fullPath' => item['fullPath'] }
  end
end