txtextcontrol-reportingcloud 1.0.3 → 1.1.1

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
  SHA1:
3
- metadata.gz: f5b632e12313e22c5615fa25a61e07f66f196851
4
- data.tar.gz: b23b146e8e07c8bdc8cc515973ec4251777c1f21
3
+ metadata.gz: d2b985e985d074bac7f609544b426343b0be9de7
4
+ data.tar.gz: 8f190bc99f4f3954f2aac8cc35a5e3e6c9bb41bc
5
5
  SHA512:
6
- metadata.gz: 90750efc45ace03aacd6756765e075a75a6942561dfdf54377a208d07ab2b3c658baceb00ee4843cb03c3fbe7678e3e45235604c37be8b80bb5121f1a9156854
7
- data.tar.gz: adcb08b8b1fc36a76d4be92392397eb2d760bab9639e7be673b8f204a24b2066ab04cd7746b9bd5d3946c53f20fc61eff54f65583651d7633a081c0ecf082b79
6
+ metadata.gz: e58da2cb52df4dc3f58fb66f51466c626f6119b7609e193877eef9ed804c516fbc890743e483ab288b524e95f065128bb11dfae2aed89b41ef7743819cb5bc37
7
+ data.tar.gz: e7b306757c6c86f695e82257d5e2d7ce4b53768d5e18a1cf25ef7fcf302f38882f6eca20f9cb25a877fdae21291aea01720e0143d5accf29d1c78afe9490736a
@@ -0,0 +1,63 @@
1
+ # ReportingCloud Ruby Wrapper
2
+ #
3
+ # Official wrapper (authored by Text Control GmbH, publisher of ReportingCloud) to access
4
+ # ReportingCloud in Ruby.
5
+ #
6
+ # Go to http://www.reporting.cloud to learn more about ReportingCloud
7
+ # Go to https://github.com/TextControl/txtextcontrol-reportingcloud-ruby for the
8
+ # canonical source repository.
9
+ #
10
+ # License: https://raw.githubusercontent.com/TextControl/txtextcontrol-reportingcloud-ruby/master/LICENSE.md
11
+ #
12
+ # Copyright: © 2017 Text Control GmbH
13
+
14
+ module TXTextControl
15
+ module ReportingCloud
16
+
17
+ # Represents an incorrect word in spell checked text.
18
+ # @attr_reader [Integer] length The length of the spelled word.
19
+ # @attr_reader [Integer] start The starting position of a spelled word.
20
+ # @attr_reader [String] text The text of the spelled word.
21
+ # @attr_reader [Boolean] is_duplicate Indicating whether the spelled word is
22
+ # declared as incorrect, because the previous word has the same text.
23
+ # @attr_reader [String] language Indicating the language the incorrect word
24
+ # was spelled.
25
+ # @author Thorsten Kummerow (@thomerow)
26
+ class IncorrectWord
27
+ attr_reader :length
28
+ attr_reader :start
29
+ attr_reader :text
30
+ attr_reader :is_duplicate
31
+ attr_reader :language
32
+
33
+ alias_method :is_duplicate?, :is_duplicate
34
+
35
+ # @param [Integer] length The starting position of a spelled word.
36
+ # @param [Integer] start The starting position of a spelled word.
37
+ # @param [String] text The text of the spelled word.
38
+ # @param [Boolean] is_duplicate Indicating whether the spelled word is
39
+ # declared as incorrect, because the previous word has the same text.
40
+ # @param [String] language Indicating the language the incorrect word
41
+ # was spelled.
42
+ def initialize(length, start, text, is_duplicate, language)
43
+ @length = Integer(length)
44
+ @start = Integer(start)
45
+ @text = text
46
+ @is_duplicate = !!is_duplicate
47
+ @language = language
48
+ end
49
+
50
+ # Creates an IncorrectWord instance from a hash.
51
+ # @param [Hash] hash The hash to try and create an IncorrectWord instance from.
52
+ # @return [IncorrectWord] A newly created IncorrectWord instance.
53
+ def self.from_camelized_hash(hash)
54
+ l = hash["length"]
55
+ s = hash["start"]
56
+ txt = hash["text"]
57
+ id = hash["isDuplicate"]
58
+ lan = hash["language"]
59
+ return IncorrectWord.new(l, s, txt, id, lan)
60
+ end
61
+ end
62
+ end
63
+ end
@@ -23,6 +23,10 @@ module TXTextControl
23
23
  # don't have merge data should be removed from the template or not.
24
24
  # @attr remove_trailing_whitespace [Boolean] Specifies whether trailing
25
25
  # whitespace should be removed before saving a document.
26
+ # @attr merge_html [Boolean] Specifies whether field data can contain
27
+ # formatted Html content or not. The default value is false. Html
28
+ # content must be enclosed in an <html /> tag element. Only active in
29
+ # the Merge endpoint.
26
30
  # @attr author [String] The document's author.
27
31
  # @attr creation_date [DateTime] The document's creation date.
28
32
  # @attr creator_application [String] The application which created the document.
@@ -36,17 +40,25 @@ module TXTextControl
36
40
  attr_accessor :remove_empty_blocks
37
41
  attr_accessor :remove_empty_images
38
42
  attr_accessor :remove_trailing_whitespace
43
+ attr_accessor :merge_html
39
44
  attr_accessor :author
40
45
  attr_accessor :creator_application
41
46
  attr_accessor :document_subject
42
47
  attr_accessor :document_title
43
48
  attr_accessor :user_password
44
49
 
50
+ alias_method :remove_empty_fields?, :remove_empty_fields
51
+ alias_method :remove_empty_blocks?, :remove_empty_blocks
52
+ alias_method :remove_empty_images?, :remove_empty_images
53
+ alias_method :remove_trailing_whitespace?, :remove_trailing_whitespace
54
+ alias_method :merge_html?, :merge_html
55
+
45
56
  def initialize
46
57
  @remove_empty_fields = true
47
58
  @remove_empty_blocks = true
48
59
  @remove_empty_images = true
49
60
  @remove_trailing_whitespace = true
61
+ @merge_html = false
50
62
 
51
63
  @author = nil
52
64
  @creation_date = nil
@@ -98,6 +110,7 @@ module TXTextControl
98
110
  "removeEmptyBlocks" => @remove_empty_blocks,
99
111
  "removeEmptyImages" => @remove_empty_images,
100
112
  "removeTrailingWhitespace" => @remove_trailing_whitespace,
113
+ "mergeHtml" => @merge_html,
101
114
  "author" => @author,
102
115
  "creationDate" => @creation_date.nil? ? nil : @creation_date.iso8601,
103
116
  "creatorApplication" => @creator_application,
@@ -19,6 +19,7 @@ require "cgi"
19
19
  require 'txtextcontrol/reportingcloud/template'
20
20
  require 'txtextcontrol/reportingcloud/template_info'
21
21
  require 'txtextcontrol/reportingcloud/account_settings'
22
+ require 'txtextcontrol/reportingcloud/incorrect_word'
22
23
  require 'txtextcontrol/reportingcloud/find_and_replace_body'
23
24
  require 'txtextcontrol/reportingcloud/template_name_validator'
24
25
  require 'txtextcontrol/reportingcloud/template_data_validator'
@@ -341,6 +342,82 @@ module TXTextControl
341
342
  end
342
343
  end
343
344
 
345
+ # Checks text for spelling errors.
346
+ # @param text [String] The text to spell check.
347
+ # @param language [String] The language that is used to spell check the
348
+ # specified text.
349
+ # @return [Array<IncorrectWord>] An array of incorrect words.
350
+ def check_text(text, language)
351
+ # Parameter validation
352
+ unless !text.nil? && !text.to_s.empty?
353
+ raise ArgumentError, "The given text must not be empty."
354
+ end
355
+ unless !language.nil? && !language.to_s.empty?
356
+ raise ArgumentError, "A language must be defined."
357
+ end
358
+
359
+ # Create query parameters
360
+ params = {
361
+ :text => text,
362
+ :language => language
363
+ }
364
+
365
+ res = request("/proofing/check", :get, params)
366
+ if res.kind_of? Net::HTTPSuccess
367
+ incorrect_words = Array.new
368
+ data = JSON.parse(res.body, object_class: OpenStruct)
369
+ data.each do |elem|
370
+ incorrect_words.push(IncorrectWord.from_camelized_hash(elem))
371
+ end
372
+ return incorrect_words
373
+ else
374
+ raise res.body
375
+ end
376
+ end
377
+
378
+ # Returns all available dictionary names.
379
+ # @return [Array<String>] Available dictionary names.
380
+ def get_available_dictionaries
381
+ res = request("/proofing/availabledictionaries", :get)
382
+ if res.kind_of? Net::HTTPSuccess
383
+ return JSON.parse(res.body)
384
+ else
385
+ raise res.body
386
+ end
387
+ end
388
+
389
+ # Returns suggestions for a misspelled word.
390
+ # @param word [String] The incorrect word that has to be determined for suggestions.
391
+ # @param language [String] The language that is used to spell check the specified text.
392
+ # @param max [Integer] The maximum number of suggestions that has to be determined.
393
+ # @return [Array<String>] Suggestions for a misspelled word.
394
+ def get_suggestions(word, language, max)
395
+ # Parameter validation
396
+ unless !word.nil? && !word.to_s.empty?
397
+ raise ArgumentError, "The given text must not be empty."
398
+ end
399
+ unless !language.nil? && !language.to_s.empty?
400
+ raise ArgumentError, "A language must be defined."
401
+ end
402
+ unless max.is_a? Integer
403
+ raise ArgumentError, "max must be an integer"
404
+ end
405
+
406
+ # Create query parameters
407
+ params = {
408
+ :word => word,
409
+ :language => language,
410
+ :max => max
411
+ }
412
+
413
+ res = request("/proofing/suggestions", :get, params)
414
+ if res.kind_of? Net::HTTPSuccess
415
+ return JSON.parse(res.body)
416
+ else
417
+ raise res.body
418
+ end
419
+ end
420
+
344
421
  # Performs a HTTP request of a given type.
345
422
  # @param request_type [Symbol] The type of the request. Possible values are +:get+,
346
423
  # +:post+ and +:delete+.
@@ -13,6 +13,6 @@
13
13
 
14
14
  module TXTextControl
15
15
  module ReportingCloud
16
- VERSION = "1.0.3"
16
+ VERSION = "1.1.1"
17
17
  end
18
18
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: txtextcontrol-reportingcloud
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thorsten Kummerow
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-03-31 00:00:00.000000000 Z
11
+ date: 2017-08-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -72,6 +72,7 @@ files:
72
72
  - lib/txtextcontrol/reportingcloud.rb
73
73
  - lib/txtextcontrol/reportingcloud/account_settings.rb
74
74
  - lib/txtextcontrol/reportingcloud/find_and_replace_body.rb
75
+ - lib/txtextcontrol/reportingcloud/incorrect_word.rb
75
76
  - lib/txtextcontrol/reportingcloud/merge_block.rb
76
77
  - lib/txtextcontrol/reportingcloud/merge_body.rb
77
78
  - lib/txtextcontrol/reportingcloud/merge_field.rb