assaydepot 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5565b98889ea2e4abfde64c7a86b9f10bb7007d9
4
+ data.tar.gz: 3637b96d37f982f765c312d15cd1b98cbf2ad728
5
+ SHA512:
6
+ metadata.gz: d465642914b663fec3017aa5c50e32a7b9a83eee1220a27a199f9f718ad5599fbfc8b4ede16c8596a5fe388d9900d9291e6e6bc7338e244f68dc9a0962f45a63
7
+ data.tar.gz: b9793e07b1c15fc4d53ac949c21b534a27bfcbf4c5f532baec682af4281c3b4a414b1df4727aedb0e1de555436335450205922d2d9d57c3b2dbbd3149a6e3d06
@@ -0,0 +1,5 @@
1
+ before_script:
2
+ - export ASSAYDEPOT_APP_ID=6hH3KQZz9oqR5lqtckyqfAUcyfNgHQ
3
+ - export ASSAYDEPOT_APP_SECRET=FDwDYchR220FSYDPtqS12e-P0pjx-7y_tbba3wyr-3VschLuVgpvOBBL
4
+ script:
5
+ - bundle exec rake spec
@@ -0,0 +1,10 @@
1
+ #The MIT License (MIT)
2
+
3
+ Copyright (c) 2012 Assay Depot
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
10
+
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Assay Depot
1
+ # Assay Depot ![Build Status](https://secure.travis-ci.org/assaydepot/assaydepot-rb.png) [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/assaydepot/assaydepot-rb)
2
2
 
3
3
  Ruby interface for Assay Depot's online laboratory (http://www.assaydepot.com).
4
4
 
@@ -66,3 +66,7 @@ AssayDepot::Provider.get(providers.first["id"])
66
66
  3. Commit your changes (`git commit -am 'Added some feature'`)
67
67
  4. Push to the branch (`git push origin my-new-feature`)
68
68
  5. Create new Pull Request
69
+
70
+ ## License
71
+
72
+ The Assay Depot Ruby SDK is released under the MIT license.
data/Rakefile CHANGED
@@ -1,2 +1,8 @@
1
1
  #!/usr/bin/env rake
2
2
  require "bundler/gem_tasks"
3
+
4
+ require 'rspec/core/rake_task'
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ task :test => :spec
8
+ task :default => :spec
@@ -9,11 +9,15 @@ Gem::Specification.new do |gem|
9
9
  gem.homepage = "https://github.com/assaydepot/assaydepot-rb"
10
10
 
11
11
  gem.add_dependency('json')
12
+ gem.add_development_dependency('rake')
13
+ gem.add_development_dependency('rspec')
14
+ gem.add_development_dependency('oauth2')
12
15
 
13
16
  gem.files = `git ls-files`.split($\)
14
17
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
15
18
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
16
19
  gem.name = "assaydepot"
17
20
  gem.require_paths = ["lib"]
21
+
18
22
  gem.version = AssayDepot::VERSION
19
23
  end
@@ -4,23 +4,4 @@ require "assaydepot/client"
4
4
  require "assaydepot/model"
5
5
  require "assaydepot/ware"
6
6
  require "assaydepot/provider"
7
-
8
- # Twitter.configure do |config|
9
- # config.consumer_key = YOUR_CONSUMER_KEY
10
- # config.consumer_secret = YOUR_CONSUMER_SECRET
11
- # config.oauth_token = YOUR_OAUTH_TOKEN
12
- # config.oauth_token_secret = YOUR_OAUTH_TOKEN_SECRET
13
- # end
14
-
15
- module AssayDepot
16
- class << self
17
- include AssayDepot::Configurable
18
- end
19
-
20
- # Delegate to a AssayDepot::Client
21
- #
22
- # @return [AssayDepot::Client]
23
- def client
24
- AssayDepot::Client.new(options)
25
- end
26
- end
7
+ require "assaydepot/core"
@@ -8,11 +8,11 @@ module AssayDepot
8
8
  end
9
9
 
10
10
  def search_url(params={})
11
- "#{AssayDepot.url}/#{@search_type}.json?#{params.collect { |k,v| "#{k}=#{v.to_s.gsub(" ","+")}"}.join("&")}"
11
+ "#{AssayDepot.url}/#{@search_type}.json"
12
12
  end
13
13
 
14
14
  def get_url(id, params={})
15
- "#{AssayDepot.url}/#{@search_type}/#{id}.json?#{params.collect { |k,v| "#{k}=#{v.to_s.gsub(" ","+")}"}.join("&")}"
15
+ "#{AssayDepot.url}/#{@search_type}/#{id}.json"
16
16
  end
17
17
 
18
18
  def search(query, facets, params={})
@@ -21,12 +21,16 @@ module AssayDepot
21
21
  facets.map do |name,value|
22
22
  params["facets[#{name}][]"] = value
23
23
  end
24
- JSON.parse(open(search_url(params)).read)
24
+ execute(search_url, params)
25
25
  end
26
26
 
27
27
  def get(id, params={})
28
28
  params["access_token"] = AssayDepot.access_token
29
- JSON.parse(open(get_url(id, params)).read)
29
+ execute(get_url(id), params)
30
+ end
31
+
32
+ def execute(url, params)
33
+ JSON.parse(open("#{url}?#{params.collect { |k,v| "#{k}=#{v.to_s.gsub(" ","+")}"}.join("&")}").read)
30
34
  end
31
35
  end
32
36
  end
@@ -0,0 +1,12 @@
1
+ module AssayDepot
2
+ class << self
3
+ include ::AssayDepot::Configurable
4
+ end
5
+
6
+ # Delegate to a AssayDepot::Client
7
+ #
8
+ # @return [AssayDepot::Client]
9
+ def client
10
+ ::AssayDepot::Client.new(options)
11
+ end
12
+ end
@@ -79,7 +79,7 @@ module AssayDepot
79
79
 
80
80
  def find(query)
81
81
  result = self.clone
82
- result.search_query = search_query
82
+ result.search_query = query
83
83
  result
84
84
  end
85
85
 
@@ -1,6 +1,6 @@
1
1
  module AssayDepot
2
2
  class Provider
3
- include Model
3
+ include ::AssayDepot::Model
4
4
 
5
5
  def self.search_type
6
6
  "providers"
@@ -1,3 +1,3 @@
1
1
  module AssayDepot
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -1,6 +1,6 @@
1
1
  module AssayDepot
2
2
  class Ware
3
- include Model
3
+ include ::AssayDepot::Model
4
4
 
5
5
  def self.search_type
6
6
  "wares"
@@ -0,0 +1,128 @@
1
+ require 'oauth2'
2
+ require 'assaydepot'
3
+
4
+ describe AssayDepot do
5
+ let(:site) { "https://staging.assaydepot.com" }
6
+
7
+ context "when accessing the api via oauth2 client credentials" do
8
+ let(:client) {
9
+ OAuth2::Client.new( ENV["ASSAYDEPOT_APP_ID"],
10
+ ENV["ASSAYDEPOT_APP_SECRET"],
11
+ :site => site)
12
+ }
13
+ let(:access_token) { client.client_credentials.get_token(:redirect_uri => 'http://localhost:4567/oauth2/callback') }
14
+ before(:all) do
15
+ AssayDepot.configure do |config|
16
+ config.access_token = access_token.token
17
+ config.url = "#{site}/api"
18
+ end
19
+ end
20
+
21
+ context "and searching for wares matching \"antibody\"" do
22
+ let(:wares) { AssayDepot::Ware.find("antibody") }
23
+
24
+ it "should return a Ware object" do
25
+ wares.class.should == AssayDepot::Ware
26
+ end
27
+
28
+ it "should return some wares" do
29
+ wares.total.should > 1
30
+ end
31
+
32
+ context "and getting the details for the first ware" do
33
+ let(:ware_result) { AssayDepot::Ware.get(wares.first["id"]) }
34
+
35
+ it "should have a ware" do
36
+ ware_result["ware"].should_not be_nil
37
+ end
38
+
39
+ it "should have a description" do
40
+ ware_result["ware"]["description"].should_not be_nil
41
+ end
42
+ end
43
+ end
44
+
45
+ context "when searching for wares of type CustomService" do
46
+ let(:wares) { AssayDepot::Ware.where(:ware_type => "CustomService") }
47
+ it "should return facets" do
48
+ wares.facets.should_not be_empty
49
+ end
50
+
51
+ it "should include the source facet" do
52
+ wares.facets.should include("source")
53
+ end
54
+
55
+ it "should include the ware_type facet" do
56
+ wares.facets.should include("ware_type")
57
+ end
58
+
59
+ it "should include the available_provider_names facet" do
60
+ wares.facets.should include("available_provider_names")
61
+ end
62
+
63
+ it "should include the certifications facet" do
64
+ wares.facets.should include("certifications")
65
+ end
66
+
67
+ it "should include the countries facet" do
68
+ wares.facets.should include("countries")
69
+ end
70
+
71
+ it "should include the protein_type facet" do
72
+ wares.facets.should include("protein_type")
73
+ end
74
+
75
+ it "should include the clonality facet" do
76
+ wares.facets.should include("clonality")
77
+ end
78
+
79
+ it "should include the cell_source facet" do
80
+ wares.facets.should include("cell_source")
81
+ end
82
+
83
+ it "should include the species facet" do
84
+ wares.facets.should include("species")
85
+ end
86
+
87
+ it "should include the tissue facet" do
88
+ wares.facets.should include("tissue")
89
+ end
90
+ end
91
+
92
+ context "when searching for wares using a chained query" do
93
+ let(:wares) { AssayDepot::Ware.where(:ware_type => "CustomService").where(:available_provider_names => "Assay Depot").page(2) }
94
+
95
+ it "should return wares" do
96
+ wares.total.should > 1
97
+ end
98
+
99
+ it "the ware's name should be available" do
100
+ wares.first["name"].should_not be_nil
101
+ end
102
+ end
103
+
104
+ context "and searching for providers that start with the letter a" do
105
+ let(:providers) { AssayDepot::Provider.where(:starts_with => "a").per_page(50) }
106
+
107
+ it "should return a Provider object" do
108
+ providers.class.should == AssayDepot::Provider
109
+ end
110
+
111
+ it "should return some providers" do
112
+ providers.total.should > 1
113
+ end
114
+
115
+ context "and getting the details for the first provider" do
116
+ let(:provider_result) { AssayDepot::Provider.get(providers.first["id"]) }
117
+
118
+ it "should have a provider" do
119
+ provider_result["provider"].should_not be_nil
120
+ end
121
+
122
+ it "should have a description" do
123
+ provider_result["provider"]["description"].should_not be_nil
124
+ end
125
+ end
126
+ end
127
+ end
128
+ end
metadata CHANGED
@@ -1,30 +1,69 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: assaydepot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
5
- prerelease:
4
+ version: 0.0.3
6
5
  platform: ruby
7
6
  authors:
8
7
  - Christopher Petersen
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-08-09 00:00:00.000000000 Z
11
+ date: 2015-08-14 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: json
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: oauth2
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
28
67
  - !ruby/object:Gem::Version
29
68
  version: '0'
30
69
  description: This is the first version of Assay Depot's Ruby SDK. It provides read
@@ -36,40 +75,43 @@ extensions: []
36
75
  extra_rdoc_files: []
37
76
  files:
38
77
  - .gitignore
78
+ - .travis.yml
39
79
  - Gemfile
40
- - LICENSE
80
+ - LICENSE.md
41
81
  - README.md
42
82
  - Rakefile
43
83
  - assaydepot.gemspec
44
84
  - lib/assaydepot.rb
45
85
  - lib/assaydepot/client.rb
46
86
  - lib/assaydepot/configurable.rb
87
+ - lib/assaydepot/core.rb
47
88
  - lib/assaydepot/model.rb
48
89
  - lib/assaydepot/provider.rb
49
90
  - lib/assaydepot/version.rb
50
91
  - lib/assaydepot/ware.rb
92
+ - spec/assaydepot_spec.rb
51
93
  homepage: https://github.com/assaydepot/assaydepot-rb
52
94
  licenses: []
95
+ metadata: {}
53
96
  post_install_message:
54
97
  rdoc_options: []
55
98
  require_paths:
56
99
  - lib
57
100
  required_ruby_version: !ruby/object:Gem::Requirement
58
- none: false
59
101
  requirements:
60
- - - ! '>='
102
+ - - '>='
61
103
  - !ruby/object:Gem::Version
62
104
  version: '0'
63
105
  required_rubygems_version: !ruby/object:Gem::Requirement
64
- none: false
65
106
  requirements:
66
- - - ! '>='
107
+ - - '>='
67
108
  - !ruby/object:Gem::Version
68
109
  version: '0'
69
110
  requirements: []
70
111
  rubyforge_project:
71
- rubygems_version: 1.8.24
112
+ rubygems_version: 2.4.2
72
113
  signing_key:
73
- specification_version: 3
114
+ specification_version: 4
74
115
  summary: Provides read access to Assay Depot's Services and Vendors.
75
- test_files: []
116
+ test_files:
117
+ - spec/assaydepot_spec.rb
data/LICENSE DELETED
@@ -1,22 +0,0 @@
1
- Copyright (c) 2012 Christopher Petersen
2
-
3
- MIT License
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining
6
- a copy of this software and associated documentation files (the
7
- "Software"), to deal in the Software without restriction, including
8
- without limitation the rights to use, copy, modify, merge, publish,
9
- distribute, sublicense, and/or sell copies of the Software, and to
10
- permit persons to whom the Software is furnished to do so, subject to
11
- the following conditions:
12
-
13
- The above copyright notice and this permission notice shall be
14
- included in all copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.