lbp 0.1.0 → 0.1.1

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.
@@ -3,123 +3,144 @@ require 'lbp'
3
3
  require 'pry'
4
4
  require 'nokogiri'
5
5
 
6
- describe 'file object' do
6
+ describe 'file object' do
7
7
  require_relative "config_globals"
8
- $fileobject = Lbp::File.new("https://bitbucket.org/jeffreycwitt/principiumiv/raw/master/principiumIV.xml", "critical", $confighash)
8
+ # schema 1.0.0 test file
9
+ $fileobject = Lbp::File.new("https://bitbucket.org/jeffreycwitt/lectio1/raw/develop/lectio1.xml", "critical", $confighash)
10
+ # schema 0.0.0 / default file
9
11
  $fileobject_private = Lbp::File.new("https://bitbucket.org/jeffreycwitt/lectio19/raw/master/lectio19.xml", "critical", $confighash)
10
12
  $fileobject3 = Lbp::File.new("https://bitbucket.org/jeffreycwitt/lectio1/raw/master/lectio1.xml", "critical", $confighash)
13
+ $fileobject_with_null_config = Lbp::File.new("https://bitbucket.org/jeffreycwitt/lectio1/raw/master/lectio1.xml", "critical", nil)
11
14
 
12
15
  it 'should return the full filename for an edited item' do
13
16
  result = $fileobject.file_path
14
17
  expect(result).to be_kind_of(String)
15
18
  end
16
19
 
17
- it 'should return the File object a given File' do
20
+ it 'should return the full filename for an edited item with null confighash' do
21
+ result = $fileobject_with_null_config.file_path
22
+ expect(result).to be_kind_of(String)
23
+ end
24
+
25
+ it 'should return the File object a given File' do
18
26
  result = $fileobject.file
19
-
27
+
20
28
  expect(result).to be_kind_of(Tempfile)
21
29
  end
22
30
 
23
- it 'should return the file from a private git repo' do
24
-
31
+ it 'should return the file from a private git repo' do
25
32
  result = $fileobject_private.file
26
33
  expect(result).to be_kind_of(Tempfile)
27
34
  end
28
35
 
29
- it 'should transform file from private git repository' do
36
+ it 'should return the file from a git repo with null confighash' do
37
+ result = $fileobject_with_null_config.file
38
+ expect(result).to be_kind_of(Tempfile)
39
+ end
40
+
41
+ it 'should transform file from private git repository' do
30
42
  result = $fileobject_private.transform_clean
31
43
  expect(result).to be_kind_of(String)
32
44
  end
33
45
 
34
- it 'should retrieve the item name from the TEI xml file' do
46
+ it 'should retrieve the validating schema label from TEI xml file' do
47
+ result = $fileobject.validating_schema_version
48
+ expect(result).to be_kind_of(String)
49
+ end
50
+ it 'should retrieve the transcription type from the TEI xml file' do
51
+ result = $fileobject.transcription_type_from_file
52
+ expect(result).to be_kind_of(String)
53
+ end
54
+
55
+ it 'should retrieve the item name from the TEI xml file' do
35
56
  result = $fileobject.title
36
57
  expect(result).to be_kind_of(String)
37
58
  end
38
59
 
39
- it 'should retrieve the author name from the TEI xml file' do
60
+ it 'should retrieve the author name from the TEI xml file' do
40
61
  result = $fileobject.author
41
- expect(result).to be_kind_of(String)
62
+ expect(result).to be_kind_of(String)
42
63
  end
43
64
 
44
- it 'should retrieve the editor name from the TEI xml file' do
65
+ it 'should retrieve the editor name from the TEI xml file' do
45
66
  result = $fileobject.editor
46
- expect(result).to be_kind_of(String)
67
+ expect(result).to be_kind_of(String)
47
68
  end
48
69
 
49
70
 
50
- it 'should retrieve the edition number from TEI xml file' do
71
+ it 'should retrieve the edition number from TEI xml file in a private git repo' do
51
72
  result = $fileobject_private.ed_no
52
- expect(result).to be_kind_of(String)
73
+ expect(result).to be_kind_of(String)
53
74
  end
54
75
 
55
- it 'should retrieve the edition date from TEI xml file' do
76
+ it 'should retrieve the edition date from TEI xml file' do
56
77
  result = $fileobject3.ed_date
57
- expect(result).to be_kind_of(String)
78
+ expect(result).to be_kind_of(String)
58
79
  end
59
80
 
60
- it 'should retrieve the pubdate from TEI xml file' do
81
+ it 'should retrieve the pubdate from TEI xml file' do
61
82
  result = $fileobject.pub_date
62
83
  expect(result).to be_kind_of(String)
63
84
  end
64
85
 
65
- # it 'should retrieve the encoding method from TEI xml file' do
86
+ # it 'should retrieve the encoding method from TEI xml file' do
66
87
  # result = $fileobject.encoding_method
67
- # expect(result).to be_kind_of(String)
88
+ # expect(result).to be_kind_of(String)
68
89
  # end
69
- # it 'should retrieve the encoding location from TEI xml file' do
90
+ # it 'should retrieve the encoding location from TEI xml file' do
70
91
  # result = $fileobject.encoding_location
71
- # expect(result).to be_kind_of(String)
92
+ # expect(result).to be_kind_of(String)
72
93
  # end
73
94
 
74
95
  it 'should transform a doc using a specified xslt file' do
75
96
  xslt_param_array = []
76
- result = $fileobject.transform($confighash[:xslt_dirs]["default"][:critical] + $confighash[:xslt_dirs]["default"][:clean_view], xslt_param_array)
77
-
97
+ result = $fileobject.transform($confighash[:xslt_base] + "default" + "/" + "critical" + "/" + $confighash[:stylesheets][:clean_view], xslt_param_array)
98
+
78
99
  expect(result).to be_instance_of(Nokogiri::XML::Document)
79
100
  end
80
101
 
81
102
  # This test should work, but include file paths break in XSL document
82
- #it 'should process an xml doc with the text_display.xslt stylesheet' do
103
+ #it 'should process an xml doc with the text_display.xslt stylesheet' do
83
104
  # result = $itemobject.transform._main_view
84
105
  # expect(result).to be_instance_of(Nokogiri::XML::Document)
85
106
  #end
86
- #it 'should process an xml doc with the text_display.xsl stylesheet' do
107
+ #it 'should process an xml doc with the text_display.xsl stylesheet' do
87
108
  # result = $itemobject.transform_index_view
88
109
  # expect(result).to be_instance_of(Nokogiri::XML::Document)
89
110
  #end
90
- it 'should process an xml doc with the cleanForStatistics.xsl stylesheet' do
111
+ it 'should process an xml doc with the cleanForStatistics.xsl stylesheet' do
91
112
  result = $fileobject.transform_clean
92
113
  expect(result).to be_instance_of(String)
93
114
  end
94
115
 
95
- it 'should process an xml doc with the cleanForStatistics.xsl stylesheet and return as nokogiri object' do
96
-
116
+ it 'should process an xml doc with the cleanForStatistics.xsl stylesheet and return as nokogiri object' do
117
+
97
118
  result = $fileobject.transform_clean_nokogiri
98
119
  expect(result).to be_instance_of(Nokogiri::XML::Document)
99
120
  end
100
121
 
101
122
  # notworking missing file
102
- # it 'should process an xml doc with the text_display.xsl stylesheet' do
123
+ # it 'should process an xml doc with the text_display.xsl stylesheet' do
103
124
  # result = $fileobject.transform_toc
104
125
  # expect(result).to be_instance_of(String)
105
126
  # end
106
127
 
107
- it 'should process an xml doc with the plaintext.xsl stylesheet and return plaintext document' do
128
+ it 'should process an xml doc with the plaintext.xsl stylesheet and return plaintext document' do
108
129
  result = $fileobject.transform_plain_text
109
130
  expect(result).to be_instance_of(String)
110
131
  end
111
132
 
112
- it 'should process an xml doc with the plaintext.xsl stylesheet and return nokogiri object of the plaintext document' do
133
+ it 'should process an xml doc with the plaintext.xsl stylesheet and return nokogiri object of the plaintext document' do
113
134
  result = $fileobject.transform_plain_text_nokogiri
114
135
  expect(result).to be_instance_of(Nokogiri::XML::Document)
115
136
  end
116
137
 
117
- it 'should get the word count of the item object' do
138
+ it 'should get the word count of the item object' do
118
139
  result = $fileobject.word_count
119
140
  #result.should eq(2122)
120
141
  expect(result).to be_kind_of(Integer)
121
142
  end
122
- it 'should get the word frequency of the item object' do
143
+ it 'should get the word frequency of the item object' do
123
144
  result = $fileobject.word_frequency("word", "ascending")
124
145
 
125
146
  expect(result).to be_kind_of(Hash)
@@ -127,4 +148,4 @@ describe 'file object' do
127
148
 
128
149
 
129
150
 
130
- end
151
+ end
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+ require 'lbp'
3
+ require 'rdf'
4
+ require 'pry'
5
+
6
+
7
+ describe 'manifestation object' do
8
+ it 'should return array of transcriptions for this manifestaiton' do
9
+ result = Lbp::Resource.find("http://scta.info/resource/lectio1/reims").transcriptions
10
+ expect(result).to be_instance_of(Array)
11
+ end
12
+ it 'should return canonical transcription for this manifestaiton' do
13
+ result = Lbp::Resource.find("http://scta.info/resource/lectio1/reims").canonical_transcription.to_s
14
+ expect(result).to be == "http://scta.info/resource/lectio1/reims/transcription"
15
+ end
16
+ end
@@ -0,0 +1,53 @@
1
+ require 'spec_helper'
2
+ require 'lbp'
3
+ require 'rdf'
4
+ require 'pry'
5
+
6
+
7
+ describe 'resource object' do
8
+
9
+ describe "when resource is a RDF::URI" do
10
+ it 'should return short_id of resource' do
11
+ object = Lbp::ResourceIdentifier.new(RDF::URI.new("http://scta.info/resource/sententia"))
12
+ result = object.short_id
13
+ expect(result).to be == "sententia"
14
+ end
15
+ it 'should return resource_url of resource' do
16
+ object = Lbp::ResourceIdentifier.new(RDF::URI.new("http://scta.info/resource/sententia"))
17
+ result = object.url
18
+ expect(result).to be == "http://scta.info/resource/sententia"
19
+ end
20
+ it 'should return resource_rdf_uri of resource created from short id' do
21
+ object = Lbp::ResourceIdentifier.new(Lbp::ResourceIdentifier.from_short("sententia"))
22
+ result = object.rdf_uri
23
+ expect(result).to be == RDF::URI.new("http://scta.info/resource/sententia")
24
+ end
25
+ it 'should return object if the resource is a uri resource (and not a literal)' do
26
+ object = Lbp::ResourceIdentifier.new("lectio1")
27
+ result = object.resource
28
+ expect(result).to be_instance_of(Lbp::Expression)
29
+ end
30
+ end
31
+ describe "when resource is a RDF::Literal" do
32
+ it 'should return short_id of resource' do
33
+ object = Lbp::ResourceIdentifier.new(RDF::Literal.new("Test"))
34
+ result = object.short_id
35
+ expect(result).to be == "Test"
36
+ end
37
+ it 'should return resource_url of resource' do
38
+ object = Lbp::ResourceIdentifier.new(RDF::Literal.new("Test"))
39
+ result = object.url
40
+ expect(result).to be == "Test"
41
+ end
42
+ it 'should return resource_rdf_uri of resource created from short id' do
43
+ object = Lbp::ResourceIdentifier.new(RDF::Literal.new("Test"))
44
+ result = object.rdf_uri #this method name is a little bit misleading
45
+ expect(result).to be == RDF::Literal.new("Test")
46
+ end
47
+ it 'should return object if the resource is a uri resource (and not a literal)' do
48
+ object = Lbp::ResourceIdentifier.new(RDF::Literal.new("Test"))
49
+ result = object.resource
50
+ expect(result).to be == nil
51
+ end
52
+ end
53
+ end
@@ -5,74 +5,54 @@ require 'nokogiri'
5
5
 
6
6
  describe 'resource object' do
7
7
  #TODO: database needs be changed so that shortID is "sententia"
8
- $resource_obj1 = Lbp::Resource.new("sententia")
9
- $resource_obj2 = Lbp::Resource.new("http://scta.info/resource/sententia")
10
- $resource_item = Lbp::Resource.new("lectio1")
11
- $resource_item2 = Lbp::Resource.new("pl-l1d1c1") #structureItem id
12
- $resource_item3 = Lbp::Resource.new("http://scta.info/resource/l1-acfefv") #paragraph url
13
- $resource_item3 = Lbp::Resource.new("l1-acfefv") #paragraph id
14
- $resource_div1 = Lbp::Resource.new("wdr-l1d1q1") #div short id
15
- $resource_div2 = Lbp::Resource.new("http://scta.info/resource/wdr-l1d1q1") #div url
8
+ $resource_obj1 = Lbp::Resource.find("sententia")
9
+ $resource_obj2 = Lbp::Resource.find("http://scta.info/resource/sententia")
10
+ $resource_item = Lbp::Resource.find("lectio1")
11
+ $resource_item2 = Lbp::Resource.find("pl-l1d1c1") #structureItem id
12
+ $resource_item3 = Lbp::Resource.find("http://scta.info/resource/l1-acfefv") #paragraph url
13
+ $resource_item3 = Lbp::Resource.find("l1-acfefv") #paragraph id
14
+ $resource_div1 = Lbp::Resource.find("wdr-l1d1q1") #div short id
15
+ $resource_div2 = Lbp::Resource.find("http://scta.info/resource/wdr-l1d1q1") #div url
16
16
 
17
17
  it 'return shortid of resource' do
18
- result = $resource_obj2.resource_shortId
18
+ result = $resource_obj2.short_id
19
19
  expect(result).to be == "sententia"
20
20
  end
21
21
  it 'return urlid of resource' do
22
- result = $resource_obj1.resource_url
22
+ result = $resource_obj1.url
23
23
  expect(result).to be == "http://scta.info/resource/sententia"
24
24
  end
25
25
  it 'returns type of resource from shortid' do
26
- result = $resource_obj1.type_shortId
26
+ result = $resource_obj1.type.short_id
27
27
  expect(result).to be == "workGroup"
28
28
  end
29
29
  it 'returns type of resource id from url' do
30
- result = $resource_obj2.type_shortId
30
+ result = $resource_obj2.type.short_id
31
31
  expect(result).to be == "workGroup"
32
32
  end
33
33
  it 'returns type of resource id from url' do
34
- result = $resource_item.type_shortId
34
+ result = $resource_item.type.short_id
35
35
  expect(result).to be == "expression"
36
36
  end
37
37
  it 'returns type of resource id from url' do
38
- result = $resource_item2.type_shortId
38
+ result = $resource_item2.type.short_id
39
39
  expect(result).to be == "expression"
40
40
  end
41
41
  it 'returns type url of resource ' do
42
- result = $resource_obj1.type
42
+ result = $resource_obj1.type.url
43
43
  expect(result).to be == "http://scta.info/resource/workGroup"
44
44
  end
45
- it 'returns object corresponding to type of resource id from url' do
46
- result = $resource_item.convert
47
-
48
- expect(result).to be_kind_of(Lbp::Expression)
49
- end
50
45
  it 'returns title of resource ' do
51
46
  result = $resource_obj1.title
52
47
  expect(result).to be == "Sentences Commentaries"
53
48
  end
54
- it 'returns structureType of resource ' do
55
- result = $resource_item.structureType_shortId
56
- expect(result).to be == "structureItem"
57
- end
58
- it 'returns structureType of resource ' do
59
- result = $resource_item2.structureType_shortId
60
- expect(result).to be == "structureItem"
61
- end
62
- it 'returns structureType of resource ' do
63
- result = $resource_item3.structureType_shortId
64
- expect(result).to be == "structureBlock"
65
- end
66
- it 'returns structureType of resource ' do
67
- result = $resource_item3.structureType
68
- expect(result).to be == "http://scta.info/resource/structureBlock"
69
- end
70
- it 'returns structureType of resource ' do
71
- result = $resource_div1.structureType_shortId
72
- expect(result).to be == "structureDivision"
49
+ it 'returns parent part of resource ' do
50
+ result = $resource_item.is_part_of
51
+ expect(result).to be_kind_of(Lbp::ResourceIdentifier)
73
52
  end
74
- it 'returns structureType of resource ' do
75
- result = $resource_div2.structureType_shortId
76
- expect(result).to be == "structureDivision"
53
+ it 'returns child parts as array' do
54
+ resource = Lbp::Resource.find("lombardsententia")
55
+ result = resource.has_parts
56
+ expect(result).to be_kind_of(Array)
77
57
  end
78
58
  end
@@ -4,11 +4,11 @@ require 'pry'
4
4
  require 'nokogiri'
5
5
 
6
6
  describe 'transcript object' do
7
- $transcript_obj1 = Lbp::Transcription.new("http://scta.info/resource/wdr-l1d1/wettf15/transcription")
8
- $transcript_obj2 = Lbp::Transcription.new("http://scta.info/resource/principiumIV/critical/transcription")
7
+ $transcript_obj1 = Lbp::Resource.find("http://scta.info/resource/wdr-l1d1/wettf15/transcription")
8
+ $transcript_obj2 = Lbp::Resource.find("http://scta.info/resource/principiumIV/critical/transcription")
9
9
 
10
10
  it 'returns type of resource' do
11
- result = $transcript_obj1.type_shortId
11
+ result = $transcript_obj1.type.short_id
12
12
  expect(result).to be == "transcription"
13
13
  end
14
14
  it 'returns transcription type of transcription (documentary)' do
@@ -17,12 +17,17 @@ describe 'transcript object' do
17
17
  end
18
18
  it 'returns transcription type of transcription (critical)' do
19
19
  result = $transcript_obj2.transcription_type
20
- expect(result).to be == "critical" # the use of documentary could be confusing because somtimes I say diplomatic
20
+ expect(result).to be == "critical"
21
21
  end
22
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")
28
+
29
+ expect(result).to be_kind_of(String)
30
+ end
26
31
  it 'returns file path for transcription' do
27
32
  result = $transcript_obj2.file_path
28
33
  expect(result).to be_kind_of(String)
@@ -0,0 +1,29 @@
1
+ require 'spec_helper'
2
+ require 'lbp'
3
+ require 'rdf'
4
+ require 'pry'
5
+
6
+
7
+ describe 'workGroup object' do
8
+ it 'should return description of workGroup' do
9
+ resource = Lbp::WorkGroup.find("http://scta.info/resource/scta")
10
+ result = resource.description
11
+ expect(result).to be_instance_of(String)
12
+ end
13
+ it 'should list of available workGroups as an array' do
14
+ resource = Lbp::WorkGroup.find("http://scta.info/resource/scta")
15
+ result = resource.work_groups
16
+ expect(result).to be_instance_of(Array)
17
+ end
18
+ it 'should list of available expressions as array' do
19
+ resource = Lbp::WorkGroup.find("http://scta.info/resource/sententia")
20
+ result = resource.expressions
21
+ expect(result).to be_instance_of(Array)
22
+ end
23
+ it 'should list of available expressions as array' do
24
+ resource = Lbp::WorkGroup.find("http://scta.info/resource/scta")
25
+ result = resource.expressions
26
+ binding.pry
27
+ expect(result).to be_instance_of(Array)
28
+ end
29
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lbp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeffrey C. Witt
@@ -184,7 +184,9 @@ files:
184
184
  - bin/lbp
185
185
  - lbp.gemspec
186
186
  - lib/lbp.rb
187
+ - lib/lbp/article.rb
187
188
  - lib/lbp/expression.rb
189
+ - lib/lbp/expression_type.rb
188
190
  - lib/lbp/file.rb
189
191
  - lib/lbp/file_part.rb
190
192
  - lib/lbp/functions.rb
@@ -192,17 +194,24 @@ files:
192
194
  - lib/lbp/paragraph_image.rb
193
195
  - lib/lbp/query.rb
194
196
  - lib/lbp/resource.rb
197
+ - lib/lbp/resource_identifier.rb
195
198
  - lib/lbp/transcription.rb
199
+ - lib/lbp/translation.rb
196
200
  - lib/lbp/version.rb
201
+ - lib/lbp/work_group.rb
202
+ - spec/article_spec.rb
197
203
  - spec/config_globals.rb
198
204
  - spec/expression_spec.rb
199
205
  - spec/file_part_spec.rb
200
206
  - spec/file_spec.rb
207
+ - spec/manifestation_spec.rb
201
208
  - spec/paragraph_image_spec.rb
202
209
  - spec/query_spec.rb
210
+ - spec/resource_identifier_spec.rb
203
211
  - spec/resource_spec.rb
204
212
  - spec/spec_helper.rb
205
213
  - spec/transcription_spec.rb
214
+ - spec/work_group_spec.rb
206
215
  homepage: ''
207
216
  licenses:
208
217
  - MIT
@@ -228,12 +237,16 @@ signing_key:
228
237
  specification_version: 4
229
238
  summary: A library for working XML documents conforming the TEI (lbp customized) schema
230
239
  test_files:
240
+ - spec/article_spec.rb
231
241
  - spec/config_globals.rb
232
242
  - spec/expression_spec.rb
233
243
  - spec/file_part_spec.rb
234
244
  - spec/file_spec.rb
245
+ - spec/manifestation_spec.rb
235
246
  - spec/paragraph_image_spec.rb
236
247
  - spec/query_spec.rb
248
+ - spec/resource_identifier_spec.rb
237
249
  - spec/resource_spec.rb
238
250
  - spec/spec_helper.rb
239
251
  - spec/transcription_spec.rb
252
+ - spec/work_group_spec.rb