Top Level Namespace

Defined Under Namespace

Modules: Rakugoka

Instance Method Summary collapse

Instance Method Details

#load_api_keyObject



4
5
6
7
8
9
10
11
12
13
# File 'lib/rakugoka.rb', line 4

def load_api_key
  config_file = ENV["HOME"] + "/.rakugoka"
  if File.exists?(config_file)
    config = YAML.load(File.read(config_file))
  else
    config = {"api_key" => RestClient.post("#{REMOTE_HOST}/api_keys", {}).to_s}
    File.open(config_file, "w") {|fh| fh.write YAML.dump(config) }
  end
  config["api_key"]
end

#load_project_url(api_key) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/rakugoka.rb', line 15

def load_project_url(api_key)
  project_config_file = Dir.pwd + "/rakugoka.yml"
  if File.exists?(project_config_file)
    project = YAML.load(File.read(project_config_file))["location"]
  else
    response = RestClient.post("#{REMOTE_HOST}/projects.xml", {"api_key" => api_key, "project[name]" => "Rakugoka import " + rand(1000).to_s })
    project = response.headers[:location]
    File.open(project_config_file, "w") {|fh| fh.write YAML.dump({"location" => project})}
  end
  project
end