lbp 0.0.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.
@@ -0,0 +1,18 @@
1
+ $confighash = { texts_dir: "/Users/JCWitt/WebPages/lbplib-testfiles/pp-projecfiles/GitTextfiles/",
2
+ projectdatafile_dir: "/Users/JCWitt/WebPages/lbplib-testfiles/pp-projectfiles/Conf/",
3
+ xslt_critical_dir: "/Users/JCWitt/WebPages/lbpwrapper/lombardpress/public/pl_xslt_stylesheets/",
4
+ xslt_documentary_dir: "/Users/JCWitt/WebPages/lbpwrapper/lombardpress/public/pl_xslt_stylesheets/",
5
+ xslt_main_view: "text_display.xsl",
6
+ xslt_index_view: "text_display_index.xsl",
7
+ xslt_clean: "clean_forStatistics.xsl",
8
+ xslt_plain_text: "plaintext.xsl",
9
+ xslt_toc: "lectio_outline.xsl",
10
+ git_repo: "bitbucket.org/jeffreycwitt/"}
11
+
12
+
13
+ #filehash = {path: "https://bitbucket.org/jeffreycwitt/lectio1/raw/master/lectio1.xml", fs: "lectio1", ed: "master", type: "critical", source: "origin"}
14
+ $filehash = {path: "/Users/JCWitt/WebPages/lbplib-testfiles/pp-projectfiles/GitTextfiles/lectio1/lectio1.xml", fs: "lectio1", ed: "master", type: "critical", source: "local"}
15
+
16
+ $projectfile = "/Users/JCWitt/WebPages/lbplib-testfiles/pp-projectfiles/Conf/projectdata.xml"
17
+
18
+ $pg_projectfile = "/Users/JCWitt/WebPages/lbplib-testfiles/pg-projectfiles/Conf/projectdata.xml"
@@ -0,0 +1,39 @@
1
+ require 'spec_helper'
2
+ require 'lbp'
3
+ require 'pry'
4
+ require 'nokogiri'
5
+
6
+ describe 'item group object' do
7
+
8
+ require_relative "config_globals"
9
+
10
+ $itemgroup = Lbp::ItemGroup.new($projectfile, "deFide")
11
+
12
+ it 'should return the item group id input at initialization' do
13
+ result = $itemgroup.igid
14
+ expect(result).to be_kind_of(String)
15
+ end
16
+
17
+ it 'should return an array of Item objects from with the Item group' do
18
+ result = $itemgroup.items
19
+ expect(result).to be_kind_of(Array)
20
+ end
21
+ it 'should return an specific item object when a specific item group id is given' do
22
+ result = $itemgroup.item('lectio1')
23
+ expect(result).to be_kind_of(Lbp::Item)
24
+ end
25
+ it 'should return the title of the item group' do
26
+ result = $itemgroup.title
27
+ expect(result).to be_kind_of(String)
28
+ end
29
+ it 'should return return true if the group has sub-groups and false if it does not' do
30
+ result = $itemgroup.has_sub_group?
31
+ # not ideal because I would prefer the test to pass if the result is either false or true
32
+ expect(result).to be false
33
+ end
34
+ it 'should return return true if the group has sub-groups and false if it does not' do
35
+ result = $itemgroup.has_parent_group?
36
+ # not ideal because I would prefer the test to pass if the result is either false or true
37
+ expect(result).to be false
38
+ end
39
+ end
@@ -0,0 +1,74 @@
1
+ require 'spec_helper'
2
+ require 'lbp'
3
+ require 'pry'
4
+ require 'nokogiri'
5
+
6
+ describe 'item object' do
7
+
8
+ require_relative "config_globals"
9
+
10
+ $itemobject = Lbp::Item.new($projectfile, 'lectio1')
11
+
12
+ it 'should return the filestem given at construction' do
13
+ result = $itemobject.fs
14
+ expect(result).to be_kind_of(String)
15
+ end
16
+
17
+ it 'should return the full directory path of file' do
18
+ result = $itemobject.file_dir
19
+ expect(result).to be_kind_of(String)
20
+ end
21
+
22
+ it 'should retrieve the item name from the TEI xml file' do
23
+ result = $itemobject.title
24
+ expect(result).to be_kind_of(String)
25
+ end
26
+ it 'should return true when file is part of a git directory' do
27
+ result = $itemobject.is_git_dir
28
+ result.should == true
29
+ end
30
+ it 'should return an array of branches' do
31
+ result = $itemobject.git_branches
32
+ expect(result).to be_instance_of(Array)
33
+ expect(result).to include("master")
34
+ end
35
+ it 'should return an array of tags' do
36
+ result = $itemobject.git_tags
37
+ expect(result).to be_instance_of(Array)
38
+ expect(result).to include("2011.10")
39
+ end
40
+ it 'should return the current branch' do
41
+ result = $itemobject.git_current_branch
42
+ expect(result).to be_instance_of(String)
43
+ #expect(result).to eq("master")
44
+ end
45
+ it 'should return the sequence number of the item' do
46
+ result = $itemobject.order_number
47
+ expect(result).to be_kind_of(Integer)
48
+ end
49
+ it 'should return an item of object of the previous item' do
50
+ result = $itemobject.previous
51
+ expect(result).to be_instance_of(Lbp::Item)
52
+ end
53
+ it 'should return an item of object of the next item' do
54
+ result = $itemobject.next
55
+ expect(result).to be_instance_of(Lbp::Item)
56
+ end
57
+ it 'should return a transcription object' do
58
+ result = $itemobject.transcription
59
+ expect(result).to be_instance_of(Lbp::Transcription)
60
+ end
61
+ it 'should return a file path for a specified transcription' do
62
+ result = $itemobject.file_path
63
+ expect(result).to be_kind_of(String)
64
+ end
65
+ it 'should return a filehash' do
66
+ result = $itemobject.file_hash
67
+ expect(result).to be_kind_of(Hash)
68
+ end
69
+ it 'should return an array of Transcriptions objects when transcriptions method is called' do
70
+ result = $itemobject.transcriptions
71
+ expect(result).to be_kind_of(Array)
72
+ end
73
+
74
+ end
@@ -0,0 +1,37 @@
1
+ require 'spec_helper'
2
+ require 'lbp'
3
+ require 'pry'
4
+ require 'nokogiri'
5
+
6
+ describe 'paragraph object' do
7
+
8
+ require_relative "config_globals"
9
+ paragraph1 = "l1-cpspfs"
10
+ paragraph3 = "l1-shoatd"
11
+ $paragraph = Lbp::Paragraph.new($projectfile, $filehash, paragraph1)
12
+
13
+ it 'should return the pid for the Paragraph object' do
14
+ result = $paragraph.pid
15
+
16
+ expect(result).to be_kind_of(String)
17
+ end
18
+ it 'should return the number of the paragraph number' do
19
+ result = $paragraph.number
20
+ expect(result).to be_kind_of(Integer)
21
+ end
22
+ it 'should return the next paragraph object or nil if there are no more paragraphs' do
23
+ result = $paragraph.next
24
+ expect(result).to be_kind_of(Lbp::Paragraph)
25
+ end
26
+ it 'should return the previous paragraph object or nil if there are no more paragraphs' do
27
+ result = $paragraph.previous
28
+ #this test works but I don't know how to write a test matching object or nil
29
+ #expect(result).to be(Lbp::Paragraph || nil)
30
+ end
31
+ it 'should return the plain text of the paragraph as a nokogiri object' do
32
+
33
+ result = $paragraph.transform_plain_text
34
+ expect(result).to be_instance_of(Nokogiri::XML::NodeSet)
35
+ end
36
+
37
+ end
@@ -0,0 +1,89 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # The generated `.rspec` file contains `--require spec_helper` which will cause this
4
+ # file to always be loaded, without a need to explicitly require it in any files.
5
+ #
6
+ # Given that it is always loaded, you are encouraged to keep this file as
7
+ # light-weight as possible. Requiring heavyweight dependencies from this file
8
+ # will add to the boot time of your test suite on EVERY test run, even for an
9
+ # individual file that may not need all of that loaded. Instead, consider making
10
+ # a separate helper file that requires the additional dependencies and performs
11
+ # the additional setup, and require it from the spec files that actually need it.
12
+ #
13
+ # The `.rspec` file also contains a few flags that are not defaults but that
14
+ # users commonly want.
15
+ #
16
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
17
+ RSpec.configure do |config|
18
+ # rspec-expectations config goes here. You can use an alternate
19
+ # assertion/expectation library such as wrong or the stdlib/minitest
20
+ # assertions if you prefer.
21
+ config.expect_with :rspec do |expectations|
22
+ # This option will default to `true` in RSpec 4. It makes the `description`
23
+ # and `failure_message` of custom matchers include text for helper methods
24
+ # defined using `chain`, e.g.:
25
+ # be_bigger_than(2).and_smaller_than(4).description
26
+ # # => "be bigger than 2 and smaller than 4"
27
+ # ...rather than:
28
+ # # => "be bigger than 2"
29
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
30
+ end
31
+
32
+ # rspec-mocks config goes here. You can use an alternate test double
33
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
34
+ config.mock_with :rspec do |mocks|
35
+ # Prevents you from mocking or stubbing a method that does not exist on
36
+ # a real object. This is generally recommended, and will default to
37
+ # `true` in RSpec 4.
38
+ mocks.verify_partial_doubles = true
39
+ end
40
+
41
+ # The settings below are suggested to provide a good initial experience
42
+ # with RSpec, but feel free to customize to your heart's content.
43
+ =begin
44
+ # These two settings work together to allow you to limit a spec run
45
+ # to individual examples or groups you care about by tagging them with
46
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
47
+ # get run.
48
+ config.filter_run :focus
49
+ config.run_all_when_everything_filtered = true
50
+
51
+ # Limits the available syntax to the non-monkey patched syntax that is recommended.
52
+ # For more details, see:
53
+ # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
54
+ # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
55
+ # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
56
+ config.disable_monkey_patching!
57
+
58
+ # This setting enables warnings. It's recommended, but in some cases may
59
+ # be too noisy due to issues in dependencies.
60
+ config.warnings = true
61
+
62
+ # Many RSpec users commonly either run the entire suite or an individual
63
+ # file, and it's useful to allow more verbose output when running an
64
+ # individual spec file.
65
+ if config.files_to_run.one?
66
+ # Use the documentation formatter for detailed output,
67
+ # unless a formatter has already been configured
68
+ # (e.g. via a command-line flag).
69
+ config.default_formatter = 'doc'
70
+ end
71
+
72
+ # Print the 10 slowest examples and example groups at the
73
+ # end of the spec run, to help surface which specs are running
74
+ # particularly slow.
75
+ config.profile_examples = 10
76
+
77
+ # Run specs in random order to surface order dependencies. If you find an
78
+ # order dependency and want to debug it, you can fix the order by providing
79
+ # the seed, which is printed after each run.
80
+ # --seed 1234
81
+ config.order = :random
82
+
83
+ # Seed global randomization in this process using the `--seed` CLI option.
84
+ # Setting this allows you to use `--seed` to deterministically reproduce
85
+ # test failures related to randomization by passing the same `--seed` value
86
+ # as the one that triggered the failure.
87
+ Kernel.srand config.seed
88
+ =end
89
+ end
@@ -0,0 +1,120 @@
1
+ require 'spec_helper'
2
+ require 'lbp'
3
+ require 'pry'
4
+ require 'nokogiri'
5
+
6
+ describe 'transcription object' do
7
+
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
18
+ 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
22
+ 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
120
+ end
metadata ADDED
@@ -0,0 +1,218 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lbp
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Jeffrey C. Witt
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-01-19 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: nokogiri
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rugged
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: thor
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rdf
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rdf-rdfxml
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: rest-client
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :runtime
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ description: A library for working XML documents conforming the TEI (lbp customized)
154
+ schema
155
+ email:
156
+ - jeffreycwitt@gmail.com
157
+ executables:
158
+ - lbp
159
+ extensions: []
160
+ extra_rdoc_files: []
161
+ files:
162
+ - ".gitignore"
163
+ - ".rspec"
164
+ - ".ruby-gemset"
165
+ - ".ruby-version"
166
+ - Gemfile
167
+ - LICENSE.txt
168
+ - README.md
169
+ - Rakefile
170
+ - bin/lbp
171
+ - lbp.gemspec
172
+ - lib/lbp.rb
173
+ - lib/lbp/collection.rb
174
+ - lib/lbp/functions.rb
175
+ - lib/lbp/item.rb
176
+ - lib/lbp/item_group.rb
177
+ - lib/lbp/paragraph.rb
178
+ - lib/lbp/transcription.rb
179
+ - lib/lbp/version.rb
180
+ - spec/collection_spec.rb
181
+ - spec/config_globals.rb
182
+ - spec/item_group_spec.rb
183
+ - spec/item_spec.rb
184
+ - spec/paragraph_spec.rb
185
+ - spec/spec_helper.rb
186
+ - spec/transcription_spec.rb
187
+ homepage: ''
188
+ licenses:
189
+ - MIT
190
+ metadata: {}
191
+ post_install_message:
192
+ rdoc_options: []
193
+ require_paths:
194
+ - lib
195
+ required_ruby_version: !ruby/object:Gem::Requirement
196
+ requirements:
197
+ - - ">="
198
+ - !ruby/object:Gem::Version
199
+ version: '0'
200
+ required_rubygems_version: !ruby/object:Gem::Requirement
201
+ requirements:
202
+ - - ">="
203
+ - !ruby/object:Gem::Version
204
+ version: '0'
205
+ requirements: []
206
+ rubyforge_project:
207
+ rubygems_version: 2.4.5
208
+ signing_key:
209
+ specification_version: 4
210
+ summary: A library for working XML documents conforming the TEI (lbp customized) schema
211
+ test_files:
212
+ - spec/collection_spec.rb
213
+ - spec/config_globals.rb
214
+ - spec/item_group_spec.rb
215
+ - spec/item_spec.rb
216
+ - spec/paragraph_spec.rb
217
+ - spec/spec_helper.rb
218
+ - spec/transcription_spec.rb