typograf 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -68,6 +68,10 @@ You can pass second argument - hash of options.
68
68
  }
69
69
  ```
70
70
 
71
+ ## TODO
72
+ - support ruby 1.8 (`encode` missing)
73
+ - implement missing specs
74
+
71
75
  ## Contributing
72
76
 
73
77
  1. Fork it
@@ -52,28 +52,28 @@ module Typograf
52
52
  def form_xml(options)
53
53
  o = options
54
54
  xml = <<-XML_TEMPLATE
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>
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.dup.force_encoding("cp1251")
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.encode("utf-8").chomp
133
+ body.chomp
134
134
  end
135
135
  end
136
136
  end
@@ -1,3 +1,3 @@
1
1
  module Typograf
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -7,6 +7,10 @@ describe Typograf do
7
7
  Typograf.process("- Это \"Типограф\"?\n— Нет, это «Типограф»!").should eq "<p>&mdash;&nbsp;Это &laquo;Типограф&raquo;?<br />\n&mdash;&nbsp;Нет, это &laquo;Типограф&raquo;!</p>"
8
8
  end
9
9
 
10
+ it ".process support options" do
11
+ Typograf.process("- Это \"Типограф\"?\n— Нет, это «Типограф»!", :paragraph => {:insert => 0}).should eq "&mdash;&nbsp;Это &laquo;Типограф&raquo;?<br />\n&mdash;&nbsp;Нет, это &laquo;Типограф&raquo;!"
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.1
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-04 00:00:00.000000000 Z
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: -1019651219
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: -1019651219
88
+ hash: 77060353
89
89
  requirements: []
90
90
  rubyforge_project:
91
91
  rubygems_version: 1.8.24