after_the_deadline 0.1.2 → 0.1.3

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.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MTA4YzNlYmM1ZGE3MzE1YzQyZDM5YTA0NGViMWQxM2VkZmUyZDMwNQ==
4
+ ZDNiZWZlN2M3MTFmNzI3MmFiMGNiNjgzNWQwZjM1MmI0YmJmYzY4Mw==
5
5
  data.tar.gz: !binary |-
6
- YWQzZTQxMmIxODAxNzc0Mzc5ZGYxZGI5MTAyMGM2YjE0YWViOWVjMw==
6
+ ZjNmMDlmYjNmMWQ2MWFjZTc2YzRlNjA4NTdhZmVmYWRmODRjNzQ4Mw==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- OWNmZGJiMDlhMTYyZDA3OWQxNzlkYTQxZGIxM2Y0YWYzZjQ5NGQ0YWI0YzZm
10
- MmY3NmNjYmJlOGY1MDMzNzI5ZTRkMDNlMDU2ZDcyNzg4YmI0MWMwOWIyY2Nh
11
- OWQ2MDliOWVjN2Y5M2EwNzAzNjAwMjcwMzZhYzA5Mjk4Y2M1NmU=
9
+ MWRiYzAwNDQyYjI5Mzg3MDIyNjQyYWZkZWNkYjIxZmQ5YWFmMGZmMmY0NjQz
10
+ YTYzZjFiMzFjNzM5OGM3ZTI4N2YwNWRjOTQyODI2MGJjYTNiNDE5ZTY0YzYz
11
+ ODkzZWUwMjQ0NGIzMjkwYWM3ZDMwM2E1ZmUyNWY4MjVjZmI5YWU=
12
12
  data.tar.gz: !binary |-
13
- NjA1YWE3YTE5YzAzMTYxNGY3MDRmMGU4ZDA2NzA1NjhhMjExYTU4ZGQwOWU5
14
- NjcxMzkyN2Y2OTRjYTExNjM2YTYyYzMyYjc3NzJiOGE2NjgzZjU4M2QxZmRk
15
- YjFjYTE2MDc4MGI2NTc5ZGI3NjdlYmNjNmFkZjllNmUwOGU4ZGY=
13
+ ZTBlYmI4MmQ5ODk1ZjM1NDlmNGQ5ODU0ODkyZjcyZTVhOTRiMjQ1YjJiMWM5
14
+ ZmMyZWYyOWQ3ZjNkMzg4YTUzMzdlNGZhZDQ2YjA2MDRmMWFmMDk2OTJkOWM4
15
+ NmZjOWMxYTMzZTcwZmI5NjRhMDMyYzNkMWU1Y2Y2MjNlZjA1NDg=
data/README.md CHANGED
@@ -64,6 +64,20 @@ Or install it yourself as:
64
64
  AfterTheDeadline.check "My last name, Sepcot, is very unique."
65
65
  => []
66
66
 
67
+ ## Multilanguage
68
+
69
+ After the deadline service provides 5 languages:
70
+
71
+ * English (en, default)
72
+ * French (fr)
73
+ * German (de)
74
+ * Spanish (es)
75
+ * Portuguese (pt)
76
+
77
+ If no language is set English is choosen by default. To set another language simply set it:
78
+
79
+ AfterTheDeadline.set_language('de') # possible values en, fr, de, es, pt
80
+
67
81
  ## Contributing
68
82
 
69
83
  1. Fork it
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = 'after_the_deadline'
5
- spec.version = '0.1.2'
5
+ spec.version = '0.1.3'
6
6
  spec.authors = ['Michael J. Sepcot']
7
7
  spec.email = ['developer@sepcot.com']
8
8
  spec.description = %q{A ruby library for working with the After The Deadline service.}
@@ -9,12 +9,14 @@ def AfterTheDeadline(dictionary = nil, types = AfterTheDeadline::DEFAULT_IGNORE_
9
9
  end
10
10
 
11
11
  class AfterTheDeadline
12
+ BASE_URI = 'http://service.afterthedeadline.com'
13
+ DEFAULT_IGNORE_TYPES = ['Bias Language', 'Cliches', 'Complex Expression', 'Diacritical Marks', 'Double Negatives', 'Hidden Verbs', 'Jargon Language', 'Passive voice', 'Phrases to Avoid', 'Redundant Expression']
14
+ SUPPORTED_LANGUAGES = %w(en fr de es pt)
15
+
12
16
  @@custom_dictionary = []
13
17
  @@ignore_types = []
14
18
  @@api_key = nil
15
-
16
- BASE_URI = 'http://service.afterthedeadline.com'
17
- DEFAULT_IGNORE_TYPES = ['Bias Language', 'Cliches', 'Complex Expression', 'Diacritical Marks', 'Double Negatives', 'Hidden Verbs', 'Jargon Language', 'Passive voice', 'Phrases to Avoid', 'Redundant Expression']
19
+ @uri = BASE_URI
18
20
 
19
21
  class <<self
20
22
  def set_custom_dictionary(dict)
@@ -33,6 +35,17 @@ class AfterTheDeadline
33
35
  @@api_key = key
34
36
  end
35
37
 
38
+ def set_language(language)
39
+ language.downcase!
40
+ unless AfterTheDeadline::SUPPORTED_LANGUAGES.include? language
41
+ raise AfterTheDeadline::Exception.new ("Unsupported language #{language}. Supported languages are #{AfterTheDeadline::SUPPORTED_LANGUAGES}")
42
+ end
43
+
44
+ @uri = 'en'.eql?(language) ? BASE_URI : "http://#{language}.service.afterthedeadline.com"
45
+ # do not return anything (the assignation in this case)
46
+ nil
47
+ end
48
+
36
49
  # Invoke the checkDocument service with provided text.
37
50
  #
38
51
  # Returns list of AfterTheDeadline::Error objects.
@@ -68,7 +81,7 @@ class AfterTheDeadline
68
81
 
69
82
  def perform(action, params)
70
83
  params[:key] = @@api_key if @@api_key
71
- response = Net::HTTP.post_form URI.parse(BASE_URI + action), params
84
+ response = Net::HTTP.post_form URI.parse("#{@uri}#{action}"), params
72
85
  raise "Unexpected response code from AtD service: #{response.code} #{response.message}" unless response.is_a? Net::HTTPSuccess
73
86
  response.body
74
87
  end
@@ -132,3 +145,10 @@ class AfterTheDeadline::Metrics
132
145
  private
133
146
  attr_writer :spell, :grammar, :stats, :style
134
147
  end
148
+
149
+ class AfterTheDeadline::Exception < StandardError
150
+ def initialize(msg = "Something went wrong")
151
+ super
152
+ end
153
+ end
154
+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: after_the_deadline
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael J. Sepcot
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-16 00:00:00.000000000 Z
11
+ date: 2013-12-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler