Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updates byebug (development) to latest version. Stubs all remaining s…
…hared test frameworks (and they run!).
- Loading branch information
Showing
11 changed files
with
374 additions
and
6 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
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
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,76 @@ | ||
class Bark::Request::GraphOfLife < Bark::Request | ||
|
||
API_VERSION = 'v2' | ||
SEARCH_BASE = [Bark::Request::BASE_URL, API_VERSION, 'graph'].join("/") | ||
|
||
# Method: {parameters} | ||
METHODS = { | ||
gol_about: %i{}, | ||
gol_source_tree: %i{}, | ||
gol_node_info: %i{}, # tree_id "is superflous and can be ignored" | ||
} | ||
|
||
# node_ids or ott_ids are required in some cases, so this | ||
# will have to be cased | ||
REQUIRED_PARAMS = { | ||
} | ||
|
||
mrp = {} | ||
|
||
REQUIRED_PARAMS.each do |k,v| | ||
v.each do |m| | ||
mrp[m].push(k) if mrp[m] | ||
mrp[m] ||= [k] | ||
end | ||
end | ||
|
||
METHODS_REQUIRED_PARAMS = mrp | ||
|
||
def initialize(method: :tol_about, params: {}) | ||
assign_options(method: method, params: params) | ||
build_uri if valid? | ||
end | ||
|
||
def assign_options(method: method, params: params) | ||
@method = method | ||
@params = params | ||
@params ||= {} | ||
end | ||
|
||
def valid? | ||
raise "Method #{@method} not recognized." if @method && !self.class::METHODS.keys.include?(@method) | ||
!@method.nil? && params_are_supported? && has_required_params? | ||
end | ||
|
||
def has_required_params? | ||
case @method | ||
when :gol_of_life | ||
end | ||
return true | ||
end | ||
|
||
def json_payload | ||
JSON.generate(@params) | ||
end | ||
|
||
private | ||
|
||
# TODO: this doesn't feel right (or could be generalized out to superclass) | ||
def build_uri | ||
@uri = URI( SEARCH_BASE + '/' + send("#{@method}_url") ) | ||
end | ||
|
||
def gol_about_url | ||
'about' | ||
end | ||
|
||
def gol_source_tree_url | ||
'source_tree' | ||
end | ||
|
||
def gol_node_info_url | ||
'node_info' | ||
end | ||
|
||
|
||
end |
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,78 @@ | ||
class Bark::Request::Taxonomy < Bark::Request | ||
|
||
API_VERSION = 'v2' | ||
SEARCH_BASE = [Bark::Request::BASE_URL, API_VERSION, 'taxonomy'].join("/") | ||
|
||
# Method: {parameters} | ||
METHODS = { | ||
taxonomy_about: %i{}, | ||
taxonomy_lica: %i{}, | ||
taxonomy_subtree: %i{}, | ||
taxonomy_taxon: %i{}, | ||
} | ||
|
||
REQUIRED_PARAMS = { | ||
} | ||
|
||
mrp = {} | ||
|
||
REQUIRED_PARAMS.each do |k,v| | ||
v.each do |m| | ||
mrp[m].push(k) if mrp[m] | ||
mrp[m] ||= [k] | ||
end | ||
end | ||
|
||
METHODS_REQUIRED_PARAMS = mrp | ||
|
||
def initialize(method: :tol_about, params: {}) | ||
assign_options(method: method, params: params) | ||
build_uri if valid? | ||
end | ||
|
||
def assign_options(method: method, params: params) | ||
@method = method | ||
@params = params | ||
@params ||= {} | ||
end | ||
|
||
def valid? | ||
raise "Method #{@method} not recognized." if @method && !self.class::METHODS.keys.include?(@method) | ||
!@method.nil? && params_are_supported? && has_required_params? | ||
end | ||
|
||
def has_required_params? | ||
case @method | ||
when :taxonomy_about | ||
end | ||
return true | ||
end | ||
|
||
def json_payload | ||
JSON.generate(@params) | ||
end | ||
|
||
private | ||
|
||
# TODO: this doesn't feel right (or could be generalized out to superclass) | ||
def build_uri | ||
@uri = URI( SEARCH_BASE + '/' + send("#{@method}_url") ) | ||
end | ||
|
||
def taxonomy_about_url | ||
'about' | ||
end | ||
|
||
def taxonomy_lica_url | ||
'lica' | ||
end | ||
|
||
def taxonomy_subtree_url | ||
'subtree' | ||
end | ||
|
||
def taxonomy_taxon_url | ||
'taxon' | ||
end | ||
|
||
end |
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,75 @@ | ||
class Bark::Request::Tnrs < Bark::Request | ||
|
||
API_VERSION = 'v2' | ||
SEARCH_BASE = [Bark::Request::BASE_URL, API_VERSION, 'tnrs'].join("/") | ||
|
||
# Method: {parameters} | ||
METHODS = { | ||
tnrs_match_names: %i{}, | ||
tnrs_contexts: %i{}, | ||
tnrs_infer_context: %i{}, | ||
} | ||
|
||
# node_ids or ott_ids are required in some cases, so this | ||
# will have to be cased | ||
REQUIRED_PARAMS = { | ||
} | ||
|
||
mrp = {} | ||
|
||
REQUIRED_PARAMS.each do |k,v| | ||
v.each do |m| | ||
mrp[m].push(k) if mrp[m] | ||
mrp[m] ||= [k] | ||
end | ||
end | ||
|
||
METHODS_REQUIRED_PARAMS = mrp | ||
|
||
def initialize(method: :tol_about, params: {}) | ||
assign_options(method: method, params: params) | ||
build_uri if valid? | ||
end | ||
|
||
def assign_options(method: method, params: params) | ||
@method = method | ||
@params = params | ||
@params ||= {} | ||
end | ||
|
||
def valid? | ||
raise "Method #{@method} not recognized." if @method && !self.class::METHODS.keys.include?(@method) | ||
!@method.nil? && params_are_supported? && has_required_params? | ||
end | ||
|
||
def has_required_params? | ||
#case @method | ||
#when :foo | ||
#end | ||
return true | ||
end | ||
|
||
def json_payload | ||
JSON.generate(@params) | ||
end | ||
|
||
private | ||
|
||
# TODO: this doesn't feel right (or could be generalized out to superclass) | ||
def build_uri | ||
@uri = URI( SEARCH_BASE + '/' + send("#{@method}_url") ) | ||
end | ||
|
||
def tnrs_match_names_url | ||
'match_names' | ||
end | ||
|
||
def tnrs_contexts_url | ||
'contexts' | ||
end | ||
|
||
def tnrs_infer_context_url | ||
'infer_context' | ||
end | ||
|
||
end |
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,44 @@ | ||
require 'spec_helper' | ||
|
||
describe Bark::Request::GraphOfLife do | ||
|
||
#context 'Ruby/Bark specific implementation' do | ||
# specify 'is written for an API_VERSION' do | ||
# expect( Bark::Request::TreeOfLife::API_VERSION).to eq('v2') | ||
# end | ||
|
||
# specify 'has an SEARCH_BASE' do | ||
# expect( Bark::Request::TreeOfLife::SEARCH_BASE).to eq('http://devapi.opentreeoflife.org/v2/tree_of_life') | ||
# end | ||
|
||
# specify 'reference methods by ot API wrapper shared name in METHODS' do | ||
# expect( Bark::Request::TreeOfLife::METHODS.keys.sort).to eq(%i{tol_about tol_mrca tol_subtree tol_induced_tree}.sort) | ||
# end | ||
|
||
# context 'building a request URI' do | ||
# specify 'for find_tree_of_life' do | ||
# a = Bark::Request::TreeOfLife.new(method: :tol_about) | ||
# expect(a.uri.to_s).to eq('http://devapi.opentreeoflife.org/v2/tree_of_life/about') | ||
# end | ||
|
||
# specify 'for matched_tree_of_life' do | ||
# a = Bark::Request::TreeOfLife.new(method: :tol_mrca) | ||
# expect(a.uri.to_s).to eq('http://devapi.opentreeoflife.org/v2/tree_of_life/mrca') | ||
# end | ||
# end | ||
|
||
# context 'basic use, for :about, in a response' do | ||
# specify 'works' do | ||
# a = Bark::Request::TreeOfLife.new(method: :tol_about, params: {}) | ||
# b = Bark::Response.new(request: a) | ||
# expect(b.request_succeeded?).to be(true) | ||
# expect(b.json.keys.include?('root_node_id')).to be(true) | ||
# end | ||
# end | ||
|
||
context 'shared tests' do | ||
run_tests(Bark::Request::GraphOfLife, SharedTestsHelper::SHARED_TESTS['graph_of_life']) | ||
end | ||
|
||
# end | ||
end |
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,44 @@ | ||
require 'spec_helper' | ||
|
||
describe Bark::Request::Taxonomy do | ||
|
||
#context 'Ruby/Bark specific implementation' do | ||
# specify 'is written for an API_VERSION' do | ||
# expect( Bark::Request::TreeOfLife::API_VERSION).to eq('v2') | ||
# end | ||
|
||
# specify 'has an SEARCH_BASE' do | ||
# expect( Bark::Request::TreeOfLife::SEARCH_BASE).to eq('http://devapi.opentreeoflife.org/v2/tree_of_life') | ||
# end | ||
|
||
# specify 'reference methods by ot API wrapper shared name in METHODS' do | ||
# expect( Bark::Request::TreeOfLife::METHODS.keys.sort).to eq(%i{tol_about tol_mrca tol_subtree tol_induced_tree}.sort) | ||
# end | ||
|
||
# context 'building a request URI' do | ||
# specify 'for find_tree_of_life' do | ||
# a = Bark::Request::TreeOfLife.new(method: :tol_about) | ||
# expect(a.uri.to_s).to eq('http://devapi.opentreeoflife.org/v2/tree_of_life/about') | ||
# end | ||
|
||
# specify 'for matched_tree_of_life' do | ||
# a = Bark::Request::TreeOfLife.new(method: :tol_mrca) | ||
# expect(a.uri.to_s).to eq('http://devapi.opentreeoflife.org/v2/tree_of_life/mrca') | ||
# end | ||
# end | ||
|
||
# context 'basic use, for :about, in a response' do | ||
# specify 'works' do | ||
# a = Bark::Request::TreeOfLife.new(method: :tol_about, params: {}) | ||
# b = Bark::Response.new(request: a) | ||
# expect(b.request_succeeded?).to be(true) | ||
# expect(b.json.keys.include?('root_node_id')).to be(true) | ||
# end | ||
# end | ||
|
||
context 'shared tests' do | ||
run_tests(Bark::Request::Taxonomy, SharedTestsHelper::SHARED_TESTS['taxonomy']) | ||
end | ||
|
||
# end | ||
end |
Oops, something went wrong.