art_typograph 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Readme.markdown +2 -3
- data/lib/art_typograph/request.rb +3 -4
- data/lib/art_typograph/version.rb +1 -1
- data/spec/request_spec.rb +1 -1
- metadata +1 -1
data/Readme.markdown
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Клиент для [веб-сервиса «Типографа»](http://www.artlebedev.ru/tools/typograf/webservice/)
|
1
|
+
Клиент для [веб-сервиса «Типографа»](http://www.artlebedev.ru/tools/typograf/webservice/) студии Лебедева, код частично позаимствован из [als_typograf](https://github.com/alsemyonov/als_typograf) и [art_typograf](https://github.com/stereobooster/art_typograf).
|
2
2
|
|
3
3
|
```ruby
|
4
4
|
ArtTypograph.process('- Это "Типограф"?')
|
@@ -15,8 +15,7 @@ ArtTypograph.process('- Это "Типограф"?', :use_p => false)
|
|
15
15
|
:entity_type => :no, # :html, :xml, :no, :mixed
|
16
16
|
:use_br => false,
|
17
17
|
:use_p => true,
|
18
|
-
:max_nobr => 3
|
19
|
-
:encoding => 'UTF-8'
|
18
|
+
:max_nobr => 3
|
20
19
|
}
|
21
20
|
```
|
22
21
|
|
@@ -14,8 +14,7 @@ module ArtTypograph
|
|
14
14
|
:entity_type => :no,
|
15
15
|
:use_br => false,
|
16
16
|
:use_p => true,
|
17
|
-
:max_nobr => 3
|
18
|
-
:encoding => 'UTF-8'
|
17
|
+
:max_nobr => 3
|
19
18
|
}
|
20
19
|
|
21
20
|
def initialize(options = {})
|
@@ -30,7 +29,7 @@ module ArtTypograph
|
|
30
29
|
'SOAPAction' => '"http://typograf.artlebedev.ru/webservices/ProcessText"'
|
31
30
|
})
|
32
31
|
request.body = <<-END_SOAP
|
33
|
-
<?xml version="1.0" encoding="
|
32
|
+
<?xml version="1.0" encoding="UTF-8" ?>
|
34
33
|
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
|
35
34
|
<soap:Body>
|
36
35
|
<ProcessText xmlns="http://typograf.artlebedev.ru/webservices/">
|
@@ -51,7 +50,7 @@ END_SOAP
|
|
51
50
|
case response
|
52
51
|
when Net::HTTPSuccess
|
53
52
|
result = if /<ProcessTextResult>\s*((.|\n)*?)\s*<\/ProcessTextResult>/m =~ response.body
|
54
|
-
$1.gsub(/>/, '>').gsub(/</, '<').gsub(/&/, '&').gsub(/(\t|\n)$/, '')
|
53
|
+
$1.gsub(/>/, '>').gsub(/</, '<').gsub(/&/, '&').gsub(/(\t|\n)$/, '').force_encoding("UTF-8").chomp
|
55
54
|
else
|
56
55
|
text
|
57
56
|
end
|
data/spec/request_spec.rb
CHANGED
@@ -17,7 +17,7 @@ describe ArtTypograph::Request do
|
|
17
17
|
subject { req.new(options) }
|
18
18
|
|
19
19
|
it 'merges default options' do
|
20
|
-
subject.options.should include(:use_br, :use_p, :entity_type, :
|
20
|
+
subject.options.should include(:use_br, :use_p, :entity_type, :max_nobr)
|
21
21
|
end
|
22
22
|
|
23
23
|
it 'processes options' do
|