typograf 0.0.1 → 0.0.2
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.
- data/README.md +4 -0
 - data/lib/typograf/client.rb +24 -24
 - data/lib/typograf/version.rb +1 -1
 - data/spec/typograf_spec.rb +4 -0
 - metadata +4 -4
 
    
        data/README.md
    CHANGED
    
    
    
        data/lib/typograf/client.rb
    CHANGED
    
    | 
         @@ -52,28 +52,28 @@ module Typograf 
     | 
|
| 
       52 
52 
     | 
    
         
             
                def form_xml(options)
         
     | 
| 
       53 
53 
     | 
    
         
             
                  o = options
         
     | 
| 
       54 
54 
     | 
    
         
             
                  xml = <<-XML_TEMPLATE
         
     | 
| 
       55 
     | 
    
         
            -
             
     | 
| 
       56 
     | 
    
         
            -
             
     | 
| 
       57 
     | 
    
         
            -
             
     | 
| 
       58 
     | 
    
         
            -
             
     | 
| 
       59 
     | 
    
         
            -
             
     | 
| 
       60 
     | 
    
         
            -
             
     | 
| 
       61 
     | 
    
         
            -
             
     | 
| 
       62 
     | 
    
         
            -
             
     | 
| 
       63 
     | 
    
         
            -
             
     | 
| 
       64 
     | 
    
         
            -
             
     | 
| 
       65 
     | 
    
         
            -
             
     | 
| 
       66 
     | 
    
         
            -
             
     | 
| 
       67 
     | 
    
         
            -
             
     | 
| 
       68 
     | 
    
         
            -
             
     | 
| 
       69 
     | 
    
         
            -
             
     | 
| 
       70 
     | 
    
         
            -
             
     | 
| 
       71 
     | 
    
         
            -
             
     | 
| 
       72 
     | 
    
         
            -
             
     | 
| 
       73 
     | 
    
         
            -
             
     | 
| 
       74 
     | 
    
         
            -
             
     | 
| 
       75 
     | 
    
         
            -
             
     | 
| 
       76 
     | 
    
         
            -
             
     | 
| 
      
 55 
     | 
    
         
            +
            <?xml version="1.0" encoding="windows-1251" ?>
         
     | 
| 
      
 56 
     | 
    
         
            +
            <preferences>
         
     | 
| 
      
 57 
     | 
    
         
            +
              <tags delete="#{o[:tags_delete]}">#{o[:tags]}</tags>
         
     | 
| 
      
 58 
     | 
    
         
            +
              <paragraph insert="#{o[:paragraph][:insert]}">
         
     | 
| 
      
 59 
     | 
    
         
            +
                <start><![CDATA[#{o[:paragraph][:start]}]]></start>
         
     | 
| 
      
 60 
     | 
    
         
            +
                <end><![CDATA[#{o[:paragraph][:end]}]]></end>
         
     | 
| 
      
 61 
     | 
    
         
            +
              </paragraph>
         
     | 
| 
      
 62 
     | 
    
         
            +
              <newline insert="#{o[:newline][:insert]}"><![CDATA[#{o[:newline][:tag]}]]></newline>
         
     | 
| 
      
 63 
     | 
    
         
            +
              <cmsNewLine valid="#{o[:cms_new_line]}" />
         
     | 
| 
      
 64 
     | 
    
         
            +
              <dos-text delete="#{o[:dos_text]}" />
         
     | 
| 
      
 65 
     | 
    
         
            +
              <nowraped insert="#{o[:nowraped][:insert]}" nonbsp="#{o[:nowraped][:nobsp]}" length="#{o[:nowraped][:length]}">
         
     | 
| 
      
 66 
     | 
    
         
            +
                <start><![CDATA[#{o[:nowraped][:start]}]]></start>
         
     | 
| 
      
 67 
     | 
    
         
            +
                <end><![CDATA[#{o[:nowraped][:end]}]]></end>
         
     | 
| 
      
 68 
     | 
    
         
            +
              </nowraped>
         
     | 
| 
      
 69 
     | 
    
         
            +
              <hanging-punct insert="#{o[:hanging_punct]}" />
         
     | 
| 
      
 70 
     | 
    
         
            +
              <hanging-line delete="#{o[:hanging_line]}" />
         
     | 
| 
      
 71 
     | 
    
         
            +
              <minus-sign><![CDATA[#{o[:minus_sign]}]]></minus-sign>
         
     | 
| 
      
 72 
     | 
    
         
            +
              <hyphen insert="#{o[:hyphen][:insert]}" length="#{o[:hyphen][:length]}" />
         
     | 
| 
      
 73 
     | 
    
         
            +
              <acronym insert="#{o[:acronym]}"></acronym>
         
     | 
| 
      
 74 
     | 
    
         
            +
              <symbols type="#{o[:symbols]}" />
         
     | 
| 
      
 75 
     | 
    
         
            +
              <link target="#{o[:link][:target]}" class="#{o[:link][:class]}" />
         
     | 
| 
      
 76 
     | 
    
         
            +
            </preferences>
         
     | 
| 
       77 
77 
     | 
    
         
             
                  XML_TEMPLATE
         
     | 
| 
       78 
78 
     | 
    
         
             
                  xml.gsub(/^\s|\s$/, '')
         
     | 
| 
       79 
79 
     | 
    
         
             
                end
         
     | 
| 
         @@ -122,7 +122,7 @@ module Typograf 
     | 
|
| 
       122 
122 
     | 
    
         
             
                    raise NetworkError, "#{response.code}: #{response.message}"
         
     | 
| 
       123 
123 
     | 
    
         
             
                  end
         
     | 
| 
       124 
124 
     | 
    
         | 
| 
       125 
     | 
    
         
            -
                  body = response.body. 
     | 
| 
      
 125 
     | 
    
         
            +
                  body = response.body.force_encoding("cp1251").encode("utf-8")
         
     | 
| 
       126 
126 
     | 
    
         | 
| 
       127 
127 
     | 
    
         
             
                  # error = "\xCE\xF8\xE8\xE1\xEA\xE0: \xE2\xFB \xE7\xE0\xE1\xFB\xEB\xE8 \xEF\xE5\xF0\xE5\xE4\xE0\xF2\xFC \xF2\xE5\xEA\xF1\xF2"
         
     | 
| 
       128 
128 
     | 
    
         
             
                  # error.force_encoding("ASCII-8BIT") if error.respond_to?(:force_encoding)
         
     | 
| 
         @@ -130,7 +130,7 @@ module Typograf 
     | 
|
| 
       130 
130 
     | 
    
         
             
                    raise NetworkError, "Ошибка: вы забыли передать текст"
         
     | 
| 
       131 
131 
     | 
    
         
             
                  end
         
     | 
| 
       132 
132 
     | 
    
         | 
| 
       133 
     | 
    
         
            -
                  body. 
     | 
| 
      
 133 
     | 
    
         
            +
                  body.chomp
         
     | 
| 
       134 
134 
     | 
    
         
             
                end
         
     | 
| 
       135 
135 
     | 
    
         
             
              end
         
     | 
| 
       136 
136 
     | 
    
         
             
            end
         
     | 
    
        data/lib/typograf/version.rb
    CHANGED
    
    
    
        data/spec/typograf_spec.rb
    CHANGED
    
    | 
         @@ -7,6 +7,10 @@ describe Typograf do 
     | 
|
| 
       7 
7 
     | 
    
         
             
                Typograf.process("- Это \"Типограф\"?\n— Нет, это «Типограф»!").should eq "<p>— Это «Типограф»?<br />\n— Нет, это «Типограф»!</p>"
         
     | 
| 
       8 
8 
     | 
    
         
             
              end
         
     | 
| 
       9 
9 
     | 
    
         | 
| 
      
 10 
     | 
    
         
            +
              it ".process support options" do
         
     | 
| 
      
 11 
     | 
    
         
            +
                Typograf.process("- Это \"Типограф\"?\n— Нет, это «Типограф»!", :paragraph => {:insert => 0}).should eq "— Это «Типограф»?<br />\n— Нет, это «Типограф»!"
         
     | 
| 
      
 12 
     | 
    
         
            +
              end
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
       10 
14 
     | 
    
         
             
              it "should raise 404 error" do
         
     | 
| 
       11 
15 
     | 
    
         
             
                lambda {Typograf.process("Тест", :url => 'http://www.typograf.ru/404')}.should raise_error Typograf::NetworkError
         
     | 
| 
       12 
16 
     | 
    
         
             
              end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: typograf
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.0.2
         
     | 
| 
       5 
5 
     | 
    
         
             
              prerelease: 
         
     | 
| 
       6 
6 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       7 
7 
     | 
    
         
             
            authors:
         
     | 
| 
         @@ -9,7 +9,7 @@ authors: 
     | 
|
| 
       9 
9 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       10 
10 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       11 
11 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       12 
     | 
    
         
            -
            date: 2012-12- 
     | 
| 
      
 12 
     | 
    
         
            +
            date: 2012-12-06 00:00:00.000000000 Z
         
     | 
| 
       13 
13 
     | 
    
         
             
            dependencies:
         
     | 
| 
       14 
14 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       15 
15 
     | 
    
         
             
              name: rake
         
     | 
| 
         @@ -76,7 +76,7 @@ required_ruby_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       76 
76 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       77 
77 
     | 
    
         
             
                  segments:
         
     | 
| 
       78 
78 
     | 
    
         
             
                  - 0
         
     | 
| 
       79 
     | 
    
         
            -
                  hash:  
     | 
| 
      
 79 
     | 
    
         
            +
                  hash: 77060353
         
     | 
| 
       80 
80 
     | 
    
         
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
       81 
81 
     | 
    
         
             
              none: false
         
     | 
| 
       82 
82 
     | 
    
         
             
              requirements:
         
     | 
| 
         @@ -85,7 +85,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       85 
85 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       86 
86 
     | 
    
         
             
                  segments:
         
     | 
| 
       87 
87 
     | 
    
         
             
                  - 0
         
     | 
| 
       88 
     | 
    
         
            -
                  hash:  
     | 
| 
      
 88 
     | 
    
         
            +
                  hash: 77060353
         
     | 
| 
       89 
89 
     | 
    
         
             
            requirements: []
         
     | 
| 
       90 
90 
     | 
    
         
             
            rubyforge_project: 
         
     | 
| 
       91 
91 
     | 
    
         
             
            rubygems_version: 1.8.24
         
     |