wolfram-alpha 0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/library/wolfram-alpha.rb +17 -0
- data/library/wolfram-alpha/client.rb +21 -0
- data/library/wolfram-alpha/pod.rb +13 -0
- data/library/wolfram-alpha/response.rb +13 -0
- data/library/wolfram-alpha/subpod.rb +13 -0
- metadata +69 -0
@@ -0,0 +1,17 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'open-uri'
|
4
|
+
require 'nokogiri'
|
5
|
+
|
6
|
+
require 'wolfram-alpha/pod'
|
7
|
+
require 'wolfram-alpha/client'
|
8
|
+
require 'wolfram-alpha/subpod'
|
9
|
+
require 'wolfram-alpha/response'
|
10
|
+
|
11
|
+
module WolframAlpha
|
12
|
+
RequestURI = "http://api.wolframalpha.com/v2/query?input=%s&appid=%s"
|
13
|
+
|
14
|
+
class << Version = [1,0]
|
15
|
+
def to_s; join '.' end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module WolframAlpha
|
4
|
+
class Client
|
5
|
+
attr_accessor :app_id
|
6
|
+
|
7
|
+
def initialize app_id = nil
|
8
|
+
@app_id = app_id
|
9
|
+
end
|
10
|
+
|
11
|
+
def compute query
|
12
|
+
document = Nokogiri::XML open WolframAlpha::RequestURI % [URI.escape(query), @app_id]#File.open("/home/mk/Documents/response.xml")
|
13
|
+
|
14
|
+
if document.root.name == "queryresult"
|
15
|
+
Response.new document
|
16
|
+
else
|
17
|
+
raise "Invalid response"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: wolfram-alpha
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 1
|
8
|
+
version: "0.1"
|
9
|
+
platform: ruby
|
10
|
+
authors:
|
11
|
+
- Mikkel Kroman
|
12
|
+
autorequire:
|
13
|
+
bindir: executables
|
14
|
+
cert_chain: []
|
15
|
+
|
16
|
+
date: 2011-01-27 00:00:00 +01:00
|
17
|
+
default_executable:
|
18
|
+
dependencies: []
|
19
|
+
|
20
|
+
description:
|
21
|
+
email: mk@maero.dk
|
22
|
+
executables: []
|
23
|
+
|
24
|
+
extensions: []
|
25
|
+
|
26
|
+
extra_rdoc_files: []
|
27
|
+
|
28
|
+
files:
|
29
|
+
- library/wolfram-alpha/client.rb
|
30
|
+
- library/wolfram-alpha/response.rb
|
31
|
+
- library/wolfram-alpha/pod.rb
|
32
|
+
- library/wolfram-alpha/subpod.rb
|
33
|
+
- library/wolfram-alpha.rb
|
34
|
+
has_rdoc: true
|
35
|
+
homepage:
|
36
|
+
licenses: []
|
37
|
+
|
38
|
+
post_install_message:
|
39
|
+
rdoc_options: []
|
40
|
+
|
41
|
+
require_paths:
|
42
|
+
- library
|
43
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
44
|
+
none: false
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
segments:
|
49
|
+
- 1
|
50
|
+
- 9
|
51
|
+
- 1
|
52
|
+
version: 1.9.1
|
53
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
54
|
+
none: false
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
segments:
|
59
|
+
- 0
|
60
|
+
version: "0"
|
61
|
+
requirements: []
|
62
|
+
|
63
|
+
rubyforge_project:
|
64
|
+
rubygems_version: 1.3.7
|
65
|
+
signing_key:
|
66
|
+
specification_version: 3
|
67
|
+
summary: Wolfram|Alpha API implementation.
|
68
|
+
test_files: []
|
69
|
+
|