enju_ndl 0.3.3 → 0.4.0.beta.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/MIT-LICENSE +1 -1
  3. data/README.md +2 -7
  4. data/Rakefile +24 -13
  5. data/app/models/concerns/enju_ndl/enju_agent.rb +12 -0
  6. data/{lib/enju_ndl/ndl_search.rb → app/models/concerns/enju_ndl/enju_manifestation.rb} +40 -34
  7. data/{lib/enju_ndl/crd.rb → app/models/concerns/enju_ndl/enju_question.rb} +12 -9
  8. data/app/models/jpno_record.rb +14 -0
  9. data/app/models/ndl_bib_id_record.rb +14 -0
  10. data/app/models/ndl_book.rb +2 -2
  11. data/app/models/ndla_record.rb +14 -0
  12. data/db/migrate/20170116150432_create_jpno_records.rb +10 -0
  13. data/db/migrate/20171126072934_create_ndla_records.rb +10 -0
  14. data/db/migrate/20190501043418_create_ndl_bib_id_records.rb +10 -0
  15. data/lib/enju_ndl/version.rb +1 -1
  16. data/lib/enju_ndl.rb +1 -21
  17. data/spec/dummy/app/models/user.rb +5 -1
  18. data/spec/dummy/bin/bundle +1 -1
  19. data/spec/dummy/bin/setup +1 -3
  20. data/spec/dummy/bin/update +4 -2
  21. data/spec/dummy/bin/yarn +3 -3
  22. data/spec/dummy/config/application.rb +2 -1
  23. data/spec/dummy/config/database.yml +70 -9
  24. data/spec/dummy/config/initializers/assets.rb +1 -1
  25. data/spec/dummy/config/initializers/session_store.rb +8 -0
  26. data/spec/dummy/db/migrate/20100606065209_create_user_has_roles.rb +2 -4
  27. data/spec/dummy/db/migrate/20140122054321_create_profiles.rb +4 -5
  28. data/spec/dummy/db/migrate/20190630113817_add_display_name_translations_to_library_group.rb +12 -0
  29. data/spec/dummy/db/migrate/20190630115523_add_login_banner_translations_to_library_group.rb +6 -0
  30. data/spec/dummy/db/migrate/20190630151446_add_display_name_translations_to_role.rb +5 -0
  31. data/spec/dummy/db/migrate/20190712163038_add_display_name_translations_to_carrier_type.rb +21 -0
  32. data/spec/dummy/db/migrate/20190713114940_add_profile_id_to_user.rb +5 -0
  33. data/spec/dummy/db/migrate/20190713115451_add_full_name_translations_to_profile.rb +5 -0
  34. data/spec/dummy/db/schema.rb +195 -147
  35. data/spec/dummy/db/test.sqlite3 +0 -0
  36. data/spec/fixtures/agent_types.yml +10 -11
  37. data/spec/fixtures/carrier_types.yml +28 -24
  38. data/spec/fixtures/frequencies.yml +17 -25
  39. data/spec/fixtures/profiles.yml +9 -12
  40. data/spec/fixtures/roles.yml +16 -13
  41. data/spec/fixtures/users.yml +7 -0
  42. data/spec/rails_helper.rb +5 -1
  43. metadata +360 -428
  44. data/app/assets/config/enju_ndl_manifest.js +0 -0
  45. data/spec/dummy/db/migrate/20190818075603_add_memo_to_manifestation.rb +0 -5
  46. data/spec/dummy/db/migrate/20190818075628_add_memo_to_item.rb +0 -5
  47. data/spec/dummy/db/migrate/20191219122214_create_custom_properties.rb +0 -12
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 586f0ffdb7eacfe137720880c478a3c86e068262b9cba5b2933cf5492474bafe
4
- data.tar.gz: a60c3c48ba901aff7bb1eae1ab5167e00131036ef215f561f0fa1064c74523fe
3
+ metadata.gz: 4d0f49eaefad35b92b61f8faea93f689ec9d62868edf983f4a95ebc3c9a58e57
4
+ data.tar.gz: 76890bbede710e50747b69687b5bdfaa67856a1e7ad7aafe80faf8a67e38b9e9
5
5
  SHA512:
6
- metadata.gz: 8d9e7a4b62b5a67aa82c78fa38b58651ebb38ca534333028c71971abe0904af852a130ab8f6d7c9ff1d09bf943add81737011cb9da4ad7482b88e414286e1118
7
- data.tar.gz: e7af12849e5d0fdd0e8d38dc245ebb6fab2adb79171f4778c5b1967e6dda30269742ae1e41beda368ff4583507d3c65ae19d54adf279a6e83d23d54dd6192bc9
6
+ metadata.gz: 45050db6983fc8e30525fe1006170f43da82a6aae370bd4194461eb7a7f80523827f8426a876803ba8ba300f25d775e6d3690b6adeefde45d85793e1e6742e9d
7
+ data.tar.gz: b105f3c85470fb0cc08c1396906cff0d1d6a397741a95441d0b368fb8c231ace97e678193619917e403cc8e5adf241c6cb07b925cde1fe8e9f2d6b9328bd9dd6
data/MIT-LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2015 Project Next-L
1
+ Copyright 2012 Kosuke Tanabe
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -1,11 +1,6 @@
1
1
  # EnjuNdl
2
- [<img src="https://travis-ci.com/next-l/enju_ndl.svg?branch=1.3" alt="Build
3
- Status" />](https://travis-ci.com/next-l/enju_ndl) [<img
4
- src="https://coveralls.io/repos/next-l/enju_ndl/badge.svg?branch=1.3&service=g
5
- ithub" alt="Coverage Status"
6
- />](https://coveralls.io/github/next-l/enju_ndl?branch=1.3) [<img
7
- src="https://hakiri.io/github/next-l/enju_ndl/1.3.svg" alt="security"
8
- />](https://hakiri.io/github/next-l/enju_ndl/1.3)
2
+ [![CircleCI](https://circleci.com/gh/next-l/enju_ndl/tree/2.x.svg?style=svg)](https://circleci.com/gh/next-l/enju_ndl/tree/2.x)
3
+ [![Coverage Status](https://coveralls.io/repos/github/next-l/enju_ndl/badge.svg?branch=2.x)](https://coveralls.io/github/next-l/enju_ndl?branch=2.x)
9
4
 
10
5
  This project rocks and uses MIT-LICENSE.
11
6
 
data/Rakefile CHANGED
@@ -1,16 +1,10 @@
1
- #!/usr/bin/env rake
2
1
  begin
3
2
  require 'bundler/setup'
4
3
  rescue LoadError
5
4
  puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
5
  end
7
- begin
8
- require 'rdoc/task'
9
- rescue LoadError
10
- require 'rdoc/rdoc'
11
- require 'rake/rdoctask'
12
- RDoc::Task = Rake::RDocTask
13
- end
6
+
7
+ require 'rdoc/task'
14
8
 
15
9
  RDoc::Task.new(:rdoc) do |rdoc|
16
10
  rdoc.rdoc_dir = 'rdoc'
@@ -23,13 +17,30 @@ end
23
17
  APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
24
18
  load 'rails/tasks/engine.rake'
25
19
 
26
- Bundler::GemHelper.install_tasks
27
20
 
28
- require 'rspec/core'
29
- require 'rspec/core/rake_task'
21
+ load 'rails/tasks/statistics.rake'
22
+
23
+
24
+
25
+ require 'bundler/gem_tasks'
26
+
27
+ require 'rake/testtask'
30
28
 
31
- RSpec::Core::RakeTask.new(:spec) do |spec|
32
- spec.pattern = FileList['spec/**/*_spec.rb']
29
+ Rake::TestTask.new(:test) do |t|
30
+ t.libs << 'lib'
31
+ t.libs << 'test'
32
+ t.pattern = 'test/**/*_test.rb'
33
+ t.verbose = false
34
+ end
35
+
36
+
37
+ begin
38
+ require 'rspec/core/rake_task'
39
+
40
+ RSpec::Core::RakeTask.new(:spec)
41
+
42
+ rescue LoadError
43
+ # no rspec available
33
44
  end
34
45
 
35
46
  task :default => :spec
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EnjuNdl
4
+ module EnjuAgent
5
+ extend ActiveSupport::Concern
6
+
7
+ included do
8
+ has_one :ndla_record
9
+ end
10
+ end
11
+ end
12
+
@@ -1,24 +1,31 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  module EnjuNdl
3
- module NdlSearch
4
- def self.included(base)
5
- base.extend ClassMethods
6
- end
4
+ module EnjuManifestation
5
+ extend ActiveSupport::Concern
6
+
7
+ included do
8
+ has_one :jpno_record
9
+ has_one :ndl_bib_id_record
10
+ searchable do
11
+ string :jpno do
12
+ jpno_record.try(:body)
13
+ end
14
+ end
7
15
 
8
- module ClassMethods
9
- def import_isbn(isbn)
16
+ def self.import_isbn(isbn)
10
17
  manifestation = Manifestation.import_from_ndl_search(isbn: isbn)
11
18
  manifestation
12
19
  end
13
20
 
14
21
  # Use http://www.ndl.go.jp/jp/dlib/standards/opendataset/aboutIDList.txt
15
- def import_ndl_bib_id(ndl_bib_id)
22
+ def self.import_ndl_bib_id(ndl_bib_id)
16
23
  url = "https://iss.ndl.go.jp/books/R100000002-I#{ndl_bib_id}-00.rdf"
17
24
  doc = Nokogiri::XML(Faraday.get(url).body)
18
25
  import_record(doc)
19
26
  end
20
27
 
21
- def import_from_ndl_search(options)
28
+ def self.import_from_ndl_search(options)
22
29
  # if options[:isbn]
23
30
  lisbn = Lisbn.new(options[:isbn])
24
31
  raise EnjuNdl::InvalidIsbn unless lisbn.valid?
@@ -33,11 +40,10 @@ module EnjuNdl
33
40
  import_record(doc)
34
41
  end
35
42
 
36
- def import_record(doc)
43
+ def self.import_record(doc)
37
44
  iss_itemno = URI.parse(doc.at('//dcndl:BibAdminResource[@rdf:about]').values.first).path.split('/').last
38
- identifier_type = IdentifierType.where(name: 'iss_itemno').first
39
- identifier_type ||= IdentifierType.where(name: 'iss_itemno').create!
40
- identifier = Identifier.where(body: iss_itemno, identifier_type_id: identifier_type.id).first
45
+ identifier_type = IdentifierType.where(name: 'iss_itemno').first_or_create!
46
+ identifier = Identifier.find_by(body: iss_itemno, identifier_type_id: identifier_type.id)
41
47
  return identifier.manifestation if identifier
42
48
 
43
49
  jpno = doc.at('//dcterms:identifier[@rdf:datatype="http://ndl.go.jp/dcndl/terms/JPNO"]').try(:content)
@@ -59,7 +65,7 @@ module EnjuNdl
59
65
  end
60
66
  end
61
67
 
62
- language = Language.where(iso_639_2: get_language(doc)).first
68
+ language = Language.find_by(iso_639_2: get_language(doc))
63
69
  language_id = if language
64
70
  language.id
65
71
  else
@@ -75,8 +81,8 @@ module EnjuNdl
75
81
  doc.xpath('//dcndl:materialType[@rdf:resource]').each do |d|
76
82
  case d.attributes['resource'].try(:content)
77
83
  when 'http://ndl.go.jp/ndltype/Book'
78
- carrier_type = CarrierType.where(name: 'print').first
79
- content_type = ContentType.where(name: 'text').first
84
+ carrier_type = CarrierType.find_by(name: 'print')
85
+ content_type = ContentType.find_by(name: 'text')
80
86
  when 'http://ndl.go.jp/ndltype/Braille'
81
87
  content_type = ContentType.where(name: 'tactile_text').first
82
88
  # when 'http://ndl.go.jp/ndltype/ComputerProgram'
@@ -148,19 +154,19 @@ module EnjuNdl
148
154
  identifier = {}
149
155
  if isbn
150
156
  identifier[:isbn] = Identifier.new(body: isbn)
151
- identifier[:isbn].identifier_type = IdentifierType.find_by(name: 'isbn') || IdnetifierType.create!(name: 'isbn')
157
+ identifier[:isbn].identifier_type = IdentifierType.where(name: 'isbn').first || IdnetifierType.create!(name: 'isbn')
152
158
  end
153
159
  if iss_itemno
154
160
  identifier[:iss_itemno] = Identifier.new(body: iss_itemno)
155
- identifier[:iss_itemno].identifier_type = IdentifierType.find_by(name: 'iss_itemno') || IdentifierType.create!(name: 'iss_itemno')
161
+ identifier[:iss_itemno].identifier_type = IdentifierType.where(name: 'iss_itemno').first || IdentifierType.create!(name: 'iss_itemno')
156
162
  end
157
163
  if jpno
158
164
  identifier[:jpno] = Identifier.new(body: jpno)
159
- identifier[:jpno].identifier_type = IdentifierType.find_by(name: 'jpno') || IdentifierType.create!(name: 'jpno')
165
+ identifier[:jpno].identifier_type = IdentifierType.where(name: 'jpno').first || IdentifierType.create!(name: 'jpno')
160
166
  end
161
167
  if issn
162
168
  identifier[:issn] = Identifier.new(body: issn)
163
- identifier[:issn].identifier_type = IdentifierType.find_by(name: 'issn') || IdentifierType.create!(name: 'issn')
169
+ identifier[:issn].identifier_type = IdentifierType.where(name: 'issn').first || IdentifierType.create!(name: 'issn')
164
170
  end
165
171
  if issn_l
166
172
  identifier[:issn_l] = Identifier.new(body: issn_l)
@@ -194,7 +200,7 @@ module EnjuNdl
194
200
  manifestation
195
201
  end
196
202
 
197
- def create_additional_attributes(doc, manifestation)
203
+ def self.create_additional_attributes(doc, manifestation)
198
204
  title = get_title(doc)
199
205
  creators = get_creators(doc).uniq
200
206
  subjects = get_subjects(doc).uniq
@@ -227,7 +233,7 @@ module EnjuNdl
227
233
  if classification_urls
228
234
  classification_urls.each do |url|
229
235
  begin
230
- ndc_url = URI.parse(url)
236
+ ndc_url = URI.parse(URI.escape(url))
231
237
  rescue URI::InvalidURIError
232
238
  end
233
239
  next unless ndc_url
@@ -251,7 +257,7 @@ module EnjuNdl
251
257
  end
252
258
  end
253
259
 
254
- def search_ndl(query, options = {})
260
+ def self.search_ndl(query, options = {})
255
261
  options = { dpid: 'iss-ndl-opac', item: 'any', idx: 1, per_page: 10, raw: false, mediatype: 1 }.merge(options)
256
262
  doc = nil
257
263
  results = {}
@@ -267,7 +273,7 @@ module EnjuNdl
267
273
  end
268
274
  end
269
275
 
270
- def normalize_isbn(isbn)
276
+ def self.normalize_isbn(isbn)
271
277
  if isbn.length == 10
272
278
  Lisbn.new(isbn).isbn13
273
279
  else
@@ -275,7 +281,7 @@ module EnjuNdl
275
281
  end
276
282
  end
277
283
 
278
- def return_xml(isbn)
284
+ def self.return_xml(isbn)
279
285
  rss = search_ndl(isbn, dpid: 'iss-ndl-opac', item: 'isbn')
280
286
  if rss.channel.totalResults.to_i == 0
281
287
  isbn = normalize_isbn(isbn)
@@ -288,7 +294,7 @@ module EnjuNdl
288
294
 
289
295
  private
290
296
 
291
- def get_title(doc)
297
+ def self.get_title(doc)
292
298
  title = {
293
299
  manifestation: doc.xpath('//dc:title/rdf:Description/rdf:value').collect(&:content).join(' '),
294
300
  transcription: doc.xpath('//dc:title/rdf:Description/dcndl:transcription').collect(&:content).join(' '),
@@ -302,7 +308,7 @@ module EnjuNdl
302
308
  title
303
309
  end
304
310
 
305
- def get_creators(doc)
311
+ def self.get_creators(doc)
306
312
  creators = []
307
313
  doc.xpath('//dcterms:creator/foaf:Agent').each do |creator|
308
314
  creators << {
@@ -314,7 +320,7 @@ module EnjuNdl
314
320
  creators
315
321
  end
316
322
 
317
- def get_subjects(doc)
323
+ def self.get_subjects(doc)
318
324
  subjects = []
319
325
  doc.xpath('//dcterms:subject/rdf:Description').each do |subject|
320
326
  subjects << {
@@ -325,7 +331,7 @@ module EnjuNdl
325
331
  subjects
326
332
  end
327
333
 
328
- def get_classifications(doc)
334
+ def self.get_classifications(doc)
329
335
  classifications = []
330
336
  doc.xpath('//dcterms:subject[@rdf:resource]').each do |classification|
331
337
  classifications << {
@@ -335,13 +341,13 @@ module EnjuNdl
335
341
  classifications
336
342
  end
337
343
 
338
- def get_language(doc)
344
+ def self.get_language(doc)
339
345
  # TODO: 言語が複数ある場合
340
346
  language = doc.at('//dcterms:language[@rdf:datatype="http://purl.org/dc/terms/ISO639-2"]').try(:content)
341
347
  language.downcase if language
342
348
  end
343
349
 
344
- def get_publishers(doc)
350
+ def self.get_publishers(doc)
345
351
  publishers = []
346
352
  doc.xpath('//dcterms:publisher/foaf:Agent').each do |publisher|
347
353
  publishers << {
@@ -353,7 +359,7 @@ module EnjuNdl
353
359
  publishers
354
360
  end
355
361
 
356
- def get_extent(doc)
362
+ def self.get_extent(doc)
357
363
  extent = doc.at('//dcterms:extent').try(:content)
358
364
  value = { start_page: nil, end_page: nil, height: nil }
359
365
  if extent
@@ -371,7 +377,7 @@ module EnjuNdl
371
377
  value
372
378
  end
373
379
 
374
- def create_series_statement(doc, manifestation)
380
+ def self.create_series_statement(doc, manifestation)
375
381
  series = series_title = {}
376
382
  series[:title] = doc.at('//dcndl:seriesTitle/rdf:Description/rdf:value').try(:content)
377
383
  series[:title_transcription] = doc.at('//dcndl:seriesTitle/rdf:Description/dcndl:transcription').try(:content)
@@ -398,8 +404,8 @@ module EnjuNdl
398
404
  manifestation
399
405
  end
400
406
 
401
- def format_query(query)
402
- Addressable::URI.encode(query.to_s.tr(' ', ' '))
407
+ def self.format_query(query)
408
+ URI.escape(query.to_s.tr(' ', ' '))
403
409
  end
404
410
  end
405
411
 
@@ -1,23 +1,26 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  module EnjuNdl
3
- module Crd
4
- def self.included(base)
5
- base.extend ClassMethods
6
- end
4
+ module EnjuQuestion
5
+ extend ActiveSupport::Concern
6
+
7
+ included do
8
+ def self.crd_per_page
9
+ 5
10
+ end
7
11
 
8
- module ClassMethods
9
- def get_crd_response(options)
12
+ def self.get_crd_response(options)
10
13
  params = { query_logic: 1, results_get_position: 1, results_num: 200, sort: 10 }.merge(options)
11
14
  query = []
12
15
  query << "01_#{params[:query_01].to_s.tr(' ', ' ')}" if params[:query_01]
13
16
  query << "02_#{params[:query_02].to_s.tr(' ', ' ')}" if params[:query_02]
14
17
  delimiter = '.'
15
- url = "http://crd.ndl.go.jp/refapi/servlet/refapi.RSearchAPI?query=#{Addressable::URI.encode(query.join(delimiter))}&query_logic=#{params[:query_logic]}&results_get_position=#{params[:results_get_position]}&results_num=#{params[:results_num]}&sort=#{params[:sort]}"
18
+ url = "http://crd.ndl.go.jp/refapi/servlet/refapi.RSearchAPI?query=#{URI.escape(query.join(delimiter))}&query_logic=#{params[:query_logic]}&results_get_position=#{params[:results_get_position]}&results_num=#{params[:results_num]}&sort=#{params[:sort]}"
16
19
 
17
- xml = open(url).read.to_s
20
+ open(url).read.to_s
18
21
  end
19
22
 
20
- def search_crd(options)
23
+ def self.search_crd(options)
21
24
  params = { page: 1 }.merge(options)
22
25
  crd_page = params[:page].to_i
23
26
  crd_page = 1 if crd_page <= 0
@@ -0,0 +1,14 @@
1
+ class JpnoRecord < ApplicationRecord
2
+ belongs_to :manifestation
3
+ end
4
+
5
+ # == Schema Information
6
+ #
7
+ # Table name: jpno_records
8
+ #
9
+ # id :bigint not null, primary key
10
+ # body :string not null
11
+ # manifestation_id :bigint not null
12
+ # created_at :datetime not null
13
+ # updated_at :datetime not null
14
+ #
@@ -0,0 +1,14 @@
1
+ class NdlBibIdRecord < ApplicationRecord
2
+ belongs_to :manifestation
3
+ end
4
+
5
+ # == Schema Information
6
+ #
7
+ # Table name: ndl_bib_id_records
8
+ #
9
+ # id :bigint not null, primary key
10
+ # body :string not null
11
+ # manifestation_id :bigint not null
12
+ # created_at :datetime not null
13
+ # updated_at :datetime not null
14
+ #
@@ -66,9 +66,9 @@ class NdlBook
66
66
  end
67
67
 
68
68
  def self.import_from_sru_response(itemno)
69
- identifier_type = IdentifierType.find_by(name: 'iss_itemno')
69
+ identifier_type = IdentifierType.where(name: 'iss_itemno').first
70
70
  identifier_type ||= IdentifierType.create!(name: 'iss_itemno')
71
- identifier = Identifier.find_by(body: itemno, identifier_type_id: identifier_type.id)
71
+ identifier = Identifier.where(body: itemno, identifier_type_id: identifier_type.id).first
72
72
  return if identifier
73
73
  url = "https://iss.ndl.go.jp/api/sru?operation=searchRetrieve&recordSchema=dcndl&maximumRecords=1&query=%28itemno=#{itemno}%29&onlyBib=true"
74
74
  xml = Faraday.get(url).body
@@ -0,0 +1,14 @@
1
+ class NdlaRecord < ApplicationRecord
2
+ belongs_to :agent
3
+ end
4
+
5
+ # == Schema Information
6
+ #
7
+ # Table name: ndla_records
8
+ #
9
+ # id :bigint not null, primary key
10
+ # agent_id :bigint
11
+ # body :string not null
12
+ # created_at :datetime not null
13
+ # updated_at :datetime not null
14
+ #
@@ -0,0 +1,10 @@
1
+ class CreateJpnoRecords < ActiveRecord::Migration[5.2]
2
+ def change
3
+ create_table :jpno_records do |t|
4
+ t.string :body, index: {unique: true}, null: false
5
+ t.references :manifestation, foreign_key: true, null: false
6
+
7
+ t.timestamps
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ class CreateNdlaRecords < ActiveRecord::Migration[5.2]
2
+ def change
3
+ create_table :ndla_records do |t|
4
+ t.references :agent, foreign_key: true
5
+ t.string :body, null: false, index: {unique: true}
6
+
7
+ t.timestamps
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ class CreateNdlBibIdRecords < ActiveRecord::Migration[5.2]
2
+ def change
3
+ create_table :ndl_bib_id_records do |t|
4
+ t.string :body, index: {unique: true}, null: false
5
+ t.references :manifestation, foreign_key: true, null: false
6
+
7
+ t.timestamps
8
+ end
9
+ end
10
+ end
@@ -1,3 +1,3 @@
1
1
  module EnjuNdl
2
- VERSION = "0.3.3".freeze
2
+ VERSION = '0.4.0.beta.1'.freeze
3
3
  end
data/lib/enju_ndl.rb CHANGED
@@ -1,30 +1,10 @@
1
- require "enju_ndl/engine"
1
+ require 'enju_ndl/engine'
2
2
  require 'open-uri'
3
- require 'enju_ndl/ndl_search'
4
- require 'enju_ndl/crd'
5
3
 
6
4
  module EnjuNdl
7
- module ActsAsMethods
8
- def self.included(base)
9
- base.extend ClassMethods
10
- end
11
-
12
- module ClassMethods
13
- def enju_ndl_ndl_search
14
- include EnjuNdl::NdlSearch
15
- end
16
-
17
- def enju_ndl_crd
18
- include EnjuNdl::Crd
19
- end
20
- end
21
- end
22
-
23
5
  class RecordNotFound < StandardError
24
6
  end
25
7
 
26
8
  class InvalidIsbn < StandardError
27
9
  end
28
10
  end
29
-
30
- ActiveRecord::Base.send :include, EnjuNdl::ActsAsMethods
@@ -1,4 +1,4 @@
1
- class User < ApplicationRecord
1
+ class User < ActiveRecord::Base
2
2
  devise :database_authenticatable, #:registerable,
3
3
  :recoverable, :rememberable, :trackable, #, :validatable
4
4
  :lockable, :lock_strategy => :none, :unlock_strategy => :none
@@ -7,3 +7,7 @@ class User < ApplicationRecord
7
7
  end
8
8
 
9
9
  Manifestation.include(EnjuSubject::EnjuManifestation)
10
+ ImportRequest.include(EnjuNdl::EnjuManifestation)
11
+ Manifestation.include(EnjuNdl::EnjuManifestation)
12
+ Agent.include(EnjuNdl::EnjuAgent)
13
+ Question.include(EnjuNdl::EnjuQuestion)
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env ruby
2
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
3
3
  load Gem.bin_path('bundler', 'bundle')
data/spec/dummy/bin/setup CHANGED
@@ -1,10 +1,9 @@
1
1
  #!/usr/bin/env ruby
2
- require 'pathname'
3
2
  require 'fileutils'
4
3
  include FileUtils
5
4
 
6
5
  # path to your application root.
7
- APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
6
+ APP_ROOT = File.expand_path('..', __dir__)
8
7
 
9
8
  def system!(*args)
10
9
  system(*args) || abort("\n== Command #{args} failed ==")
@@ -21,7 +20,6 @@ chdir APP_ROOT do
21
20
  # Install JavaScript dependencies if using Yarn
22
21
  # system('bin/yarn')
23
22
 
24
-
25
23
  # puts "\n== Copying sample files =="
26
24
  # unless File.exist?('config/database.yml')
27
25
  # cp 'config/database.yml.sample', 'config/database.yml'
@@ -1,10 +1,9 @@
1
1
  #!/usr/bin/env ruby
2
- require 'pathname'
3
2
  require 'fileutils'
4
3
  include FileUtils
5
4
 
6
5
  # path to your application root.
7
- APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
6
+ APP_ROOT = File.expand_path('..', __dir__)
8
7
 
9
8
  def system!(*args)
10
9
  system(*args) || abort("\n== Command #{args} failed ==")
@@ -18,6 +17,9 @@ chdir APP_ROOT do
18
17
  system! 'gem install bundler --conservative'
19
18
  system('bundle check') || system!('bundle install')
20
19
 
20
+ # Install JavaScript dependencies if using Yarn
21
+ # system('bin/yarn')
22
+
21
23
  puts "\n== Updating database =="
22
24
  system! 'bin/rails db:migrate'
23
25
 
data/spec/dummy/bin/yarn CHANGED
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
- VENDOR_PATH = File.expand_path('..', __dir__)
3
- Dir.chdir(VENDOR_PATH) do
2
+ APP_ROOT = File.expand_path('..', __dir__)
3
+ Dir.chdir(APP_ROOT) do
4
4
  begin
5
- exec "yarnpkg #{ARGV.join(" ")}"
5
+ exec "yarnpkg", *ARGV
6
6
  rescue Errno::ENOENT
7
7
  $stderr.puts "Yarn executable was not detected in the system."
8
8
  $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install"
@@ -5,11 +5,12 @@ require 'rails/all'
5
5
  Bundler.require(*Rails.groups)
6
6
  require "enju_ndl"
7
7
  require "enju_question"
8
+ require "enju_subject"
8
9
 
9
10
  module Dummy
10
11
  class Application < Rails::Application
11
12
  # Initialize configuration defaults for originally generated Rails version.
12
- config.load_defaults 5.1
13
+ config.load_defaults 5.2
13
14
 
14
15
  # Settings in config/environments/* take precedence over those specified here.
15
16
  # Application configuration should go into files in config/initializers