zemanta_client 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/zemanta/configuration.rb +3 -2
- data/lib/zemanta/markup.rb +7 -2
- data/lib/zemanta/version.rb +1 -1
- data/spec/spec_helper.rb +2 -1
- data/spec/zemanta/markup_spec.rb +8 -1
- data/zemanta.gemspec +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a826891a23b929efc62b9d12cd6cf848cf131ad1
|
4
|
+
data.tar.gz: ddc9a237b1fba5ea489fff916cd3483b939f246c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5000915ce42368b89f0d8fc116af9fd627c7ce2a66285becf96f336fe7040e4b6a0288dfc056df01eb1ff59820700009faebee7119d74223f93cca44d8c84a6d
|
7
|
+
data.tar.gz: a60cfb2a04fe40db2f1ba655bef73453e220b067dfa6f4f6f4f13898cdea823d56881f9474f1aa01c14b486432b196f776515ce606c7a28c1f6eb00134818c21
|
@@ -1,6 +1,7 @@
|
|
1
1
|
module Zemanta
|
2
2
|
class Configuration
|
3
|
-
attr_accessor :custom_request_opts, :format, :api_key, :cache_storage
|
3
|
+
attr_accessor :custom_request_opts, :format, :api_key, :cache_storage,
|
4
|
+
:character_limit
|
4
5
|
|
5
6
|
def initialize
|
6
7
|
@custom_request_opts = {}
|
@@ -25,4 +26,4 @@ module Zemanta
|
|
25
26
|
@api_key || ENV["ZEMANTA_KEY"] or raise "You need to specify ZEMANTA_KEY in your environment or set api_key in your config"
|
26
27
|
end
|
27
28
|
end
|
28
|
-
end
|
29
|
+
end
|
data/lib/zemanta/markup.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
module Zemanta
|
2
|
+
|
2
3
|
class Markup
|
3
4
|
attr_reader :text, :links
|
4
5
|
|
@@ -26,11 +27,15 @@ module Zemanta
|
|
26
27
|
|
27
28
|
def self.suggest_markup_request(text, opts)
|
28
29
|
return {'links' => []} if text.to_s.empty?
|
29
|
-
request({ text: text, method: "zemanta.suggest_markup" }.merge(opts))["markup"]
|
30
|
+
request({ text: shortened_text(text), method: "zemanta.suggest_markup" }.merge(opts))["markup"]
|
30
31
|
end
|
31
32
|
|
32
33
|
def self.request(opts)
|
33
34
|
Fetcher.new(opts).post
|
34
35
|
end
|
36
|
+
|
37
|
+
def self.shortened_text(text)
|
38
|
+
text[0..Zemanta.config.character_limit-1]
|
39
|
+
end
|
35
40
|
end
|
36
|
-
end
|
41
|
+
end
|
data/lib/zemanta/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -3,7 +3,8 @@ require 'webmock/rspec'
|
|
3
3
|
require 'json'
|
4
4
|
|
5
5
|
Zemanta.configure do |c|
|
6
|
-
c.api_key
|
6
|
+
c.api_key = 'fake_key'
|
7
|
+
c.character_limit = 20000
|
7
8
|
end
|
8
9
|
# This file was generated by the `rspec --init` command. Conventionally, all
|
9
10
|
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
data/spec/zemanta/markup_spec.rb
CHANGED
@@ -34,6 +34,13 @@ describe Zemanta::Markup do
|
|
34
34
|
Zemanta::Markup.fetch("").should be_a Zemanta::Markup
|
35
35
|
end
|
36
36
|
|
37
|
+
it "truncated text that is over the characted limit" do
|
38
|
+
Zemanta.config.character_limit = 10
|
39
|
+
text = 'Text over 10 characters'
|
40
|
+
Zemanta::Fetcher.should_receive(:new).with(hash_including(text: text[0..9])).and_call_original
|
41
|
+
Zemanta::Markup.fetch(text)
|
42
|
+
end
|
43
|
+
|
37
44
|
it "does not hit fetcher if empty string passed" do
|
38
45
|
Zemanta::Fetcher.any_instance.should_not_receive(:post)
|
39
46
|
Zemanta::Markup.fetch("")
|
@@ -69,4 +76,4 @@ describe Zemanta::Markup do
|
|
69
76
|
end
|
70
77
|
end
|
71
78
|
end
|
72
|
-
end
|
79
|
+
end
|
data/zemanta.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zemanta_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Łukasz Strzebińczyk
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-06-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: typhoeus
|
@@ -42,16 +42,16 @@ dependencies:
|
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ~>
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
47
|
+
version: '2.0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ~>
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
54
|
+
version: '2.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: webmock
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|