cdd 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in cdd.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 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.
@@ -0,0 +1,55 @@
1
+ # CDD - Collaborative Drug Discovery
2
+
3
+ Collaborative Drug Discovery is a web based tool for storing and sharing pharmaceutical research. This is a ruby wrapper for their API.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'cdd'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install cdd
18
+
19
+ ## Usage
20
+
21
+ Setup your client:
22
+
23
+ ```ruby
24
+ require 'cdd'
25
+ cdd = CDD::Client.new(YOUR_TOKEN)
26
+ ```
27
+
28
+ Retrieve your vaults
29
+
30
+ ```ruby
31
+ vaults = cdd.vaults
32
+ ```
33
+
34
+ Returns a list of vault objects that look like:
35
+ ```ruby
36
+ [{"name"=>"Your Vault Name", "id"=>1234}]
37
+ ```
38
+
39
+ With a vault object, you can retrieve it's project list:
40
+ ```ruby
41
+ projects = vaults.first.projects
42
+ ```
43
+
44
+ Returns a list of project objects that look like:
45
+ ```ruby
46
+ [{"name"=>"Your Project Name", "id"=>1234}]
47
+ ```
48
+
49
+ ## Contributing
50
+
51
+ 1. Fork it
52
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
53
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
54
+ 4. Push to the branch (`git push origin my-new-feature`)
55
+ 5. Create new Pull Request
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,22 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/cdd/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Christopher Petersen"]
6
+ gem.email = ["christopher.petersen@gmail.com"]
7
+ gem.description = %q{A ruby wrapper for CDD's API}
8
+ gem.summary = %q{Collaborative Drug Discovery is a web based tool for storing and sharing pharmaceutical research. This is a ruby wrapper for their API.}
9
+ gem.homepage = "http://github.com/cpetersen/cdd"
10
+
11
+ gem.add_dependency('json')
12
+ gem.add_dependency('rest-client')
13
+ gem.add_development_dependency('rake')
14
+ gem.add_development_dependency('rspec')
15
+
16
+ gem.files = `git ls-files`.split($\)
17
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
18
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
19
+ gem.name = "cdd"
20
+ gem.require_paths = ["lib"]
21
+ gem.version = CDD::VERSION
22
+ end
@@ -0,0 +1,4 @@
1
+ require "cdd/client"
2
+ require "cdd/project"
3
+ require "cdd/vault"
4
+ require "cdd/version"
@@ -0,0 +1,29 @@
1
+ require "rest_client"
2
+ require "json"
3
+
4
+ module CDD
5
+ class Client
6
+ attr_accessor :token
7
+ attr_accessor :url
8
+
9
+ def initialize(token, options={})
10
+ self.token = token
11
+ self.url = options[:url] || "https://app.collaborativedrug.com"
12
+ end
13
+
14
+ def vaults
15
+ execute(vaults_uri).collect do |hash|
16
+ CDD::Vault.new(self,hash)
17
+ end
18
+ end
19
+
20
+ def vaults_uri
21
+ "/api/v1/vaults"
22
+ end
23
+
24
+ def execute(uri, params={})
25
+ response = RestClient.get "#{self.url}#{uri}", { :params => params, "X-CDD-Token" => token }
26
+ JSON.parse(response.to_s)
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,22 @@
1
+ module CDD
2
+ class Project
3
+ attr_accessor :id
4
+ attr_accessor :name
5
+ attr_accessor :client
6
+
7
+ def initialize(client, options={})
8
+ self.client = client
9
+ options.each do |k,v|
10
+ self.send("#{k}=",v)
11
+ end
12
+ end
13
+
14
+ def projects
15
+ client.execute(projects_url)
16
+ end
17
+
18
+ def projects_url
19
+ "/api/v1/vaults/#{self.id}/projects"
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,24 @@
1
+ module CDD
2
+ class Vault
3
+ attr_accessor :id
4
+ attr_accessor :name
5
+ attr_accessor :client
6
+
7
+ def initialize(client, options={})
8
+ self.client = client
9
+ options.each do |k,v|
10
+ self.send("#{k}=",v)
11
+ end
12
+ end
13
+
14
+ def projects
15
+ client.execute(projects_url).collect do |hash|
16
+ CDD::Project.new(self.client, hash)
17
+ end
18
+ end
19
+
20
+ def projects_url
21
+ "/api/v1/vaults/#{self.id}/projects"
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,3 @@
1
+ module CDD
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,127 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cdd
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Christopher Petersen
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-01-17 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: json
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rest-client
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rake
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: rspec
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ description: A ruby wrapper for CDD's API
79
+ email:
80
+ - christopher.petersen@gmail.com
81
+ executables: []
82
+ extensions: []
83
+ extra_rdoc_files: []
84
+ files:
85
+ - .gitignore
86
+ - Gemfile
87
+ - LICENSE
88
+ - README.md
89
+ - Rakefile
90
+ - cdd.gemspec
91
+ - lib/cdd.rb
92
+ - lib/cdd/client.rb
93
+ - lib/cdd/project.rb
94
+ - lib/cdd/vault.rb
95
+ - lib/cdd/version.rb
96
+ homepage: http://github.com/cpetersen/cdd
97
+ licenses: []
98
+ post_install_message:
99
+ rdoc_options: []
100
+ require_paths:
101
+ - lib
102
+ required_ruby_version: !ruby/object:Gem::Requirement
103
+ none: false
104
+ requirements:
105
+ - - ! '>='
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ segments:
109
+ - 0
110
+ hash: -2264778669571184428
111
+ required_rubygems_version: !ruby/object:Gem::Requirement
112
+ none: false
113
+ requirements:
114
+ - - ! '>='
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ segments:
118
+ - 0
119
+ hash: -2264778669571184428
120
+ requirements: []
121
+ rubyforge_project:
122
+ rubygems_version: 1.8.24
123
+ signing_key:
124
+ specification_version: 3
125
+ summary: Collaborative Drug Discovery is a web based tool for storing and sharing
126
+ pharmaceutical research. This is a ruby wrapper for their API.
127
+ test_files: []