Module: ClassicApi
- Includes:
- ActiveSupport::Configurable
- Defined in:
- lib/classic_api.rb,
lib/classic_api/version.rb,
lib/classic_api/util/format.rb,
lib/classic_api/command/base.rb,
lib/classic_api/command/main.rb,
lib/classic_api/command/users.rb,
lib/classic_api/query/builder.rb,
lib/classic_api/resource/base.rb,
lib/classic_api/resource/user.rb,
lib/classic_api/command/images.rb,
lib/classic_api/resource/image.rb,
lib/classic_api/query/requestor.rb,
lib/classic_api/resource/policy.rb,
lib/classic_api/resource/transformation.rb
Defined Under Namespace
Modules: Command, Query, Resource, Util
Classes: APIEntityException, ValidationError
Constant Summary
collapse
- VERSION =
"1.0.0"
Class Method Summary
collapse
Class Method Details
.load_config(path) ⇒ Object
21
22
23
24
25
26
27
|
# File 'lib/classic_api.rb', line 21
def self.load_config(path)
path = File.expand_path(path)
yaml_config = YAML.load_file(path)
config.site = yaml_config["classic"]["site"]
config.api_key = yaml_config["classic"]["api_key"]
config
end
|
.login(site = nil, api_key = nil) ⇒ Object
39
40
41
42
43
44
45
46
47
|
# File 'lib/classic_api.rb', line 39
def self.login(site=nil, api_key=nil)
config.site = site unless site.nil?
config.api_key = api_key unless api_key.nil?
Resource::Base.site = config.site
Resource::Base.connection(true) do |c|
c.faraday.["X-Classic-Api-Key"] = config.api_key
end
self
end
|
.save_config(path) ⇒ Object
29
30
31
32
33
34
35
36
37
|
# File 'lib/classic_api.rb', line 29
def self.save_config(path)
path = File.expand_path(path)
FileUtils.mkdir_p(File.dirname(path)) if !File.directory?(File.dirname(path))
yaml_config = YAML.load_file(path)
yaml_config["classic"]["site"] = config.site
yaml_config["classic"]["api_key"] = config.api_key
File.open(File.expand_path(path), "w") {|file| file << YAML.dump(yaml_config)}
true
end
|