evri 0.03 → 0.04

Sign up to get free protection for your applications and to get access to all the features.
data/README.txt CHANGED
@@ -6,17 +6,16 @@
6
6
 
7
7
  A beautiful API that wraps the RESTful services provided by evri.com.
8
8
 
9
- == FEATURES/PROBLEMS:
10
-
11
- None yet.
12
-
13
9
  == SYNOPSIS:
14
10
 
15
- None yet.
11
+ obama = Evri::Entity.search("Barack Obama").first
12
+ obama.relationships
13
+ obama.images
14
+ obama.articles
16
15
 
17
16
  == REQUIREMENTS:
18
17
 
19
- none yet.
18
+ json
20
19
 
21
20
  == INSTALL:
22
21
 
data/Rakefile CHANGED
@@ -19,4 +19,10 @@ task :github do
19
19
  `rake debug_gem | sed 1d > evri-api.gemspec`
20
20
  end
21
21
 
22
+ task :make_index_html do
23
+ sh "scp index.html joevandyk@rubyforge.org:/var/www/gforge-projects/evri-api"
24
+ end
25
+
26
+ task :publish_docs => :make_index_html
27
+
22
28
  # vim: syntax=Ruby
data/lib/evri/entity.rb CHANGED
@@ -3,7 +3,10 @@ module Evri
3
3
  class Entity
4
4
  attr_reader :properties
5
5
 
6
- # Finds a specific entity, given an ID.
6
+ # Finds a specific Entity, given an ID. An Entity is a person, company, product, etc.
7
+ #
8
+ # IDs look like <tt>/person/barack-obama-0x16f69</tt> or <tt>product/forgetting-sarah-marshall-0x1e0d1</tt>
9
+ # Entity.find "/person/barack-obama-0x16f69"
7
10
  def self.find id
8
11
  @entended_properties = true
9
12
  @results ||= {}
@@ -14,7 +17,9 @@ module Evri
14
17
  end
15
18
  end
16
19
 
17
- # Searches for an exact match.
20
+ # Searches for an exact match. It will return an array of Entities.
21
+ # Entity.search "Barack Obama"
22
+ # Entity.search "Forgetting Sarah Marshall"
18
23
  def self.search name
19
24
  create_from_jsons do
20
25
  Evri.query(:type => :search, :query => name)
@@ -22,31 +27,47 @@ module Evri
22
27
  end
23
28
 
24
29
  # Searches for a partial match. i.e. 'ob' will return 'Obama'.
30
+ #
31
+ # Entity.search_by_prefix("oba")
32
+ #
33
+ # will likely return an Entity representing Barack Obama.
25
34
  def self.search_by_prefix prefix
26
35
  create_from_jsons do
27
36
  Evri.query(:type => :prefix, :query => prefix)
28
37
  end
29
38
  end
30
39
 
31
- # Given a :uri and :text options, return the related entities.
40
+ # Returns Entities that the given +:uri+ option mentions.
41
+ #
42
+ # Entity.from_media :uri => "http://www.evri.com/rd/servlet/RequestDispatcherServlet?req=cl&url=http%3A%2F%2Ffeeds.feedburner.com%2F%7Er%2Fvariety%2Fnews%2Ftv%2F%7E3%2F434927667%2FVR1117994787"
43
+ #
44
+ # If Evri doesn't know about the given +:uri+ option, you can pass in a
45
+ # +:text+ option.
46
+ #
47
+ # text = %(He starred in "Forgetting Sarah Marshall" and was picked as one of Variety's 10 comics to watch, but Russell Brand's latest performance is no laughing matter for the BBC.")
48
+ # uri = "http://www.evri.com/rd/servlet/RequestDispatcherServlet?req=cl&url=http%3A%2F%2Ffeeds.feedburner.com%2F%7Er%2Fvariety%2Fnews%2Ftv%2F%7E3%2F434927667%2FVR1117994787"
49
+ # Evri.from_media :uri => uri, :text => text
32
50
  def self.from_media options={}
33
51
  uri, text = options[:uri], options[:text]
34
52
  raise ArgumentError, "Must specify URI via the :uri option" unless uri
35
53
  raise ArgumentError, "Must specify some text via the :text option" unless text
36
54
 
37
55
  json = Evri.parse_json(Evri.query(:type => :from_media, :uri => uri, :text => text))
38
- json["graph"]["entities"].map do |e, entity_json|
56
+ json["graph"]["entities"]["entity"].map do |entity_json|
39
57
  Entity.new entity_json
40
58
  end
41
59
  end
42
60
 
43
- # Returns where the information for this entity came from.
61
+ # Returns the URL where the information for this entity came from.
44
62
  def source_url
45
63
  @source_url
46
64
  end
47
65
 
48
66
  # Returns information about an entity.
49
- # i.e obama.info(:birth_date)
67
+ #
68
+ # obama.info(:birth_date)
69
+ #
70
+ # If +:options+ is nil, will return all the available information.
50
71
  def info option=nil
51
72
  @properties ||= {}
52
73
  if defined?(@extended_properties)
@@ -70,7 +91,7 @@ module Evri
70
91
  "#<Evri::Entity:#{to_s}>"
71
92
  end
72
93
 
73
- # Returns the name of the entity
94
+ # Returns the name of the entity.
74
95
  def name
75
96
  @parsed_json["name"]["$"] || @parsed_json["name"]
76
97
  end
@@ -102,6 +123,8 @@ module Evri
102
123
  end
103
124
 
104
125
  # Returns relationships for the entity
126
+ #
127
+ # obama.relations
105
128
  def relations options={}
106
129
  from_domains = nil
107
130
  if options[:from]
data/lib/evri/media.rb CHANGED
@@ -1,3 +1,5 @@
1
+ require 'date'
2
+
1
3
  module Evri
2
4
  class Media
3
5
  end
data/lib/evri.rb CHANGED
@@ -24,7 +24,7 @@ module Evri
24
24
  # Raised whenever the entity you are searching for cannot be found.
25
25
  class EntityNotFound < Error; end
26
26
 
27
- VERSION = "0.03"
27
+ VERSION = "0.04"
28
28
  @@api_host = "api.evri.com"
29
29
  @@source_host = @@api_host
30
30
  @@source_url = nil
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: evri
3
3
  version: !ruby/object:Gem::Version
4
- version: "0.03"
4
+ version: "0.04"
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joe Van Dyk