lbp 0.0.2 → 0.1.0

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.
@@ -0,0 +1,130 @@
1
+ require 'spec_helper'
2
+ require 'lbp'
3
+ require 'pry'
4
+ require 'nokogiri'
5
+
6
+ describe 'file object' do
7
+ require_relative "config_globals"
8
+ $fileobject = Lbp::File.new("https://bitbucket.org/jeffreycwitt/principiumiv/raw/master/principiumIV.xml", "critical", $confighash)
9
+ $fileobject_private = Lbp::File.new("https://bitbucket.org/jeffreycwitt/lectio19/raw/master/lectio19.xml", "critical", $confighash)
10
+ $fileobject3 = Lbp::File.new("https://bitbucket.org/jeffreycwitt/lectio1/raw/master/lectio1.xml", "critical", $confighash)
11
+
12
+ it 'should return the full filename for an edited item' do
13
+ result = $fileobject.file_path
14
+ expect(result).to be_kind_of(String)
15
+ end
16
+
17
+ it 'should return the File object a given File' do
18
+ result = $fileobject.file
19
+
20
+ expect(result).to be_kind_of(Tempfile)
21
+ end
22
+
23
+ it 'should return the file from a private git repo' do
24
+
25
+ result = $fileobject_private.file
26
+ expect(result).to be_kind_of(Tempfile)
27
+ end
28
+
29
+ it 'should transform file from private git repository' do
30
+ result = $fileobject_private.transform_clean
31
+ expect(result).to be_kind_of(String)
32
+ end
33
+
34
+ it 'should retrieve the item name from the TEI xml file' do
35
+ result = $fileobject.title
36
+ expect(result).to be_kind_of(String)
37
+ end
38
+
39
+ it 'should retrieve the author name from the TEI xml file' do
40
+ result = $fileobject.author
41
+ expect(result).to be_kind_of(String)
42
+ end
43
+
44
+ it 'should retrieve the editor name from the TEI xml file' do
45
+ result = $fileobject.editor
46
+ expect(result).to be_kind_of(String)
47
+ end
48
+
49
+
50
+ it 'should retrieve the edition number from TEI xml file' do
51
+ result = $fileobject_private.ed_no
52
+ expect(result).to be_kind_of(String)
53
+ end
54
+
55
+ it 'should retrieve the edition date from TEI xml file' do
56
+ result = $fileobject3.ed_date
57
+ expect(result).to be_kind_of(String)
58
+ end
59
+
60
+ it 'should retrieve the pubdate from TEI xml file' do
61
+ result = $fileobject.pub_date
62
+ expect(result).to be_kind_of(String)
63
+ end
64
+
65
+ # it 'should retrieve the encoding method from TEI xml file' do
66
+ # result = $fileobject.encoding_method
67
+ # expect(result).to be_kind_of(String)
68
+ # end
69
+ # it 'should retrieve the encoding location from TEI xml file' do
70
+ # result = $fileobject.encoding_location
71
+ # expect(result).to be_kind_of(String)
72
+ # end
73
+
74
+ it 'should transform a doc using a specified xslt file' do
75
+ xslt_param_array = []
76
+ result = $fileobject.transform($confighash[:xslt_dirs]["default"][:critical] + $confighash[:xslt_dirs]["default"][:clean_view], xslt_param_array)
77
+
78
+ expect(result).to be_instance_of(Nokogiri::XML::Document)
79
+ end
80
+
81
+ # 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
83
+ # result = $itemobject.transform._main_view
84
+ # expect(result).to be_instance_of(Nokogiri::XML::Document)
85
+ #end
86
+ #it 'should process an xml doc with the text_display.xsl stylesheet' do
87
+ # result = $itemobject.transform_index_view
88
+ # expect(result).to be_instance_of(Nokogiri::XML::Document)
89
+ #end
90
+ it 'should process an xml doc with the cleanForStatistics.xsl stylesheet' do
91
+ result = $fileobject.transform_clean
92
+ expect(result).to be_instance_of(String)
93
+ end
94
+
95
+ it 'should process an xml doc with the cleanForStatistics.xsl stylesheet and return as nokogiri object' do
96
+
97
+ result = $fileobject.transform_clean_nokogiri
98
+ expect(result).to be_instance_of(Nokogiri::XML::Document)
99
+ end
100
+
101
+ # notworking missing file
102
+ # it 'should process an xml doc with the text_display.xsl stylesheet' do
103
+ # result = $fileobject.transform_toc
104
+ # expect(result).to be_instance_of(String)
105
+ # end
106
+
107
+ it 'should process an xml doc with the plaintext.xsl stylesheet and return plaintext document' do
108
+ result = $fileobject.transform_plain_text
109
+ expect(result).to be_instance_of(String)
110
+ end
111
+
112
+ it 'should process an xml doc with the plaintext.xsl stylesheet and return nokogiri object of the plaintext document' do
113
+ result = $fileobject.transform_plain_text_nokogiri
114
+ expect(result).to be_instance_of(Nokogiri::XML::Document)
115
+ end
116
+
117
+ it 'should get the word count of the item object' do
118
+ result = $fileobject.word_count
119
+ #result.should eq(2122)
120
+ expect(result).to be_kind_of(Integer)
121
+ end
122
+ it 'should get the word frequency of the item object' do
123
+ result = $fileobject.word_frequency("word", "ascending")
124
+
125
+ expect(result).to be_kind_of(Hash)
126
+ end
127
+
128
+
129
+
130
+ end
@@ -0,0 +1,46 @@
1
+ require 'spec_helper'
2
+ require 'lbp'
3
+ require 'pry'
4
+ require 'nokogiri'
5
+
6
+ describe 'paragraph object' do
7
+ require_relative "config_globals"
8
+ paragraph1 = "l7-cmisir"
9
+ #paragraph1 = "l7-seqgpe"
10
+ position = 2
11
+ paragraphurl = "http://scta.info/text/plaoulcommentary/transcription/sorb_lectio7/paragraph/#{paragraph1}"
12
+ $paragraph_image = Lbp::ParagraphImage.new(paragraphurl, position)
13
+
14
+ it 'should return the ulx for the Paragraph Image object' do
15
+ result = $paragraph_image.ulx
16
+ expect(result).to be_kind_of(Integer)
17
+ end
18
+ it 'should return the uly for the Paragraph Image object' do
19
+ result = $paragraph_image.uly
20
+ expect(result).to be_kind_of(Integer)
21
+ end
22
+ it 'should return the lrx for the Paragraph Image object' do
23
+ result = $paragraph_image.lrx
24
+ expect(result).to be_kind_of(Integer)
25
+ end
26
+ it 'should return the uly for the Paragraph Image object' do
27
+ result = $paragraph_image.lry
28
+ expect(result).to be_kind_of(Integer)
29
+ end
30
+ it 'should return the width for the Paragraph Image object' do
31
+ result = $paragraph_image.width
32
+ expect(result).to be_kind_of(Integer)
33
+ end
34
+ it 'should return the height for the Paragraph Image object' do
35
+ result = $paragraph_image.height
36
+ expect(result).to be_kind_of(Integer)
37
+ end
38
+ it 'should return the url for the Paragraph Image object' do
39
+ result = $paragraph_image.url
40
+ expect(result).to be_kind_of(String)
41
+ end
42
+ it 'should return the canvas for the Paragraph Image object' do
43
+ result = $paragraph_image.canvas
44
+ expect(result).to be_kind_of(String)
45
+ end
46
+ end
@@ -0,0 +1,27 @@
1
+ require 'lbp'
2
+ require 'pry'
3
+ require 'rdf'
4
+ require 'sparql'
5
+
6
+ describe 'query object' do
7
+
8
+ require_relative "config_globals"
9
+
10
+ $query_obj = Lbp::Query.new()
11
+
12
+ it "should return result object from sparqle query" do
13
+ result = $query_obj.collection_query("<" + $commentary_url + ">")
14
+ expect(result).to be_kind_of(Array)
15
+ end
16
+
17
+ it "should return result object from item info query" do
18
+ result = $query_obj.item_query("<http://scta.info/resource/lectio1>")
19
+ expect(result).to be_kind_of(Array)
20
+ end
21
+
22
+ it "should return result object from item expressionElement query" do
23
+ result = $query_obj.expressionElementQuery("http://scta.info/resource/plaoulcommentary", "http://scta.info/resource/structureElementName")
24
+ expect(result).to be_kind_of(Array)
25
+ end
26
+
27
+ end
@@ -0,0 +1,78 @@
1
+ require 'spec_helper'
2
+ require 'lbp'
3
+ require 'pry'
4
+ require 'nokogiri'
5
+
6
+ describe 'resource object' do
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
16
+
17
+ it 'return shortid of resource' do
18
+ result = $resource_obj2.resource_shortId
19
+ expect(result).to be == "sententia"
20
+ end
21
+ it 'return urlid of resource' do
22
+ result = $resource_obj1.resource_url
23
+ expect(result).to be == "http://scta.info/resource/sententia"
24
+ end
25
+ it 'returns type of resource from shortid' do
26
+ result = $resource_obj1.type_shortId
27
+ expect(result).to be == "workGroup"
28
+ end
29
+ it 'returns type of resource id from url' do
30
+ result = $resource_obj2.type_shortId
31
+ expect(result).to be == "workGroup"
32
+ end
33
+ it 'returns type of resource id from url' do
34
+ result = $resource_item.type_shortId
35
+ expect(result).to be == "expression"
36
+ end
37
+ it 'returns type of resource id from url' do
38
+ result = $resource_item2.type_shortId
39
+ expect(result).to be == "expression"
40
+ end
41
+ it 'returns type url of resource ' do
42
+ result = $resource_obj1.type
43
+ expect(result).to be == "http://scta.info/resource/workGroup"
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
+ it 'returns title of resource ' do
51
+ result = $resource_obj1.title
52
+ expect(result).to be == "Sentences Commentaries"
53
+ 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"
73
+ end
74
+ it 'returns structureType of resource ' do
75
+ result = $resource_div2.structureType_shortId
76
+ expect(result).to be == "structureDivision"
77
+ end
78
+ end
@@ -3,118 +3,28 @@ require 'lbp'
3
3
  require 'pry'
4
4
  require 'nokogiri'
5
5
 
6
- describe 'transcription object' do
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
9
 
8
- require_relative "config_globals"
9
- $transcriptionobject = Lbp::Transcription.new($projectfile, $filehash)
10
-
11
- it 'should return the filestem given at construction' do
12
- result = $transcriptionobject.fs
13
- expect(result).to be_kind_of(String)
14
- end
15
-
16
- it 'should return the full filename for an edited item' do
17
- result = $transcriptionobject.file_path
10
+ it 'returns type of resource' do
11
+ result = $transcript_obj1.type_shortId
12
+ expect(result).to be == "transcription"
13
+ end
14
+ it 'returns transcription type of transcription (documentary)' do
15
+ result = $transcript_obj1.transcription_type
16
+ expect(result).to be == "documentary" # the use of documentary could be confusing because somtimes I say diplomatic
17
+ end
18
+ it 'returns transcription type of transcription (critical)' do
19
+ result = $transcript_obj2.transcription_type
20
+ expect(result).to be == "critical" # the use of documentary could be confusing because somtimes I say diplomatic
21
+ end
22
+ it 'returns file path for transcription' do
23
+ result = $transcript_obj1.file_path
18
24
  expect(result).to be_kind_of(String)
19
- end
20
- it 'should retrieve the item name from the TEI xml file' do
21
- result = $transcriptionobject.title
25
+ end
26
+ it 'returns file path for transcription' do
27
+ result = $transcript_obj2.file_path
22
28
  expect(result).to be_kind_of(String)
23
- end
24
-
25
- it 'should retrieve the author name from the TEI xml file' do
26
- result = $transcriptionobject.author
27
- expect(result).to be_kind_of(String)
28
- end
29
- it 'should retrieve the editor name from the TEI xml file' do
30
- result = $transcriptionobject.editor
31
- expect(result).to be_kind_of(String)
32
- end
33
- it 'should retrieve the edition number from TEI xml file' do
34
- result = $transcriptionobject.ed_no
35
- expect(result).to be_kind_of(String)
36
- end
37
- it 'should retrieve the edition date from TEI xml file' do
38
- result = $transcriptionobject.ed_date
39
- expect(result).to be_kind_of(String)
40
- end
41
- it 'should retrieve the pubdate from TEI xml file' do
42
- result = $transcriptionobject.pub_date
43
- expect(result).to be_kind_of(String)
44
- end
45
- it 'should retrieve the encoding method from TEI xml file' do
46
- result = $transcriptionobject.encoding_method
47
- expect(result).to be_kind_of(String)
48
- end
49
- it 'should retrieve the encoding location from TEI xml file' do
50
- result = $transcriptionobject.encoding_location
51
- expect(result).to be_kind_of(String)
52
- end
53
- =begin
54
- it 'should retrieve the number of columns based on presence of cb element and return 2' do
55
- result = $transcriptionobject.number_of_columns('svict')
56
- result.should == nil
57
- end
58
- =end
59
- =begin
60
- it 'should retrieve the number of columns based on presence of pb element and return 1' do
61
- result = $itemobject.number_of_columns('erlang')
62
- result.should == 1
63
- end
64
- =end
65
-
66
- it 'should transform a doc using a specified xslt file' do
67
- xslt_param_array = []
68
- result = $transcriptionobject.transform($confighash[:xslt_critical_dir] + $confighash[:xslt_clean], xslt_param_array)
69
-
70
- expect(result).to be_instance_of(Nokogiri::XML::Document)
71
- end
72
- # This test should work, but include file paths break in XSL document
73
- #it 'should process an xml doc with the text_display.xslt stylesheet' do
74
- # result = $itemobject.transform._main_view
75
- # expect(result).to be_instance_of(Nokogiri::XML::Document)
76
- #end
77
- #it 'should process an xml doc with the text_display.xsl stylesheet' do
78
- # result = $itemobject.transform_index_view
79
- # expect(result).to be_instance_of(Nokogiri::XML::Document)
80
- #end
81
- it 'should process an xml doc with the cleanForStatistics.xsl stylesheet' do
82
- file_path = $transcriptionobject.file_path
83
- nokogiri = $transcriptionobject.nokogiri
84
- result = $transcriptionobject.transform_clean
85
-
86
- expect(result).to be_instance_of(Nokogiri::XML::Document)
87
- end
88
- it 'should process an xml doc with the text_display.xsl stylesheet' do
89
- result = $transcriptionobject.transform_toc
90
- expect(result).to be_instance_of(Nokogiri::XML::Document)
91
- end
92
- it 'should process an xml doc with the text_display.xsl stylesheet' do
93
- result = $transcriptionobject.transform_plain_text
94
- expect(result).to be_instance_of(Nokogiri::XML::Document)
95
- end
96
- it 'should get the word count of the item object' do
97
- result = $transcriptionobject.word_count
98
- #result.should eq(2122)
99
- expect(result).to be_kind_of(Integer)
100
- end
101
- it 'should get the word frequency of the item object' do
102
- result = $transcriptionobject.word_frequency("word", "ascending")
103
-
104
- expect(result).to be_kind_of(Hash)
105
- end
106
- it 'should get the paragraph count of the item object' do
107
- result = $transcriptionobject.number_of_body_paragraphs
108
-
109
- expect(result).to be_kind_of(Integer)
110
- end
111
- it 'should return an array of paragraph objects' do
112
- result = $transcriptionobject.paragraphs
113
-
114
- expect(result).to be_kind_of(Array)
115
- end
116
- it 'should return an paragraph object for the named id' do
117
- result = $transcriptionobject.paragraph("l1-cpspfs")
118
- expect(result).to be_instance_of(Lbp::Paragraph)
119
- end
29
+ end
120
30
  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.0.2
4
+ version: 0.1.0
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: 2015-01-19 00:00:00.000000000 Z
11
+ date: 2016-08-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -81,7 +81,7 @@ dependencies:
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
- name: rugged
84
+ name: thor
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - ">="
@@ -95,7 +95,7 @@ dependencies:
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
- name: thor
98
+ name: rdf
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - ">="
@@ -109,7 +109,7 @@ dependencies:
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
- name: rdf
112
+ name: rdf-rdfxml
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - ">="
@@ -123,7 +123,7 @@ dependencies:
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  - !ruby/object:Gem::Dependency
126
- name: rdf-rdfxml
126
+ name: rdf-vocab
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
129
  - - ">="
@@ -150,6 +150,20 @@ dependencies:
150
150
  - - ">="
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: sparql
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :runtime
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
153
167
  description: A library for working XML documents conforming the TEI (lbp customized)
154
168
  schema
155
169
  email:
@@ -170,18 +184,23 @@ files:
170
184
  - bin/lbp
171
185
  - lbp.gemspec
172
186
  - lib/lbp.rb
173
- - lib/lbp/collection.rb
187
+ - lib/lbp/expression.rb
188
+ - lib/lbp/file.rb
189
+ - lib/lbp/file_part.rb
174
190
  - lib/lbp/functions.rb
175
- - lib/lbp/item.rb
176
- - lib/lbp/item_group.rb
177
- - lib/lbp/paragraph.rb
191
+ - lib/lbp/manifestation.rb
192
+ - lib/lbp/paragraph_image.rb
193
+ - lib/lbp/query.rb
194
+ - lib/lbp/resource.rb
178
195
  - lib/lbp/transcription.rb
179
196
  - lib/lbp/version.rb
180
- - spec/collection_spec.rb
181
197
  - spec/config_globals.rb
182
- - spec/item_group_spec.rb
183
- - spec/item_spec.rb
184
- - spec/paragraph_spec.rb
198
+ - spec/expression_spec.rb
199
+ - spec/file_part_spec.rb
200
+ - spec/file_spec.rb
201
+ - spec/paragraph_image_spec.rb
202
+ - spec/query_spec.rb
203
+ - spec/resource_spec.rb
185
204
  - spec/spec_helper.rb
186
205
  - spec/transcription_spec.rb
187
206
  homepage: ''
@@ -204,15 +223,17 @@ required_rubygems_version: !ruby/object:Gem::Requirement
204
223
  version: '0'
205
224
  requirements: []
206
225
  rubyforge_project:
207
- rubygems_version: 2.4.5
226
+ rubygems_version: 2.4.6
208
227
  signing_key:
209
228
  specification_version: 4
210
229
  summary: A library for working XML documents conforming the TEI (lbp customized) schema
211
230
  test_files:
212
- - spec/collection_spec.rb
213
231
  - spec/config_globals.rb
214
- - spec/item_group_spec.rb
215
- - spec/item_spec.rb
216
- - spec/paragraph_spec.rb
232
+ - spec/expression_spec.rb
233
+ - spec/file_part_spec.rb
234
+ - spec/file_spec.rb
235
+ - spec/paragraph_image_spec.rb
236
+ - spec/query_spec.rb
237
+ - spec/resource_spec.rb
217
238
  - spec/spec_helper.rb
218
239
  - spec/transcription_spec.rb