Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Genki Sugawara
committed
May 17, 2015
1 parent
53b6e39
commit 335f305
Showing
3 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,3 +13,5 @@ | |
*.a | ||
mkmf.log | ||
test.rb | ||
Barkfile | ||
*.bark |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
class Barkdog::Client | ||
def initialize(options = {}) | ||
@options = options | ||
|
||
api_key, app_key = @options.values_at(:api_key, :application_key) | ||
raise 'API Key does not exist' unless api_key | ||
raise 'Application Key does not exist' unless app_key | ||
|
||
@dog = Dogapi::Client.new(api_key, app_key) | ||
end | ||
|
||
def export(export_options = {}) | ||
exported = Barkdog::Exporter.export(@dog, @options) | ||
Barkdog::DSL.convert(exported, @options) | ||
end | ||
|
||
def apply(file) | ||
walk(file) | ||
end | ||
|
||
private | ||
|
||
def walk(file) | ||
expected = load_file(file) | ||
actual = Barkdog::Exporter.export(@dog, @options) | ||
|
||
# XXX: | ||
[expected, actual] | ||
end | ||
|
||
def load_file(file) | ||
if file.kind_of?(String) | ||
open(file) do |f| | ||
Barkdog::DSL.parse(f.read, file) | ||
end | ||
elsif [File, Tempfile].any? {|i| file.kind_of?(i) } | ||
Barkdog::DSL.parse(file.read, file.path) | ||
else | ||
raise TypeError, "can't convert #{file} into File" | ||
end | ||
end | ||
end |