ken 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.textile CHANGED
@@ -13,12 +13,13 @@ Also you can use this library as a Data Layer (instead of or in addition to Acti
13
13
 
14
14
  h2. Installation
15
15
 
16
- Use GitHub RubyGems:
16
+ Use "Gemcutter":http://gemcutter.org RubyGems:
17
17
 
18
18
  <pre>
19
19
  <code>
20
- $ gem sources -a http://gems.github.com (you only have to do this once)
21
- $ sudo gem install michael-ken
20
+ $ gem install gemcutter
21
+ $ gem tumble
22
+ $ gem install ken
22
23
  </code>
23
24
  </pre>
24
25
 
@@ -27,7 +28,6 @@ In your Ruby files add:
27
28
  <pre>
28
29
  <code>
29
30
  require 'rubygems'
30
- gem 'michael-ken'
31
31
  require 'ken'
32
32
  </code>
33
33
  </pre>
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.2
1
+ 0.1.3
data/ken.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{ken}
8
- s.version = "0.1.2"
8
+ s.version = "0.1.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["michael"]
12
- s.date = %q{2009-10-16}
12
+ s.date = %q{2009-10-23}
13
13
  s.email = %q{ma[at]zive[dot]at}
14
14
  s.extra_rdoc_files = [
15
15
  "LICENSE",
data/lib/ken/session.rb CHANGED
@@ -45,6 +45,8 @@ module Ken
45
45
  SERVICES = {
46
46
  :mqlread => '/api/service/mqlread',
47
47
  :mqlwrite => '/api/service/mqlwrite',
48
+ :blurb => '/api/trans/blurb',
49
+ :raw => '/api/trans/raw',
48
50
  :login => '/api/account/login',
49
51
  :upload => '/api/service/upload'
50
52
  }
@@ -90,6 +92,20 @@ module Ken
90
92
  end
91
93
  query_result
92
94
  end
95
+
96
+ def raw_content(id, options = {})
97
+ puts raw_service_url
98
+ response = http_request raw_service_url+id, options
99
+ Ken.logger.info "<<< Received Raw Content Response: #{response}"
100
+ response
101
+ end
102
+
103
+ def blurb_content(id, options = {})
104
+ puts blurb_service_url
105
+ response = http_request blurb_service_url+id, options
106
+ Ken.logger.info "<<< Received Blurb Content Response: #{response}"
107
+ response
108
+ end
93
109
 
94
110
  protected
95
111
  # returns parsed json response from freebase mqlread service
@@ -109,7 +125,7 @@ module Ken
109
125
 
110
126
  # encode parameters
111
127
  def params_to_string(parameters)
112
- parameters.keys.map {|k| "#{URI.encode(k.to_s)}=#{URI.encode(parameters[k])}" }.join('&')
128
+ parameters.keys.map {|k| "#{URI.encode(k.to_s)}=#{URI.encode(parameters[k].to_s)}" }.join('&')
113
129
  end
114
130
 
115
131
  # does the dirty work
@@ -6,12 +6,12 @@ class SessionTest < Test::Unit::TestCase
6
6
  Ken::Logger.new(STDOUT, :info)
7
7
  Ken::Session.new('http://www.freebase.com', 'ma', 'xxxxx')
8
8
  end
9
-
9
+
10
10
  should 'return the correct set of types' do
11
11
  result = Ken.session.mqlread({:id => "/en/the_police", :type => []})
12
12
  result['type'].length.should >= 1
13
13
  end
14
-
14
+
15
15
  should 'raise a Ken::MqlReadError if node does not exist' do
16
16
  lambda { Ken.session.mqlread({:id => "/en/the_police", :evil_property => []}) }.should raise_error(Ken::ReadError)
17
17
  end
@@ -23,5 +23,13 @@ class SessionTest < Test::Unit::TestCase
23
23
  should 'do cursored queries' do
24
24
  Ken.session.mqlread([{:type => '/chemistry/chemical_element'}], :cursor => true).length.should >= 117
25
25
  end
26
+
27
+ should 'do raw content requests' do
28
+ Ken.session.raw_content("/guid/9202a8c04000641f800000000002c4f3").length.should >= 50
29
+ end
30
+
31
+ should 'do blurb content requests' do
32
+ Ken.session.blurb_content("/guid/9202a8c04000641f800000000002c4f3", :maxlength => 200).length.should >= 50
33
+ end
26
34
  end # context
27
35
  end # SessionTest
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ken
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - michael
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-10-16 00:00:00 +02:00
12
+ date: 2009-10-23 00:00:00 +02:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency