qa 0.0.2 → 0.0.3

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: 873698ac06d737a85d38e567cfbc86a237c11726
4
- data.tar.gz: aca833c7eaaf7b53e5181f9705828e6bdd64267d
3
+ metadata.gz: fed80fc0a3c24bbbd3032d4073f7e75aac0aa9c5
4
+ data.tar.gz: 965f2f9ec8fe396b5d31bfc3fa6d87e2787cd556
5
5
  SHA512:
6
- metadata.gz: 48ff5de3dabe9ff003cd066d67ded425ac5782ecc5f493d41879832ab0d9bf047118f96b10d091656af0a866e1169e896a86d15958014b15091e1b3f6004d356
7
- data.tar.gz: 860a602fc303ec68bdd76f7651a5d193c97ac2656fa281ee83b7c998acb9461d4800f73bd8c8a1d63b53591b446f315cff64854694fbda8e87f93d6b897f3e43
6
+ metadata.gz: 0c008f809edb88cdea1d9f39c17f938d6d496b9b2e709976789b206cccc9c37bcbe72f30cf585c6f05fce0701fa50337bc6809303863d6d192db0d51652b6b69
7
+ data.tar.gz: 80c6e14d23838e345affc9723f0d99d56f3c2731a6be9f45d939966ee2d22ea8bcfb80746d1612379cf50837386959aded55bc664dfe88c8169df566b721cb50
@@ -17,6 +17,10 @@ module Qa::Authorities
17
17
  end
18
18
  end
19
19
 
20
+ def full_record(id)
21
+ terms.find { |term| term[:id] == id } || {}
22
+ end
23
+
20
24
  class << self
21
25
  def sub_authorities_path
22
26
  config_path = AUTHORITIES_CONFIG[:local_path]
@@ -1,6 +1,8 @@
1
+ require 'deprecation'
1
2
  module Qa::Authorities
2
3
 
3
4
  class Local < Qa::Authorities::Base
5
+ extend Deprecation
4
6
 
5
7
  class << self
6
8
  def sub_authority(name)
@@ -18,16 +20,19 @@ module Qa::Authorities
18
20
  end
19
21
  end
20
22
 
23
+ delegate :sub_authority, to: self
24
+
21
25
  def search(q, sub_authority)
22
- Local.sub_authority(sub_authority).search(q)
26
+ sub_authority(sub_authority).search(q)
27
+ end
28
+
29
+ def full_record(id, sub_authority)
30
+ sub_authority(sub_authority).full_record(id)
23
31
  end
24
32
 
25
33
  def get_full_record(id, sub_authority)
26
- terms = Local.sub_authority(sub_authority).terms
27
- terms.each do |term|
28
- return term if term[:id] == id
29
- end
30
- return {}
34
+ Deprecation.warn(Local, "get_full_record is deprecated and will be removed in 0.1.0. Use full_record instead", caller)
35
+ full_record(id, sub_authority)
31
36
  end
32
37
 
33
38
  end
data/lib/qa/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Qa
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -0,0 +1,26 @@
1
+ require 'benchmark'
2
+
3
+ namespace :mesh do
4
+ desc "Import MeSH terms from the file $MESH_FILE, it will update any terms which are already in the database"
5
+ task :import => :environment do
6
+ fname = ENV['MESH_FILE']
7
+ if fname.nil?
8
+ puts "Need to set $MESH_FILE with path to file to ingest"
9
+ next # transfers control out of this block
10
+ end
11
+ Benchmark.bm(30) do |bm|
12
+ bm.report("Importing #{fname}") do
13
+ m = Qa::Authorities::MeshTools::MeshImporter.new
14
+ File.open(fname) do |f|
15
+ m.import_from_file(f)
16
+ end
17
+ end
18
+ end
19
+ end
20
+
21
+ desc "Delete all mesh terms from the database---not implemented"
22
+ task :clear do
23
+ puts "Not implemented"
24
+ end
25
+
26
+ end
@@ -1,9 +1,10 @@
1
1
  PATH
2
2
  remote: ../../../questioning_authority
3
3
  specs:
4
- qa (0.0.1)
4
+ qa (0.0.2)
5
5
  activerecord-import (>= 0.4.0)
6
6
  curb
7
+ deprecation
7
8
  nokogiri (~> 1.6.0)
8
9
  rails (~> 4.0.0)
9
10
  rest-client
@@ -51,6 +52,8 @@ GEM
51
52
  crack (0.4.1)
52
53
  safe_yaml (~> 0.9.0)
53
54
  curb (0.8.5)
55
+ deprecation (0.0.5)
56
+ activesupport
54
57
  diff-lcs (1.2.4)
55
58
  erubis (2.7.0)
56
59
  execjs (2.0.2)
Binary file
@@ -6548,3 +6548,499 @@ Completed 400 Bad Request in 0ms (ActiveRecord: 0.0ms)
6548
6548
   (0.1ms) rollback transaction
6549
6549
   (0.1ms) begin transaction
6550
6550
   (0.1ms) rollback transaction
6551
+ ActiveRecord::SchemaMigration Load (0.6ms) SELECT "schema_migrations".* FROM "schema_migrations"
6552
+  (0.1ms) begin transaction
6553
+  (0.3ms) rollback transaction
6554
+  (0.1ms) begin transaction
6555
+  (0.1ms) rollback transaction
6556
+  (0.1ms) begin transaction
6557
+  (0.1ms) rollback transaction
6558
+  (0.1ms) begin transaction
6559
+  (0.1ms) rollback transaction
6560
+  (0.1ms) begin transaction
6561
+  (0.1ms) rollback transaction
6562
+  (0.1ms) begin transaction
6563
+  (0.2ms) rollback transaction
6564
+  (0.1ms) begin transaction
6565
+  (0.1ms) rollback transaction
6566
+  (0.1ms) begin transaction
6567
+  (0.1ms) rollback transaction
6568
+  (0.1ms) begin transaction
6569
+  (0.2ms) rollback transaction
6570
+  (0.1ms) begin transaction
6571
+  (0.1ms) rollback transaction
6572
+  (0.1ms) begin transaction
6573
+  (0.2ms) rollback transaction
6574
+  (0.1ms) begin transaction
6575
+  (0.1ms) rollback transaction
6576
+  (0.1ms) begin transaction
6577
+  (0.1ms) rollback transaction
6578
+  (0.1ms) begin transaction
6579
+  (0.2ms) rollback transaction
6580
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
6581
+  (0.1ms) begin transaction
6582
+  (0.1ms) rollback transaction
6583
+  (0.1ms) begin transaction
6584
+  (0.1ms) rollback transaction
6585
+  (0.1ms) begin transaction
6586
+  (0.1ms) rollback transaction
6587
+  (0.1ms) begin transaction
6588
+  (0.1ms) rollback transaction
6589
+  (0.1ms) begin transaction
6590
+  (0.1ms) rollback transaction
6591
+  (0.1ms) begin transaction
6592
+  (0.1ms) rollback transaction
6593
+  (0.1ms) begin transaction
6594
+  (0.1ms) rollback transaction
6595
+  (0.1ms) begin transaction
6596
+  (0.0ms) rollback transaction
6597
+  (0.1ms) begin transaction
6598
+  (0.1ms) rollback transaction
6599
+  (0.2ms) begin transaction
6600
+  (0.1ms) rollback transaction
6601
+  (0.1ms) begin transaction
6602
+  (0.1ms) rollback transaction
6603
+  (0.1ms) begin transaction
6604
+  (0.1ms) rollback transaction
6605
+  (0.1ms) begin transaction
6606
+  (0.1ms) rollback transaction
6607
+  (0.1ms) begin transaction
6608
+  (0.1ms) rollback transaction
6609
+  (0.1ms) begin transaction
6610
+  (0.1ms) rollback transaction
6611
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
6612
+  (0.1ms) begin transaction
6613
+  (0.1ms) rollback transaction
6614
+  (0.1ms) begin transaction
6615
+  (0.1ms) rollback transaction
6616
+  (0.1ms) begin transaction
6617
+  (0.1ms) rollback transaction
6618
+  (0.1ms) begin transaction
6619
+  (0.1ms) rollback transaction
6620
+  (0.1ms) begin transaction
6621
+  (0.1ms) rollback transaction
6622
+  (0.1ms) begin transaction
6623
+  (0.1ms) rollback transaction
6624
+  (0.1ms) begin transaction
6625
+  (0.1ms) rollback transaction
6626
+  (0.1ms) begin transaction
6627
+  (0.1ms) rollback transaction
6628
+  (0.1ms) begin transaction
6629
+  (0.1ms) rollback transaction
6630
+  (0.1ms) begin transaction
6631
+  (0.1ms) rollback transaction
6632
+  (0.1ms) begin transaction
6633
+  (0.1ms) rollback transaction
6634
+  (0.1ms) begin transaction
6635
+  (0.1ms) rollback transaction
6636
+  (0.1ms) begin transaction
6637
+  (0.1ms) rollback transaction
6638
+  (0.1ms) begin transaction
6639
+  (0.1ms) rollback transaction
6640
+  (0.0ms) begin transaction
6641
+  (0.0ms) rollback transaction
6642
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
6643
+  (0.1ms) begin transaction
6644
+  (0.1ms) rollback transaction
6645
+  (0.1ms) begin transaction
6646
+  (0.1ms) rollback transaction
6647
+  (0.1ms) begin transaction
6648
+  (0.1ms) rollback transaction
6649
+  (0.1ms) begin transaction
6650
+  (0.1ms) rollback transaction
6651
+  (0.1ms) begin transaction
6652
+  (0.1ms) rollback transaction
6653
+  (0.1ms) begin transaction
6654
+  (0.1ms) rollback transaction
6655
+  (0.1ms) begin transaction
6656
+  (0.1ms) rollback transaction
6657
+  (0.1ms) begin transaction
6658
+  (0.1ms) rollback transaction
6659
+  (0.1ms) begin transaction
6660
+  (0.1ms) rollback transaction
6661
+  (0.1ms) begin transaction
6662
+  (0.1ms) rollback transaction
6663
+  (0.1ms) begin transaction
6664
+  (0.1ms) rollback transaction
6665
+  (0.1ms) begin transaction
6666
+  (0.1ms) rollback transaction
6667
+  (0.1ms) begin transaction
6668
+  (0.1ms) rollback transaction
6669
+  (0.1ms) begin transaction
6670
+  (0.1ms) rollback transaction
6671
+  (0.1ms) begin transaction
6672
+  (0.1ms) rollback transaction
6673
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
6674
+  (0.1ms) begin transaction
6675
+  (0.1ms) rollback transaction
6676
+  (0.1ms) begin transaction
6677
+  (0.1ms) rollback transaction
6678
+  (0.1ms) begin transaction
6679
+  (0.1ms) rollback transaction
6680
+  (0.1ms) begin transaction
6681
+  (0.1ms) rollback transaction
6682
+  (0.1ms) begin transaction
6683
+  (0.1ms) rollback transaction
6684
+  (0.1ms) begin transaction
6685
+  (0.1ms) rollback transaction
6686
+  (0.1ms) begin transaction
6687
+  (0.1ms) rollback transaction
6688
+  (0.1ms) begin transaction
6689
+  (0.1ms) rollback transaction
6690
+  (0.1ms) begin transaction
6691
+  (0.1ms) rollback transaction
6692
+  (0.1ms) begin transaction
6693
+  (0.1ms) rollback transaction
6694
+  (0.1ms) begin transaction
6695
+  (0.1ms) rollback transaction
6696
+  (0.1ms) begin transaction
6697
+  (0.1ms) rollback transaction
6698
+  (0.1ms) begin transaction
6699
+  (0.0ms) rollback transaction
6700
+  (0.1ms) begin transaction
6701
+  (0.1ms) rollback transaction
6702
+  (0.1ms) begin transaction
6703
+  (0.1ms) rollback transaction
6704
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
6705
+  (0.1ms) begin transaction
6706
+  (0.1ms) rollback transaction
6707
+  (0.1ms) begin transaction
6708
+  (0.1ms) rollback transaction
6709
+  (0.1ms) begin transaction
6710
+  (0.1ms) rollback transaction
6711
+  (0.1ms) begin transaction
6712
+  (0.1ms) rollback transaction
6713
+  (0.1ms) begin transaction
6714
+  (0.1ms) rollback transaction
6715
+  (0.1ms) begin transaction
6716
+  (0.1ms) rollback transaction
6717
+  (0.1ms) begin transaction
6718
+  (0.1ms) rollback transaction
6719
+  (0.1ms) begin transaction
6720
+  (0.0ms) rollback transaction
6721
+  (0.1ms) begin transaction
6722
+  (0.0ms) rollback transaction
6723
+  (0.1ms) begin transaction
6724
+  (0.1ms) rollback transaction
6725
+  (0.0ms) begin transaction
6726
+  (0.1ms) rollback transaction
6727
+  (0.1ms) begin transaction
6728
+  (0.1ms) rollback transaction
6729
+  (0.1ms) begin transaction
6730
+  (0.1ms) rollback transaction
6731
+  (0.1ms) begin transaction
6732
+  (0.1ms) rollback transaction
6733
+  (0.1ms) begin transaction
6734
+  (0.1ms) rollback transaction
6735
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
6736
+  (0.1ms) begin transaction
6737
+  (0.1ms) rollback transaction
6738
+  (0.1ms) begin transaction
6739
+  (0.1ms) rollback transaction
6740
+  (0.1ms) begin transaction
6741
+  (0.0ms) rollback transaction
6742
+  (0.1ms) begin transaction
6743
+  (0.0ms) rollback transaction
6744
+  (0.1ms) begin transaction
6745
+  (0.1ms) rollback transaction
6746
+  (0.1ms) begin transaction
6747
+  (0.1ms) rollback transaction
6748
+  (0.1ms) begin transaction
6749
+  (0.1ms) rollback transaction
6750
+  (0.1ms) begin transaction
6751
+  (0.1ms) rollback transaction
6752
+  (0.1ms) begin transaction
6753
+  (0.1ms) rollback transaction
6754
+  (0.1ms) begin transaction
6755
+  (0.1ms) rollback transaction
6756
+  (0.1ms) begin transaction
6757
+  (0.1ms) rollback transaction
6758
+  (0.1ms) begin transaction
6759
+  (0.0ms) rollback transaction
6760
+  (0.0ms) begin transaction
6761
+  (0.0ms) rollback transaction
6762
+  (0.0ms) begin transaction
6763
+  (0.0ms) rollback transaction
6764
+  (0.0ms) begin transaction
6765
+  (0.1ms) rollback transaction
6766
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
6767
+ ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
6768
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
6769
+  (0.1ms) begin transaction
6770
+  (0.1ms) rollback transaction
6771
+  (0.1ms) begin transaction
6772
+  (0.1ms) rollback transaction
6773
+  (0.1ms) begin transaction
6774
+  (0.1ms) rollback transaction
6775
+  (0.1ms) begin transaction
6776
+  (0.1ms) rollback transaction
6777
+  (0.1ms) begin transaction
6778
+  (0.1ms) rollback transaction
6779
+  (0.1ms) begin transaction
6780
+  (0.1ms) rollback transaction
6781
+  (0.1ms) begin transaction
6782
+  (0.1ms) rollback transaction
6783
+  (0.1ms) begin transaction
6784
+  (0.1ms) rollback transaction
6785
+  (0.1ms) begin transaction
6786
+  (0.1ms) rollback transaction
6787
+  (0.1ms) begin transaction
6788
+  (0.1ms) rollback transaction
6789
+  (0.2ms) begin transaction
6790
+  (0.1ms) rollback transaction
6791
+  (0.1ms) begin transaction
6792
+  (0.1ms) rollback transaction
6793
+  (0.1ms) begin transaction
6794
+  (0.1ms) rollback transaction
6795
+  (0.1ms) begin transaction
6796
+  (0.1ms) rollback transaction
6797
+  (0.1ms) begin transaction
6798
+  (0.1ms) rollback transaction
6799
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
6800
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
6801
+  (0.1ms) begin transaction
6802
+  (0.1ms) rollback transaction
6803
+  (0.1ms) begin transaction
6804
+  (0.1ms) rollback transaction
6805
+  (0.1ms) begin transaction
6806
+  (0.1ms) rollback transaction
6807
+  (0.1ms) begin transaction
6808
+  (0.1ms) rollback transaction
6809
+  (0.1ms) begin transaction
6810
+  (0.1ms) rollback transaction
6811
+  (0.1ms) begin transaction
6812
+  (0.1ms) rollback transaction
6813
+  (0.1ms) begin transaction
6814
+  (0.1ms) rollback transaction
6815
+  (0.1ms) begin transaction
6816
+  (0.0ms) rollback transaction
6817
+  (0.1ms) begin transaction
6818
+  (0.1ms) rollback transaction
6819
+  (0.1ms) begin transaction
6820
+  (0.1ms) rollback transaction
6821
+  (0.1ms) begin transaction
6822
+  (0.1ms) rollback transaction
6823
+  (0.1ms) begin transaction
6824
+  (0.1ms) rollback transaction
6825
+  (0.1ms) begin transaction
6826
+  (0.1ms) rollback transaction
6827
+  (0.1ms) begin transaction
6828
+  (0.1ms) rollback transaction
6829
+  (0.1ms) begin transaction
6830
+  (0.1ms) rollback transaction
6831
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
6832
+  (0.1ms) begin transaction
6833
+  (0.1ms) rollback transaction
6834
+  (0.1ms) begin transaction
6835
+  (0.1ms) rollback transaction
6836
+  (0.1ms) begin transaction
6837
+  (0.1ms) rollback transaction
6838
+  (0.1ms) begin transaction
6839
+  (0.1ms) rollback transaction
6840
+  (0.1ms) begin transaction
6841
+  (0.1ms) rollback transaction
6842
+  (0.1ms) begin transaction
6843
+  (0.1ms) rollback transaction
6844
+  (0.1ms) begin transaction
6845
+  (0.1ms) rollback transaction
6846
+  (0.1ms) begin transaction
6847
+  (0.1ms) rollback transaction
6848
+  (0.1ms) begin transaction
6849
+  (0.1ms) rollback transaction
6850
+  (0.1ms) begin transaction
6851
+  (0.1ms) rollback transaction
6852
+  (0.1ms) begin transaction
6853
+  (0.1ms) rollback transaction
6854
+  (0.1ms) begin transaction
6855
+  (0.1ms) rollback transaction
6856
+  (0.1ms) begin transaction
6857
+  (0.1ms) rollback transaction
6858
+  (0.1ms) begin transaction
6859
+  (0.1ms) rollback transaction
6860
+  (0.1ms) begin transaction
6861
+  (0.0ms) rollback transaction
6862
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
6863
+  (0.1ms) begin transaction
6864
+  (0.1ms) rollback transaction
6865
+  (0.1ms) begin transaction
6866
+  (0.1ms) rollback transaction
6867
+  (0.1ms) begin transaction
6868
+  (0.1ms) rollback transaction
6869
+  (0.1ms) begin transaction
6870
+  (0.1ms) rollback transaction
6871
+  (0.1ms) begin transaction
6872
+  (0.1ms) rollback transaction
6873
+  (0.1ms) begin transaction
6874
+  (0.1ms) rollback transaction
6875
+  (0.1ms) begin transaction
6876
+  (0.1ms) rollback transaction
6877
+  (0.1ms) begin transaction
6878
+  (0.1ms) rollback transaction
6879
+  (0.1ms) begin transaction
6880
+  (0.1ms) rollback transaction
6881
+  (0.1ms) begin transaction
6882
+  (0.1ms) rollback transaction
6883
+  (0.1ms) begin transaction
6884
+  (0.1ms) rollback transaction
6885
+  (0.1ms) begin transaction
6886
+  (0.0ms) rollback transaction
6887
+  (0.1ms) begin transaction
6888
+  (0.1ms) rollback transaction
6889
+  (0.1ms) begin transaction
6890
+  (0.1ms) rollback transaction
6891
+  (0.1ms) begin transaction
6892
+  (0.1ms) rollback transaction
6893
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
6894
+  (0.1ms) begin transaction
6895
+  (0.1ms) rollback transaction
6896
+  (0.1ms) begin transaction
6897
+  (0.1ms) rollback transaction
6898
+  (0.1ms) begin transaction
6899
+  (0.1ms) select sqlite_version(*)
6900
+ Class Create Many Without Validations Or Callbacks (0.4ms) INSERT INTO "qa_subject_mesh_terms" ("term_id","term","term_lower","synonyms") VALUES ('D008288','Malaria','malaria','Marsh Fever|Plasmodium Infections|Remittent Fever|Infections, Plasmodium|Paludism|Fever, Marsh|Fever, Remittent|Infection, Plasmodium|Plasmodium Infection'),('D000001','Calcimycin','calcimycin','A-23187|A23187|Antibiotic A23187|A 23187|A23187, Antibiotic'),('D005260','Female','female','Females'),('D005261','Female Urogenital Diseases and Pregnancy Complications','female urogenital diseases and pregnancy complications',''),('D010272','Parasitic Diseases','parasitic diseases','Disease, Parasitic|Diseases, Parasitic|Parasitic Disease'),('D011528','Protozoan Infections','protozoan infections','Histomoniasis|Infections, Protozoan|Histomoniases|Infection, Protozoan|Protozoan Infection'),('D062310','Tropical Diseases','tropical diseases','Disease, Tropical|Diseases, Tropical|Tropical Disease'),('D013568','Pathological Conditions, Signs and Symptoms','pathological conditions, signs and symptoms','Symptoms and General Pathology'),('D001583','Benzoxazoles','benzoxazoles',''),('D006574','Heterocyclic Compounds, 2-Ring','heterocyclic compounds, 2-ring','2-Ring Heterocyclic Compounds|Compounds, 2-Ring Heterocyclic|Heterocyclic Compounds, 2 Ring'),('D006571','Heterocyclic Compounds','heterocyclic compounds','Compounds, Heterocyclic')
6901
+ Class Create Many Without Validations Or Callbacks (0.2ms) INSERT INTO "qa_mesh_trees" ("term_id","tree_number") VALUES ('D008288','C03.752.530'),('D008288','C23.996.660'),('D000001','D03.438.221.173'),('D005261','C13'),('D010272','C03'),('D011528','C03.752'),('D062310','C03.883'),('D062310','C23.996'),('D013568','C23'),('D001583','D03.438.221'),('D006574','D03.438'),('D006571','D03')
6902
+ Qa::SubjectMeshTerm Load (0.1ms) SELECT "qa_subject_mesh_terms".* FROM "qa_subject_mesh_terms" WHERE "qa_subject_mesh_terms"."term_lower" = 'malaria'
6903
+ Qa::SubjectMeshTerm Load (0.1ms) SELECT "qa_subject_mesh_terms".* FROM "qa_subject_mesh_terms" WHERE "qa_subject_mesh_terms"."term" = 'Malaria'
6904
+ Qa::SubjectMeshTerm Load (0.1ms) SELECT "qa_subject_mesh_terms".* FROM "qa_subject_mesh_terms" WHERE "qa_subject_mesh_terms"."term_id" = 'D008288'
6905
+ Qa::SubjectMeshTerm Load (0.3ms) SELECT "qa_subject_mesh_terms".* FROM "qa_subject_mesh_terms"
6906
+  (1.0ms) rollback transaction
6907
+  (0.1ms) begin transaction
6908
+ SQL (0.6ms) INSERT INTO "qa_subject_mesh_terms" ("term", "term_id", "term_lower") VALUES (?, ?, ?) [["term", "Mr Plow"], ["term_id", "1"], ["term_lower", "mr plow"]]
6909
+  (1.5ms) commit transaction
6910
+  (0.1ms) begin transaction
6911
+ SQL (0.3ms) INSERT INTO "qa_subject_mesh_terms" ("term", "term_id", "term_lower") VALUES (?, ?, ?) [["term", "Mr Snow"], ["term_id", "2"], ["term_lower", "mr snow"]]
6912
+  (1.4ms) commit transaction
6913
+  (0.1ms) begin transaction
6914
+ SQL (0.3ms) INSERT INTO "qa_subject_mesh_terms" ("term", "term_id", "term_lower") VALUES (?, ?, ?) [["term", "Mrs Fields"], ["term_id", "3"], ["term_lower", "mrs fields"]]
6915
+  (1.4ms) commit transaction
6916
+  (0.1ms) begin transaction
6917
+ Qa::SubjectMeshTerm Load (0.2ms) SELECT "qa_subject_mesh_terms".* FROM "qa_subject_mesh_terms" WHERE (term_lower LIKE 'mr%') LIMIT 10
6918
+  (0.1ms) rollback transaction
6919
+  (0.1ms) begin transaction
6920
+ Qa::SubjectMeshTerm Load (0.2ms) SELECT "qa_subject_mesh_terms".* FROM "qa_subject_mesh_terms" WHERE "qa_subject_mesh_terms"."term_id" = '2' ORDER BY "qa_subject_mesh_terms"."id" ASC LIMIT 1
6921
+  (0.1ms) rollback transaction
6922
+ SQL (1.6ms) DELETE FROM "qa_subject_mesh_terms"
6923
+  (0.1ms) begin transaction
6924
+  (0.1ms) rollback transaction
6925
+  (0.1ms) begin transaction
6926
+  (0.1ms) rollback transaction
6927
+  (0.1ms) begin transaction
6928
+  (0.1ms) rollback transaction
6929
+  (0.0ms) begin transaction
6930
+  (0.1ms) rollback transaction
6931
+  (0.1ms) begin transaction
6932
+  (0.1ms) rollback transaction
6933
+  (0.1ms) begin transaction
6934
+  (0.1ms) rollback transaction
6935
+  (0.1ms) begin transaction
6936
+  (0.1ms) rollback transaction
6937
+  (0.1ms) begin transaction
6938
+  (0.0ms) rollback transaction
6939
+  (0.1ms) begin transaction
6940
+  (0.1ms) rollback transaction
6941
+  (0.0ms) begin transaction
6942
+  (0.1ms) rollback transaction
6943
+  (0.0ms) begin transaction
6944
+  (0.1ms) rollback transaction
6945
+  (0.1ms) begin transaction
6946
+  (0.1ms) rollback transaction
6947
+  (0.1ms) begin transaction
6948
+  (0.1ms) rollback transaction
6949
+  (0.1ms) begin transaction
6950
+  (0.0ms) rollback transaction
6951
+  (0.1ms) begin transaction
6952
+  (0.1ms) rollback transaction
6953
+  (0.1ms) begin transaction
6954
+  (0.1ms) rollback transaction
6955
+  (0.1ms) begin transaction
6956
+  (0.1ms) rollback transaction
6957
+  (0.1ms) begin transaction
6958
+  (0.0ms) rollback transaction
6959
+  (0.1ms) begin transaction
6960
+  (0.1ms) rollback transaction
6961
+  (0.1ms) begin transaction
6962
+  (0.1ms) rollback transaction
6963
+  (0.1ms) begin transaction
6964
+  (0.1ms) rollback transaction
6965
+  (0.1ms) begin transaction
6966
+  (0.1ms) rollback transaction
6967
+  (0.1ms) begin transaction
6968
+  (0.1ms) rollback transaction
6969
+  (0.1ms) begin transaction
6970
+ Processing by Qa::TermsController#index as HTML
6971
+ Parameters: {"q"=>"foo", "vocab"=>"loc"}
6972
+ Completed 200 OK in 5ms (Views: 0.2ms | ActiveRecord: 0.0ms)
6973
+  (0.1ms) rollback transaction
6974
+  (0.1ms) begin transaction
6975
+ Processing by Qa::TermsController#index as HTML
6976
+ Parameters: {"q"=>"Tibetan", "vocab"=>"tgnlang"}
6977
+ Completed 200 OK in 48ms (Views: 0.2ms | ActiveRecord: 0.0ms)
6978
+  (0.1ms) rollback transaction
6979
+  (0.1ms) begin transaction
6980
+ Processing by Qa::TermsController#index as HTML
6981
+ Parameters: {"q"=>"foo", "vocab"=>"loc", "sub_authority"=>"relators"}
6982
+ Completed 200 OK in 4ms (Views: 0.2ms | ActiveRecord: 0.0ms)
6983
+  (0.1ms) rollback transaction
6984
+  (0.1ms) begin transaction
6985
+ Processing by Qa::TermsController#index as HTML
6986
+ Parameters: {"q"=>"Blues", "vocab"=>"lcsh"}
6987
+ Completed 200 OK in 5ms (Views: 0.6ms | ActiveRecord: 0.0ms)
6988
+  (0.1ms) rollback transaction
6989
+  (0.1ms) begin transaction
6990
+ Processing by Qa::TermsController#index as HTML
6991
+ Parameters: {"q"=>"foo", "vocab"=>"bar"}
6992
+ Filter chain halted as :check_authority rendered or redirected
6993
+ Completed 400 Bad Request in 2ms (ActiveRecord: 0.0ms)
6994
+  (0.1ms) rollback transaction
6995
+  (0.1ms) begin transaction
6996
+ Processing by Qa::TermsController#index as HTML
6997
+ Parameters: {"q"=>nil}
6998
+ Filter chain halted as :check_vocab_param rendered or redirected
6999
+ Completed 400 Bad Request in 0ms (ActiveRecord: 0.0ms)
7000
+  (0.1ms) rollback transaction
7001
+  (0.1ms) begin transaction
7002
+ Processing by Qa::TermsController#index as HTML
7003
+ Parameters: {"q"=>"foo", "vocab"=>"loc", "sub_authority"=>"foo"}
7004
+ Filter chain halted as :check_sub_authority rendered or redirected
7005
+ Completed 400 Bad Request in 0ms (ActiveRecord: 0.0ms)
7006
+  (0.1ms) rollback transaction
7007
+  (0.1ms) begin transaction
7008
+ Processing by Qa::TermsController#index as HTML
7009
+ Parameters: {"vocab"=>nil}
7010
+ Filter chain halted as :check_vocab_param rendered or redirected
7011
+ Completed 400 Bad Request in 0ms (ActiveRecord: 0.0ms)
7012
+  (0.1ms) rollback transaction
7013
+  (0.1ms) begin transaction
7014
+  (0.1ms) rollback transaction
7015
+  (0.1ms) begin transaction
7016
+  (0.2ms) rollback transaction
7017
+  (0.1ms) begin transaction
7018
+  (0.1ms) rollback transaction
7019
+  (0.1ms) begin transaction
7020
+  (0.1ms) rollback transaction
7021
+  (0.1ms) begin transaction
7022
+ SQL (0.4ms) INSERT INTO "qa_subject_mesh_terms" ("term", "term_id") VALUES (?, ?) [["term", "Glyphon"], ["term_id", "ABCDEFG"]]
7023
+  (1.4ms) commit transaction
7024
+  (0.1ms) begin transaction
7025
+  (0.1ms) rollback transaction
7026
+  (0.1ms) begin transaction
7027
+  (0.1ms) SAVEPOINT active_record_1
7028
+ SQL (0.4ms) INSERT INTO "qa_subject_mesh_terms" ("synonyms", "term_id") VALUES (?, ?) [["synonyms", "b|c"], ["term_id", "a"]]
7029
+  (0.0ms) RELEASE SAVEPOINT active_record_1
7030
+  (0.9ms) rollback transaction
7031
+  (0.1ms) begin transaction
7032
+  (0.1ms) SAVEPOINT active_record_1
7033
+ SQL (0.4ms) INSERT INTO "qa_mesh_trees" ("term_id", "tree_number") VALUES (?, ?) [["term_id", "ABCDEFG"], ["tree_number", "D1.2.3.4"]]
7034
+  (0.0ms) RELEASE SAVEPOINT active_record_1
7035
+ Qa::SubjectMeshTerm Load (0.1ms) SELECT "qa_subject_mesh_terms".* FROM "qa_subject_mesh_terms" INNER JOIN qa_mesh_trees ON qa_subject_mesh_terms.term_id = qa_mesh_trees.term_id WHERE (qa_mesh_trees.tree_number = 'D1.2.3.4')
7036
+  (0.8ms) rollback transaction
7037
+  (0.1ms) begin transaction
7038
+ Qa::MeshTree Load (0.2ms) SELECT "qa_mesh_trees".* FROM "qa_mesh_trees" WHERE "qa_mesh_trees"."term_id" = 'ABCDEFG'
7039
+  (0.1ms) rollback transaction
7040
+  (0.1ms) begin transaction
7041
+ SQL (2.2ms) DELETE FROM "qa_subject_mesh_terms" WHERE "qa_subject_mesh_terms"."id" = ? [["id", 180]]
7042
+  (1.6ms) commit transaction
7043
+  (0.1ms) begin transaction
7044
+  (0.1ms) rollback transaction
7045
+  (0.1ms) begin transaction
7046
+  (0.1ms) rollback transaction
@@ -12,9 +12,17 @@ describe Qa::Authorities::Local do
12
12
  Qa::Authorities::Local.sub_authorities.should include "authority_B"
13
13
  end
14
14
 
15
+ describe "the class" do
16
+ subject { Qa::Authorities::Local }
17
+ it "should return a sub_authority" do
18
+ expect { subject.sub_authority('authority_Z')}.to raise_error ArgumentError, "Invalid sub-authority 'authority_Z'"
19
+ expect(subject.sub_authority('authority_A')).to be_kind_of Qa::Authorities::Subauthority
20
+ end
21
+ end
22
+
15
23
  it "should return a sub_authority" do
16
- expect { Qa::Authorities::Local.sub_authority('authority_Z')}.to raise_error ArgumentError, "Invalid sub-authority 'authority_Z'"
17
- expect(Qa::Authorities::Local.sub_authority('authority_A')).to be_kind_of Qa::Authorities::Subauthority
24
+ expect { subject.sub_authority('authority_Z')}.to raise_error ArgumentError, "Invalid sub-authority 'authority_Z'"
25
+ expect(subject.sub_authority('authority_A')).to be_kind_of Qa::Authorities::Subauthority
18
26
  end
19
27
  end
20
28
 
@@ -78,14 +86,14 @@ describe Qa::Authorities::Local do
78
86
  let(:id) { "A2" }
79
87
  let(:expected) { { 'id' => "A2", 'term' => "Term A2", 'active' => false } }
80
88
  it "should return the full term record" do
81
- record = authorities.get_full_record(id, "authority_A")
89
+ record = authorities.full_record(id, "authority_A")
82
90
  expect(record).to be_a HashWithIndifferentAccess
83
91
  expect(record).to eq(expected)
84
92
  end
85
93
  end
86
94
  context "source is a list" do
87
95
  it "should be indifferent access" do
88
- record = authorities.get_full_record('Term C1', "authority_C")
96
+ record = authorities.full_record('Term C1', "authority_C")
89
97
  expect(record).to be_a HashWithIndifferentAccess
90
98
  end
91
99
  end
@@ -94,7 +102,15 @@ describe Qa::Authorities::Local do
94
102
  let(:id) { "NonID" }
95
103
  let(:expected) { {} }
96
104
  it "should return an empty hash" do
97
- expect(authorities.get_full_record(id, "authority_A")).to eq(expected)
105
+ expect(authorities.full_record(id, "authority_A")).to eq(expected)
106
+ end
107
+ end
108
+
109
+ context "on a sub-authority" do
110
+ it "should return the full term record" do
111
+ record = authorities.sub_authority('authority_A').full_record('A2')
112
+ expect(record).to be_a HashWithIndifferentAccess
113
+ expect(record).to eq('id' => "A2", 'term' => "Term A2", 'active' => false)
98
114
  end
99
115
  end
100
116
 
@@ -0,0 +1,43 @@
1
+ require 'spec_helper'
2
+ require 'rake'
3
+ require 'stringio'
4
+
5
+ describe "mesh rake tasks" do
6
+ before do
7
+ @rake = Rake::Application.new
8
+ Rake.application = @rake
9
+ Rake.application.rake_require "mesh", ["#{Rails.root}/lib/tasks", "#{Rails.root}/../../lib/tasks"], []
10
+ Rake::Task.define_task(:environment) # rspec has loaded rails
11
+ end
12
+
13
+ describe "mesh:import" do
14
+ before do
15
+ @task_name = "mesh:import"
16
+ @output = StringIO.new
17
+ $stdout = @output
18
+ end
19
+ after :all do
20
+ $stdout = STDOUT
21
+ end
22
+ it "should have 'environment' as a prereq" do
23
+ @rake[@task_name].prerequisites.should include("environment")
24
+ end
25
+ it "should require $MESH_FILE to be set" do
26
+ old_mesh_file = ENV.delete('MESH_FILE')
27
+ @rake[@task_name].invoke
28
+ @output.seek(0)
29
+ @output.read.should =~ /Need to set \$MESH_FILE with path to file to ingest/
30
+ ENV['MESH_FILE'] = old_mesh_file
31
+ end
32
+ it "should create or update all records in the config file" do
33
+ ENV['MESH_FILE'] = "dummy"
34
+ input = StringIO.new("*NEWRECORD\nUI = 5\nMH = test\n")
35
+ File.should_receive(:open).with("dummy").and_yield(input)
36
+ @rake[@task_name].invoke
37
+ term = Qa::SubjectMeshTerm.find_by_term_id(5)
38
+ term.should_not be_nil
39
+ term.term.should == "test"
40
+ ENV['MESH_FILE'] = nil
41
+ end
42
+ end
43
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen Anderson
@@ -15,7 +15,7 @@ authors:
15
15
  autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
- date: 2013-11-07 00:00:00.000000000 Z
18
+ date: 2013-11-11 00:00:00.000000000 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: rails
@@ -87,6 +87,20 @@ dependencies:
87
87
  - - '>='
88
88
  - !ruby/object:Gem::Version
89
89
  version: 0.4.0
90
+ - !ruby/object:Gem::Dependency
91
+ name: deprecation
92
+ requirement: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ type: :runtime
98
+ prerelease: false
99
+ version_requirements: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
90
104
  - !ruby/object:Gem::Dependency
91
105
  name: sqlite3
92
106
  requirement: !ruby/object:Gem::Requirement
@@ -226,6 +240,7 @@ files:
226
240
  - lib/qa/engine.rb
227
241
  - lib/qa/version.rb
228
242
  - lib/qa.rb
243
+ - lib/tasks/mesh.rake
229
244
  - lib/tasks/qa_tasks.rake
230
245
  - LICENSE
231
246
  - Rakefile
@@ -293,6 +308,7 @@ files:
293
308
  - spec/lib/authorities_oclcts_spec.rb
294
309
  - spec/lib/authorities_tgnlang_spec.rb
295
310
  - spec/lib/mesh_data_parser_spec.rb
311
+ - spec/lib/tasks/mesh.rake_spec.rb
296
312
  - spec/models/subject_mesh_term_spec.rb
297
313
  - spec/spec_helper.rb
298
314
  - spec/support/lib/generators/test_app_generator.rb
@@ -384,6 +400,7 @@ test_files:
384
400
  - spec/lib/authorities_oclcts_spec.rb
385
401
  - spec/lib/authorities_tgnlang_spec.rb
386
402
  - spec/lib/mesh_data_parser_spec.rb
403
+ - spec/lib/tasks/mesh.rake_spec.rb
387
404
  - spec/models/subject_mesh_term_spec.rb
388
405
  - spec/spec_helper.rb
389
406
  - spec/support/lib/generators/test_app_generator.rb