lbp 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5c8f418230bba408ab7abcc2bfc63535ce44a425
4
- data.tar.gz: 89cb6d564dfd559786f940882b168ee20deab8b5
3
+ metadata.gz: f14f2c06206b6b7dc4363adf804dd6ab9a80c6a0
4
+ data.tar.gz: f6830a79e5ccc39462855457d76c1e1178d226cc
5
5
  SHA512:
6
- metadata.gz: 4f0cc56d0015815ac15c2e71e801afb290e3958205a0205c9b0160139e1c918a39aa6278e611b1f8f4f13b5931f1bd2f289b8c58cdb665b5de25afed919a89dd
7
- data.tar.gz: dae6f816869aeeeb625a89c5eaffd4153c63ab071d79ed585611e3f8e293e0ef867461ac0d9ec5cb21ca1a378f4906cc8cac65bd1658aa1607b76b7b38f3ef7d
6
+ metadata.gz: e4880d84d9d763e52cd1a203c780beef3ef1510809eb5d5cbd3421569f227fb8bad1903e421ea39f19e27947f1438e21cbde4d533f14c9450551dd37a3c20a0c
7
+ data.tar.gz: 236fe2daf7e79a48e8c8c0d95db2e78da2f2040a49fa84d3d6322621e11f7807d43482c09ca86a24f30ed93e0678f91b8b84e4bc054ca082e21e021fd747a815
@@ -32,9 +32,9 @@ module Lbp
32
32
 
33
33
  def file
34
34
  file = open(self.file_path)
35
- if file.base_uri.to_s != self.file_path
36
- file = open(self.file_path, {:http_basic_authentication => [@confighash[:git_username], @confighash[:git_password]]})
37
- end
35
+ if file.base_uri.to_s != self.file_path
36
+ file = open(self.file_path, {:http_basic_authentication => [@confighash[:git_username], @confighash[:git_password] ]})
37
+ end
38
38
  return file
39
39
  end
40
40
  def nokogiri
@@ -4,13 +4,14 @@ require 'rdf/rdfxml'
4
4
  require 'rdf/ntriples'
5
5
  require 'rdf/vocab'
6
6
  require 'lbp'
7
+ #require 'forwardable'
7
8
 
8
9
 
9
10
  module Lbp
10
- class Resource
11
+ class Resource
11
12
  class << self
12
13
  def find(resource_id)
13
- #adding the to_s method allows a resource to be created
14
+ #adding the to_s method allows a resource to be created
14
15
  #by passing in an RDF::URL object as well as the url string.
15
16
  if resource_id.to_s.include? "http"
16
17
  query = Query.new
@@ -26,8 +27,8 @@ module Lbp
26
27
  end
27
28
  def create(resource_url, results)
28
29
  type = results.dup.filter(:p => RDF::URI("http://www.w3.org/1999/02/22-rdf-syntax-ns#type")).first[:o].to_s.split("/").last
29
- klass = if type == "workGroup"
30
- Lbp.const_get("WorkGroup")
30
+ klass = if type == "workGroup"
31
+ Lbp.const_get("WorkGroup")
31
32
  elsif type == "expressionType"
32
33
  Lbp.const_get("ExpressionType")
33
34
  else
@@ -38,15 +39,15 @@ module Lbp
38
39
  Resource.new(resource_url, results)
39
40
  end
40
41
  end
41
-
42
+
42
43
  # end class level methods
43
-
44
- attr_reader :identifier, :results
45
- extend Forwardable
44
+
45
+ attr_reader :identifier, :results
46
+ extend Forwardable
46
47
  def_delegators :@identifier, :short_id, :url, :rdf_uri, :to_s
47
-
48
+
48
49
  def initialize(resource_url, results)
49
- # if there are problems with results being empty
50
+ # if there are problems with results being empty
50
51
  # and, for example, dup or filter being called on a null class
51
52
  # consider changing the following line to @results = results || <an empty object for whatever results normally is>
52
53
  @results = results || RDF::Query::Solutions.new()
@@ -62,13 +63,13 @@ module Lbp
62
63
 
63
64
  def value(property) # should return a single resource identifier; and error if there is more than one property for this value
64
65
  value = @results.dup.filter(:p => RDF::URI(property))
65
- if value.count > 0
66
+ if value.count > 0
66
67
  value = value.first[:o]
67
68
  ResourceIdentifier.new(value)
68
- else
69
+ else
69
70
  nil
70
71
  end
71
-
72
+
72
73
  end
73
74
 
74
75
  #query for properties global to all resources
@@ -77,9 +78,9 @@ module Lbp
77
78
  end
78
79
  def title
79
80
  #careful here; title in db is not actualy a uri, but a litteral
80
- #to_s method should work, but it might not be correct for this to be initially
81
- #instantiated into a resource identifer.
82
- # This is why I'm forcing the to_s method in the return value rather than
81
+ #to_s method should work, but it might not be correct for this to be initially
82
+ #instantiated into a resource identifer.
83
+ # This is why I'm forcing the to_s method in the return value rather than
83
84
  # return the ResourceIdentifer object itself as in the case of type above
84
85
  value(RDF::Vocab::DC11.title).to_s
85
86
  end
@@ -95,4 +96,4 @@ module Lbp
95
96
 
96
97
 
97
98
  end
98
- end
99
+ end
@@ -8,22 +8,35 @@ require 'lbp'
8
8
  module Lbp
9
9
  class Transcription < Resource
10
10
  #initionalization handled by Resource Class
11
- def file_path(branch="master")
11
+ def file_path
12
12
  file_path = value("http://scta.info/property/hasXML").to_s
13
13
  #file_path = self.results.dup.filter(:p => RDF::URI("http://scta.info/property/hasXML")).first[:o].to_s
14
- if branch != "master"
15
- file_path.gsub!("master", branch)
14
+ if ENV['EXIST'] == "local"
15
+ file_path.gsub!("exist.scta.info", "localhost:8080")
16
16
  end
17
17
  return file_path
18
18
  end
19
+ #TODO; this will need to change because an expression above the item level will have more than one doc listed
20
+ def doc_path(branch="master")
21
+ doc_path = value("http://scta.info/property/hasDocument").to_s
22
+ #file_path = self.results.dup.filter(:p => RDF::URI("http://scta.info/property/hasXML")).first[:o].to_s
23
+ if branch != "master"
24
+ doc_path.gsub!("master", branch)
25
+ end
26
+ return doc_path
27
+ end
19
28
  def transcription_type
20
29
  type = value("http://scta.info/property/transcriptionType")
21
30
  #type = self.results.dup.filter(:p => RDF::URI("http://scta.info/property/transcriptionType")).first[:o].to_s
22
31
  type.to_s.downcase
23
32
  end
24
33
 
25
- def file(branch: "master", confighash: nil)
26
- file = File.new(self.file_path(branch), self.transcription_type, confighash)
34
+ def file(branch: "master", confighash: nil, path: "doc")
35
+ if path == "file"
36
+ file = File.new(self.file_path, self.transcription_type, confighash)
37
+ else path == "doc"
38
+ file = File.new(self.doc_path(branch), self.transcription_type, confighash)
39
+ end
27
40
  return file
28
41
  end
29
42
  #NOTE: this really is a temporary method, since the database
@@ -31,8 +44,12 @@ module Lbp
31
44
  #dynamically generated by the exist-db database.
32
45
  # but this could remain in case it was useful to grab the part
33
46
  # from a file that would include a tei header etc.
34
- def file_part(partid: nil, confighash: nil)
35
- file = FilePart.new(self.file_path, self.transcription_type, confighash, partid)
47
+ def file_part(partid: nil, confighash: nil, path: "doc")
48
+ if path == "file"
49
+ file = FilePart.new(self.file_path, self.transcription_type, confighash, partid)
50
+ else path == "doc"
51
+ file = FilePart.new(self.doc_path, self.transcription_type, confighash, partid)
52
+ end
36
53
  return file
37
54
  end
38
55
  end
@@ -1,3 +1,3 @@
1
1
  module Lbp
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -11,6 +11,7 @@ describe 'file object' do
11
11
  $fileobject_private = Lbp::File.new("https://bitbucket.org/jeffreycwitt/lectio19/raw/master/lectio19.xml", "critical", $confighash)
12
12
  $fileobject3 = Lbp::File.new("https://bitbucket.org/jeffreycwitt/lectio1/raw/master/lectio1.xml", "critical", $confighash)
13
13
  $fileobject_with_null_config = Lbp::File.new("https://bitbucket.org/jeffreycwitt/lectio1/raw/master/lectio1.xml", "critical", nil)
14
+ $file_from_transcription = Lbp::Resource.find("lectio1/critical/transcription").file
14
15
 
15
16
  it 'should return the full filename for an edited item' do
16
17
  result = $fileobject.file_path
@@ -47,7 +48,8 @@ describe 'file object' do
47
48
  result = $fileobject.validating_schema_version
48
49
  expect(result).to be_kind_of(String)
49
50
  end
50
- it 'should retrieve the transcription type from the TEI xml file' do
51
+
52
+ it 'should retrieve the transcription type from the TEI xml file' do
51
53
  result = $fileobject.transcription_type_from_file
52
54
  expect(result).to be_kind_of(String)
53
55
  end
@@ -57,6 +59,12 @@ describe 'file object' do
57
59
  expect(result).to be_kind_of(String)
58
60
  end
59
61
 
62
+ it 'should retrieve the validating schema label from TEI xml file from existDB batabase using hasXML rather than hasDoc' do
63
+ result = $file_from_transcription.title
64
+ binding.pry
65
+ expect(result).to be_kind_of(String)
66
+ end
67
+
60
68
  it 'should retrieve the author name from the TEI xml file' do
61
69
  result = $fileobject.author
62
70
  expect(result).to be_kind_of(String)
@@ -70,11 +78,12 @@ describe 'file object' do
70
78
 
71
79
  it 'should retrieve the edition number from TEI xml file in a private git repo' do
72
80
  result = $fileobject_private.ed_no
81
+
73
82
  expect(result).to be_kind_of(String)
74
83
  end
75
84
 
76
85
  it 'should retrieve the edition date from TEI xml file' do
77
- result = $fileobject3.ed_date
86
+ result = $fileobject_private.ed_date
78
87
  expect(result).to be_kind_of(String)
79
88
  end
80
89
 
@@ -3,33 +3,33 @@ require 'lbp'
3
3
  require 'pry'
4
4
  require 'nokogiri'
5
5
 
6
- describe 'transcript object' do
6
+ describe 'transcript object' do
7
7
  $transcript_obj1 = Lbp::Resource.find("http://scta.info/resource/wdr-l1d1/wettf15/transcription")
8
8
  $transcript_obj2 = Lbp::Resource.find("http://scta.info/resource/principiumIV/critical/transcription")
9
-
10
- it 'returns type of resource' do
9
+
10
+ it 'returns type of resource' do
11
11
  result = $transcript_obj1.type.short_id
12
12
  expect(result).to be == "transcription"
13
13
  end
14
- it 'returns transcription type of transcription (documentary)' do
14
+ it 'returns transcription type of transcription (documentary)' do
15
15
  result = $transcript_obj1.transcription_type
16
- expect(result).to be == "documentary" # the use of documentary could be confusing because somtimes I say diplomatic
16
+ expect(result).to be == "documentary" # the use of documentary could be confusing because somtimes I say diplomatic
17
17
  end
18
- it 'returns transcription type of transcription (critical)' do
18
+ it 'returns transcription type of transcription (critical)' do
19
19
  result = $transcript_obj2.transcription_type
20
- expect(result).to be == "critical"
20
+ expect(result).to be == "critical"
21
21
  end
22
- it 'returns file path for transcription' do
22
+ it 'returns file path for transcription' do
23
23
  result = $transcript_obj1.file_path
24
24
  expect(result).to be_kind_of(String)
25
25
  end
26
- it 'returns file path for transcription' do
27
- result = $transcript_obj1.file_path("develop")
26
+ it 'returns file path for transcription' do
27
+ result = $transcript_obj1.doc_path("develop")
28
28
 
29
29
  expect(result).to be_kind_of(String)
30
30
  end
31
- it 'returns file path for transcription' do
31
+ it 'returns file path for transcription' do
32
32
  result = $transcript_obj2.file_path
33
33
  expect(result).to be_kind_of(String)
34
34
  end
35
- end
35
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lbp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeffrey C. Witt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-25 00:00:00.000000000 Z
11
+ date: 2016-08-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler