wolfram 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gemspec +2 -3
- data/.travis.yml +6 -0
- data/CHANGELOG.rdoc +4 -0
- data/CONTRIBUTING.md +1 -0
- data/README.md +73 -0
- data/README.rdoc +3 -0
- data/lib/wolfram.rb +1 -0
- data/lib/wolfram/hash_presenter.rb +42 -0
- data/lib/wolfram/version.rb +1 -1
- data/test/fixtures/boston.xml +108 -176
- data/test/hash_presenter_test.rb +46 -0
- data/test/test_helper.rb +5 -0
- metadata +93 -69
data/.gemspec
CHANGED
@@ -11,7 +11,6 @@ Gem::Specification.new do |s|
|
|
11
11
|
s.summary = "Wolfram V2 API client"
|
12
12
|
s.description = "Explore the vast world of computational knowledge available for free via Wolfram's v2 API."
|
13
13
|
s.required_rubygems_version = ">= 1.3.6"
|
14
|
-
s.rubyforge_project = 'tagaholic'
|
15
14
|
s.executables = ['wolfram']
|
16
15
|
s.add_dependency 'nokogiri', '>= 1.4.3'
|
17
16
|
s.add_development_dependency 'rr'
|
@@ -19,7 +18,7 @@ Gem::Specification.new do |s|
|
|
19
18
|
s.add_development_dependency 'bacon-rr'
|
20
19
|
s.add_development_dependency 'bacon-bits'
|
21
20
|
s.files = Dir.glob(%w[{lib,test}/**/*.rb bin/* [A-Z]*.{txt,rdoc} ext/**/*.{rb,c} **/deps.rip]) + %w{Rakefile .gemspec}
|
22
|
-
s.files += Dir.glob(['test/fixtures/*.xml'])
|
23
|
-
s.extra_rdoc_files = ["README.
|
21
|
+
s.files += Dir.glob(['test/fixtures/*.xml']) + %w{.travis.yml CONTRIBUTING.md}
|
22
|
+
s.extra_rdoc_files = ["README.md", "LICENSE.txt"]
|
24
23
|
s.license = 'MIT'
|
25
24
|
end
|
data/.travis.yml
ADDED
data/CHANGELOG.rdoc
CHANGED
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
Thanks for trying out this project! [See here for contribution guidelines.](http://tagaholic.me/contributing.html)
|
data/README.md
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
Description
|
2
|
+
===========
|
3
|
+
|
4
|
+
Explore the vast world of computational knowledge available for free via Wolfram's v2 API.
|
5
|
+
|
6
|
+
|
7
|
+
### Install
|
8
|
+
|
9
|
+
To install this gem:
|
10
|
+
|
11
|
+
```bash
|
12
|
+
gem install wolfram
|
13
|
+
```
|
14
|
+
|
15
|
+
|
16
|
+
### Setup
|
17
|
+
|
18
|
+
You'll need a Wolfram Appid (api key) by [creating an account
|
19
|
+
here](http://developer.wolframalpha.com/portal/apisignup.html) and
|
20
|
+
then clicking on the 'Get an APPID' button.
|
21
|
+
|
22
|
+
Once you have your own appid, set it in your shell, preferably in your ~/.bashrc:
|
23
|
+
|
24
|
+
```bash
|
25
|
+
export WOLFRAM_APPID='YOURKEY'
|
26
|
+
```
|
27
|
+
|
28
|
+
If you want to explicitly set your appid in a script:
|
29
|
+
|
30
|
+
```ruby
|
31
|
+
Wolfram.appid = "YOURKEY"
|
32
|
+
```
|
33
|
+
|
34
|
+
|
35
|
+
### Usage
|
36
|
+
|
37
|
+
Query away on the commandline!
|
38
|
+
|
39
|
+
```bash
|
40
|
+
# Calculate distance and travel time between places
|
41
|
+
wolfram from boston to new york
|
42
|
+
|
43
|
+
# Solve an equation
|
44
|
+
wolfram x^3 - 4x^2 + 6x - 24 = 0
|
45
|
+
|
46
|
+
# Find words ending with able
|
47
|
+
wolfram words ending with able
|
48
|
+
```
|
49
|
+
|
50
|
+
Regular ruby usage:
|
51
|
+
|
52
|
+
```ruby
|
53
|
+
query = 'boston population'
|
54
|
+
result = Wolfram.fetch(query)
|
55
|
+
# to see the result as a hash of pods and assumptions:
|
56
|
+
hash = HashPresenter.new(result).to_hash
|
57
|
+
```
|
58
|
+
|
59
|
+
For many more examples, [see here](http://www.wolframalpha.com/examples/).
|
60
|
+
|
61
|
+
|
62
|
+
## Credits
|
63
|
+
|
64
|
+
* [Ian White](https://github.com/ianwhite) is the original author of this gem.
|
65
|
+
* spaghetticode for HashPresenter
|
66
|
+
* bdigital for a bug fix
|
67
|
+
|
68
|
+
|
69
|
+
## Todo
|
70
|
+
|
71
|
+
* More tests!
|
72
|
+
* A better inspect
|
73
|
+
* Handle more api options including format
|
data/README.rdoc
CHANGED
@@ -41,6 +41,9 @@ For many more examples, {see here}[http://www.wolframalpha.com/examples/].
|
|
41
41
|
* {Ian White}[https://github.com/ianwhite] is the original author of this gem.
|
42
42
|
* bdigital for a bug fix
|
43
43
|
|
44
|
+
== Contributing
|
45
|
+
{See here}[http://tagaholic.me/contributing.html]
|
46
|
+
|
44
47
|
== Todo
|
45
48
|
* More tests!
|
46
49
|
* A better inspect
|
data/lib/wolfram.rb
CHANGED
@@ -0,0 +1,42 @@
|
|
1
|
+
module Wolfram
|
2
|
+
class HashPresenter
|
3
|
+
attr_reader :result
|
4
|
+
|
5
|
+
def initialize(result)
|
6
|
+
@result = result
|
7
|
+
end
|
8
|
+
|
9
|
+
def to_hash
|
10
|
+
{
|
11
|
+
:pods => pods_to_hash,
|
12
|
+
:assumptions => assumptions_to_hash
|
13
|
+
}
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def pods_to_hash
|
19
|
+
pods.inject Hash.new do |hash, pod|
|
20
|
+
hash.update pod.title => pod.subpods.map(&:plaintext)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def assumptions_to_hash
|
25
|
+
assumptions.inject Hash.new do |hash, assumption|
|
26
|
+
hash.update assumption.name => assumption.values.map(&:desc)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def method_missing(method, *args, &block)
|
31
|
+
if result.respond_to? method
|
32
|
+
result.send(method, *args, &block)
|
33
|
+
else
|
34
|
+
super
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def respond_to_missing?(meth, include_private)
|
39
|
+
result.respond_to?(meth, include_private) || super
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
data/lib/wolfram/version.rb
CHANGED
data/test/fixtures/boston.xml
CHANGED
@@ -1,187 +1,119 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
<?xml version='1.0' encoding='UTF-8'?>
|
2
|
+
<queryresult success='true'
|
3
|
+
error='false'
|
4
|
+
numpods='2'
|
5
|
+
datatypes='City,MetropolitanArea,UrbanArea'
|
6
|
+
timedout='Data,Character'
|
7
|
+
timedoutpods=''
|
8
|
+
timing='1.157'
|
9
|
+
parsetiming='0.237'
|
10
|
+
parsetimedout='false'
|
11
|
+
recalculate='http://www4a.wolframalpha.com/api/v2/recalc.jsp?id=MSPa30241a3hbabae907f3a000002a85ade2hci82h1e&s=53'
|
12
|
+
id='MSPa30251a3hbabae907f3a00000470a85hc67b99i3h'
|
13
|
+
host='http://www4a.wolframalpha.com'
|
14
|
+
server='53'
|
15
|
+
related='http://www4a.wolframalpha.com/api/v2/relatedQueries.jsp?id=MSPa30261a3hbabae907f3a000003427e8938201ddg4&s=53'
|
16
|
+
version='2.6'>
|
17
|
+
<pod title='Input interpretation'
|
18
|
+
scanner='Identity'
|
19
|
+
id='Input'
|
20
|
+
position='100'
|
21
|
+
error='false'
|
22
|
+
numsubpods='1'>
|
23
|
+
<subpod title=''>
|
24
|
+
<plaintext>Boston, Massachusetts, United States</plaintext>
|
25
|
+
<img src='http://www4a.wolframalpha.com/Calculate/MSP/MSP30271a3hbabae907f3a000004d0heg3h53ih4b3e?MSPStoreType=image/gif&s=53'
|
26
|
+
alt='Boston, Massachusetts, United States'
|
27
|
+
title='Boston, Massachusetts, United States'
|
28
|
+
width='241'
|
29
|
+
height='18' />
|
6
30
|
</subpod>
|
7
31
|
</pod>
|
8
|
-
<pod title=
|
9
|
-
|
10
|
-
|
32
|
+
<pod title='Populations'
|
33
|
+
scanner='Data'
|
34
|
+
id='Population:CityData'
|
35
|
+
position='200'
|
36
|
+
error='false'
|
37
|
+
numsubpods='1'
|
38
|
+
primary='true'>
|
39
|
+
<subpod title=''>
|
40
|
+
<plaintext>city population | 617594 people (country rank: 23rd) (2010 estimate)
|
11
41
|
urban area population | 4.032 million people (Boston urban area) (country rank: 7th) (2000 estimate)
|
12
|
-
metro area population | 4.
|
13
|
-
<img src=
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
<img src="http://www1.wolframalpha.com/Calculate/MSP/MSP102819e3b0ea35330h1a000020e9fi69ecabg1i0?MSPStoreType=image/gif&s=12" alt="" title="" width="300" height="161"/>
|
23
|
-
</subpod>
|
24
|
-
<states count="2">
|
25
|
-
<state name="World map" input="Location:CityData__World map"/>
|
26
|
-
<state name="Show coordinates" input="Location:CityData__Show coordinates"/>
|
27
|
-
</states>
|
28
|
-
<infos count="1">
|
29
|
-
<info>
|
30
|
-
<link url="http://maps.google.com/maps?t=h&ie=UTF8&ll=42.3216,-71.0891&z=12" text="Satellite image"/>
|
31
|
-
</info>
|
32
|
-
</infos>
|
33
|
-
</pod>
|
34
|
-
<pod title="Local map" scanner="Data" id="Map:CityData" position="400" error="false" numsubpods="1">
|
35
|
-
<subpod title="">
|
36
|
-
<plaintext/>
|
37
|
-
<img src="http://www1.wolframalpha.com/Calculate/MSP/MSP102919e3b0ea35330h1a000038e0a9d82ceg5fga?MSPStoreType=image/gif&s=12" alt="" title="" width="256" height="278"/>
|
38
|
-
</subpod>
|
39
|
-
<states count="3">
|
40
|
-
<state name="Metric" input="Map:CityData__Metric"/>
|
41
|
-
<state name="Larger display" input="Map:CityData__Larger display"/>
|
42
|
-
<statelist count="13" value="9 miles across">
|
43
|
-
<state name="2 miles across" input="Map:CityData__2 miles across"/>
|
44
|
-
<state name="4 miles across" input="Map:CityData__4 miles across"/>
|
45
|
-
<state name="9 miles across" input="Map:CityData__9 miles across"/>
|
46
|
-
<state name="18 miles across" input="Map:CityData__18 miles across"/>
|
47
|
-
<state name="36 miles across" input="Map:CityData__36 miles across"/>
|
48
|
-
<state name="72 miles across" input="Map:CityData__72 miles across"/>
|
49
|
-
<state name="140 miles across" input="Map:CityData__140 miles across"/>
|
50
|
-
<state name="290 miles across" input="Map:CityData__290 miles across"/>
|
51
|
-
<state name="570 miles across" input="Map:CityData__570 miles across"/>
|
52
|
-
<state name="1100 miles across" input="Map:CityData__1100 miles across"/>
|
53
|
-
<state name="2200 miles across" input="Map:CityData__2200 miles across"/>
|
54
|
-
<state name="3900 miles across" input="Map:CityData__3900 miles across"/>
|
55
|
-
<state name="7200 miles across" input="Map:CityData__7200 miles across"/>
|
56
|
-
</statelist>
|
57
|
-
</states>
|
58
|
-
<infos count="1">
|
59
|
-
<info>
|
60
|
-
<link url="http://maps.google.com/maps?t=h&ie=UTF8&ll=42.3216,-71.0891&z=12" text="Satellite image"/>
|
61
|
-
</info>
|
62
|
-
</infos>
|
63
|
-
</pod>
|
64
|
-
<pod title="Current local time" scanner="Data" id="CurrentTime:CityData" position="500" error="false" numsubpods="1">
|
65
|
-
<subpod title="">
|
66
|
-
<plaintext>5:32 pm EST | Sunday, January 23, 2011</plaintext>
|
67
|
-
<img src="http://www1.wolframalpha.com/Calculate/MSP/MSP103019e3b0ea35330h1a000025c691cb4f654g5c?MSPStoreType=image/gif&s=12" alt="5:32 pm EST | Sunday, January 23, 2011" title="5:32 pm EST | Sunday, January 23, 2011" width="270" height="20"/>
|
68
|
-
</subpod>
|
69
|
-
</pod>
|
70
|
-
<pod title="Current weather" scanner="Data" id="WeatherPod:CityData" position="600" error="false" numsubpods="1">
|
71
|
-
<subpod title="">
|
72
|
-
<plaintext>19 °F (wind chill: 7 °F) | relative humidity: 45% | wind: 12 mph | partly cloudy</plaintext>
|
73
|
-
<img src="http://www1.wolframalpha.com/Calculate/MSP/MSP103119e3b0ea35330h1a000037d137ggg45f08b4?MSPStoreType=image/gif&s=12" alt="19 °F (wind chill: 7 °F) | relative humidity: 45% | wind: 12 mph | partly cloudy" title="19 °F (wind chill: 7 °F) | relative humidity: 45% | wind: 12 mph | partly cloudy" width="496" height="42"/>
|
74
|
-
</subpod>
|
75
|
-
<states count="2">
|
76
|
-
<state name="Show history" input="WeatherPod:CityData__Show history"/>
|
77
|
-
<state name="Show metric" input="WeatherPod:CityData__Show metric"/>
|
78
|
-
</states>
|
79
|
-
</pod>
|
80
|
-
<pod title="Economic properties" scanner="Data" id="EconomicProperties:CityData" position="700" error="false" numsubpods="1">
|
81
|
-
<subpod title="">
|
82
|
-
<plaintext>cost of living index | 1.3 × national average (Q3 2010)
|
83
|
-
median home price | $332900 (Boston metro area) (annual change: -7.81%) (2009)
|
84
|
-
unemployment rate | 8% (September 2010)
|
85
|
-
total sales tax rate | 6.25%</plaintext>
|
86
|
-
<img src="http://www1.wolframalpha.com/Calculate/MSP/MSP103219e3b0ea35330h1a00003ih0c624f9fcig5g?MSPStoreType=image/gif&s=12" alt="cost of living index | 1.3 × national average (Q3 2010) median home price | $332900 (Boston metro area) (annual change: -7.81%) (2009) unemployment rate | 8% (September 2010) total sales tax rate | 6.25%" title="cost of living index | 1.3 × national average (Q3 2010) median home price | $332900 (Boston metro area) (annual change: -7.81%) (2009) unemployment rate | 8% (September 2010) total sales tax rate | 6.25%" width="496" height="158"/>
|
87
|
-
</subpod>
|
88
|
-
</pod>
|
89
|
-
<pod title="Other indicators" scanner="Data" id="QualityOfLife:CityData" position="800" error="false" numsubpods="1">
|
90
|
-
<subpod title="">
|
91
|
-
<plaintext>total rate of violent crime | 2.4 × national average (2008 estimate)
|
92
|
-
total rate of property crime | 1.2 × national average (2008 estimate)
|
93
|
-
average daily traffic delay | 7.1 min/day</plaintext>
|
94
|
-
<img src="http://www1.wolframalpha.com/Calculate/MSP/MSP103319e3b0ea35330h1a00002c43ica63fee46b2?MSPStoreType=image/gif&s=12" alt="total rate of violent crime | 2.4 × national average (2008 estimate) total rate of property crime | 1.2 × national average (2008 estimate) average daily traffic delay | 7.1 min/day" title="total rate of violent crime | 2.4 × national average (2008 estimate) total rate of property crime | 1.2 × national average (2008 estimate) average daily traffic delay | 7.1 min/day" width="474" height="106"/>
|
95
|
-
</subpod>
|
96
|
-
<infos count="1">
|
97
|
-
<info>
|
98
|
-
<units count="1">
|
99
|
-
<unit short="min/day" long="minutes per day"/>
|
100
|
-
<img src="http://www1.wolframalpha.com/Calculate/MSP/MSP103419e3b0ea35330h1a00003eheg0g4i784h0a8?MSPStoreType=image/gif&s=12" width="179" height="26"/>
|
101
|
-
</units>
|
102
|
-
</info>
|
103
|
-
</infos>
|
104
|
-
</pod>
|
105
|
-
<pod title="Geographic properties" scanner="Data" id="GeographicProperties:CityData" position="900" error="false" numsubpods="1">
|
106
|
-
<subpod title="">
|
107
|
-
<plaintext>elevation | 46 ft
|
108
|
-
area | 48.43 mi^2
|
109
|
-
population density | 12576 people/mi^2</plaintext>
|
110
|
-
<img src="http://www1.wolframalpha.com/Calculate/MSP/MSP103519e3b0ea35330h1a00001a2di1ih5177fie0?MSPStoreType=image/gif&s=12" alt="elevation | 46 ft area | 48.43 mi^2 population density | 12576 people/mi^2" title="elevation | 46 ft area | 48.43 mi^2 population density | 12576 people/mi^2" width="286" height="106"/>
|
111
|
-
</subpod>
|
112
|
-
<states count="1">
|
113
|
-
<state name="Show metric" input="GeographicProperties:CityData__Show metric"/>
|
114
|
-
</states>
|
115
|
-
<infos count="1">
|
116
|
-
<info>
|
117
|
-
<units count="3">
|
118
|
-
<unit short="ft" long="feet"/>
|
119
|
-
<unit short="mi^2" long="square miles"/>
|
120
|
-
<unit short="people/mi^2" long="people per square mile"/>
|
121
|
-
<img src="http://www1.wolframalpha.com/Calculate/MSP/MSP103619e3b0ea35330h1a00003d88iibb6i7093e8?MSPStoreType=image/gif&s=12" width="232" height="74"/>
|
122
|
-
</units>
|
123
|
-
</info>
|
124
|
-
</infos>
|
125
|
-
</pod>
|
126
|
-
<pod title="Nearby cities" scanner="Data" id="CityHierarchyInfo:CityData" position="1000" error="false" numsubpods="1">
|
127
|
-
<subpod title="">
|
128
|
-
<plaintext>Cambridge, Massachusetts | 4 miles north-northwest | 105596 people
|
129
|
-
Quincy, Massachusetts | 6 miles southeast | 92339 people
|
130
|
-
Providence, Rhode Island | 38 miles south-southwest | 171557 people
|
131
|
-
New York City, New York | 184 miles southwest | 8.364 million people
|
132
|
-
(straight-line distances between city centers)</plaintext>
|
133
|
-
<img src="http://www1.wolframalpha.com/Calculate/MSP/MSP103719e3b0ea35330h1a00000ddigh995a68547a?MSPStoreType=image/gif&s=12" alt="Cambridge, Massachusetts | 4 miles north-northwest | 105596 people Quincy, Massachusetts | 6 miles southeast | 92339 people Providence, Rhode Island | 38 miles south-southwest | 171557 people New York City, New York | 184 miles southwest | 8.364 million people (straight-line distances between city centers)" title="Cambridge, Massachusetts | 4 miles north-northwest | 105596 people Quincy, Massachusetts | 6 miles southeast | 92339 people Providence, Rhode Island | 38 miles south-southwest | 171557 people New York City, New York | 184 miles southwest | 8.364 million people (straight-line distances between city centers)" width="495" height="209"/>
|
134
|
-
</subpod>
|
135
|
-
<states count="2">
|
136
|
-
<state name="Show metric" input="CityHierarchyInfo:CityData__Show metric"/>
|
137
|
-
<state name="More" input="CityHierarchyInfo:CityData__More"/>
|
138
|
-
</states>
|
139
|
-
</pod>
|
140
|
-
<pod title="County" scanner="Data" id="CountyInfo:CityData" position="1100" error="false" numsubpods="1">
|
141
|
-
<subpod title="">
|
142
|
-
<plaintext>Suffolk County, Massachusetts</plaintext>
|
143
|
-
<img src="http://www1.wolframalpha.com/Calculate/MSP/MSP103819e3b0ea35330h1a000011cc3hc37d56i612?MSPStoreType=image/gif&s=12" alt="Suffolk County, Massachusetts" title="Suffolk County, Massachusetts" width="201" height="20"/>
|
144
|
-
</subpod>
|
145
|
-
</pod>
|
146
|
-
<pod title="Nicknames" scanner="Data" id="BasicInformation:CityData" position="1200" error="false" numsubpods="1">
|
147
|
-
<subpod title="">
|
148
|
-
<plaintext>Athens of America | Beantown | The Hub | The Cradle of Liberty</plaintext>
|
149
|
-
<img src="http://www1.wolframalpha.com/Calculate/MSP/MSP103919e3b0ea35330h1a0000332h1hcg83g4g27a?MSPStoreType=image/gif&s=12" alt="Athens of America | Beantown | The Hub | The Cradle of Liberty" title="Athens of America | Beantown | The Hub | The Cradle of Liberty" width="452" height="20"/>
|
150
|
-
</subpod>
|
151
|
-
</pod>
|
152
|
-
<pod title="Notable people born in Boston" scanner="Data" id="NotablePeople:CityData" position="1300" error="false" numsubpods="1">
|
153
|
-
<subpod title="">
|
154
|
-
<plaintext>Benjamin Franklin (1706) | Edgar Allan Poe (1809) | Michael Bloomberg (1942) | Robert F. Kennedy (1925) | James Taylor (1948) | Ralph Waldo Emerson (1803) | Donna Summer (1948) | Guru (1961) | Leonard Nimoy (1931) | Uma Thurman (1970) | ...</plaintext>
|
155
|
-
<img src="http://www1.wolframalpha.com/Calculate/MSP/MSP104019e3b0ea35330h1a00006509g4f69da8a7i5?MSPStoreType=image/gif&s=12" alt="Benjamin Franklin (1706) | Edgar Allan Poe (1809) | Michael Bloomberg (1942) | Robert F. Kennedy (1925) | James Taylor (1948) | Ralph Waldo Emerson (1803) | Donna Summer (1948) | Guru (1961) | Leonard Nimoy (1931) | Uma Thurman (1970) | ..." title="Benjamin Franklin (1706) | Edgar Allan Poe (1809) | Michael Bloomberg (1942) | Robert F. Kennedy (1925) | James Taylor (1948) | Ralph Waldo Emerson (1803) | Donna Summer (1948) | Guru (1961) | Leonard Nimoy (1931) | Uma Thurman (1970) | ..." width="461" height="101"/>
|
42
|
+
metro area population | 4.591 million people (Boston metro area) (country rank: 10th) (2011 estimate)</plaintext>
|
43
|
+
<img src='http://www4a.wolframalpha.com/Calculate/MSP/MSP30281a3hbabae907f3a000002i57d68ab7148579?MSPStoreType=image/gif&s=53'
|
44
|
+
alt='city population | 617594 people (country rank: 23rd) (2010 estimate)
|
45
|
+
urban area population | 4.032 million people (Boston urban area) (country rank: 7th) (2000 estimate)
|
46
|
+
metro area population | 4.591 million people (Boston metro area) (country rank: 10th) (2011 estimate)'
|
47
|
+
title='city population | 617594 people (country rank: 23rd) (2010 estimate)
|
48
|
+
urban area population | 4.032 million people (Boston urban area) (country rank: 7th) (2000 estimate)
|
49
|
+
metro area population | 4.591 million people (Boston metro area) (country rank: 10th) (2011 estimate)'
|
50
|
+
width='496'
|
51
|
+
height='151' />
|
156
52
|
</subpod>
|
157
|
-
<states count=
|
158
|
-
<state name=
|
159
|
-
|
160
|
-
<state name="Show occupations" input="NotablePeople:CityData__Show occupations"/>
|
161
|
-
<state name="Show deaths" input="NotablePeople:CityData__Show deaths"/>
|
53
|
+
<states count='1'>
|
54
|
+
<state name='Show history'
|
55
|
+
input='Population:CityData__Show history' />
|
162
56
|
</states>
|
163
57
|
</pod>
|
164
|
-
<assumptions count=
|
165
|
-
<assumption type=
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
<value name=
|
58
|
+
<assumptions count='2'>
|
59
|
+
<assumption type='Clash'
|
60
|
+
word='boston'
|
61
|
+
template='Assuming "${word}" is ${desc1}. Use as ${desc2} instead'
|
62
|
+
count='6'>
|
63
|
+
<value name='City'
|
64
|
+
desc='a city'
|
65
|
+
input='*C.boston-_*City-' />
|
66
|
+
<value name='MLBTeam'
|
67
|
+
desc='an MLB team'
|
68
|
+
input='*C.boston-_*MLBTeam-' />
|
69
|
+
<value name='MusicAct'
|
70
|
+
desc='a music act'
|
71
|
+
input='*C.boston-_*MusicAct-' />
|
72
|
+
<value name='AdministrativeDivision'
|
73
|
+
desc='an administrative division'
|
74
|
+
input='*C.boston-_*AdministrativeDivision-' />
|
75
|
+
<value name='Surname'
|
76
|
+
desc='a surname'
|
77
|
+
input='*C.boston-_*Surname-' />
|
78
|
+
<value name='GivenName'
|
79
|
+
desc='a given name'
|
80
|
+
input='*C.boston-_*GivenName-' />
|
170
81
|
</assumption>
|
171
|
-
<assumption type=
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
<value name=
|
176
|
-
|
177
|
-
|
178
|
-
<value name=
|
82
|
+
<assumption type='SubCategory'
|
83
|
+
word='boston'
|
84
|
+
template='Assuming ${desc1}. Use ${desc2} instead'
|
85
|
+
count='7'>
|
86
|
+
<value name='{Boston, Massachusetts, UnitedStates}'
|
87
|
+
desc='Boston (Massachusetts, USA)'
|
88
|
+
input='*DPClash.CityE.boston-_**Boston.Massachusetts.UnitedStates--' />
|
89
|
+
<value name='{Boston, Lincolnshire, UnitedKingdom}'
|
90
|
+
desc='Boston (United Kingdom)'
|
91
|
+
input='*DPClash.CityE.boston-_**Boston.Lincolnshire.UnitedKingdom--' />
|
92
|
+
<value name='{Boston, Karakalpakstan, Uzbekistan}'
|
93
|
+
desc='Boston (Uzbekistan)'
|
94
|
+
input='*DPClash.CityE.boston-_**Boston.Karakalpakstan.Uzbekistan--' />
|
95
|
+
<value name='{Boston, NewYork, UnitedStates}'
|
96
|
+
desc='Boston (New York, USA)'
|
97
|
+
input='*DPClash.CityE.boston-_**Boston.NewYork.UnitedStates--' />
|
98
|
+
<value name='{Boston, DavaoOriental, Philippines}'
|
99
|
+
desc='Boston (Philippines)'
|
100
|
+
input='*DPClash.CityE.boston-_**Boston.DavaoOriental.Philippines--' />
|
101
|
+
<value name='{Boston, Georgia, UnitedStates}'
|
102
|
+
desc='Boston (Georgia, USA)'
|
103
|
+
input='*DPClash.CityE.boston-_**Boston.Georgia.UnitedStates--' />
|
104
|
+
<value name='{Boston, Indiana, UnitedStates}'
|
105
|
+
desc='Boston (Indiana, USA)'
|
106
|
+
input='*DPClash.CityE.boston-_**Boston.Indiana.UnitedStates--' />
|
179
107
|
</assumption>
|
180
108
|
</assumptions>
|
181
|
-
<sources count=
|
182
|
-
<source url=
|
183
|
-
|
184
|
-
<source url=
|
185
|
-
|
109
|
+
<sources count='4'>
|
110
|
+
<source url='http://www.wolframalpha.com/sources/CityDataSourceInformationNotes.html'
|
111
|
+
text='City data' />
|
112
|
+
<source url='http://www.wolframalpha.com/sources/MetropolitanAreaDataSourceInformationNotes.html'
|
113
|
+
text='Metropolitan area data' />
|
114
|
+
<source url='http://www.wolframalpha.com/sources/UrbanAreaDataSourceInformationNotes.html'
|
115
|
+
text='Urban area data' />
|
116
|
+
<source url='http://www.wolframalpha.com/sources/USCensusDataSourceInformationNotes.html'
|
117
|
+
text='US census data' />
|
186
118
|
</sources>
|
187
119
|
</queryresult>
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require File.expand_path('../test_helper', __FILE__)
|
2
|
+
|
3
|
+
module Wolfram
|
4
|
+
describe 'HashPresenter' do
|
5
|
+
before do
|
6
|
+
mock(Query).fetch(anything) { read_fixture('boston') }
|
7
|
+
@result = Wolfram.fetch('boston')
|
8
|
+
@presenter = HashPresenter.new(@result)
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'has #result reader' do
|
12
|
+
@presenter.result.should == @result
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'raises errors for methods that cannot handle' do
|
16
|
+
lambda { @presenter.asdasd }.should.raise(NoMethodError)
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'delegates #pods to #result' do
|
20
|
+
mock(@result).pods
|
21
|
+
@presenter.pods
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'delegates #assumptions to #result' do
|
25
|
+
mock(@result).assumptions
|
26
|
+
@presenter.assumptions
|
27
|
+
end
|
28
|
+
|
29
|
+
describe '#to_hash' do
|
30
|
+
before { @to_hash = @presenter.to_hash }
|
31
|
+
|
32
|
+
it 'returns a hash' do
|
33
|
+
Hash.should === @to_hash
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'has :pods and :assumptions as keys' do
|
37
|
+
@to_hash.keys.sort.should == [:pods, :assumptions].sort
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'includes expected data' do
|
41
|
+
@to_hash[:pods]['Populations'].first.should =~ /city population | 617594 people/
|
42
|
+
@to_hash[:assumptions]['Clash'].first.should == 'a city'
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,85 +1,109 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: wolfram
|
3
|
-
version: !ruby/object:Gem::Version
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
4
5
|
prerelease:
|
5
|
-
version: 0.1.2
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
7
|
+
authors:
|
8
8
|
- Gabriel Horner
|
9
9
|
- Ian White
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
dependencies:
|
17
|
-
- !ruby/object:Gem::Dependency
|
13
|
+
date: 2013-02-07 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
18
16
|
name: nokogiri
|
19
|
-
|
20
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
21
18
|
none: false
|
22
|
-
requirements:
|
23
|
-
- -
|
24
|
-
- !ruby/object:Gem::Version
|
19
|
+
requirements:
|
20
|
+
- - ! '>='
|
21
|
+
- !ruby/object:Gem::Version
|
25
22
|
version: 1.4.3
|
26
23
|
type: :runtime
|
27
|
-
version_requirements: *id001
|
28
|
-
- !ruby/object:Gem::Dependency
|
29
|
-
name: rr
|
30
24
|
prerelease: false
|
31
|
-
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ! '>='
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: 1.4.3
|
31
|
+
- !ruby/object:Gem::Dependency
|
32
|
+
name: rr
|
33
|
+
requirement: !ruby/object:Gem::Requirement
|
32
34
|
none: false
|
33
|
-
requirements:
|
34
|
-
- -
|
35
|
-
- !ruby/object:Gem::Version
|
36
|
-
version:
|
35
|
+
requirements:
|
36
|
+
- - ! '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
37
39
|
type: :development
|
38
|
-
version_requirements: *id002
|
39
|
-
- !ruby/object:Gem::Dependency
|
40
|
-
name: bacon
|
41
40
|
prerelease: false
|
42
|
-
|
41
|
+
version_requirements: !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ! '>='
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: bacon
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
43
50
|
none: false
|
44
|
-
requirements:
|
45
|
-
- -
|
46
|
-
- !ruby/object:Gem::Version
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
47
54
|
version: 1.1.0
|
48
55
|
type: :development
|
49
|
-
version_requirements: *id003
|
50
|
-
- !ruby/object:Gem::Dependency
|
51
|
-
name: bacon-rr
|
52
56
|
prerelease: false
|
53
|
-
|
57
|
+
version_requirements: !ruby/object:Gem::Requirement
|
54
58
|
none: false
|
55
|
-
requirements:
|
56
|
-
- -
|
57
|
-
- !ruby/object:Gem::Version
|
58
|
-
version:
|
59
|
+
requirements:
|
60
|
+
- - ! '>='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 1.1.0
|
63
|
+
- !ruby/object:Gem::Dependency
|
64
|
+
name: bacon-rr
|
65
|
+
requirement: !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
67
|
+
requirements:
|
68
|
+
- - ! '>='
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
59
71
|
type: :development
|
60
|
-
version_requirements: *id004
|
61
|
-
- !ruby/object:Gem::Dependency
|
62
|
-
name: bacon-bits
|
63
72
|
prerelease: false
|
64
|
-
|
73
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
74
|
none: false
|
66
|
-
requirements:
|
67
|
-
- -
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
version:
|
75
|
+
requirements:
|
76
|
+
- - ! '>='
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
- !ruby/object:Gem::Dependency
|
80
|
+
name: bacon-bits
|
81
|
+
requirement: !ruby/object:Gem::Requirement
|
82
|
+
none: false
|
83
|
+
requirements:
|
84
|
+
- - ! '>='
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
70
87
|
type: :development
|
71
|
-
|
72
|
-
|
88
|
+
prerelease: false
|
89
|
+
version_requirements: !ruby/object:Gem::Requirement
|
90
|
+
none: false
|
91
|
+
requirements:
|
92
|
+
- - ! '>='
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
95
|
+
description: Explore the vast world of computational knowledge available for free
|
96
|
+
via Wolfram's v2 API.
|
73
97
|
email: gabriel.horner@gmail.com
|
74
|
-
executables:
|
98
|
+
executables:
|
75
99
|
- wolfram
|
76
100
|
extensions: []
|
77
|
-
|
78
|
-
|
79
|
-
- README.rdoc
|
101
|
+
extra_rdoc_files:
|
102
|
+
- README.md
|
80
103
|
- LICENSE.txt
|
81
|
-
files:
|
104
|
+
files:
|
82
105
|
- lib/wolfram/assumption.rb
|
106
|
+
- lib/wolfram/hash_presenter.rb
|
83
107
|
- lib/wolfram/pod.rb
|
84
108
|
- lib/wolfram/query.rb
|
85
109
|
- lib/wolfram/result.rb
|
@@ -87,6 +111,7 @@ files:
|
|
87
111
|
- lib/wolfram/version.rb
|
88
112
|
- lib/wolfram/xml_container.rb
|
89
113
|
- lib/wolfram.rb
|
114
|
+
- test/hash_presenter_test.rb
|
90
115
|
- test/test_helper.rb
|
91
116
|
- test/util_test.rb
|
92
117
|
- test/wolfram_test.rb
|
@@ -99,33 +124,32 @@ files:
|
|
99
124
|
- Rakefile
|
100
125
|
- .gemspec
|
101
126
|
- test/fixtures/boston.xml
|
102
|
-
|
127
|
+
- .travis.yml
|
128
|
+
- CONTRIBUTING.md
|
129
|
+
- README.md
|
103
130
|
homepage: http://github.com/cldwalker/wolfram
|
104
|
-
licenses:
|
131
|
+
licenses:
|
105
132
|
- MIT
|
106
133
|
post_install_message:
|
107
134
|
rdoc_options: []
|
108
|
-
|
109
|
-
require_paths:
|
135
|
+
require_paths:
|
110
136
|
- lib
|
111
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
137
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
112
138
|
none: false
|
113
|
-
requirements:
|
114
|
-
- -
|
115
|
-
- !ruby/object:Gem::Version
|
116
|
-
version:
|
117
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
139
|
+
requirements:
|
140
|
+
- - ! '>='
|
141
|
+
- !ruby/object:Gem::Version
|
142
|
+
version: '0'
|
143
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
118
144
|
none: false
|
119
|
-
requirements:
|
120
|
-
- -
|
121
|
-
- !ruby/object:Gem::Version
|
145
|
+
requirements:
|
146
|
+
- - ! '>='
|
147
|
+
- !ruby/object:Gem::Version
|
122
148
|
version: 1.3.6
|
123
149
|
requirements: []
|
124
|
-
|
125
|
-
|
126
|
-
rubygems_version: 1.6.2
|
150
|
+
rubyforge_project:
|
151
|
+
rubygems_version: 1.8.24
|
127
152
|
signing_key:
|
128
153
|
specification_version: 3
|
129
154
|
summary: Wolfram V2 API client
|
130
155
|
test_files: []
|
131
|
-
|