monkeyhelper-muddyit_fu 0.2.2 → 0.2.3

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.rdoc CHANGED
@@ -32,20 +32,26 @@ can be stored in a yml file, an example of which is provided below.
32
32
  access_token: "YOUR_ACCESS_TOKEN"
33
33
  access_token_secret: "YOUR_ACCESS_TOKEN_SECRET"
34
34
 
35
- == Retrieving a site
35
+ == Retrieving all sites
36
36
 
37
37
  require 'muddyit_fu'
38
38
  muddyit = Muddyit.new('muddyit.yml')
39
- muddyit.sites.each do |site|
39
+ muddyit.sites.find(:all).each do |site|
40
40
  puts "#{site.label} : #{site.token}"
41
41
  end
42
42
 
43
+ == Retrieving a single site
44
+
45
+ require 'muddyit_fu'
46
+ muddyit = Muddyit.new('muddyit.yml')
47
+ puts muddyit.sites.find('a0ret4').label
48
+
43
49
  == Categorisation request
44
50
 
45
51
  require 'muddyit_fu'
46
52
  muddyit = Muddyit.new('muddyit.yml')
47
53
  site = muddyit.sites.first
48
- site.pages.categorise({:identifier => 'http://news.bbc.co.uk/1/hi/uk_politics/8011321.stm'}, {:minium_confidence => 0.2})
54
+ site.pages.create({:identifier => 'http://news.bbc.co.uk/1/hi/uk_politics/8011321.stm'}, {:minium_confidence => 0.2})
49
55
 
50
56
  == View categorised pages
51
57
 
@@ -55,10 +61,10 @@ can be stored in a yml file, an example of which is provided below.
55
61
  :access_token => 'ccc',
56
62
  :access_token_secret => 'ddd')
57
63
  site = muddyit.sites.first
58
- site.pages.index do |page|
64
+ site.pages.find(:all) do |page|
59
65
  puts page.title
60
- page.results.each do |result|
61
- puts result.uri
66
+ page.entities.each do |entity|
67
+ puts entity.uri
62
68
  end
63
69
  end
64
70
 
@@ -66,7 +72,7 @@ can be stored in a yml file, an example of which is provided below.
66
72
 
67
73
  require 'muddyit_fu'
68
74
  muddyit = Muddyit.new('muddyit.yml')
69
- site = muddyit.sites.first
75
+ site = muddyit.sites.find(:all).first
70
76
  site.pages.find_by_entity('http://dbpedia.org/resource/Gordon_Brown') do |page|
71
77
  puts page.identifier
72
78
  end
@@ -75,8 +81,8 @@ can be stored in a yml file, an example of which is provided below.
75
81
 
76
82
  require 'muddyit_fu'
77
83
  muddyit = Muddyit.new('muddyit.yml')
78
- site = muddyit.sites.first
79
- site.entities.related('http://dbpedia.org/resource/Gordon_Brown').each do |entity|
84
+ site = muddyit.sites.find(:all).first
85
+ site.entities.find_related('http://dbpedia.org/resource/Gordon_Brown').each do |entity|
80
86
  puts "#{entity.uri} : #{entity.confidence}"
81
87
  end
82
88
 
@@ -84,20 +90,19 @@ can be stored in a yml file, an example of which is provided below.
84
90
 
85
91
  require 'muddyit_fu'
86
92
  muddyit = Muddyit.new('muddyit.yml')
87
- site = muddyit.sites.first
88
- page = site.pages.find('http://news.bbc.co.uk/1/hi/uk_politics/7878418.stm')
93
+ site = muddyit.sites.find(:all).first
94
+ page = site.pages.find(:all, :uri => 'http://news.bbc.co.uk/1/hi/uk_politics/7878418.stm').first
89
95
  puts "Our page : #{page.title}\n\n"
90
96
  page.related_content.each do |results|
91
97
  puts "#{results[:page].title} #{results[:count]}"
92
98
  end
93
99
 
94
- == Authorising clients using irb
100
+ == Obtaining oauth access credentials
95
101
 
96
- See http://gist.github.com/178993 for details on how to obtain access credentials.
102
+ See http://gist.github.com/178993
97
103
 
98
104
  == Contact
99
105
 
100
106
  Author: Rob Lee
101
107
  Email: robl [at] monkeyhelper.com
102
108
  Main Repository: http://github.com/monkeyhelper/muddyit_fu/tree/master
103
-
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.2
1
+ 0.2.3
@@ -14,7 +14,7 @@ class Muddyit::Sites::Site::Entities::Entity < Muddyit::Generic
14
14
  # * options (Optional)
15
15
  #
16
16
  def related(options = {})
17
- api_url = "/sites/#{self.site.attributes[:token]}/entities/#{Digest::MD5.hexdigest(URI.encode(@attributes[:uri]))}/related"
17
+ api_url = "/sites/#{self.site.attributes[:token]}/entities/#{Digest::MD5.hexdigest(@attributes[:uri])}/related"
18
18
  response = @muddyit.send_request(api_url, :get, options)
19
19
 
20
20
  results = []
@@ -27,7 +27,7 @@ class Muddyit::Sites::Site::Entities::Entity < Muddyit::Generic
27
27
 
28
28
  protected
29
29
  def fetch
30
- api_url = "/sites/#{@attributes[:site][:token]}/entities/#{Digest::MD5.hexdigest(URI.encode(@attributes[:uri]))}"
30
+ api_url = "/sites/#{@attributes[:site][:token]}/entities/#{Digest::MD5.hexdigest(@attributes[:uri])}"
31
31
  response = @muddyit.send_request(api_url, :get)
32
32
  response.nested_symbolize_keys!
33
33
  end
@@ -1,4 +1,4 @@
1
- class Muddyit::Sites::Site::Entities
1
+ class Muddyit::Sites::Site::Entities < Muddyit::Generic
2
2
  # Placeholder
3
3
 
4
4
  # retrieve entities related to the specified entity within the site entities collection
@@ -6,9 +6,10 @@ class Muddyit::Sites::Site::Entities
6
6
  # Params
7
7
  # * options (Optional)
8
8
  #
9
- def related(uri, options = {})
9
+ def find_related(uri, options = {})
10
+
10
11
  raise if uri.nil?
11
- api_url = "/sites/#{self.site.attributes[:token]}/entities/#{Digest::MD5.hexdigest(URI.encode(uri))}/related"
12
+ api_url = "/sites/#{self.site.attributes[:token]}/entities/#{Digest::MD5.hexdigest(uri)}/related"
12
13
  response = @muddyit.send_request(api_url, :get, options)
13
14
 
14
15
  results = []
@@ -125,7 +125,7 @@ class Muddyit::Sites::Site::Pages < Muddyit::Generic
125
125
  # must contain uri parameter which corresponds to dbpedia uri
126
126
  #
127
127
  def queryAllWithURI(uri, options, &block)
128
- api_url = "/sites/#{self.site.attributes[:token]}/entities/#{Digest::MD5.hexdigest(URI.encode(uri))}"
128
+ api_url = "/sites/#{self.site.attributes[:token]}/entities/#{Digest::MD5.hexdigest(uri)}"
129
129
  query_page(api_url, options, &block)
130
130
  end
131
131
 
@@ -138,7 +138,7 @@ class Muddyit::Sites::Site::Pages < Muddyit::Generic
138
138
  #
139
139
  #
140
140
  def queryAllWithTerm(term, options, &block)
141
- api_url = "/sites/#{self.site.attributes[:token]}/terms/#{URI.escape(CGI.escape(term),'.')}"
141
+ api_url = "/sites/#{self.site.attributes[:token]}/terms/#{term}"
142
142
  query_page(api_url, options, &block)
143
143
  end
144
144
 
@@ -3,6 +3,7 @@ class Muddyit::Sites::Site < Muddyit::Generic
3
3
  # get pages object for site
4
4
  #
5
5
  def pages() @pages ||= Muddyit::Sites::Site::Pages.new(@muddyit, :site => self) end
6
+ def entities() @entities ||= Muddyit::Sites::Site::Entities.new(@muddyit, :site => self) end
6
7
 
7
8
  protected
8
9
  def fetch
data/muddyit_fu.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{muddyit_fu}
5
- s.version = "0.2.2"
5
+ s.version = "0.2.3"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["robl"]
9
- s.date = %q{2009-09-10}
9
+ s.date = %q{2009-09-23}
10
10
  s.email = %q{robl[at]monkeyhelper.com}
11
11
  s.extra_rdoc_files = [
12
12
  "LICENSE",
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: monkeyhelper-muddyit_fu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - robl
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-09-10 00:00:00 -07:00
12
+ date: 2009-09-23 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency