onlyoffice_pdf_parser 0.1.2 → 0.4.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: 1a697279502703e39f149142d8c2db8dfd0ec6339896cecdbec8f091fea63c6f
4
- data.tar.gz: 011565b90b198dd993bce278a8a1336d143bfc01ca41a49e8cc9d1258e100319
3
+ metadata.gz: aa1e4904848f330f9e50f850cfdcab6e4b0e170e2478491a94c1e6ca5172bea2
4
+ data.tar.gz: afc8fcd96b544e8d7ec8dd5cab7db1d7225359a0d2e5423b706243fa24252654
5
5
  SHA512:
6
- metadata.gz: 1af64743d41cb0629a9582dd2f9ad8cbb162a3a59e045bbb3f3866cbfcd93378ded503f189464bc1a1f33985c9b4fb285aa7e393c3f89b5ccaae7270f27faf37
7
- data.tar.gz: d1bf15f86cce7de63f60e42c66ab98fdc8a0972047492ef50182f7e7aca3a5dac04f3d6ad4a0fefe0ffc1413a9d0e495c8f3dda0bbdf0844cc810f6e10927ae4
6
+ metadata.gz: '05112925b5f8dfb5abd423435e96410344e421e1cf1705733b2c142cf2225bee45dc1611e89915d70233ac548ae131edf6711d91500c3bf85b76a6562b3a493f'
7
+ data.tar.gz: 45e19650bd51a9bffca33598e45831389eb4caa6a732651a901cedd1fce41813c7ffe3dc2dfcbfc19f08532289da43c01a8f33e30c4fda0dcba3bb015cd6a603
@@ -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)
@@ -95,7 +107,7 @@ module OnlyofficePdfParser
95
107
  # @return [Void] Fill @pixel with data
96
108
  def fetch_pixels
97
109
  tmp_file = Tempfile.new('onlyoffice_pdf_parser')
98
- File.open(tmp_file, 'wb') { |file| file.write(data) }
110
+ File.binwrite(tmp_file, data)
99
111
  @pixels = ImageList.new(tmp_file.path).get_pixels(0, 0, width, height).each_slice(width).to_a
100
112
  tmp_file.unlink
101
113
  end
@@ -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.2'
6
+ # @return [String] version of gem
7
+ STRING = '0.4.0'
6
8
  end
7
9
  end
@@ -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'
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.2
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Lobashov
@@ -9,22 +9,28 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-03-13 00:00:00.000000000 Z
12
+ date: 2022-01-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: image_size
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - "~>"
18
+ - - ">="
19
19
  - !ruby/object:Gem::Version
20
20
  version: '2'
21
+ - - "<"
22
+ - !ruby/object:Gem::Version
23
+ version: '4'
21
24
  type: :runtime
22
25
  prerelease: false
23
26
  version_requirements: !ruby/object:Gem::Requirement
24
27
  requirements:
25
- - - "~>"
28
+ - - ">="
26
29
  - !ruby/object:Gem::Version
27
30
  version: '2'
31
+ - - "<"
32
+ - !ruby/object:Gem::Version
33
+ version: '4'
28
34
  - !ruby/object:Gem::Dependency
29
35
  name: pdf-reader
30
36
  requirement: !ruby/object:Gem::Requirement
@@ -43,36 +49,156 @@ dependencies:
43
49
  name: rmagick
44
50
  requirement: !ruby/object:Gem::Requirement
45
51
  requirements:
46
- - - ">="
47
- - !ruby/object:Gem::Version
48
- version: '2'
49
- - - "<"
52
+ - - "~>"
50
53
  - !ruby/object:Gem::Version
51
- version: '5'
54
+ version: '4'
52
55
  type: :runtime
53
56
  prerelease: false
54
57
  version_requirements: !ruby/object:Gem::Requirement
55
58
  requirements:
56
- - - ">="
59
+ - - "~>"
57
60
  - !ruby/object:Gem::Version
58
- version: '2'
59
- - - "<"
61
+ version: '4'
62
+ - !ruby/object:Gem::Dependency
63
+ name: overcommit
64
+ requirement: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
60
67
  - !ruby/object:Gem::Version
61
- version: '5'
68
+ version: '0'
69
+ type: :development
70
+ prerelease: false
71
+ version_requirements: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ - !ruby/object:Gem::Dependency
77
+ name: parallel_tests
78
+ requirement: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3'
83
+ type: :development
84
+ prerelease: false
85
+ version_requirements: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '3'
62
90
  - !ruby/object:Gem::Dependency
63
91
  name: rake
64
92
  requirement: !ruby/object:Gem::Requirement
65
93
  requirements:
66
94
  - - "~>"
67
95
  - !ruby/object:Gem::Version
68
- version: '13.0'
96
+ version: '13'
97
+ type: :development
98
+ prerelease: false
99
+ version_requirements: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '13'
104
+ - !ruby/object:Gem::Dependency
105
+ name: rspec
106
+ requirement: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '3'
111
+ type: :development
112
+ prerelease: false
113
+ version_requirements: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '3'
118
+ - !ruby/object:Gem::Dependency
119
+ name: rubocop
120
+ requirement: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '1'
125
+ type: :development
126
+ prerelease: false
127
+ version_requirements: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '1'
132
+ - !ruby/object:Gem::Dependency
133
+ name: rubocop-performance
134
+ requirement: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '1'
139
+ type: :development
140
+ prerelease: false
141
+ version_requirements: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '1'
146
+ - !ruby/object:Gem::Dependency
147
+ name: rubocop-rake
148
+ requirement: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
69
153
  type: :development
70
154
  prerelease: false
71
155
  version_requirements: !ruby/object:Gem::Requirement
72
156
  requirements:
73
157
  - - "~>"
74
158
  - !ruby/object:Gem::Version
75
- version: '13.0'
159
+ version: '0'
160
+ - !ruby/object:Gem::Dependency
161
+ name: rubocop-rspec
162
+ requirement: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: '2'
167
+ type: :development
168
+ prerelease: false
169
+ version_requirements: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - "~>"
172
+ - !ruby/object:Gem::Version
173
+ version: '2'
174
+ - !ruby/object:Gem::Dependency
175
+ name: simplecov
176
+ requirement: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - "~>"
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
181
+ type: :development
182
+ prerelease: false
183
+ version_requirements: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - "~>"
186
+ - !ruby/object:Gem::Version
187
+ version: '0'
188
+ - !ruby/object:Gem::Dependency
189
+ name: yard
190
+ requirement: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - ">="
193
+ - !ruby/object:Gem::Version
194
+ version: 0.9.20
195
+ type: :development
196
+ prerelease: false
197
+ version_requirements: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - ">="
200
+ - !ruby/object:Gem::Version
201
+ version: 0.9.20
76
202
  description: Library for parsing, converting and extracting PDF data
77
203
  email:
78
204
  - shockwavenn@gmail.com
@@ -86,19 +212,21 @@ files:
86
212
  - lib/onlyoffice_pdf_parser/helpers/array_helper.rb
87
213
  - lib/onlyoffice_pdf_parser/helpers/cursor_point.rb
88
214
  - lib/onlyoffice_pdf_parser/helpers/file_helper.rb
215
+ - lib/onlyoffice_pdf_parser/name.rb
89
216
  - lib/onlyoffice_pdf_parser/pdf_structure.rb
90
217
  - lib/onlyoffice_pdf_parser/pdf_structure/pdf_convert_to_bmp_helper.rb
91
218
  - lib/onlyoffice_pdf_parser/pdf_structure/pdf_reader_helper.rb
92
219
  - lib/onlyoffice_pdf_parser/version.rb
93
- homepage: https://github.com/onlyoffice-testing-robot/onlyoffice_pdf_parser
220
+ homepage: https://github.com/ONLYOFFICE-QA/onlyoffice_pdf_parser
94
221
  licenses:
95
222
  - AGPL-3.0
96
223
  metadata:
97
- bug_tracker_uri: https://github.com/onlyoffice-testing-robot/onlyoffice_pdf_parser/issues
98
- changelog_uri: https://github.com/onlyoffice-testing-robot/onlyoffice_pdf_parser/blob/master/CHANGELOG.md
224
+ bug_tracker_uri: https://github.com/ONLYOFFICE-QA/onlyoffice_pdf_parser/issues
225
+ changelog_uri: https://github.com/ONLYOFFICE-QA/onlyoffice_pdf_parser/blob/master/CHANGELOG.md
99
226
  documentation_uri: https://www.rubydoc.info/gems/onlyoffice_pdf_parser
100
- homepage_uri: https://github.com/onlyoffice-testing-robot/onlyoffice_pdf_parser
101
- source_code_uri: https://github.com/onlyoffice-testing-robot/onlyoffice_pdf_parser
227
+ homepage_uri: https://github.com/ONLYOFFICE-QA/onlyoffice_pdf_parser
228
+ source_code_uri: https://github.com/ONLYOFFICE-QA/onlyoffice_pdf_parser
229
+ rubygems_mfa_required: 'true'
102
230
  post_install_message:
103
231
  rdoc_options: []
104
232
  require_paths:
@@ -107,14 +235,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
107
235
  requirements:
108
236
  - - ">="
109
237
  - !ruby/object:Gem::Version
110
- version: '0'
238
+ version: '2.5'
111
239
  required_rubygems_version: !ruby/object:Gem::Requirement
112
240
  requirements:
113
241
  - - ">="
114
242
  - !ruby/object:Gem::Version
115
243
  version: '0'
116
244
  requirements: []
117
- rubygems_version: 3.0.6
245
+ rubygems_version: 3.3.4
118
246
  signing_key:
119
247
  specification_version: 4
120
248
  summary: ONLYOFFICE PDF Parser Gem