zemanta_client 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/README.md +44 -25
- data/lib/zemanta/version.rb +1 -1
- data/zemanta.gemspec +1 -1
- metadata +3 -3
data/README.md
CHANGED
@@ -19,48 +19,66 @@ Or install it yourself as:
|
|
19
19
|
## Api key
|
20
20
|
|
21
21
|
You need to set api_key to use the client. If you won't do that, gem will raise an error. There are 2 ways:
|
22
|
+
|
22
23
|
1. Environment variable
|
23
|
-
- Set ZEMANTA_KEY key in you environment variables and gem will use it
|
24
|
+
- Set `ZEMANTA_KEY` key in you environment variables and gem will use it
|
24
25
|
|
25
26
|
2. Configuration
|
26
27
|
- You can set your api_key in configuration block like this:
|
27
|
-
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
Zemanta.configure { |c| c.api_key = 'your_api_key' }
|
31
|
+
```
|
28
32
|
|
29
33
|
|
30
34
|
## Usage
|
31
35
|
|
32
|
-
|
36
|
+
Two use cases are implemented:
|
37
|
+
|
38
|
+
1. Retrieving suggest_markup data and enhancing the text.
|
33
39
|
|
34
|
-
|
40
|
+
```ruby
|
41
|
+
Zemanta::Markup.fetch(text, opts = {})
|
42
|
+
```
|
43
|
+
|
35
44
|
It will fetch suggest_markup data for passed text from Zemanta api and wrap it in custom classes.
|
36
45
|
|
37
|
-
|
46
|
+
|
47
|
+
2. Enhancing the text with links:
|
48
|
+
|
49
|
+
```ruby
|
50
|
+
Zemanta::Enhancer.new(text, opts = {}).enhance
|
51
|
+
```
|
52
|
+
|
38
53
|
It will fetch suggest_markup data for given text and for every returned link it will wrap the keyword with this link.
|
39
|
-
|
54
|
+
Then it will return the updated text.
|
40
55
|
|
41
|
-
|
56
|
+
In both relevance and confidence keys can be passes inside opts to filter any links that are below passed values.
|
42
57
|
|
43
58
|
## Configuration
|
44
59
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
+
There are several configuration options you can set:
|
61
|
+
|
62
|
+
```ruby
|
63
|
+
Zemanta.configure do |config|
|
64
|
+
# You can pass a hash of custom options that will be passed into each request. It's empty by default.
|
65
|
+
config.custom_request_opts = {}
|
66
|
+
|
67
|
+
# Zemanta supports various response formats. However, this client works only with json, so changing this would be rather bad idea.
|
68
|
+
config.format = "json"
|
69
|
+
|
70
|
+
# This client supports caching, details below. Default is no caching.
|
71
|
+
config.cache_store = Zemanta::Configuration::NullStorage
|
72
|
+
|
73
|
+
# You can pass api_key to zemanta, as described above.
|
74
|
+
config.api_key = "yourapikeyhere"
|
75
|
+
end
|
76
|
+
```
|
60
77
|
|
61
78
|
## Caching
|
62
|
-
|
63
|
-
|
79
|
+
|
80
|
+
By default there is no caching. You can pass any cache store to `config.cache_store` in configuration.
|
81
|
+
The only expectation is that it answers to `[]` and `[]=` methods. For example, you can pass ruby hash or `Cache::Disk.new`
|
64
82
|
object to use simple file system storage.
|
65
83
|
|
66
84
|
## Contributing
|
@@ -73,6 +91,7 @@ You need to set api_key to use the client. If you won't do that, gem will raise
|
|
73
91
|
|
74
92
|
## Changelog
|
75
93
|
|
94
|
+
0.0.4 - fixed yajl require in gemspec
|
76
95
|
0.0.3 - Added Enhancer class, used yajl for json parsing, changed external gem api.
|
77
96
|
0.0.2 - Got rid of autoloads.
|
78
|
-
0.0.1 - Initial release. Support for suggest_markup method and caching.
|
97
|
+
0.0.1 - Initial release. Support for suggest_markup method and caching.
|
data/lib/zemanta/version.rb
CHANGED
data/zemanta.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.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: 2013-06-
|
12
|
+
date: 2013-06-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: typhoeus
|
@@ -28,7 +28,7 @@ dependencies:
|
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: '0'
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
|
-
name: yajl
|
31
|
+
name: yajl-ruby
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
33
33
|
none: false
|
34
34
|
requirements:
|