Module: Orcid
- Defined in:
- lib/orcid.rb,
lib/orcid/engine.rb,
lib/orcid/version.rb,
lib/orcid/exceptions.rb,
app/models/orcid/work.rb,
lib/orcid/configuration.rb,
app/models/orcid/profile.rb,
app/services/orcid/remote.rb,
lib/orcid/named_callbacks.rb,
app/models/orcid/profile_status.rb,
app/models/orcid/profile_request.rb,
app/models/orcid/work/xml_parser.rb,
lib/orcid/configuration/provider.rb,
app/services/orcid/remote/service.rb,
app/models/orcid/work/xml_renderer.rb,
app/models/orcid/profile_connection.rb,
app/services/orcid/remote/work_service.rb,
app/controllers/orcid/application_controller.rb,
lib/generators/orcid/install/install_generator.rb,
app/services/orcid/remote/profile_query_service.rb,
app/controllers/orcid/profile_requests_controller.rb,
app/services/orcid/remote/profile_creation_service.rb,
app/controllers/orcid/profile_connections_controller.rb,
app/services/orcid/remote/profile_query_service/response_parser.rb,
app/services/orcid/remote/profile_query_service/search_response.rb,
app/services/orcid/remote/profile_query_service/query_parameter_builder.rb
Overview
The namespace for all things related to Orcid integration
Defined Under Namespace
Modules: Remote
Classes: ApplicationController, Configuration, ConfigurationError, Engine, InstallGenerator, NamedCallbacks, Profile, ProfileConnection, ProfileConnectionsController, ProfileRequest, ProfileRequestsController, ProfileStatus, RemoteServiceError, Work
Constant Summary
collapse
- VERSION =
'0.8.0'
Class Attribute Summary collapse
Class Method Summary
collapse
Class Attribute Details
.configuration ⇒ Object
17
18
19
|
# File 'lib/orcid.rb', line 17
def configuration
@configuration ||= Configuration.new
end
|
Class Method Details
.access_token_for(orcid_profile_id, options = {}) ⇒ Object
49
50
51
52
53
54
55
|
# File 'lib/orcid.rb', line 49
def access_token_for(orcid_profile_id, options = {})
client = options.fetch(:client) { oauth_client }
tokenizer = options.fetch(:tokenizer) { authentication_model }
tokenizer.to_access_token(
uid: orcid_profile_id, provider: 'orcid', client: client
)
end
|
.authenticated_orcid?(orcid_profile_id) ⇒ Boolean
Returns true if the person with the given ORCID has already obtained an ORCID access token by authenticating via ORCID.
59
60
61
62
63
|
# File 'lib/orcid.rb', line 59
def authenticated_orcid?(orcid_profile_id)
Orcid.access_token_for(orcid_profile_id).present?
rescue Devise::MultiAuth::AccessTokenError
return false
end
|
.authentication_model ⇒ Object
39
40
41
|
# File 'lib/orcid.rb', line 39
def authentication_model
configuration.authentication_model
end
|
.client_credentials_token(scope, options = {}) ⇒ Object
86
87
88
89
|
# File 'lib/orcid.rb', line 86
def client_credentials_token(scope, options = {})
tokenizer = options.fetch(:tokenizer) { oauth_client.client_credentials }
tokenizer.get_token(scope: scope)
end
|
23
24
25
|
# File 'lib/orcid.rb', line 23
def configure
yield(configuration)
end
|
.connect_user_and_orcid_profile(user, orcid_profile_id) ⇒ Object
43
44
45
46
47
|
# File 'lib/orcid.rb', line 43
def connect_user_and_orcid_profile(user, orcid_profile_id)
authentication_model.create!(
provider: 'orcid', uid: orcid_profile_id, user: user
)
end
|
.enqueue(object) ⇒ Object
70
71
72
|
# File 'lib/orcid.rb', line 70
def enqueue(object)
object.run
end
|
.mapper ⇒ Object
27
28
29
|
# File 'lib/orcid.rb', line 27
def mapper
configuration.mapper
end
|
.oauth_client ⇒ Object
78
79
80
81
82
83
84
|
# File 'lib/orcid.rb', line 78
def oauth_client
@oauth_client ||= Devise::MultiAuth.oauth_client_for(
'orcid', options: { site: provider.site_url }
)
end
|
.parent_controller ⇒ Object
35
36
37
|
# File 'lib/orcid.rb', line 35
def parent_controller
configuration.parent_controller
end
|
.profile_for(user) ⇒ Object
65
66
67
68
|
# File 'lib/orcid.rb', line 65
def profile_for(user)
auth = authentication_model.where(provider: 'orcid', user: user).first
auth && Orcid::Profile.new(auth.uid)
end
|
.provider ⇒ Object
31
32
33
|
# File 'lib/orcid.rb', line 31
def provider
configuration.provider
end
|
.table_name_prefix ⇒ Object
This method is part of a private API.
You should avoid using this method if possible, as it may be removed or be changed in the future.
As per an isolated_namespace Rails engine. But the isolated namespace creates issues.
8
9
10
|
# File 'lib/orcid/engine.rb', line 8
def table_name_prefix
'orcid_'
end
|
.url_for_orcid_id(orcid_profile_id) ⇒ Object
74
75
76
|
# File 'lib/orcid.rb', line 74
def url_for_orcid_id(orcid_profile_id)
File.join(provider.host_url, orcid_profile_id)
end
|
.use_relative_model_naming? ⇒ Boolean
This method is part of a private API.
You should avoid using this method if possible, as it may be removed or be changed in the future.
Because I am not using isolate_namespace for Orcid::Engine I need this for the application router to find the appropriate routes.
15
16
17
|
# File 'lib/orcid/engine.rb', line 15
def use_relative_model_naming?
true
end
|