typograf 0.0.3 → 0.0.4

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/.gitignore CHANGED
@@ -1,17 +1,17 @@
1
- *.gem
2
- *.rbc
3
- .bundle
4
- .config
5
- .yardoc
6
- Gemfile.lock
7
- InstalledFiles
8
- _yardoc
9
- coverage
10
- doc/
11
- lib/bundler/man
12
- pkg
13
- rdoc
14
- spec/reports
15
- test/tmp
16
- test/version_tmp
17
- tmp
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in typograf.gemspec
4
- gemspec
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in typograf.gemspec
4
+ gemspec
data/LICENSE.txt CHANGED
@@ -1,22 +1,22 @@
1
- Copyright (c) 2012 Stereobooster
2
-
3
- MIT License
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining
6
- a copy of this software and associated documentation files (the
7
- "Software"), to deal in the Software without restriction, including
8
- without limitation the rights to use, copy, modify, merge, publish,
9
- distribute, sublicense, and/or sell copies of the Software, and to
10
- permit persons to whom the Software is furnished to do so, subject to
11
- the following conditions:
12
-
13
- The above copyright notice and this permission notice shall be
14
- included in all copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
1
+ Copyright (c) 2012 Stereobooster
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
22
  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,81 +1,82 @@
1
- # Typograf
2
-
3
- Universal tool for preparing russian text for web publishing. Ruby wrapper for typograf.ru webservice
4
-
5
- ## Installation
6
-
7
- Add this line to your application's Gemfile:
8
-
9
- gem 'typograf'
10
-
11
- And then execute:
12
-
13
- $ bundle
14
-
15
- Or install it yourself as:
16
-
17
- $ gem install typograf
18
-
19
- ## Usage
20
-
21
- ```ruby
22
- require "typograf"
23
-
24
- Typograf.process('text')
25
- ```
26
-
27
- You can pass second argument - hash of options.
28
-
29
- ### Default options
30
-
31
- ```ruby
32
- {
33
- :tags => 1, # 0 — не расставлять; 1 — расставлять
34
- :tags_delete => 0, # 0 — не удалять; 1 — удалять до типографирования; 2 — удалять после типографирования
35
- :paragraph => {
36
- :insert => 1, # 1 — ставить; 0 — не ставить
37
- # теги задают внешний вид обрамления параграфа, начальные и конечные теги соответственно (могут быть пустыми)
38
- :start => '<p>',
39
- :end => '</p>'
40
- },
41
- :newline => {
42
- :tag => '<br/>', # теги перевода строки.
43
- :insert => 1 # перевод строки: 1 — ставить; 0 — не ставить
44
- },
45
- :cms_new_line => 0, # Переводы строк <p>&nbsp;</p>
46
- :dos_text => 0, # удаляет одинарные переводы строк и переносы: 0 — не удалять; 1 — удалять
47
- :nowraped => {
48
- :insert => 1, # 1 — ставить; 0 — не ставить
49
- :nonbsp => 0, # 0 — не использовать неразрывные конструкции вместо (неразрывного пробела); 1 — наоборот
50
- :length => 0, # не объединять в неразрывные конструкции слова, написанные через дефис, с общей длинной больше N знаков. Если 0 то не используется
51
- :start => '<nobr>',
52
- :end => '</nobr>'
53
- },
54
- :hanging_punct => 0, # висячая пунктуация: 1 — использовать; 0 — не использовать
55
- :hanging_line => 0, # висячие строки: 1 — удалять; 0 — не удалять
56
- :minus_sign => '&ndash;', # указывает какой символ использовать вместо знака минус: — &ndash; или &minus;
57
- :hyphen => {
58
- :insert => 0,
59
- :length => 0
60
- },
61
- :acronym => 1, # выделять сокращения: 1 — выделять; 0 — не выделять
62
- :symbols => 0, # как выводить типографированный текст: 0 — буквенными символами (&nbsp;); 1 — числовыми (&#160;); 2 - просто символами
63
- # добавляет дополнительные атрибуты к ссылкам
64
- :link => {
65
- :target => '',
66
- :class => ''
67
- }
68
- }
69
- ```
70
-
71
- ## TODO
72
- - support ruby 1.8 (`encode` missing)
73
- - implement missing specs
74
-
75
- ## Contributing
76
-
77
- 1. Fork it
78
- 2. Create your feature branch (`git checkout -b my-new-feature`)
79
- 3. Commit your changes (`git commit -am 'Add some feature'`)
80
- 4. Push to the branch (`git push origin my-new-feature`)
81
- 5. Create new Pull Request
1
+ # Typograf
2
+
3
+ Universal tool for preparing russian text for web publishing. Ruby wrapper for typograf.ru webservice
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'typograf'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install typograf
18
+
19
+ ## Usage
20
+
21
+ ```ruby
22
+ require "typograf"
23
+
24
+ Typograf.process('text')
25
+ ```
26
+
27
+ You can pass second argument - hash of options.
28
+
29
+ ### Default options
30
+
31
+ ```ruby
32
+ {
33
+ :tags => 1, # 0 — не расставлять; 1 — расставлять
34
+ :tags_delete => 0, # 0 — не удалять; 1 — удалять до типографирования; 2 — удалять после типографирования
35
+ :paragraph => {
36
+ :insert => 1, # 1 — ставить; 0 — не ставить
37
+ # теги задают внешний вид обрамления параграфа, начальные и конечные теги соответственно (могут быть пустыми)
38
+ :start => '<p>',
39
+ :end => '</p>'
40
+ },
41
+ :newline => {
42
+ :tag => '<br/>', # теги перевода строки.
43
+ :insert => 1 # перевод строки: 1 — ставить; 0 — не ставить
44
+ },
45
+ :cms_new_line => 0, # Переводы строк <p>&nbsp;</p>
46
+ :dos_text => 0, # удаляет одинарные переводы строк и переносы: 0 — не удалять; 1 — удалять
47
+ :nowraped => {
48
+ :insert => 1, # 1 — ставить; 0 — не ставить
49
+ :nonbsp => 0, # 0 — не использовать неразрывные конструкции вместо (неразрывного пробела); 1 — наоборот
50
+ :length => 0, # не объединять в неразрывные конструкции слова, написанные через дефис, с общей длинной больше N знаков. Если 0 то не используется
51
+ :start => '<nobr>',
52
+ :end => '</nobr>'
53
+ },
54
+ :hanging_punct => 0, # висячая пунктуация: 1 — использовать; 0 — не использовать
55
+ :hanging_line => 0, # висячие строки: 1 — удалять; 0 — не удалять
56
+ :minus_sign => '&ndash;', # указывает какой символ использовать вместо знака минус: — &ndash; или &minus;
57
+ :hyphen => {
58
+ :insert => 0,
59
+ :length => 0
60
+ },
61
+ :acronym => 1, # выделять сокращения: 1 — выделять; 0 — не выделять
62
+ :symbols => 0, # как выводить типографированный текст: 0 — буквенными символами (&nbsp;); 1 — числовыми (&#160;); 2 - просто символами
63
+ # добавляет дополнительные атрибуты к ссылкам
64
+ :link => {
65
+ :target => '',
66
+ :class => ''
67
+ }
68
+ }
69
+ ```
70
+
71
+ ## TODO
72
+ - refactor options (do not use nested options; use symbols instead of "magic" numbers)
73
+ - support ruby 1.8 (`encode` missing)
74
+ - implement missing specs
75
+
76
+ ## Contributing
77
+
78
+ 1. Fork it
79
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
80
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
81
+ 4. Push to the branch (`git push origin my-new-feature`)
82
+ 5. Create new Pull Request
data/Rakefile CHANGED
@@ -1,7 +1,7 @@
1
- require "bundler/gem_tasks"
2
-
3
- require 'rspec/core/rake_task'
4
- desc "Run all examples"
5
- RSpec::Core::RakeTask.new(:spec)
6
-
7
- task :default => :spec
1
+ require "bundler/gem_tasks"
2
+
3
+ require 'rspec/core/rake_task'
4
+ desc "Run all examples"
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ task :default => :spec
data/lib/typograf.rb CHANGED
@@ -1,8 +1,8 @@
1
- require "typograf/version"
2
- require "typograf/client"
3
-
4
- module Typograf
5
- def self.process(text, options = {})
6
- Client.new(options).send_request(text)
7
- end
8
- end
1
+ require "typograf/version"
2
+ require "typograf/client"
3
+
4
+ module Typograf
5
+ def self.process(text, options = {})
6
+ Client.new(options).send_request(text)
7
+ end
8
+ end
@@ -120,9 +120,8 @@ module Typograf
120
120
  'text' => text.encode("cp1251"),
121
121
  }
122
122
  params['xml'] = @xml if @xml
123
- # params['chr'] = @chr if @chr
124
- params = URI.encode_www_form params
125
- request = Net::HTTP::Post.new(@url.path + '?' + params)
123
+ request = Net::HTTP::Post.new(@url.path)
124
+ request.set_form_data(params)
126
125
 
127
126
  begin
128
127
  response = Net::HTTP.new(@url.host, @url.port).start do |http|
@@ -1,3 +1,3 @@
1
- module Typograf
2
- VERSION = "0.0.3"
3
- end
1
+ module Typograf
2
+ VERSION = "0.0.4"
3
+ end
@@ -19,20 +19,11 @@ describe Typograf do
19
19
  lambda {Typograf.process("Тест", :url => 'http://www.typograf.ru/404')}.should raise_error Typograf::NetworkError
20
20
  end
21
21
 
22
- it "should raise host not found error" do
23
- lambda {Typograf.process("Тест", :url => 'http://www')}.should raise_error Typograf::NetworkError
24
- end
25
-
26
22
  # TODO: mock server for offline testing, for detecting service change
27
23
  # TODO: test every option
28
24
  end
29
25
 
30
26
  describe Typograf::Client do
31
- it ".deep_merge" do
32
- pending "TODO"
33
- end
34
-
35
- it ".form_xml" do
36
- pending "TODO"
37
- end
27
+ it ".deep_merge"
28
+ it ".form_xml"
38
29
  end
data/typograf.gemspec CHANGED
@@ -1,25 +1,25 @@
1
- # -*- encoding: utf-8 -*-
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'typograf/version'
5
-
6
- Gem::Specification.new do |gem|
7
- gem.name = "typograf"
8
- gem.version = Typograf::VERSION
9
- gem.authors = ["stereobooster"]
10
- gem.email = ["stereobooster@gmail.com"]
11
- gem.description = %q{Universal tool for preparing russian text for web publishing. Ruby wrapper for typograf.ru webservice}
12
- gem.summary = %q{Universal tool for preparing russian text for web publishing}
13
- gem.homepage = "https://github.com/stereobooster/typograf"
14
- gem.license = "MIT"
15
-
16
- gem.files = `git ls-files`.split($/)
17
- gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
18
- gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
19
- gem.require_paths = ["lib"]
20
-
21
- gem.add_dependency "htmlentities"
22
-
23
- gem.add_development_dependency "rake"
24
- gem.add_development_dependency "rspec"
25
- end
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'typograf/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "typograf"
8
+ gem.version = Typograf::VERSION
9
+ gem.authors = ["stereobooster"]
10
+ gem.email = ["stereobooster@gmail.com"]
11
+ gem.description = %q{Universal tool for preparing russian text for web publishing. Ruby wrapper for typograf.ru webservice}
12
+ gem.summary = %q{Universal tool for preparing russian text for web publishing}
13
+ gem.homepage = "https://github.com/stereobooster/typograf"
14
+ gem.license = "MIT"
15
+
16
+ gem.files = `git ls-files`.split($/)
17
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
18
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
19
+ gem.require_paths = ["lib"]
20
+
21
+ gem.add_dependency "htmlentities"
22
+
23
+ gem.add_development_dependency "rake"
24
+ gem.add_development_dependency "rspec"
25
+ 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.3
4
+ version: 0.0.4
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-06 00:00:00.000000000 Z
12
+ date: 2012-12-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: htmlentities
@@ -92,7 +92,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
92
92
  version: '0'
93
93
  segments:
94
94
  - 0
95
- hash: 256397741
95
+ hash: 660226351
96
96
  required_rubygems_version: !ruby/object:Gem::Requirement
97
97
  none: false
98
98
  requirements:
@@ -101,7 +101,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
101
101
  version: '0'
102
102
  segments:
103
103
  - 0
104
- hash: 256397741
104
+ hash: 660226351
105
105
  requirements: []
106
106
  rubyforge_project:
107
107
  rubygems_version: 1.8.24