Module: FIR

Includes:
Util
Defined in:
lib/fir.rb,
lib/fir/cli.rb,
lib/fir/util.rb,
lib/fir/version.rb,
lib/fir/util/info.rb,
lib/fir/util/build.rb,
lib/fir/util/login.rb,
lib/fir/util/publish.rb

Defined Under Namespace

Modules: Build, Info, Login, Publish, Util Classes: CLI

Constant Summary collapse

CONFIG_PATH =
"#{ENV['HOME']}/.fir-cli"
API_YML_PATH =
"#{File.dirname(__FILE__)}/fir/api.yml"
APP_FILE_TYPE =
%w(.ipa .apk).freeze
VERSION =
"1.0.7"

Class Attribute Summary collapse

Class Method Summary collapse

Methods included from Util

included

Class Attribute Details

.apiObject

Returns the value of attribute api.



33
34
35
# File 'lib/fir.rb', line 33

def api
  @api
end

.configObject

Returns the value of attribute config.



33
34
35
# File 'lib/fir.rb', line 33

def config
  @config
end

.loggerObject

Returns the value of attribute logger.



33
34
35
# File 'lib/fir.rb', line 33

def logger
  @logger
end

Class Method Details

.current_tokenObject



51
52
53
# File 'lib/fir.rb', line 51

def current_token
  @token ||= config[:token] if config
end

.get(url, params = {}) ⇒ Object



55
56
57
58
59
60
61
62
63
# File 'lib/fir.rb', line 55

def get url, params = {}
  begin
    res = RestClient.get(url, params: params)
  rescue RestClient::Exception => e
    logger.error e.response
    exit 1
  end
  JSON.parse(res.body.force_encoding("UTF-8"), symbolize_names: true)
end

.post(url, query, content_type = :json) ⇒ Object



65
66
67
68
69
70
71
72
73
# File 'lib/fir.rb', line 65

def post url, query, content_type = :json
  begin
    res = RestClient.post(url, query, { content_type: content_type })
  rescue RestClient::Exception => e
    logger.error e.response
    exit 1
  end
  JSON.parse(res.body.force_encoding("UTF-8"), symbolize_names: true)
end

.put(url, query, content_type = :json) ⇒ Object



75
76
77
78
79
80
81
82
83
# File 'lib/fir.rb', line 75

def put url, query, content_type = :json
  begin
    res = RestClient.put(url, query, { content_type: content_type })
  rescue RestClient::Exception => e
    logger.error e.response
    exit 1
  end
  JSON.parse(res.body.force_encoding("UTF-8"), symbolize_names: true)
end

.reload_configObject



43
44
45
# File 'lib/fir.rb', line 43

def reload_config
  @config = YAML.load_file(CONFIG_PATH).symbolize_keys
end

.write_config(hash) ⇒ Object



47
48
49
# File 'lib/fir.rb', line 47

def write_config hash
  File.open(CONFIG_PATH, 'w+') { |f| f << YAML.dump(hash) }
end