onlyoffice_pdf_parser 0.1.2 → 0.2.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: 6212798444987cba5c3430c125dafe40d3478f63ea2d15d0b09a2369a569d6d8
4
+ data.tar.gz: 5efb6bb19820c51ad65668ac10918388953b152d82dbbd24335b5fd281b0949d
5
5
  SHA512:
6
- metadata.gz: 1af64743d41cb0629a9582dd2f9ad8cbb162a3a59e045bbb3f3866cbfcd93378ded503f189464bc1a1f33985c9b4fb285aa7e393c3f89b5ccaae7270f27faf37
7
- data.tar.gz: d1bf15f86cce7de63f60e42c66ab98fdc8a0972047492ef50182f7e7aca3a5dac04f3d6ad4a0fefe0ffc1413a9d0e495c8f3dda0bbdf0844cc810f6e10927ae4
6
+ metadata.gz: e16d59adb7d67b3c603ab14445d06767c41d16ff6c6079d85880d0c92f7236b6c1414522801f369a94bd76f0fc58845ef918a0c898fb60e7e840cb0ba7148b10
7
+ data.tar.gz: 681e14dd31f14a6ec45302e0646ba82d45e926490e79601445dfd6db1550bb8baccd950394a3646c84126f7448e5c49a4c1c983b17595abccecabf861f20357f
@@ -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.2'
6
+ # @return [String] version of gem
7
+ STRING = '0.2.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.2
4
+ version: 0.2.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-08-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: image_size
@@ -59,20 +59,146 @@ dependencies:
59
59
  - - "<"
60
60
  - !ruby/object:Gem::Version
61
61
  version: '5'
62
+ - !ruby/object:Gem::Dependency
63
+ name: overcommit
64
+ requirement: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '='
67
+ - !ruby/object:Gem::Version
68
+ version: 0.55.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.55.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.1.0
83
+ type: :development
84
+ prerelease: false
85
+ version_requirements: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '='
88
+ - !ruby/object:Gem::Version
89
+ version: 3.1.0
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.0.1
69
97
  type: :development
70
98
  prerelease: false
71
99
  version_requirements: !ruby/object:Gem::Requirement
72
100
  requirements:
73
- - - "~>"
101
+ - - '='
102
+ - !ruby/object:Gem::Version
103
+ version: 13.0.1
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.9.0
111
+ type: :development
112
+ prerelease: false
113
+ version_requirements: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '='
116
+ - !ruby/object:Gem::Version
117
+ version: 3.9.0
118
+ - !ruby/object:Gem::Dependency
119
+ name: rubocop
120
+ requirement: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '='
123
+ - !ruby/object:Gem::Version
124
+ version: 0.89.1
125
+ type: :development
126
+ prerelease: false
127
+ version_requirements: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - '='
130
+ - !ruby/object:Gem::Version
131
+ version: 0.89.1
132
+ - !ruby/object:Gem::Dependency
133
+ name: rubocop-performance
134
+ requirement: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - '='
74
137
  - !ruby/object:Gem::Version
75
- version: '13.0'
138
+ version: 1.7.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.7.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.5.1
153
+ type: :development
154
+ prerelease: false
155
+ version_requirements: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - '='
158
+ - !ruby/object:Gem::Version
159
+ version: 0.5.1
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: 1.43.1
167
+ type: :development
168
+ prerelease: false
169
+ version_requirements: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - '='
172
+ - !ruby/object:Gem::Version
173
+ version: 1.43.1
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.19.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.19.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.25
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.25
76
202
  description: Library for parsing, converting and extracting PDF data
77
203
  email:
78
204
  - shockwavenn@gmail.com
@@ -86,6 +212,7 @@ 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
@@ -107,14 +234,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
107
234
  requirements:
108
235
  - - ">="
109
236
  - !ruby/object:Gem::Version
110
- version: '0'
237
+ version: '2.5'
111
238
  required_rubygems_version: !ruby/object:Gem::Requirement
112
239
  requirements:
113
240
  - - ">="
114
241
  - !ruby/object:Gem::Version
115
242
  version: '0'
116
243
  requirements: []
117
- rubygems_version: 3.0.6
244
+ rubygems_version: 3.1.4
118
245
  signing_key:
119
246
  specification_version: 4
120
247
  summary: ONLYOFFICE PDF Parser Gem