Module: App

Includes:
API, Watch
Defined in:
lib/app.rb

Constant Summary

Constants included from API

API::API_PATHS

Class Method Summary collapse

Class Method Details

.apiObject



30
31
32
# File 'lib/app.rb', line 30

def self.api
  HTTP
end

.setupObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/app.rb', line 9

def self.setup
  # Create config file
  unless File.exists? @config_path
    new_file = File.open(@config_path, 'w')
    new_file.write $DEFAULT_CONFIG
    new_file.close
  end

  # Read and Parse config file
  @config_file = File.open(@config_path, 'r')
  @config = JSON.parse(@config_file.read)

  if @config['email'].empty? or @config['pass'].empty?
    abort "You have not configured your credentials yet, add them to ~/.pack"
  end

  @config['username'] = @config['email'][/[^@]*/]

  self.api.setup(@config)
end

.watch(path, &fn) ⇒ Object



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

def self.watch(path, &fn)
  Watch.watch path, &fn
end