auto_tagging 0.0.1 → 1.0.0

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.
@@ -1,6 +1,6 @@
1
1
  = AutoTagging
2
2
 
3
- A Ruby wrapper library for multiple auto tagging services such as Open Calais, Yahoo Content Analysis and Alchemy.
3
+ A Ruby wrapper library for multiple auto tagging services such as Alchemy, Delicious, Yahoo Content Analysis and Open Calais.
4
4
  Learn more about these services at:
5
5
 
6
6
  http://www.alchemyapi.com/
@@ -9,6 +9,8 @@ http://www.opencalais.com/
9
9
 
10
10
  http://developer.yahoo.com/contentanalysis/
11
11
 
12
+ https://delicious.com/developers
13
+
12
14
  Just by specifying a paragraph or an url , meaningful tags/keywords will return in form of an array
13
15
 
14
16
  == Examples :
@@ -34,16 +36,18 @@ or
34
36
  AutoTagging.services = [{:open_calais => "open_calais_api_key}]
35
37
  or
36
38
  AutoTagging.services = ["yahoo"]
39
+ or
40
+ AutoTagging.services = ["delicious"]
37
41
  or
38
42
  AutoTagging.services = [{:open_calais => "open_calais_api_key}, {:alchemy => "alchemy_api_key"}, "yahoo"]
39
43
 
40
44
  Note: The result will be the combination of the results return from these services calls but it will slow down the run time
41
45
 
42
- Then invoke
46
+ For PARAGRAPH , (Delicious service doesn't support this)
43
47
  AutoTagging.get_tags("Put content here")
44
48
 
45
- You can give url as parameter , please note that this feature only available for Yahoo Content Analysis service and Alchemy
46
- AutoTagging.get_tags({:url => "rubygems.org"})
49
+ For URL , (OpenCalais service doesn't support this)
50
+ AutoTagging.get_tags(url: "rubygems.org")
47
51
 
48
52
  == Contributing
49
53
 
@@ -3,9 +3,11 @@ require File.expand_path('../lib/auto_tagging/version', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |gem|
5
5
  gem.authors = ["Eastagile"]
6
- gem.email = ["@eastagile.com"]
7
- gem.description = %q{A Ruby wrapper library for multiple auto tagging services such as Open Calais, Yahoo, Alchemy.}
8
- gem.summary = %q{A Ruby wrapper library for multiple auto tagging services such as Open Calais, Yahoo, Alchemy.}
6
+ gem.email = ["admin@eastagile.com"]
7
+ gem.description = %q{A ruby wrapper library for all current top tags/keywords/terms extraction services , this version
8
+ supports Alchemy, Yahoo Content Analysis, Delicious V1 API and OpenCalais }
9
+ gem.summary = %q{Supports tags extraction for both text and url ,just simply call AutoTagging.get_tags(url: "http://google.com")
10
+ or AutoTagging.get_tags("Neque porro quisquam est qui dolorem ipsum quia dolor sit amet")}
9
11
  gem.homepage = "http://www.eastagile.com"
10
12
 
11
13
  gem.files = `git ls-files`.split($\)
@@ -1,6 +1,7 @@
1
1
  require "auto_tagging/open_calais"
2
2
  require "auto_tagging/alchemy"
3
3
  require "auto_tagging/yahoo"
4
+ require "auto_tagging/delicious"
4
5
  require "auto_tagging/error"
5
6
  require "auto_tagging/string_ext"
6
7
 
@@ -0,0 +1,45 @@
1
+ require 'net/http'
2
+ require 'auto_tagging/search_param'
3
+ require 'rexml/document'
4
+
5
+ module AutoTagging
6
+ class Delicious
7
+ USERNAME = 'auto_tagging_gem'
8
+ PASSWORD = 'notsecure'
9
+
10
+ API_HOST = 'api.del.icio.us'
11
+
12
+ def get_tags(opts)
13
+ AutoTagging::SearchParam.url_search?(opts) ? api_request(url(opts)) : []
14
+ end
15
+
16
+ def api_request(url)
17
+ wait_for_next_valid_request
18
+ http = Net::HTTP.new(API_HOST, 443)
19
+ http.use_ssl = true
20
+ http.start do |http|
21
+ req = Net::HTTP::Get.new("/v1/posts/suggest?url=#{url}", {"User-Agent" => "auto_tagging ruby gem"})
22
+ req.basic_auth(USERNAME, PASSWORD)
23
+ parse_response(http.request(req))
24
+ end
25
+ rescue SocketError => e
26
+ []
27
+ end
28
+
29
+ def parse_response(response)
30
+ xml = response.body
31
+
32
+ REXML::Document.new(xml).root.elements.map { |e| e.attributes['tag'] }
33
+ rescue
34
+ []
35
+ end
36
+
37
+ def wait_for_next_valid_request
38
+ sleep 1
39
+ end
40
+
41
+ def url(opts)
42
+ "#{URI.encode(AutoTagging::SearchParam.to_valid_url(opts[:url]))}"
43
+ end
44
+ end
45
+ end
@@ -1,3 +1,3 @@
1
1
  module AutoTagging
2
- VERSION = "0.0.1"
2
+ VERSION = "1.0.0"
3
3
  end
@@ -0,0 +1,31 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
+
3
+ describe "AutoTagging::Delicious" do
4
+ let(:main) { AutoTagging::Delicious.new }
5
+
6
+ context "valid options" do
7
+ context "with valid url" do
8
+ let(:url) { "www.facebook.com" }
9
+
10
+ it "should return an array" do
11
+ main.get_tags(url: url).should_not be_empty
12
+ end
13
+ end
14
+
15
+ context "with invalid url" do
16
+ let(:url) { "www.amustbeinvalidwebsitebb.com"}
17
+
18
+ it "should return an empty array" do
19
+ main.get_tags(url: url).should be_empty
20
+ end
21
+ end
22
+ end
23
+
24
+ context "invalid options" do
25
+ let(:opt) { "an invalid opt" }
26
+
27
+ it "should return an empty array" do
28
+ main.get_tags(opt).should be_empty
29
+ end
30
+ end
31
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: auto_tagging
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 1.0.0
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-03-21 00:00:00.000000000 Z
12
+ date: 2013-03-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -59,10 +59,11 @@ dependencies:
59
59
  - - ! '>='
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
- description: A Ruby wrapper library for multiple auto tagging services such as Open
63
- Calais, Yahoo, Alchemy.
62
+ description: ! "A ruby wrapper library for all current top tags/keywords/terms extraction
63
+ services , this version \n supports Alchemy, Yahoo Content
64
+ Analysis, Delicious V1 API and OpenCalais "
64
65
  email:
65
- - ! '@eastagile.com'
66
+ - admin@eastagile.com
66
67
  executables: []
67
68
  extensions: []
68
69
  extra_rdoc_files: []
@@ -79,6 +80,7 @@ files:
79
80
  - lib/auto_tagging.rb
80
81
  - lib/auto_tagging/alchemy.rb
81
82
  - lib/auto_tagging/config.rb
83
+ - lib/auto_tagging/delicious.rb
82
84
  - lib/auto_tagging/error.rb
83
85
  - lib/auto_tagging/open_calais.rb
84
86
  - lib/auto_tagging/search_param.rb
@@ -87,6 +89,7 @@ files:
87
89
  - lib/auto_tagging/yahoo.rb
88
90
  - spec/fixtures/content.yml
89
91
  - spec/lib/auto_tagging/alchemy_spec.rb
92
+ - spec/lib/auto_tagging/delicious_spec.rb
90
93
  - spec/lib/auto_tagging/open_calais_spec.rb
91
94
  - spec/lib/auto_tagging/search_param_spec.rb
92
95
  - spec/lib/auto_tagging/yahoo_spec.rb
@@ -113,14 +116,16 @@ required_rubygems_version: !ruby/object:Gem::Requirement
113
116
  version: '0'
114
117
  requirements: []
115
118
  rubyforge_project:
116
- rubygems_version: 1.8.24
119
+ rubygems_version: 1.8.25
117
120
  signing_key:
118
121
  specification_version: 3
119
- summary: A Ruby wrapper library for multiple auto tagging services such as Open Calais,
120
- Yahoo, Alchemy.
122
+ summary: ! 'Supports tags extraction for both text and url ,just simply call AutoTagging.get_tags(url:
123
+ "http://google.com") or AutoTagging.get_tags("Neque porro quisquam est qui dolorem
124
+ ipsum quia dolor sit amet")'
121
125
  test_files:
122
126
  - spec/fixtures/content.yml
123
127
  - spec/lib/auto_tagging/alchemy_spec.rb
128
+ - spec/lib/auto_tagging/delicious_spec.rb
124
129
  - spec/lib/auto_tagging/open_calais_spec.rb
125
130
  - spec/lib/auto_tagging/search_param_spec.rb
126
131
  - spec/lib/auto_tagging/yahoo_spec.rb