onlyoffice_pdf_parser 0.1.0 → 0.3.0

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
  SHA256:
3
- metadata.gz: 661dfba5483c4463abeac412e29aef2c7813ac31edf78e17ca3593ed879e10aa
4
- data.tar.gz: 5bcabaa8c35ecf07a814f555693c64720234bffd1e9ee2e82b831e8c65f72a09
3
+ metadata.gz: 0b9aae5d167a597a5a3ed130df76fdf6556f56a0584e37f0d8cb1628072efb53
4
+ data.tar.gz: 504d27e360ad224a8c8d81c03f7d7acd8a21cbb6742d5260a5cd0f03653a98c6
5
5
  SHA512:
6
- metadata.gz: a91f4477b8d9a32de8459856a6e3e965380f5143be90cea0c67b1b94367ecfc1e4961f34be916dc5ae9bfbdf634d0f331d3a45f0b7c34261cf6d7ad9ddc392eb
7
- data.tar.gz: b0960da736c0e12c99f02c7dc8c8dc3c08569b25f81b5995b858fd060322e77ab7c3145c4aeca9670be3ef12e8247d8550b410335c3b407bdc5a5a0b7aaf8f55
6
+ metadata.gz: 93f18f9b66233ad8164def6ac45e41b8ed8ca4a72da22ada40b45df5678856031e49839084ae72571c62f036c5c9b44e85f1c7951099c0116993b6fd255c29ba
7
+ data.tar.gz: ec867fb44f95b59a28a32dc290bef278698d92ecbf49697672b5ac2a1ffa3879684a64d6652ce87f0c97941408262c015cfdf3c7ab0adaf66594c23648248f10
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative 'onlyoffice_pdf_parser/bmp_image.rb'
4
- require_relative 'onlyoffice_pdf_parser/pdf_structure.rb'
3
+ require_relative 'onlyoffice_pdf_parser/bmp_image'
4
+ require_relative 'onlyoffice_pdf_parser/pdf_structure'
@@ -13,7 +13,9 @@ module OnlyofficePdfParser
13
13
  # @return [String] binary dat of file
14
14
  attr_reader :data
15
15
 
16
- def initialize(param = nil)
16
+ def initialize(param = nil, width: nil, height: nil)
17
+ @width = width
18
+ @height = height
17
19
  return unless param
18
20
 
19
21
  init_data(param)
@@ -24,10 +26,14 @@ module OnlyofficePdfParser
24
26
  fetch_pixels
25
27
  end
26
28
 
29
+ # @return [String] convert object to string
27
30
  def to_s
28
31
  path_to_image
29
32
  end
30
33
 
34
+ # Compare object with other
35
+ # @param other [Object] object to compare
36
+ # @return [True, False] result of comparison
31
37
  def ==(other)
32
38
  return false unless other.width == width && other.height == height
33
39
 
@@ -41,8 +47,13 @@ module OnlyofficePdfParser
41
47
  true
42
48
  end
43
49
 
50
+ # Get sub image from coordinates
51
+ # @param start_point [CursorPoint] top left coordinates to get
52
+ # @param width [Integer] width to get
53
+ # @param height [Integer] height to get
54
+ # @return [BmpImage] result
44
55
  def get_sub_image(start_point = CursorPoint.new(0, 0), width = 0, height = 0)
45
- sub_image = BmpImage.new
56
+ sub_image = BmpImage.new(nil, width: width, height: height)
46
57
  pixels_array = []
47
58
  height.times do |current_height|
48
59
  line_array = []
@@ -56,11 +67,12 @@ module OnlyofficePdfParser
56
67
  pixels_array << line_array
57
68
  end
58
69
  sub_image.pixels = pixels_array
59
- sub_image.width = width
60
- sub_image.height = height
61
70
  sub_image
62
71
  end
63
72
 
73
+ # Get sub image from file pattern coordinates
74
+ # @param path_to_sub_image [String] path to pattern to find
75
+ # @return [Array<CursorPoint>] result
64
76
  def get_sub_image_array(path_to_sub_image)
65
77
  coordinates_array = []
66
78
  sub_image = BmpImage.new(path_to_sub_image)
@@ -15,14 +15,20 @@ module OnlyofficePdfParser
15
15
  alias x left
16
16
  alias y top
17
17
 
18
+ # Make a copy of object
19
+ # @return [CursorPoint] another object
18
20
  def dup
19
21
  CursorPoint.new(@left, @top)
20
22
  end
21
23
 
24
+ # @return [String] convert object to string
22
25
  def to_s
23
26
  "[#{@left}, #{@top}]"
24
27
  end
25
28
 
29
+ # Compare object with other
30
+ # @param other [Object] object to compare
31
+ # @return [True, False] result of comparison
26
32
  def ==(other)
27
33
  if other.respond_to?(:left) && other.respond_to?(:top)
28
34
  @left == other.left && @top == other.top
@@ -31,6 +37,9 @@ module OnlyofficePdfParser
31
37
  end
32
38
  end
33
39
 
40
+ # Accessor of attributes like hash
41
+ # @param name [Symbol] attribute name
42
+ # @return [Object] value of attribute
34
43
  def [](name)
35
44
  case name
36
45
  when :width
@@ -43,5 +52,6 @@ module OnlyofficePdfParser
43
52
  end
44
53
  end
45
54
 
55
+ # Alias for this object
46
56
  Dimensions = CursorPoint
47
57
  end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Namespace of gem
4
+ module OnlyofficePdfParser
5
+ # Module with name of Gem
6
+ module Name
7
+ # @return [String] name of gem
8
+ STRING = 'onlyoffice_pdf_parser'
9
+ end
10
+ end
@@ -24,6 +24,9 @@ module OnlyofficePdfParser
24
24
  @pages_in_bmp = []
25
25
  end
26
26
 
27
+ # Accessor of attributes like hash
28
+ # @param parameter [Symbol] attribute name
29
+ # @return [Object] value of attribute
27
30
  def [](parameter)
28
31
  case parameter
29
32
  when :pages
@@ -70,6 +73,7 @@ module OnlyofficePdfParser
70
73
  @page_size ||= "Landscape #{PAGE_SIZE_FOR_PDF.key(page_size_points.reverse)}"
71
74
  end
72
75
 
76
+ # @return [Hash] list of default page size and names
73
77
  PAGE_SIZE_FOR_PDF = { 'US Letter' => [612, 792],
74
78
  'US Legal' => [612, 1008],
75
79
  'A4' => [595, 842],
@@ -84,6 +88,9 @@ module OnlyofficePdfParser
84
88
  'Envelope Choukei 3' => [340, 666],
85
89
  'Super B/A3' => [936, 1368] }.freeze
86
90
 
91
+ # Parse file
92
+ # @param filename [String] path to file
93
+ # @return [PdfStructure] result of parse
87
94
  def self.parse(filename)
88
95
  file = PdfStructure.new(pages: [], file_path: filename)
89
96
  file.pdf_reader_parse
@@ -93,5 +100,6 @@ module OnlyofficePdfParser
93
100
  end
94
101
  end
95
102
 
103
+ # Alias for object
96
104
  PdfParser = PdfStructure
97
105
  end
@@ -1,7 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OnlyofficePdfParser
4
+ # Module with version of Gem
4
5
  module Version
5
- STRING = '0.1.0'
6
+ # @return [String] version of gem
7
+ STRING = '0.3.0'
6
8
  end
7
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: onlyoffice_pdf_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Lobashov
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-03-13 00:00:00.000000000 Z
12
+ date: 2020-11-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: image_size
@@ -43,23 +43,157 @@ dependencies:
43
43
  name: rmagick
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
- - - ">="
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: '4'
49
+ type: :runtime
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: '4'
56
+ - !ruby/object:Gem::Dependency
57
+ name: overcommit
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ - !ruby/object:Gem::Dependency
71
+ name: parallel_tests
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - "~>"
75
+ - !ruby/object:Gem::Version
76
+ version: '3'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - "~>"
82
+ - !ruby/object:Gem::Version
83
+ version: '3'
84
+ - !ruby/object:Gem::Dependency
85
+ name: rake
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - "~>"
89
+ - !ruby/object:Gem::Version
90
+ version: '13'
91
+ type: :development
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - "~>"
96
+ - !ruby/object:Gem::Version
97
+ version: '13'
98
+ - !ruby/object:Gem::Dependency
99
+ name: rspec
100
+ requirement: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - "~>"
103
+ - !ruby/object:Gem::Version
104
+ version: '3'
105
+ type: :development
106
+ prerelease: false
107
+ version_requirements: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - "~>"
110
+ - !ruby/object:Gem::Version
111
+ version: '3'
112
+ - !ruby/object:Gem::Dependency
113
+ name: rubocop
114
+ requirement: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - "~>"
117
+ - !ruby/object:Gem::Version
118
+ version: '1'
119
+ type: :development
120
+ prerelease: false
121
+ version_requirements: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - "~>"
124
+ - !ruby/object:Gem::Version
125
+ version: '1'
126
+ - !ruby/object:Gem::Dependency
127
+ name: rubocop-performance
128
+ requirement: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - "~>"
131
+ - !ruby/object:Gem::Version
132
+ version: '1'
133
+ type: :development
134
+ prerelease: false
135
+ version_requirements: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - "~>"
138
+ - !ruby/object:Gem::Version
139
+ version: '1'
140
+ - !ruby/object:Gem::Dependency
141
+ name: rubocop-rake
142
+ requirement: !ruby/object:Gem::Requirement
143
+ requirements:
144
+ - - "~>"
145
+ - !ruby/object:Gem::Version
146
+ version: '0'
147
+ type: :development
148
+ prerelease: false
149
+ version_requirements: !ruby/object:Gem::Requirement
150
+ requirements:
151
+ - - "~>"
152
+ - !ruby/object:Gem::Version
153
+ version: '0'
154
+ - !ruby/object:Gem::Dependency
155
+ name: rubocop-rspec
156
+ requirement: !ruby/object:Gem::Requirement
157
+ requirements:
158
+ - - "~>"
47
159
  - !ruby/object:Gem::Version
48
160
  version: '2'
49
- - - "<"
161
+ type: :development
162
+ prerelease: false
163
+ version_requirements: !ruby/object:Gem::Requirement
164
+ requirements:
165
+ - - "~>"
50
166
  - !ruby/object:Gem::Version
51
- version: '5'
52
- type: :runtime
167
+ version: '2'
168
+ - !ruby/object:Gem::Dependency
169
+ name: simplecov
170
+ requirement: !ruby/object:Gem::Requirement
171
+ requirements:
172
+ - - "~>"
173
+ - !ruby/object:Gem::Version
174
+ version: '0'
175
+ type: :development
53
176
  prerelease: false
54
177
  version_requirements: !ruby/object:Gem::Requirement
178
+ requirements:
179
+ - - "~>"
180
+ - !ruby/object:Gem::Version
181
+ version: '0'
182
+ - !ruby/object:Gem::Dependency
183
+ name: yard
184
+ requirement: !ruby/object:Gem::Requirement
55
185
  requirements:
56
186
  - - ">="
57
187
  - !ruby/object:Gem::Version
58
- version: '2'
59
- - - "<"
188
+ version: 0.9.20
189
+ type: :development
190
+ prerelease: false
191
+ version_requirements: !ruby/object:Gem::Requirement
192
+ requirements:
193
+ - - ">="
60
194
  - !ruby/object:Gem::Version
61
- version: '5'
62
- description: Wrapper for Testrail by OnlyOffice
195
+ version: 0.9.20
196
+ description: Library for parsing, converting and extracting PDF data
63
197
  email:
64
198
  - shockwavenn@gmail.com
65
199
  - kvazilife@gmail.com
@@ -67,20 +201,25 @@ executables: []
67
201
  extensions: []
68
202
  extra_rdoc_files: []
69
203
  files:
70
- - README.md
71
204
  - lib/onlyoffice_pdf_parser.rb
72
205
  - lib/onlyoffice_pdf_parser/bmp_image.rb
73
206
  - lib/onlyoffice_pdf_parser/helpers/array_helper.rb
74
207
  - lib/onlyoffice_pdf_parser/helpers/cursor_point.rb
75
208
  - lib/onlyoffice_pdf_parser/helpers/file_helper.rb
209
+ - lib/onlyoffice_pdf_parser/name.rb
76
210
  - lib/onlyoffice_pdf_parser/pdf_structure.rb
77
211
  - lib/onlyoffice_pdf_parser/pdf_structure/pdf_convert_to_bmp_helper.rb
78
212
  - lib/onlyoffice_pdf_parser/pdf_structure/pdf_reader_helper.rb
79
213
  - lib/onlyoffice_pdf_parser/version.rb
80
- homepage: https://github.com/onlyoffice-testing-robot/onlyoffice_pdf_parser
214
+ homepage: https://github.com/ONLYOFFICE-QA/onlyoffice_pdf_parser
81
215
  licenses:
82
216
  - AGPL-3.0
83
- metadata: {}
217
+ metadata:
218
+ bug_tracker_uri: https://github.com/ONLYOFFICE-QA/onlyoffice_pdf_parser/issues
219
+ changelog_uri: https://github.com/ONLYOFFICE-QA/onlyoffice_pdf_parser/blob/master/CHANGELOG.md
220
+ documentation_uri: https://www.rubydoc.info/gems/onlyoffice_pdf_parser
221
+ homepage_uri: https://github.com/ONLYOFFICE-QA/onlyoffice_pdf_parser
222
+ source_code_uri: https://github.com/ONLYOFFICE-QA/onlyoffice_pdf_parser
84
223
  post_install_message:
85
224
  rdoc_options: []
86
225
  require_paths:
@@ -89,15 +228,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
89
228
  requirements:
90
229
  - - ">="
91
230
  - !ruby/object:Gem::Version
92
- version: '0'
231
+ version: '2.5'
93
232
  required_rubygems_version: !ruby/object:Gem::Requirement
94
233
  requirements:
95
234
  - - ">="
96
235
  - !ruby/object:Gem::Version
97
236
  version: '0'
98
237
  requirements: []
99
- rubygems_version: 3.0.6
238
+ rubygems_version: 3.1.4
100
239
  signing_key:
101
240
  specification_version: 4
102
- summary: ONLYOFFICE Testrail Wrapper Gem
241
+ summary: ONLYOFFICE PDF Parser Gem
103
242
  test_files: []
data/README.md DELETED
@@ -1,12 +0,0 @@
1
- # Onlyoffice PDF Parser
2
-
3
- It is gem for parsing pdf files.
4
-
5
- ### Example
6
-
7
- ```
8
- require 'onlyoffice_pdf_parser'
9
-
10
- OnlyofficePdfParser::PdfParser.parse('Text.pdf')
11
-
12
- ```