google_tts2 0.0.3 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -3,11 +3,14 @@ source 'https://rubygems.org'
3
3
  gem 'rake'
4
4
 
5
5
  group :development do
6
+ gem 'pry'
6
7
  gem 'rspec'
7
8
  gem 'fuubar' # rspec style
8
-
9
9
  gem 'guard-rspec'
10
10
  gem 'spork', '~> 0.9'
11
11
  gem 'guard-spork', '~> 1.4'
12
12
  gem 'terminal-notifier-guard'
13
13
  end
14
+
15
+ gemspec
16
+
data/Gemfile.lock CHANGED
@@ -1,3 +1,9 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ google_tts2 (0.0.4)
5
+ nokogiri
6
+
1
7
  GEM
2
8
  remote: https://rubygems.org/
3
9
  specs:
@@ -30,6 +36,9 @@ GEM
30
36
  rb-kqueue (>= 0.2)
31
37
  lumberjack (1.0.4)
32
38
  method_source (0.8.2)
39
+ mini_portile (0.5.2)
40
+ nokogiri (1.6.1)
41
+ mini_portile (~> 0.5.0)
33
42
  pry (0.9.12.2)
34
43
  coderay (~> 1.0.5)
35
44
  method_source (~> 0.8)
@@ -60,8 +69,10 @@ PLATFORMS
60
69
 
61
70
  DEPENDENCIES
62
71
  fuubar
72
+ google_tts2!
63
73
  guard-rspec
64
74
  guard-spork (~> 1.4)
75
+ pry
65
76
  rake
66
77
  rspec
67
78
  spork (~> 0.9)
@@ -17,4 +17,5 @@ Gem::Specification.new do |gem|
17
17
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
18
  gem.require_paths = ["lib"]
19
19
  gem.add_development_dependency 'rspec'
20
+ gem.add_runtime_dependency 'nokogiri'
20
21
  end
@@ -27,7 +27,7 @@ module GoogleTts
27
27
  end
28
28
 
29
29
  def raise_error(response)
30
- raise "Error: response code #{response.code}"
30
+ raise "Error: response code #{response.code} #{response.body}"
31
31
  end
32
32
 
33
33
  end
@@ -0,0 +1,35 @@
1
+ require 'nokogiri'
2
+ require 'open-uri'
3
+
4
+ module GoogleTts
5
+
6
+ class ProxyFetcher
7
+ @@SOURCES = [
8
+ "http://www.xroxy.com/proxyrss.xml",
9
+ "http://www.freeproxylists.com/rss",
10
+ "http://www.proxz.com/proxylists.xml"
11
+ ]
12
+
13
+ def self.list
14
+ list = []
15
+ @@SOURCES.each do |url|
16
+ Nokogiri::XML(open url).xpath("//prx:proxy").each do |node|
17
+ proxy = { host: node.xpath("prx:ip").text,
18
+ port: node.xpath("prx:port").text,
19
+ type: node.xpath("prx:type").text,
20
+ ssl: node.xpath("prx:ssl").text.downcase == "true" }
21
+ list << proxy if (proxy[:type] == "Anonymous" and not proxy[:ssl])
22
+ end
23
+ end
24
+ list
25
+ end
26
+
27
+ def self.random_proxy
28
+ @@list.sample
29
+ end
30
+
31
+ @@list = list
32
+
33
+ end
34
+
35
+ end
data/lib/google_tts.rb CHANGED
@@ -2,9 +2,10 @@ require 'google_tts/connector'
2
2
  require 'google_tts/query_builder'
3
3
  require 'google_tts/parser'
4
4
  require 'google_tts/mp3writer'
5
+ require 'google_tts/proxy_fetcher'
5
6
 
6
7
  module GoogleTts
7
- VERSION = "0.0.3"
8
+ VERSION = "0.0.5"
8
9
 
9
10
  class Client
10
11
  include GoogleTts
@@ -36,4 +37,9 @@ module GoogleTts
36
37
  Client.new(Connector.new(connection), QueryBuilder.new(lang), Mp3Writer.new(output))
37
38
  end
38
39
 
40
+ def self.with_proxy(params = {})
41
+ params[:proxy] = ProxyFetcher.random_proxy
42
+ instantiate params
43
+ end
44
+
39
45
  end
@@ -0,0 +1,15 @@
1
+ # encoding: UTF-8
2
+ require 'spec_helper'
3
+ require 'uri'
4
+
5
+ describe GoogleTts::ProxyFetcher do
6
+
7
+ it 'get proxy sample' do
8
+ proxy = GoogleTts::ProxyFetcher.random_proxy
9
+ expect(proxy).to include(:host, :port)
10
+ expect(proxy[:ssl]).to be(false)
11
+ end
12
+
13
+ end
14
+
15
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google_tts2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -27,6 +27,22 @@ dependencies:
27
27
  - - ! '>='
28
28
  - !ruby/object:Gem::Version
29
29
  version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: nokogiri
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
30
46
  description: Google TTS client which accepts large text input, parses and split into
31
47
  multiple requests. Saves a single mp3 matching the input text.
32
48
  email:
@@ -42,16 +58,18 @@ files:
42
58
  - LICENSE
43
59
  - README.md
44
60
  - Rakefile
45
- - google_tts2.gempspec
61
+ - google_tts2.gemspec
46
62
  - lib/google_tts.rb
47
63
  - lib/google_tts/connector.rb
48
64
  - lib/google_tts/mp3writer.rb
49
65
  - lib/google_tts/parser.rb
66
+ - lib/google_tts/proxy_fetcher.rb
50
67
  - lib/google_tts/query_builder.rb
51
68
  - spec/fixtures/big_text.txt
52
69
  - spec/lib/google_tts/connector_spec.rb
53
70
  - spec/lib/google_tts/mp3writer_spec.rb
54
71
  - spec/lib/google_tts/parser_spec.rb
72
+ - spec/lib/google_tts/proxy_fetcher_spec.rb
55
73
  - spec/lib/google_tts/query_builder_spec.rb
56
74
  - spec/lib/google_tts_spec.rb
57
75
  - spec/spec_helper.rb
@@ -84,6 +102,7 @@ test_files:
84
102
  - spec/lib/google_tts/connector_spec.rb
85
103
  - spec/lib/google_tts/mp3writer_spec.rb
86
104
  - spec/lib/google_tts/parser_spec.rb
105
+ - spec/lib/google_tts/proxy_fetcher_spec.rb
87
106
  - spec/lib/google_tts/query_builder_spec.rb
88
107
  - spec/lib/google_tts_spec.rb
89
108
  - spec/spec_helper.rb