orcid 0.0.3 → 0.0.4

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: ba10205d401221950e7596687248cd0bd5a370e8
4
- data.tar.gz: 25c078f04696083a4e71fb896a344a73f4fd4929
3
+ metadata.gz: 76d282e5fe1e457a4e664b9744c7798a699868b0
4
+ data.tar.gz: 8e9d224124856d459ba29a413116667553d16307
5
5
  SHA512:
6
- metadata.gz: a252eb074a444073a01d31ce1b453c4b36a003dc3d412815932303498b968621141821aff853222804a1b202b9baac3584fc1851d05c421f088b4cf2fc80f58b
7
- data.tar.gz: f281ed0b68af192d53f1a5f51d038a80f250130ea485cfdd6efbf7026e46412053e2b1d609ecc86b1fd574226938d42be08b62c37191bcfef4ff7c16956671df
6
+ metadata.gz: 1fbcf299a9e8d0701c2d42438f61d56094f35eda93bce08ba0b6829184616aeba9bf2eb9c149ae66a252433d77b5f5cfc7f41647c33e17071de1fb6ed12b123b
7
+ data.tar.gz: 1bedcf2b30666c9e9131b52070641954dc334d5e26ee1eae3fb7f583735567efc63f32d31d0fbdc8660b13383c71ba173e5fc2e2aefec920089ab2267956a8cc
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  ##########################################################################
2
2
  #
3
- # Copyright 2013 University of Notre Dame
3
+ # Copyright 2014 University of Notre Dame
4
4
  #
5
5
  # Additional copyright may be held by others, as reflected in the commit log
6
6
  #
data/README.md CHANGED
@@ -16,3 +16,8 @@ And then execute:
16
16
  And then install:
17
17
 
18
18
  $ rails generate orcid:install
19
+
20
+
21
+ ## TODO Items
22
+
23
+ * When searching for your profile, expose Name and associated DOI as query parameters.
@@ -5,7 +5,14 @@ module Orcid
5
5
  include Virtus.model
6
6
  include ActiveModel::Validations
7
7
  extend ActiveModel::Naming
8
- attribute :email
8
+
9
+ self.class_attribute :available_query_attribute_names
10
+ self.available_query_attribute_names = [:email, :text]
11
+
12
+ available_query_attribute_names.each do |attribute_name|
13
+ attribute attribute_name
14
+ end
15
+
9
16
  attribute :orcid_profile_id
10
17
  attribute :user
11
18
 
@@ -35,7 +42,7 @@ module Orcid
35
42
  private :default_profile_lookup_service
36
43
 
37
44
  def with_orcid_profile_candidates
38
- yield(orcid_profile_candidates) if email.present?
45
+ yield(orcid_profile_candidates) if query_requested?
39
46
  end
40
47
 
41
48
  attr_writer :orcid_profile_candidates
@@ -45,11 +52,22 @@ module Orcid
45
52
  end
46
53
 
47
54
  def lookup_profile_candidates
48
- if email.present?
49
- profile_lookup_service.call(email: email)
55
+ if query_requested?
56
+ profile_lookup_service.call(query_attributes)
50
57
  end
51
58
  end
52
59
  private :lookup_profile_candidates
53
60
 
61
+ def query_requested?
62
+ !!available_query_attribute_names.detect { |attribute_name|
63
+ attributes[attribute_name].present?
64
+ }
65
+ end
66
+ private :query_requested?
67
+
68
+ def query_attributes
69
+ attributes.slice(*available_query_attribute_names)
70
+ end
71
+
54
72
  end
55
73
  end
@@ -1,17 +1,21 @@
1
- require_dependency './app/runners/orcid/runner'
1
+ require 'orcid/runner'
2
2
  module Orcid
3
3
  class ProfileLookupRunner < Runner
4
4
 
5
5
  def initialize(config = {}, &block)
6
6
  super(&block)
7
7
  @query_service = config.fetch(:query_service) { Remote::ProfileLookupService }
8
+ @query_builder = config.fetch(:query_parameter_builder) {
9
+ require 'orcid/query_parameter_builder'
10
+ Orcid::QueryParameterBuilder
11
+ }
8
12
  end
9
- attr_reader :query_service
10
- private :query_service
13
+ attr_reader :query_service, :query_builder
14
+ private :query_service, :query_builder
11
15
 
12
- def call(parameters)
13
- email = parameters.fetch(:email)
14
- response = query_service.call({q: "email:#{email}"})
16
+ def call(raw_parameters)
17
+ query_parameters = query_builder.call(raw_parameters)
18
+ response = query_service.call(query_parameters)
15
19
  handle(response)
16
20
  end
17
21
 
@@ -1,4 +1,4 @@
1
- require_dependency './lib/orcid/named_callbacks'
1
+ require 'orcid/named_callbacks'
2
2
  module Orcid
3
3
  class Runner
4
4
  def initialize
@@ -1,4 +1,4 @@
1
- require_dependency './app/services/orcid/remote/service'
1
+ require 'orcid/remote/service'
2
2
  module Orcid::Remote
3
3
  # Responsible for minting a new ORCID for the given payload.
4
4
  class ProfileCreationService < Orcid::Remote::Service
@@ -40,9 +40,12 @@ module Orcid::Remote
40
40
  orcid_bio = profile.fetch('orcid-bio')
41
41
  given_names = orcid_bio.fetch('personal-details').fetch('given-names').fetch('value')
42
42
  family_name = orcid_bio.fetch('personal-details').fetch('family-name').fetch('value')
43
- emails = orcid_bio.fetch('contact-details').fetch('email').collect {|email| email.fetch('value') }
43
+ emails = []
44
+ if contact_details = orcid_bio['contact-details']
45
+ emails = (contact_details['email'] || []).collect {|email| email.fetch('value') }
46
+ end
44
47
  label = "#{given_names} #{family_name}"
45
- label << " (" << emails.join(",") << ")" if emails.any?
48
+ label << " (" << emails.join(", ") << ")" if emails.any?
46
49
  label << " [ORCID: #{identifier}]"
47
50
 
48
51
  returning_value << response_builder.new("id" => identifier, "label" => label)
@@ -1,4 +1,4 @@
1
- require_dependency './lib/orcid/named_callbacks'
1
+ require 'orcid/named_callbacks'
2
2
  module Orcid::Remote
3
3
  class Service
4
4
  def initialize
@@ -1,4 +1,4 @@
1
- require_dependency './lib/orcid/exceptions'
1
+ require 'orcid/exceptions'
2
2
  module Orcid::Remote
3
3
  class WorkService
4
4
  def self.call(orcid_profile_id, options = {})
@@ -1,6 +1,8 @@
1
1
  <%= simple_form_for(profile_connection, as: :profile_connection, url: orcid.new_profile_connection_path, method: :get, html: {class: 'search-form'}) do |f| %>
2
2
  <%= field_set_tag("Search ORCID Profiles", class: 'accessible-hidden') do %>
3
- <%= f.input :email, type: :search %>
3
+ <% profile_connection.available_query_attribute_names.each do |field_name| %>
4
+ <%= f.input field_name, as: :search %>
5
+ <% end %>
4
6
  <% end %>
5
7
  <button type="submit" class="search-submit btn btn-primary" id="keyword-search-submit" tabindex="2">
6
8
  <i class="icon-search icon-white"></i><span class="accessible-hidden">Search</span>
@@ -0,0 +1,25 @@
1
+ # Add account credentials and API keys here.
2
+ # See http://railsapps.github.io/rails-environment-variables.html
3
+ # This file should be listed in .gitignore to keep your settings secret!
4
+ # Each entry sets a local environment variable and overrides ENV variables in the Unix shell.
5
+ # For example, setting:
6
+ # GMAIL_USERNAME: Your_Gmail_Username
7
+ # makes 'Your_Gmail_Username' available as ENV["GMAIL_USERNAME"]
8
+
9
+ # Add application configuration variables here, as shown below.
10
+ #
11
+ ADMIN_NAME: First User
12
+ ADMIN_EMAIL: user@example.com
13
+ ADMIN_PASSWORD: changeme
14
+
15
+ # From http://support.orcid.org/knowledgebase/articles/162412-tutorial-create-a-new-profile-using-curl
16
+ ORCID_APP_ID: 0000-0002-6683-6607
17
+ ORCID_APP_SECRET: e1ff26a2-d889-40be-bd41-acac09214cae
18
+
19
+ ORCID_EXISTING_PUB_EMAIL: jeremy.n.friesen@gmail.com
20
+ ORCID_EXISTING_PUB_PROFILE_ID: 0000-0002-3636-1153
21
+ ORCID_EXISTING_PUB_NAME: Jeremy Friesen
22
+
23
+ ORCID_CLAIMED_PROFILE_ID: 0000-0002-1117-8571
24
+ ORCID_CLAIMED_PROFILE_PASSWORD: password1A
25
+ ORCID_CLAIMED_PROFILE_EMAIL: cwksfxyqkmrudrfrdxvlzjxl@mailinator.com
@@ -36,7 +36,7 @@ module Orcid
36
36
  configuration.authentication_model
37
37
  end
38
38
 
39
- def connect_user_and_orcid_profile(user, orcid_profile_id, options = {})
39
+ def connect_user_and_orcid_profile(user, orcid_profile_id)
40
40
  authentication_model.create!(provider: 'orcid', uid: orcid_profile_id, user: user)
41
41
  end
42
42
 
@@ -2,16 +2,22 @@ module Orcid
2
2
  class Configuration
3
3
  attr_reader :mapper
4
4
  def initialize(options = {})
5
- @mapper = options.fetch(:mapper) { ::Mappy }
6
- @provider = Configuration::Provider.new
5
+ @mapper = options.fetch(:mapper) {
6
+ require 'mappy'
7
+ ::Mappy
8
+ }
9
+ @provider = options.fetch(:provider) {
10
+ require 'orcid/configuration/provider'
11
+ Provider.new
12
+ }
13
+ @authentication_model = options.fetch(:authentication_model) {
14
+ require 'devise-multi_auth'
15
+ ::Devise::MultiAuth::Authentication
16
+ }
7
17
  end
8
18
 
9
- attr_reader :provider
10
-
11
- attr_writer :authentication_model
12
- def authentication_model
13
- @authentication_model ||= Devise::MultiAuth::Authentication
14
- end
19
+ attr_accessor :provider
20
+ attr_accessor :authentication_model
15
21
 
16
22
  def register_mapping_to_orcid_work(source_type, legend)
17
23
  mapper.configure do |config|
@@ -20,4 +26,3 @@ module Orcid
20
26
  end
21
27
  end
22
28
  end
23
- require 'orcid/configuration/provider'
@@ -0,0 +1,38 @@
1
+ module Orcid
2
+ # http://support.orcid.org/knowledgebase/articles/132354-searching-with-the-public-api
3
+ module QueryParameterBuilder
4
+
5
+ module_function
6
+ # Responsible for converting an arbitrary query string to the acceptable
7
+ # Orcid query format.
8
+ #
9
+ # @TODO - Note this is likely not correct, but is providing the singular
10
+ # point of entry
11
+ def call(input = {})
12
+ params = {}
13
+ q_params = []
14
+ text_params = []
15
+ input.each do |key, value|
16
+ next if value.nil? || value.to_s.strip == ''
17
+ case key.to_s
18
+ when 'start', 'row'
19
+ params[key] = value
20
+ when 'q', 'text'
21
+ text_params << "#{value}"
22
+ else
23
+ q_params << "#{key.to_s.gsub('_', '-')}:#{value}"
24
+ end
25
+ end
26
+
27
+ case text_params.size
28
+ when 0; then nil
29
+ when 1
30
+ q_params << "text:#{text_params.first}"
31
+ else
32
+ q_params << "text:((#{text_params.join(') AND (')}))"
33
+ end
34
+ params[:q] = q_params.join(" AND ")
35
+ params
36
+ end
37
+ end
38
+ end
@@ -1,3 +1,3 @@
1
1
  module Orcid
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: orcid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Friesen
@@ -108,20 +108,6 @@ dependencies:
108
108
  - - '>='
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
- - !ruby/object:Gem::Dependency
112
- name: byebug
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - '>='
116
- - !ruby/object:Gem::Version
117
- version: '0'
118
- type: :runtime
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - '>='
123
- - !ruby/object:Gem::Version
124
- version: '0'
125
111
  - !ruby/object:Gem::Dependency
126
112
  name: sqlite3
127
113
  requirement: !ruby/object:Gem::Requirement
@@ -316,7 +302,6 @@ files:
316
302
  - app/controllers/orcid/application_controller.rb
317
303
  - app/controllers/orcid/profile_connections_controller.rb
318
304
  - app/controllers/orcid/profile_requests_controller.rb
319
- - app/helpers/orcid/application_helper.rb
320
305
  - app/models/orcid/profile.rb
321
306
  - app/models/orcid/profile_connection.rb
322
307
  - app/models/orcid/profile_request.rb
@@ -334,6 +319,7 @@ files:
334
319
  - app/views/orcid/profile_connections/new.html.erb
335
320
  - app/views/orcid/profile_requests/new.html.erb
336
321
  - app/views/orcid/profile_requests/show.html.erb
322
+ - config/application.yml
337
323
  - config/locales/orcid.en.yml
338
324
  - config/routes.rb
339
325
  - db/migrate/20140205185338_create_orcid_profile_requests.rb
@@ -344,6 +330,7 @@ files:
344
330
  - lib/orcid/engine.rb
345
331
  - lib/orcid/exceptions.rb
346
332
  - lib/orcid/named_callbacks.rb
333
+ - lib/orcid/query_parameter_builder.rb
347
334
  - lib/orcid/spec_support.rb
348
335
  - lib/orcid/version.rb
349
336
  - lib/orcid.rb
@@ -1,4 +0,0 @@
1
- module Orcid
2
- module ApplicationHelper
3
- end
4
- end