openbel-api 0.4.0-java → 0.5.0-java

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 84860112a47f326439806c8f6f81987e31a47121
4
- data.tar.gz: 55a1281b0db90eae0ba49b6314d3727c29225268
3
+ metadata.gz: 51e6f9a762021d8b56fd1bf8a2dfe97a42c97b98
4
+ data.tar.gz: 3f83ea9644a89fc9c019858594ebe6e31507a4b2
5
5
  SHA512:
6
- metadata.gz: 1a3d631752e68f0be2686c1bf8eb4efa13b19f803fe9dc9a1572a3171f36f881904e5c5279e537587ee9005c49fa12c5ff61cff096ac142f42d870eb5e653562
7
- data.tar.gz: 094034e7a35004b6e05da1174cad42e1b372a77e526159a939891824e2c20e309a658a15084a001551b9caafd1fc6c68ec6d06cd485dbe0f67c0a1c81762be41
6
+ metadata.gz: ada40940474506e44d79afb3300733149a363716b7d2bc8bf8232a3264079fd91f85b58ab8363554ff0f3a96c686e270f93f4eb907cbb789b9fa8bf9fce35d8a
7
+ data.tar.gz: 0166d8e47e7db5f1354df5cd7c8e6740f2da365d4f34747e4aabc6f7431eb9cfa21c83aed9e333ee11576c87529ccca5635fef8c04bf62e1a60ee75123bd2848
data/.gemspec CHANGED
@@ -1,6 +1,8 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = 'openbel-api'
3
- spec.version = '0.4.0'
3
+ spec.version = File.read(
4
+ File.join(File.expand_path(File.dirname(__FILE__)), 'VERSION')
5
+ )
4
6
  spec.summary = %q{The OpenBEL API provided over RESTful HTTP endpoints.}
5
7
  spec.description = %q{The OpenBEL API provides a RESTful API over HTTP to manage BEL knowledge.}
6
8
  spec.license = 'Apache-2.0'
@@ -9,13 +11,14 @@ Gem::Specification.new do |spec|
9
11
  'Nick Bargnesi',
10
12
  'William Hayes'
11
13
  ]
12
- spec.date = %q{2015-12-02}
14
+ spec.date = %q{2015-12-17}
13
15
  spec.email = %q{abargnesi@selventa.com}
14
16
  spec.files = [
15
17
  Dir.glob('app/**/*.{json,rb,ru}'),
16
18
  Dir.glob('config/**/*.{rb,yml}'),
17
19
  Dir.glob('lib/**/*.rb'),
18
20
  __FILE__,
21
+ 'VERSION',
19
22
  'CHANGELOG.md',
20
23
  'LICENSE',
21
24
  'INSTALL.md',
@@ -31,13 +34,13 @@ Gem::Specification.new do |spec|
31
34
  # Dependencies
32
35
 
33
36
  ## bel.rb
34
- spec.add_runtime_dependency 'bel', '0.4.0'
37
+ spec.add_runtime_dependency 'bel', '0.4.1'
35
38
 
36
39
  ## bel.rb plugin - annotation/namespace search
37
- spec.add_runtime_dependency 'bel-search-sqlite', '0.4.0'
40
+ spec.add_runtime_dependency 'bel-search-sqlite', '0.4.2'
38
41
 
39
42
  ## bel.rb plugin - RDF repository using Apache Jena
40
- spec.add_runtime_dependency 'bel-rdf-jena', '0.4.0'
43
+ spec.add_runtime_dependency 'bel-rdf-jena', '0.4.1'
41
44
 
42
45
  ## RDF - RDF abstraction
43
46
  spec.add_runtime_dependency 'rdf', '1.99.0'
@@ -3,7 +3,22 @@ All notable changes to openbel-api will be documented in this file. The curated
3
3
 
4
4
  This project adheres to [Semantic Versioning][Semantic Versioning].
5
5
 
6
- ## [0.4.0][0.4.0] - 2015-12-14
6
+ ## [0.5.0][0.5.0] - 2015-12-17
7
+ ### Added
8
+ - Report API version from executables (`openbel-api`, `openbel-config`) and REST API (`GET /api/version`) ([Issue #91][91]).
9
+ - Support for MongoDB user authentication ([Issue #92][92]).
10
+ - See [MongoDB User Authentication][MongoDB User Authentication].
11
+
12
+ ### Changed
13
+ - Namespace value autocompletion will not return identifier-based namespace (e.g. Entrez Gene) suggestions unless the namespace prefix is used. For example "p(AKT" will not suggest "EGID:207" although "p(EG:AKT" will.
14
+
15
+ ### Fixed
16
+ - Namespace value autocompletion will return the namespace prefix if the BEL term requires it. For example "p(AKT" will now suggest "HGNC:AKT1".
17
+ - Namespace value autocompletion now queries against the Resource RDF to lookup namespaces by prefix. Previously this resolves namespaces from hardcoded values in bel.rb.
18
+
19
+ -----
20
+
21
+ ## 0.4.0 - 2015-12-14
7
22
  ### Added
8
23
  - Evidence Store
9
24
  - Storage of evidence including creation, retrieval, modification, and deletion actions.
@@ -19,4 +34,8 @@ This project adheres to [Semantic Versioning][Semantic Versioning].
19
34
  - Retrieve equivalent namespace values from the individual.
20
35
  - Retrieve orthologous namespace values from the individual.
21
36
 
22
- [Semantic Versioning]: http://semver.org
37
+ [0.5.0]: https://github.com/OpenBEL/openbel-api/compare/0.4.0...0.5.0
38
+ [Semantic Versioning]: http://semver.org
39
+ [MongoDB User Authentication]: https://github.com/OpenBEL/openbel-api/wiki/Configuring-the-Evidence-Store#mongodb-user-authentication
40
+ [91]: https://github.com/OpenBEL/openbel-api/issues/91
41
+ [92]: https://github.com/OpenBEL/openbel-api/issues/92
data/README.md CHANGED
@@ -51,8 +51,9 @@ The OpenBEL API is built to run with [JRuby][JRuby] and [Java 8][Java 8].
51
51
  *System Requirements*
52
52
 
53
53
  - [Java 8][Java 8]
54
- - [JRuby][JRuby], 1.7.x or 9.x series (9.0.x.0 is recommended)
55
- - Follow [JRuby Getting Started][JRuby Getting Started] for installation instructions.
54
+ - [JRuby][JRuby], 9.x series (9.0.x.0 is recommended)
55
+ - The 9.x series is required due to a Ruby language 2.0 requirement.
56
+ - See "Installation" below for configuring JRuby and isolating the openbel-api application.
56
57
  - [MongoDB][MongoDB], version 3.0 or greater
57
58
  - Follow [MongoDB download][MongoDB download] page for download and installation instructions.
58
59
  - [SQLite][SQLite], version 3.8.0 or greater
@@ -64,6 +65,25 @@ The OpenBEL API is built to run with [JRuby][JRuby] and [Java 8][Java 8].
64
65
 
65
66
  The OpenBEL API is packaged and installed as a Ruby gem. A Ruby gem is packed library or application that runs on the Ruby virtual machine. In this case OpenBEL API runs only on [JRuby][JRuby].
66
67
 
68
+ #### JRuby Configuration
69
+
70
+ - Unpack JRuby archive.
71
+ - Export the JRUBY_HOME environment variable to the unpacked JRuby archive directory.
72
+ - Add "$JRUBY_HOME/bin" to your PATH environment variable.
73
+ - Export the GEM_HOME and GEM_PATH environment variable to any directory accessible to the current user. This is where JRuby gems will be installed. The OpenBEL API and dependencies will be installed into this directory for isolation from other Ruby applications running on the system.
74
+
75
+ *Example JRuby Configuration*
76
+
77
+ Assume that we have unpacked JRuby to `/opt/jruby`. We should then:
78
+
79
+ - Export `JRUBY_HOME` to `/opt/jruby`.
80
+ - Add `$JRUBY_HOME/bin` to our `PATH` environment variable.
81
+ - Export both `GEM_HOME` and `GEM_PATH` to `/opt/jruby/gems`.
82
+ - Add `$GEM_HOME/bin` to our `PATH` environment variable.
83
+ - Proceed with *Installation of OpenBEL API*.
84
+
85
+ #### Installation of OpenBEL API
86
+
67
87
  Installation uses the [RubyGems][RubyGems] site to download and install the gem from. To install the OpenBEL API gem run the `gem install` command available within your [JRuby][JRuby] installation.
68
88
 
69
89
  ```bash
@@ -72,6 +92,9 @@ gem install openbel-api
72
92
 
73
93
  All of the application dependencies needed by `openbel-api` will be installed during this process.
74
94
 
95
+ **Tip**
96
+ If the `openbel-api` executable is not available make sure `$GEM_HOME/bin` is included on your `PATH`. See *JRuby Configuration* above.
97
+
75
98
  ### Configuration
76
99
 
77
100
  The OpenBEL API requires a configuration file to set up a few things. You can create an initial configuration file using the `openbel-config` command.
@@ -93,6 +116,8 @@ evidence_store:
93
116
  database: 'openbel'
94
117
  ```
95
118
 
119
+ There are also settings for user authentication. See [MongoDB User Authentication][MongoDB User Authentication] on the wiki.
120
+
96
121
  *Resource RDF data*
97
122
  Annotations, namespaces, and dataset storage are represented as [RDF][RDF] data. The data is stored in an on-disk database using Apache Jena (Java library included with `openbel-api`).
98
123
 
@@ -176,9 +201,36 @@ openbel-api --file openbel-api-config.yml -- --port 9000 --threads 1:16
176
201
  **Note**
177
202
  Run `openbel-api --help` for more information and options.
178
203
 
204
+ ### Running behind Nginx (or another reverse proxy)
205
+
206
+ The OpenBEL API beings at the `/api` path. If you plan OpenBEL API behing a reverse proxy then you will want to setup a route to `/api`.
207
+
208
+ For example the following [Nginx][Nginx] configuration will proxy from `http://$hostname/api` to `http://localhost:9000/api`.
209
+
210
+ ```
211
+ server {
212
+ listen 0.0.0.0:80;
213
+ server_name $hostname;
214
+ access_log /var/log/nginx/access.log main;
215
+ error_log /var/log/nginx/error.log info;
216
+
217
+ location /api {
218
+ proxy_pass http://localhost:9000;
219
+ proxy_set_header Host $host;
220
+ proxy_set_header X-Real-IP $remote_addr;
221
+ proxy_set_header X-Real-Base-URL $scheme://$host;
222
+ proxy_set_header X-Real-URL $scheme://$host$request_uri;
223
+ proxy_buffer_size 128k;
224
+ proxy_buffers 4 256k;
225
+ proxy_busy_buffers_size 256k;
226
+ client_max_body_size 50M;
227
+ }
228
+ }
229
+ ```
230
+
179
231
  ## API Documentation
180
232
 
181
- The REST API is defined by a [RAML][RAML] specification. The specification is published [here][OpenBEL API RAML specification].
233
+ The REST API is defined by a [RAML][RAML] specification. Th is published [here][OpenBEL API RAML specification].
182
234
 
183
235
  API documentation with *Try it* functionality is available [here][OpenBEL API documentation].
184
236
 
@@ -205,4 +257,5 @@ Built with collaboration and :heart: by the [OpenBEL][OpenBEL] community.
205
257
  [Puma HTTP server]: http://puma.io/
206
258
  [Resource RDF 20150611]: http://build.openbel.org/browse/OR-RRD2/latestSuccessful/artifact
207
259
  [Resource Search 20150611]: http://build.openbel.org/browse/OR-RSD2/latestSuccessful/artifact
208
-
260
+ [Nginx]: http://nginx.org/
261
+ [MongoDB User Authentication]: https://github.com/OpenBEL/openbel-api/wiki/Configuring-the-Evidence-Store#mongodb-user-authentication
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.5.0
@@ -10,6 +10,7 @@ require 'sinatra/base'
10
10
  require "sinatra/reloader"
11
11
  require "sinatra/cookies"
12
12
 
13
+ require_relative 'version'
13
14
  require_relative 'config'
14
15
  require_relative 'routes/base'
15
16
  require_relative 'routes/root'
@@ -20,6 +21,7 @@ require_relative 'routes/expressions'
20
21
  require_relative 'routes/functions'
21
22
  require_relative 'routes/namespaces'
22
23
  require_relative 'routes/authenticate'
24
+ require_relative 'routes/version'
23
25
  require_relative 'middleware/auth'
24
26
 
25
27
  module OpenBEL
@@ -65,6 +67,7 @@ module OpenBEL
65
67
 
66
68
  # routes not requiring authentication
67
69
  use OpenBEL::Routes::Root
70
+ use OpenBEL::Routes::Version
68
71
  use OpenBEL::Routes::Annotations
69
72
  use OpenBEL::Routes::Expressions
70
73
  use OpenBEL::Routes::Functions
@@ -22,7 +22,10 @@ module OpenBEL
22
22
  if block_given?
23
23
  yield failure[1]
24
24
  else
25
- fail "Configuration error: #{failure[1]}"
25
+ fail(<<-ERR.gsub(/^\s+/, ''))
26
+ Configuration error within #{File.expand_path(config_file)}:
27
+ #{failure[1]}
28
+ ERR
26
29
  end
27
30
  end
28
31
 
@@ -32,9 +35,94 @@ module OpenBEL
32
35
  private
33
36
 
34
37
  def self.validate(cfg)
38
+ # validate evidence_store block
39
+ evidence_store = cfg[:evidence_store]
40
+ unless evidence_store
41
+ return [
42
+ true, <<-ERR
43
+ An "evidence_store" is not configured.
44
+ #{boilerplate_help}
45
+ ERR
46
+ ]
47
+ end
48
+ evidence_failure = self.validate_evidence_store(cfg[:evidence_store])
49
+ return evidence_failure if evidence_failure
50
+
35
51
  nil
36
52
  end
37
53
 
54
+ def self.validate_evidence_store(evidence_store)
55
+ mongo = evidence_store[:mongo]
56
+ unless mongo
57
+ return [
58
+ true, <<-ERR
59
+ The "evidence_store.mongo" configuration block is not configured.
60
+ #{boilerplate_help}
61
+ ERR
62
+ ]
63
+ end
64
+
65
+ required = [:host, :port, :database]
66
+
67
+ required.each do |setting|
68
+ unless mongo[setting]
69
+ return [
70
+ true, <<-ERR
71
+ The "evidence_store.mongo.#{setting}" setting is not configured.
72
+ #{boilerplate_help}
73
+ ERR
74
+ ]
75
+ end
76
+ end
77
+
78
+ # Test connection to the MongoDB instance.
79
+ require 'mongo'
80
+ begin
81
+ mongo_client = Mongo::MongoClient.new(mongo[:host], mongo[:port])
82
+ mongo_client.connect
83
+ rescue Mongo::ConnectionFailure => e
84
+ return [
85
+ true, <<-ERR
86
+ Unable to connect to MongoDB at host "#{mongo[:host]}" and port "#{mongo[:port]}".
87
+ #{boilerplate_help}
88
+
89
+ MongoDB error:
90
+ #{e}
91
+ ERR
92
+ ]
93
+ end
94
+
95
+ # Attempt access of database.
96
+ db = mongo_client.db(mongo[:database])
97
+
98
+ # Authenticate user if provided.
99
+ if mongo[:username] && mongo[:password]
100
+ auth_db = mongo[:authentication_database] || mongo[:database]
101
+ begin
102
+ db.authenticate(mongo[:username], mongo[:password], nil, auth_db)
103
+ rescue Mongo::AuthenticationError => e
104
+ return [
105
+ true, <<-ERR
106
+ Unable to authenticate "#{mongo[:username]}" against the "#{auth_db}" authentication database.
107
+ #{boilerplate_help}
108
+
109
+ MongoDB error:
110
+ #{e}
111
+ ERR
112
+ ]
113
+ end
114
+ end
115
+
116
+ nil
117
+ end
118
+
119
+ def self.boilerplate_help
120
+ <<-ERR.gsub(/^\s+/, '')
121
+ Run the "openbel-config" command to see an example configuration.
122
+ See https://github.com/OpenBEL/openbel-api/wiki/Configuring-the-Evidence-Store for details on how to configure an Evidence Store.
123
+ ERR
124
+ end
125
+
38
126
  class SilentProperties < Properties
39
127
  def method_missing(key, *args, &block)
40
128
  return nil unless has_key?(key)
@@ -84,8 +84,9 @@ module OpenBEL
84
84
  halt 404 unless match.length > 1
85
85
 
86
86
  match_results = @search.search(wildcard_match(match), :annotation_concept, nil, nil,
87
- :start => start,
88
- :size => size
87
+ :start => start,
88
+ :size => size,
89
+ :exclude_identifier_schemes => false
89
90
  ).map { |result|
90
91
  value = OpenBEL::Resource::Annotations::AnnotationValueSearchResult.new(@rr, result.uri)
91
92
  value.match_text = result.snippet
@@ -131,8 +132,9 @@ module OpenBEL
131
132
  halt 404 unless match.length > 1
132
133
 
133
134
  match_results = @search.search(wildcard_match(match), :annotation_concept, annotation.uri.to_s, nil,
134
- :start => start,
135
- :size => size
135
+ :start => start,
136
+ :size => size,
137
+ :exclude_identifier_schemes => false
136
138
  ).map { |result|
137
139
  value = OpenBEL::Resource::Annotations::AnnotationValueSearchResult.new(@rr, result.uri)
138
140
  value.match_text = result.snippet
@@ -49,12 +49,6 @@ module OpenBEL
49
49
 
50
50
  disable :protection
51
51
 
52
- before do
53
- unless request.preferred_type(SPOKEN_CONTENT_TYPES)
54
- halt 406
55
- end
56
- end
57
-
58
52
  helpers do
59
53
 
60
54
  def as_bool(value)
@@ -28,11 +28,8 @@ module OpenBEL
28
28
  super
29
29
 
30
30
  # Evidence API using Mongo.
31
- @api = OpenBEL::Evidence::Evidence.new(
32
- :host => OpenBEL::Settings[:evidence_store][:mongo][:host],
33
- :port => OpenBEL::Settings[:evidence_store][:mongo][:port],
34
- :database => OpenBEL::Settings[:evidence_store][:mongo][:database]
35
- )
31
+ mongo = OpenBEL::Settings[:evidence_store][:mongo]
32
+ @api = OpenBEL::Evidence::Evidence.new(mongo)
36
33
 
37
34
  # RdfRepository using Jena.
38
35
  @rr = BEL::RdfRepository.plugins[:jena].create_repository(
@@ -16,11 +16,8 @@ module OpenBEL
16
16
  def initialize(app)
17
17
  super
18
18
 
19
- @api = OpenBEL::Evidence::Evidence.new(
20
- :host => OpenBEL::Settings[:evidence_store][:mongo][:host],
21
- :port => OpenBEL::Settings[:evidence_store][:mongo][:port],
22
- :database => OpenBEL::Settings[:evidence_store][:mongo][:database]
23
- )
19
+ mongo = OpenBEL::Settings[:evidence_store][:mongo]
20
+ @api = OpenBEL::Evidence::Evidence.new(mongo)
24
21
 
25
22
  # RdfRepository using Jena
26
23
  @rr = BEL::RdfRepository.plugins[:jena].create_repository(
@@ -123,7 +123,7 @@ module OpenBEL
123
123
  halt 400 unless bel and caret_position
124
124
 
125
125
  begin
126
- completions = BEL::Completion.complete(bel, @search, caret_position)
126
+ completions = BEL::Completion.complete(bel, @search, @namespaces, caret_position)
127
127
  rescue IndexError => ex
128
128
  halt(
129
129
  400,
@@ -118,8 +118,9 @@ module OpenBEL
118
118
  halt 404 unless match.length > 1
119
119
 
120
120
  match_results = @search.search(wildcard_match(match), :namespace_concept, nil, nil,
121
- :start => start,
122
- :size => size
121
+ :start => start,
122
+ :size => size,
123
+ :exclude_identifier_schemes => false
123
124
  ).map { |result|
124
125
  value = OpenBEL::Resource::Namespaces::NamespaceValueSearchResult.new(@rr, result.uri)
125
126
  value.match_text = result.snippet
@@ -169,8 +170,9 @@ module OpenBEL
169
170
  halt 404 unless match.length > 1
170
171
 
171
172
  match_results = @search.search(wildcard_match(match), :namespace_concept, namespace.uri.to_s, nil,
172
- :start => start,
173
- :size => size
173
+ :start => start,
174
+ :size => size,
175
+ :exclude_identifier_schemes => false
174
176
  ).map { |result|
175
177
  value = OpenBEL::Resource::Namespaces::NamespaceValueSearchResult.new(@rr, result.uri)
176
178
  value.match_text = result.snippet
@@ -0,0 +1,49 @@
1
+ require_relative '../version'
2
+ require 'rack/mime'
3
+
4
+ module OpenBEL
5
+ module Routes
6
+
7
+ class Version < Base
8
+
9
+ JSON = Rack::Mime.mime_type('.json')
10
+ TEXT = Rack::Mime.mime_type('.txt')
11
+ ACCEPTED_TYPES = {'json' => JSON, 'text' => TEXT}
12
+ DEFAULT_TYPE = TEXT
13
+
14
+ options '/api/version' do
15
+ response.headers['Allow'] = 'OPTIONS,GET'
16
+ status 200
17
+ end
18
+
19
+ get '/api/version' do
20
+ accept_type = request.accept.find { |accept_entry|
21
+ ACCEPTED_TYPES.values.include?(accept_entry.to_s)
22
+ }
23
+ accept_type ||= DEFAULT_TYPE
24
+
25
+ format = params[:format]
26
+ if format
27
+ accept_type = ACCEPTED_TYPES[format]
28
+ halt 406 unless accept_type
29
+ end
30
+
31
+ if accept_type == JSON
32
+ render_json(
33
+ {
34
+ :version => {
35
+ :string => OpenBEL::Version.to_s,
36
+ :semantic_version_numbers => OpenBEL::Version.to_a
37
+ }
38
+ }
39
+ )
40
+ else
41
+ response.headers['Content-Type'] = 'text/plain'
42
+ OpenBEL::Version.to_s
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
48
+ # vim: ts=2 sw=2:
49
+ # encoding: utf-8
@@ -0,0 +1,38 @@
1
+ module OpenBEL
2
+
3
+ # Captures the version of the OpenBEL API.
4
+ module Version
5
+
6
+ # The frozen version {String}. See {Object#freeze}.
7
+ STRING = File.read(
8
+ File.join(
9
+ File.expand_path(File.dirname(__FILE__)),
10
+ '..', '..','..',
11
+ 'VERSION'
12
+ )
13
+ ).chomp.freeze
14
+
15
+ # The frozen {Fixnum version numbers}. See {Object#freeze}.
16
+ MAJOR, MINOR, PATCH = STRING.split('.').map(&:freeze)
17
+
18
+ # The frozen {Array} of {Fixnum version numbers}. See {Object#freeze}.
19
+ VERSION_NUMBERS = [MAJOR, MINOR, PATCH].freeze
20
+
21
+ # Add singleton methods to the metaclass of {OpenBEL::Version}.
22
+ class << self
23
+
24
+ # Return the frozen, semantic version {String} for the OpenBEL API.
25
+ # @return [frozen String] the semantic version of the OpenBEL API
26
+ def to_s
27
+ STRING
28
+ end
29
+ alias :to_str :to_s
30
+
31
+ # Return the frozen, semantic version number {Array} for the OpenBEL API.
32
+ # @return [frozen Array] the semantic version numbers of the OpenBEL API
33
+ def to_a
34
+ VERSION_NUMBERS
35
+ end
36
+ end
37
+ end
38
+ end
@@ -52,6 +52,13 @@ OpenBEL API Options
52
52
  opts.on('-f', '--file FILE', 'The file where the configuration will be written.') do |file|
53
53
  options[:file] = file
54
54
  end
55
+
56
+ opts.on('-v', '--version', 'The version of the OpenBEL API.') do
57
+ require 'openbel/api/version'
58
+
59
+ $stdout.puts OpenBEL::Version
60
+ exit
61
+ end
55
62
  end
56
63
 
57
64
  parser.default_argv = OPENBEL_ARGV
@@ -61,6 +68,15 @@ if options[:file]
61
68
  config_file = options[:file]
62
69
  end
63
70
 
71
+ unless config_file
72
+ $stderr.puts <<-ERR.gsub(/^\s+/, '')
73
+ The OpenBEL API configuration file was not set.
74
+ Run the "openbel-api --help" command to review the options for setting the configuration file.
75
+ See https://github.com/OpenBEL/openbel-api/wiki/OpenBEL-API-Config for further details on the OpenBEL API configuration file.
76
+ ERR
77
+ exit 1
78
+ end
79
+
64
80
  begin
65
81
  File.open(config_file, 'r')
66
82
  rescue SystemCallError => err
@@ -15,6 +15,13 @@ OptionParser.new do |opts|
15
15
  opts.on('-f', '--file FILE', 'The file where the configuration will be written.') do |file|
16
16
  options[:file] = file
17
17
  end
18
+
19
+ opts.on('-v', '--version', 'The version of the OpenBEL API.') do
20
+ require 'openbel/api/version'
21
+
22
+ $stdout.puts OpenBEL::Version
23
+ exit
24
+ end
18
25
  end.parse!
19
26
 
20
27
  # resolve path for config.yml template
@@ -3,9 +3,40 @@
3
3
  # Storage of evidence through the Mongo database.
4
4
  evidence_store:
5
5
  mongo:
6
- host: 'localhost'
7
- port: 27017
8
- database: 'openbel'
6
+
7
+ # The MongoDB host to connect to. For example if MongoDB's net.bindIp
8
+ # setting is configured as 127.0.0.1 we should be able to connect using
9
+ # localhost.
10
+ host: 'localhost'
11
+
12
+ # The default MongoDB port. Configured under MongoDB's `net.port` setting.
13
+ port: 27017
14
+
15
+ # The name of your database. We think "openbel-evidence" should be fine,
16
+ # but it's up to you.
17
+ database: 'openbel-evidence'
18
+
19
+ # MongoDB authentication and role assignment. These settings are necessary
20
+ # if you would like to have a MongoDB user authenticated and authorized to
21
+ # use the configure database.
22
+
23
+ #First, you will need to create a MongoDB user with the "readWrite" and
24
+ #"dbAdmin" roles for the "database" value set above. This is to allow read,
25
+ #write, and index creation in the OpenBEL API application.
26
+ #See https://github.com/OpenBEL/openbel-api/wiki/Configuring-the-Evidence-Store#adding-the-openbel-user
27
+ #username: 'openbel-user'
28
+
29
+ #Second, you will need to set a password for the MongoDB user set above.
30
+ #MongoDB passwords are hashed using SCRAM-SHA-1 on the client and server.
31
+ #This is the default hashing strategy on MongoDB 3.0 and after.
32
+ #See https://docs.mongodb.org/v3.0/core/security-scram-sha-1/
33
+ #password: 'changeme'
34
+
35
+ # If your MongoDB users are managed in a separate Mongo database then you
36
+ # will need to set it here. This can be useful if you are managing users in
37
+ # a separate Mongo database from the application's database.
38
+ # Optional; defaults to the "database" set above.
39
+ #authentication_database: 'openbel'
9
40
 
10
41
  # RDF dataset for BEL datasets, annotations, and namespaces using Apache Jena.
11
42
  resource_rdf:
@@ -11,10 +11,19 @@ module OpenBEL
11
11
  include Mongo
12
12
 
13
13
  def initialize(options = {})
14
- host = options.delete(:host)
15
- port = options.delete(:port)
16
- db = options.delete(:database)
14
+ host = options[:host]
15
+ port = options[:port]
16
+ db = options[:database]
17
17
  @db = MongoClient.new(host, port).db(db)
18
+
19
+ # Authenticate user if provided.
20
+ username = options[:username]
21
+ password = options[:password]
22
+ if username && password
23
+ auth_db = options[:authentication_database] || db
24
+ @db.authenticate(username, password, nil, auth_db)
25
+ end
26
+
18
27
  @collection = @db[:evidence]
19
28
  @collection.ensure_index(
20
29
  {:"bel_statement" => Mongo::ASCENDING },
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openbel-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: java
6
6
  authors:
7
7
  - Anthony Bargnesi
@@ -10,14 +10,14 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-12-02 00:00:00.000000000 Z
13
+ date: 2015-12-17 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
18
  - - '='
19
19
  - !ruby/object:Gem::Version
20
- version: 0.4.0
20
+ version: 0.4.1
21
21
  name: bel
22
22
  prerelease: false
23
23
  type: :runtime
@@ -25,13 +25,13 @@ dependencies:
25
25
  requirements:
26
26
  - - '='
27
27
  - !ruby/object:Gem::Version
28
- version: 0.4.0
28
+ version: 0.4.1
29
29
  - !ruby/object:Gem::Dependency
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
32
  - - '='
33
33
  - !ruby/object:Gem::Version
34
- version: 0.4.0
34
+ version: 0.4.2
35
35
  name: bel-search-sqlite
36
36
  prerelease: false
37
37
  type: :runtime
@@ -39,13 +39,13 @@ dependencies:
39
39
  requirements:
40
40
  - - '='
41
41
  - !ruby/object:Gem::Version
42
- version: 0.4.0
42
+ version: 0.4.2
43
43
  - !ruby/object:Gem::Dependency
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
46
  - - '='
47
47
  - !ruby/object:Gem::Version
48
- version: 0.4.0
48
+ version: 0.4.1
49
49
  name: bel-rdf-jena
50
50
  prerelease: false
51
51
  type: :runtime
@@ -53,7 +53,7 @@ dependencies:
53
53
  requirements:
54
54
  - - '='
55
55
  - !ruby/object:Gem::Version
56
- version: 0.4.0
56
+ version: 0.4.1
57
57
  - !ruby/object:Gem::Dependency
58
58
  requirement: !ruby/object:Gem::Requirement
59
59
  requirements:
@@ -292,6 +292,7 @@ files:
292
292
  - INSTALL_RUBY.md
293
293
  - LICENSE
294
294
  - README.md
295
+ - VERSION
295
296
  - app/openbel/api/app.rb
296
297
  - app/openbel/api/config.rb
297
298
  - app/openbel/api/config.ru
@@ -315,6 +316,7 @@ files:
315
316
  - app/openbel/api/routes/functions.rb
316
317
  - app/openbel/api/routes/namespaces.rb
317
318
  - app/openbel/api/routes/root.rb
319
+ - app/openbel/api/routes/version.rb
318
320
  - app/openbel/api/schemas.rb
319
321
  - app/openbel/api/schemas/annotation_collection.schema.json
320
322
  - app/openbel/api/schemas/annotation_resource.schema.json
@@ -328,6 +330,7 @@ files:
328
330
  - app/openbel/api/schemas/namespace_value_collection.schema.json
329
331
  - app/openbel/api/schemas/namespace_value_resource.schema.json
330
332
  - app/openbel/api/util.rb
333
+ - app/openbel/api/version.rb
331
334
  - bin/openbel-api
332
335
  - bin/openbel-config
333
336
  - config/async_evidence.rb