eoflife 0.1.0.pre

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm --create 1.9.2-p180@eoflife
data/Gemfile ADDED
@@ -0,0 +1,17 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ gem "httparty", "~> 0.7"
5
+ gem "hashie", "~> 1.0.0"
6
+
7
+ # Add dependencies to develop your gem here.
8
+ # Include everything needed to run rake, tests, features, etc.
9
+ group :development do
10
+ gem "rspec", "~> 2.3.0"
11
+ gem "yard", "~> 0.6.0"
12
+ gem "cucumber", ">= 0"
13
+ gem "bundler", "~> 1.0.0"
14
+ gem "jeweler", "~> 1.5.2"
15
+ gem "rcov", ">= 0"
16
+ gem "webmock", ">= 1.6.2"
17
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,53 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ addressable (2.2.4)
5
+ builder (3.0.0)
6
+ crack (0.1.8)
7
+ cucumber (0.10.0)
8
+ builder (>= 2.1.2)
9
+ diff-lcs (~> 1.1.2)
10
+ gherkin (~> 2.3.2)
11
+ json (~> 1.4.6)
12
+ term-ansicolor (~> 1.0.5)
13
+ diff-lcs (1.1.2)
14
+ gherkin (2.3.4)
15
+ json (~> 1.4.6)
16
+ git (1.2.5)
17
+ hashie (1.0.0)
18
+ httparty (0.7.4)
19
+ crack (= 0.1.8)
20
+ jeweler (1.5.2)
21
+ bundler (~> 1.0.0)
22
+ git (>= 1.2.5)
23
+ rake
24
+ json (1.4.6)
25
+ rake (0.8.7)
26
+ rcov (0.9.9)
27
+ rspec (2.3.0)
28
+ rspec-core (~> 2.3.0)
29
+ rspec-expectations (~> 2.3.0)
30
+ rspec-mocks (~> 2.3.0)
31
+ rspec-core (2.3.1)
32
+ rspec-expectations (2.3.0)
33
+ diff-lcs (~> 1.1.2)
34
+ rspec-mocks (2.3.0)
35
+ term-ansicolor (1.0.5)
36
+ webmock (1.6.2)
37
+ addressable (>= 2.2.2)
38
+ crack (>= 0.1.7)
39
+ yard (0.6.4)
40
+
41
+ PLATFORMS
42
+ ruby
43
+
44
+ DEPENDENCIES
45
+ bundler (~> 1.0.0)
46
+ cucumber
47
+ hashie (~> 1.0.0)
48
+ httparty (~> 0.7)
49
+ jeweler (~> 1.5.2)
50
+ rcov
51
+ rspec (~> 2.3.0)
52
+ webmock (>= 1.6.2)
53
+ yard (~> 0.6.0)
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Marc Chung
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,47 @@
1
+ eoflife - API for EOL.org/API
2
+ =============================
3
+
4
+ ## Description
5
+
6
+ The eoflife rubygem is a wrapper for eol.org/api. API development is currently a work in progress.
7
+
8
+ ## Synopsis
9
+
10
+ eol = Eoflife::Client.new
11
+ eol.ping #=> Hash response
12
+ eol.search("Western Honeybee") #=> Hash response
13
+
14
+ ## Getting Started
15
+
16
+ Use RubyGems to install the Eoflife gem
17
+
18
+ $ gem install eoflife
19
+
20
+ ## Installing on Rails 3
21
+
22
+ Add this to your `Gemfile`:
23
+
24
+ gem "eoflife"
25
+
26
+ ## Contributing to eoflife
27
+
28
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
29
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
30
+ * Fork the project
31
+ * Start a feature/bugfix branch
32
+ * Commit and push until you are happy with your contribution
33
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
34
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
35
+
36
+ ## Thanks
37
+
38
+ * www.eol.org
39
+
40
+ ## See Also
41
+
42
+ * [EOL API documentation](http://www.eol.org/api)
43
+
44
+ ## Copyright
45
+
46
+ Copyright (c) 2011 Marc Chung. See LICENSE.txt for further details.
47
+
data/Rakefile ADDED
@@ -0,0 +1,47 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'rake'
11
+
12
+ require 'jeweler'
13
+ require './lib/eoflife/version'
14
+
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "eoflife"
18
+ gem.homepage = "http://github.com/mchung/eoflife"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{API for the Encylopedia of Life}
21
+ gem.description = %Q{Programmatic access to the Encylopedia of Life's API}
22
+ gem.email = "mchung@gmail.com"
23
+ gem.authors = ["Marc Chung"]
24
+ gem.version = Eoflife::Version::STRING
25
+
26
+ # Include your dependencies below. Runtime dependencies are required when using your gem,
27
+ # and development dependencies are only needed for development (ie running rake tasks, tests, etc)
28
+ # gem.add_runtime_dependency 'jabber4r', '> 0.1'
29
+ # gem.add_development_dependency 'rspec', '> 1.2.3'
30
+ end
31
+ Jeweler::RubygemsDotOrgTasks.new
32
+
33
+ require 'rspec/core'
34
+ require 'rspec/core/rake_task'
35
+ RSpec::Core::RakeTask.new(:spec) do |spec|
36
+ spec.pattern = FileList['spec/**/*_spec.rb']
37
+ end
38
+
39
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
40
+ spec.pattern = 'spec/**/*_spec.rb'
41
+ spec.rcov = true
42
+ end
43
+
44
+ task :default => :spec
45
+
46
+ require 'yard'
47
+ YARD::Rake::YardocTask.new
data/examples/pages.rb ADDED
@@ -0,0 +1,9 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+
3
+ require 'eoflife'
4
+
5
+ client = Eoflife::Client.new
6
+ # rv = client.pages("328672", {:images => 6, :vetted => 1, :format => "html"})
7
+ # rv = client.pages("1045608", {:common_names => "1", :details => "1", :images => "2", :subjects => "all", :text => "2"})
8
+ rv = client.pages("1045608", {:details => "1", :subjects => "all"})
9
+ pp [:response, rv]
data/examples/ping.rb ADDED
@@ -0,0 +1,7 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+
3
+ require 'eoflife'
4
+
5
+ client = Eoflife::Client.new
6
+ rv = client.ping
7
+ puts rv.response.message
@@ -0,0 +1,8 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+
3
+ require 'eoflife'
4
+
5
+ client = Eoflife::Client.new
6
+ pp client.search("lion")
7
+
8
+ # pp client.search("lion", {:page => 1, :exact => 1})
data/lib/eoflife.rb ADDED
@@ -0,0 +1,12 @@
1
+ require 'httparty'
2
+ require 'hashie'
3
+ require 'uri'
4
+
5
+ require 'pp'
6
+
7
+ module Eoflife
8
+
9
+ end
10
+
11
+ require 'eoflife/error'
12
+ require 'eoflife/client'
@@ -0,0 +1,57 @@
1
+ module Eoflife
2
+ class Client
3
+ include HTTParty
4
+ base_uri "http://www.eol.org/api"
5
+
6
+ # Pings the API
7
+ #
8
+ # @see http://www.eol.org/api/docs/ping
9
+ # @return [Hashie::Mash] Success or failure results
10
+ def ping
11
+ handle_response self.class.get("/ping.json")
12
+ end
13
+
14
+ # Searches EOL
15
+ #
16
+ # @see http://www.eol.org/api/docs/search
17
+ # @param [String] search_query The species you're looking for.
18
+ # @param [Hash] query_options The QUERY_STRING as a hash
19
+ # @option query_options [String] :page Limits the number of returned image objects, 0-75.
20
+ # @option query_options [String] :exact will find taxon pages if the preferred name or any synonym or common name exactly matches the search term, `0` or `1`
21
+ # @return [Hashie::Mash] Parsed OpenSearch query
22
+ def search(search_query, query_options = {})
23
+ s = URI.escape(search_query)
24
+ handle_response self.class.get("/search/1.0/#{s}.json", :query => query_options)
25
+ end
26
+
27
+ # Pages returns the scientific name for that page, and optionally returns information
28
+ # about common names, media (text, images and videos), and references to the hierarchies
29
+ # which recognize the taxon described on the page.
30
+ #
31
+ # @see http://www.eol.org/api/docs/pages
32
+ # @param [String] taxon_id The taxon ID
33
+ # @param [Hash] query_options The QUERY_STRING as a hash
34
+ # @option query_options [String] :images Limits the number of returned image objects, `0` to `75`
35
+ # @option query_options [String] :videos Limits the number of returned videos objects, `0` to `75`
36
+ # @option query_options [String] :text Limits the number of returned text objects, `0` to `75`
37
+ # @return [Hashie::Mash] the scientific name for that page
38
+ def pages(taxon_id, query_options = {})
39
+ handle_response self.class.get("/pages/1.0/#{taxon_id}.json", :query => query_options)
40
+ end
41
+
42
+ # @private
43
+ def handle_response(response)
44
+ # case response.code
45
+ # when 400...500
46
+ # raise Error.new(response)
47
+ # else
48
+ # response
49
+ # end
50
+ if response.is_a?(Array)
51
+ response.map{|item| Hashie::Mash.new(item)}
52
+ else
53
+ Hashie::Mash.new(response)
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,10 @@
1
+ module Eoflife
2
+ class Error < StandardError
3
+ attr_reader :data
4
+
5
+ def initialize(data)
6
+ @data = data
7
+ super
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ class Eoflife
2
+ module Version
3
+ MAJOR = 0
4
+ MINOR = 1
5
+ PATCH = 0
6
+ BUILD = 'pre'
7
+
8
+ STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join('.')
9
+ end
10
+ end
@@ -0,0 +1,30 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "Eoflife" do
4
+
5
+ before(:each) do
6
+ @client = Eoflife::Client.new
7
+ end
8
+
9
+ it "should #ping" do
10
+ stub_endpoint("http://www.eol.org/api/ping.json", "ping.json")
11
+
12
+ r = @client.ping
13
+ r.response.message.should == "Success"
14
+ end
15
+
16
+ it "should #search" do
17
+ stub_endpoint("http://www.eol.org/api/search/1.0/Ursus.json?", "search.json")
18
+
19
+ r = @client.search("Ursus")
20
+ r.totalResults.should == 126
21
+ end
22
+
23
+ # it "should fetch #pages" do
24
+ # stub_endpoint("http://www.eol.org/api/pages/1.0/1045608.json?", "pages.json")
25
+ #
26
+ # r = @client.pages("1045608", {:common_names => 1, :details => 1, :images => 2, :subjects => "all", :text => 2})
27
+ # r.taxonConcepts[0].sourceIdentfier.should == 154396
28
+ # end
29
+
30
+ end
@@ -0,0 +1,378 @@
1
+ {
2
+ "taxonConcepts":
3
+ [
4
+ {
5
+ "sourceIdentfier":"154396",
6
+ "nameAccordingTo":"Integrated Taxonomic Information System (ITIS)",
7
+ "scientificName":"Apis mellifera Linnaeus 1758",
8
+ "identifier":20451196
9
+ },
10
+ {
11
+ "sourceIdentfier":"1926761",
12
+ "nameAccordingTo":"Species 2000 & ITIS Catalogue of Life: Annual Checklist 2009",
13
+ "scientificName":"Apis mellifera Linnaeus 1758",
14
+ "identifier":25435626
15
+ },
16
+ {
17
+ "sourceIdentfier":"7460",
18
+ "nameAccordingTo":"NCBI Taxonomy",
19
+ "scientificName":"Apis mellifera",
20
+ "identifier":29080011
21
+ }
22
+ ],
23
+ "dataObjects":
24
+ [
25
+ {
26
+ "mediaURL":"http://upload.wikimedia.org/wikipedia/commons/thumb/c/cd/Honeybee-27527-1.jpg/460px-Honeybee-27527-1.jpg",
27
+ "modified":"0000-00-00 00:00:00",
28
+ "title":"File:Honeybee-27527-1.jpg",
29
+ "license":"http://creativecommons.org/licenses/publicdomain/",
30
+ "mimeType":null,
31
+ "eolMediaURL":"http://content8.eol.org/content/2009/09/15/14/65086_large.jpg",
32
+ "language":"en",
33
+ "dataType":"http://purl.org/dc/dcmitype/StillImage",
34
+ "agents":
35
+ [
36
+ {
37
+ "role":"provider",
38
+ "homepage":"http://commons.wikimedia.org/",
39
+ "full_name":"Wikimedia Commons"
40
+ },
41
+ {
42
+ "role":"photographer",
43
+ "homepage":"http://commons.wikimedia.org/wiki/User:Ken_Thomas",
44
+ "full_name":"Ken Thomas"
45
+ }
46
+ ],
47
+ "eolThumbnailURL":"http://content9.eol.org/content/2009/09/15/14/65086_medium.jpg",
48
+ "description":"<a href='http://en.wikipedia.org/wiki/Apis mellifera ligustica'>Italian honeybee</a> (<i>Apis mellifera ligustica</i>) <a href='http://en.wikipedia.org/wiki/Worker_bee'>worker</a>.<br>Photo taken with a <a href='http://en.wikipedia.org/wiki/Panasonic_Lumix_DMC-FZ50'>Panasonic Lumix DMC-FZ50</a> (with a <a href='http://en.wikipedia.org/wiki/Tiffen'>Tiffen</a> +4 <a href='http://en.wikipedia.org/wiki/Close-up_lens'>Dioptic Lens</a>) in <a href='http://en.wikipedia.org/wiki/Caldwell_County%2C_North_Carolina'>Caldwell County, USA</a>.",
49
+ "source":"http://commons.wikimedia.org/wiki/File:Honeybee-27527-1.jpg",
50
+ "identifier":"5bd05f95cc663ef658a6cbd33e8f3e8d",
51
+ "references":
52
+ [
53
+ ],
54
+ "created":"0000-00-00 00:00:00"
55
+ },
56
+ {
57
+ "mediaURL":"http://farm3.static.flickr.com/2619/3730360050_1336b71208.jpg",
58
+ "modified":"0000-00-00 00:00:00",
59
+ "latitude":"39.989368",
60
+ "location":"Yorklyn, Pennsylvania, United States",
61
+ "title":"Honey Bee on Mountain Mint",
62
+ "license":"http://creativecommons.org/licenses/by/2.0/",
63
+ "mimeType":"image/jpeg",
64
+ "eolMediaURL":"http://content10.eol.org/content/2009/08/26/01/47113_large.jpg",
65
+ "language":"en",
66
+ "dataType":"http://purl.org/dc/dcmitype/StillImage",
67
+ "agents":
68
+ [
69
+ {
70
+ "role":"provider",
71
+ "homepage":"http://www.flickr.com/groups/encyclopedia_of_life",
72
+ "full_name":"EOL Images Group on Flickr"
73
+ },
74
+ {
75
+ "role":"photographer",
76
+ "homepage":"http://www.flickr.com/photos/38875278@N08",
77
+ "full_name":"John Baker"
78
+ }
79
+ ],
80
+ "eolThumbnailURL":"http://content1.eol.org/content/2009/08/26/01/47113_medium.jpg",
81
+ "longitude":"-76.648567",
82
+ "description":"A honey bee (Apis mellifera) visiting a mountain mint (Pycnanthemum muticum) blossom.&nbsp;&nbsp;The Pennsylvania Department of Agriculture is conducting a citizen scientist native bee monitoring project that will ultimately allow us ( The Pa Dept of Ag) to make reccommendations to gardeners as to what kind of plants they should plant in a garden to make it pollinator friendly.&nbsp;&nbsp;The project is in part funded by Haagen--Dazs. For more information please visit:&nbsp;<a href=\"http://www.helpthehoneybees.com\" rel=\"nofollow\">www.helpthehoneybees.com</a>&nbsp;&nbsp;For information on the Penn State Master Gardeners,
83
+ please visit: &nbsp;horticulture.psu.edu/extension/mg&quot;",
84
+ "source":"http://www.flickr.com/photos/38875278@N08/3730360050/",
85
+ "identifier":"d72801627bf4adf1a38d9c5f10cc767f",
86
+ "references":
87
+ [
88
+ ],
89
+ "created":"2009-07-12 11:13:19"
90
+ },
91
+ {
92
+ "modified":"0000-00-00 00:00:00",
93
+ "title":"Biology",
94
+ "rights":"Copyright Wildscreen 2003-2008",
95
+ "license":"http://creativecommons.org/licenses/by-nc-sa/3.0/",
96
+ "mimeType":"text/html",
97
+ "language":"en",
98
+ "dataType":"http://purl.org/dc/dcmitype/Text",
99
+ "agents":
100
+ [
101
+ {
102
+ "role":"provider",
103
+ "homepage":"http://www.arkive.org/",
104
+ "full_name":"ARKive"
105
+ }
106
+ ],
107
+ "subject":"http://rs.tdwg.org/ontology/voc/SPMInfoItems#TaxonBiology",
108
+ "rightsHolder":"Wildscreen",
109
+ "description":"The hive structure consists of wax 'honeycombs',
110
+ each honeycomb is made of small cells,
111
+ which are used to store food or to rear the brood. Bees feed on nectar and pollen taken from flowers; stores of honey (regurgitated nectar) and pollen (gathered on the legs in special 'pollen baskets') see them through the winter (5). Honey bees have a complex system of communication; when a good supply of flowers has been discovered,
112
+ a returning forager can convey the location of the food to other workers by means of special dances. The discovery of a good foraging location is announced by the 'round dance' in which the forager circles around rapidly,
113
+ while the 'waggle dance',
114
+ involving a rapid movement of the tail,
115
+ contains information on the distance and direction of the flowers in relation to the hive,
116
+ using the sun as a compass (5).&nbsp;The queen is the only bee within the colony to lay eggs,
117
+ the workers care for the brood,
118
+ and carry out many other duties for the hive,
119
+ including foraging and cleaning (5). The queen mates just once,
120
+ on a 'nuptial flight' during spring,
121
+ and stores enough sperm inside her body to allow her to fertilise her eggs for the rest of her life. Eggs are laid from March to October; each egg is deposited into a cell,
122
+ and a small,
123
+ white larva emerges after around 3 days. Workers provide the larva with food; after 6 days the pupal stage will develop,
124
+ and the workers cap the cells containing fully developed larvae with wax. The adult bee will climb out of the cell 12 days later. Drones (males) are produced from unfertilised eggs,
125
+ and appear in the colony during spring and early summer; they take three days longer to develop into adults than workers,
126
+ and are ejected from the colony later in the year by the workers (5). Both worker and queen bee larvae are fed on a rich liquid known as 'royal jelly' in the first days of life. Workers are then fed on pollen and nectar,
127
+ but larvae that continue to be given royal jelly develop into queens. The first new queen to emerge may sting the other developing queens to death. After mating she may either take the place of her mother (who may have departed the hive in a swarm,
128
+ taking half of the workers with her),
129
+ or establish a new colony (5).",
130
+ "source":"http://www.arkive.org/honey-bee/apis-mellifera/",
131
+ "identifier":"8ad9be27871b41c112353d179130cf27",
132
+ "references":
133
+ [
134
+ ],
135
+ "created":"0000-00-00 00:00:00"
136
+ },
137
+ {
138
+ "modified":"0000-00-00 00:00:00",
139
+ "title":"Groups vote on hive locations: honeybees",
140
+ "rights":"\u00a92008-2009,
141
+ The Biomimicry Institute",
142
+ "license":"http://creativecommons.org/licenses/by-nc/3.0/",
143
+ "mimeType":"text/html",
144
+ "language":"en",
145
+ "dataType":"http://purl.org/dc/dcmitype/Text",
146
+ "agents":
147
+ [
148
+ {
149
+ "role":"provider",
150
+ "homepage":"http://www.AskNature.org/",
151
+ "full_name":"AskNature"
152
+ },
153
+ {
154
+ "role":"editor",
155
+ "homepage":"",
156
+ "full_name":"Aron Kisdi"
157
+ }
158
+ ],
159
+ "subject":"http://rs.tdwg.org/ontology/voc/SPMInfoItems#GeneralDescription",
160
+ "rightsHolder":"The Biomimicry Institute",
161
+ "description":"&nbsp; <p><strong>Honeybees in a colony select a new hive location via range voting.</strong></p>&nbsp; <div><a href=\"http://www.asknature.org/browse/type/aof/selected/strategy%7C921\">Maintain community</a> &gt; <a href=\"http://www.asknature.org/browse/type/aof/selected/strategy%7C921%7C946\">Cooperate and compete</a> &gt; <a href=\"http://www.asknature.org/browse/type/aof/selected/strategy%7C921%7C946%7C951\"><strong>Within the same species</strong></a>&nbsp;</div>&nbsp;<br/>&nbsp; <a href=\"http://www.youtube.com/watch?v=NFdUahlyHGI\" target=\"_blank\"><img class=\"wiser left\" src=\"http://www.asknature.org/images/icons/play_video.png\" alt=\"\" width=\"33\" height=\"33\" /></a> <a href=\"http://www.youtube.com/watch?v=NFdUahlyHGI\" target=\"_blank\"> View this animation of bee voting</a>,
162
+ a collaboration of Sweet Onion Creations and The Biomimicry Institute.<br /><br /><br />\"Thomas Seeley,
163
+ a biologist at Cornell University,
164
+ has been looking into the uncanny ability of honeybees to make good decisions. With as many as 50,
165
+ 000 workers in a single hive,
166
+ honeybees have evolved ways to work through individual differences of opinion to do what's best for the colony. If only people could be as effective in boardrooms,
167
+ church committees,
168
+ and town meetings,
169
+ Seeley says,
170
+ we could avoid problems making decisions in our own lives. <br /><br />\"During the past decade,
171
+ Seeley,
172
+ Kirk Visscher of the University of California,
173
+ Riverside,
174
+ and others have been studying colonies of honeybees (<em>Apis mellifera</em>) to see how they choose a new home. In late spring,
175
+ when a hive gets too crowded,
176
+ a colony normally splits,
177
+ and the queen,
178
+ some drones,
179
+ and about half the workers fly a short distance to cluster on a tree branch. There the bees bivouac while a small percentage of them go searching for new real estate. Ideally,
180
+ the site will be a cavity in a tree,
181
+ well off the ground,
182
+ with a small entrance hole facing south,
183
+ and lots of room inside for brood and honey. Once a colony selects a site,
184
+ it usually won't move again,
185
+ so it has to make the right choice.<br /><br />\"To find out how,
186
+ Seeley's team applied paint dots and tiny plastic tags to identify all 4,
187
+ 000 bees in each of several small swarms that they ferried to Appledore Island,
188
+ home of the Shoals Marine Laboratory. There,
189
+ in a series of experiments,
190
+ they released each swarm to locate nest boxes they'd placed on one side of the half-mile-long (one kilometer) island,
191
+ which has plenty of shrubs but almost no trees or other places for nests.<br /><br />\"In one test they put out five nest boxes,
192
+ four that weren't quite big enough and one that was just about perfect. Scout bees soon appeared at all five. When they returned to the swarm,
193
+ each performed a waggle dance urging other scouts to go have a look. (These dances include a code giving directions to a box's location.) The strength of each dance reflected the scout's enthusiasm for the site. After a while,
194
+ dozens of scouts were dancing their little feet off,
195
+ some for one site,
196
+ some for another,
197
+ and a small cloud of bees was buzzing around each box.<br /><br />\"The decisive moment didn't take place in the main cluster of bees,
198
+ but out at the boxes,
199
+ where scouts were building up. As soon as the number of scouts visible near the entrance to a box reached about 15&mdash;a threshold confirmed by other experiments&mdash;the bees at that box sensed that a quorum had been reached,
200
+ and they returned to the swarm with the news. <br /><br />\"'It was a race,
201
+ ' Seeley says. 'Which site was going to build up 15 bees first?' <br /><br />\"Scouts from the chosen box then spread through the swarm,
202
+ signaling that it was time to move. Once all the bees had warmed up,
203
+ they lifted off for their new home,
204
+ which,
205
+ to no one's surprise,
206
+ turned out to be the best of the five boxes.<br /><br />\"The bees' rules for decision-making&mdash;seek a diversity of options,
207
+ encourage a free competition among ideas,
208
+ and use an effective mechanism to narrow choices&mdash;so impressed Seeley that he now uses them at Cornell as chairman of his department.\" (Miller 2007:4-5)<br /><br/>&nbsp; <a class=\"external_link\" href=\"http://www.asknature.org/strategy/209b5fa3de3573d76df73854f1cd9dba\">Learn more about this functional adaptation.</a>",
209
+ "source":"http://www.asknature.org/strategy/209b5fa3de3573d76df73854f1cd9dba",
210
+ "identifier":"45deb1b01be4aa3cbfa93a2b8c7bbd10",
211
+ "references":
212
+ [
213
+ "Miller,
214
+ Peter. July. The Genius of Swarms. National Geographic."
215
+ ],
216
+ "created":"2008-11-02 06:18:53"
217
+ },
218
+ {
219
+ "mediaURL":"http://www.flickr.com/apps/video/stewart.swf?v=71377&photo_id=3236419704&photo_secret=68be62ac11",
220
+ "modified":"0000-00-00 00:00:00",
221
+ "latitude":"37.287574",
222
+ "location":"Faro,
223
+ Portugal",
224
+ "title":"Abelhas numa Azinheira // Honey Bees on a Holm Oak (Apis mellifera)",
225
+ "license":"http://creativecommons.org/licenses/by-nc-sa/2.0/",
226
+ "mimeType":"video/x-flv",
227
+ "language":"en",
228
+ "dataType":"http://purl.org/dc/dcmitype/MovingImage",
229
+ "agents":
230
+ [
231
+ {
232
+ "role":"provider",
233
+ "homepage":"http://www.flickr.com/groups/encyclopedia_of_life",
234
+ "full_name":"EOL Images Group on Flickr"
235
+ },
236
+ {
237
+ "role":"photographer",
238
+ "homepage":"http://www.flickr.com/photos/58213213@N00",
239
+ "full_name":"Valter Jacinto"
240
+ }
241
+ ],
242
+ "longitude":"-7.500743",
243
+ "description":"<b>Location</b>: Azinhal &gt; Castro Marim &gt; Algarve &gt; Portugal&nbsp;&nbsp;<b>Recording Date</b>: January 24,
244
+ 2009&nbsp;",
245
+ "source":"http://www.flickr.com/photos/valter/3236419704/",
246
+ "identifier":"e70cb321fd2933d4db48b6c41271068b",
247
+ "references":
248
+ [
249
+ ],
250
+ "created":"2009-01-24 11:44:09"
251
+ },
252
+ {
253
+ "mediaURL":"http://www.flickr.com/apps/video/stewart.swf?v=71377&photo_id=3272354945&photo_secret=5d62f7dda0",
254
+ "modified":"0000-00-00 00:00:00",
255
+ "latitude":"-27.6223",
256
+ "location":"Hodgson Vale,
257
+ Queensland,
258
+ Australia",
259
+ "title":"Apis mellifera (European Honeybee) - Introduced",
260
+ "license":"http://creativecommons.org/licenses/by-nc-sa/2.0/",
261
+ "mimeType":"video/x-flv",
262
+ "language":"en",
263
+ "dataType":"http://purl.org/dc/dcmitype/MovingImage",
264
+ "agents":
265
+ [
266
+ {
267
+ "role":"provider",
268
+ "homepage":"http://www.flickr.com/groups/encyclopedia_of_life",
269
+ "full_name":"EOL Images Group on Flickr"
270
+ },
271
+ {
272
+ "role":"photographer",
273
+ "homepage":"http://www.flickr.com/photos/32005048@N06",
274
+ "full_name":"Arthur Chapman"
275
+ }
276
+ ],
277
+ "longitude":"151.9376",
278
+ "description":"European Honeybee (Apis mellifera) - an introduced species near Toowoomba,
279
+ Queensland,
280
+ Australia. Photographed on 3 February 2005.&nbsp;&nbsp;High quality .avi files are held and may be available by individual request.",
281
+ "source":"http://www.flickr.com/photos/arthur_chapman/3272354945/",
282
+ "identifier":"24cd66d45036306efa84c5792ba99c14",
283
+ "references":
284
+ [
285
+ ],
286
+ "created":"2005-02-03 15:25:07"
287
+ }
288
+ ],
289
+ "scientificName":"Apis mellifera Linnaeus 1758",
290
+ "identifier":1045608,
291
+ "vernacularNames":
292
+ [
293
+ {
294
+ "vernacularName":"\u041c\u0435\u0434\u043e\u043d\u043e\u0441\u043d\u0430 \u043f\u0447\u0435\u043b\u0430",
295
+ "language":"bg"
296
+ },
297
+ {
298
+ "vernacularName":"V\u010dela medonosn\u00e1",
299
+ "language":"cs"
300
+ },
301
+ {
302
+ "vernacularName":"Honningbi",
303
+ "language":"da"
304
+ },
305
+ {
306
+ "vernacularName":"honey bee",
307
+ "language":"en"
308
+ },
309
+ {
310
+ "vernacularName":"Tarhamehil\u00e4inen",
311
+ "language":"fi"
312
+ },
313
+ {
314
+ "vernacularName":"abeille domestique",
315
+ "language":"fr"
316
+ },
317
+ {
318
+ "vernacularName":"Honigbiene",
319
+ "language":"de"
320
+ },
321
+ {
322
+ "vernacularName":"\u05d3\u05d1\u05d5\u05e8\u05ea \u05d4\u05d3\u05d1\u05e9",
323
+ "language":"he"
324
+ },
325
+ {
326
+ "vernacularName":"M\u00e9zel\u0151 m\u00e9h",
327
+ "language":"hu"
328
+ },
329
+ {
330
+ "vernacularName":"Alib\u00fdfluga",
331
+ "language":"is"
332
+ },
333
+ {
334
+ "vernacularName":"ape del miele",
335
+ "language":"it"
336
+ },
337
+ {
338
+ "vernacularName":"\u30bb\u30a4\u30e8\u30a6\u30df\u30c4\u30d0\u30c1",
339
+ "language":"ja"
340
+ },
341
+ {
342
+ "vernacularName":"Eiropas medus bite",
343
+ "language":"lv"
344
+ },
345
+ {
346
+ "vernacularName":"Europeisk honningbie",
347
+ "language":"nn"
348
+ },
349
+ {
350
+ "vernacularName":"Pszczo\u0142a miodna",
351
+ "language":"pl"
352
+ },
353
+ {
354
+ "vernacularName":"abelha do mel",
355
+ "language":"pt"
356
+ },
357
+ {
358
+ "vernacularName":"\u041c\u0435\u0434\u043e\u043d\u043e\u0441\u043d\u0430\u044f \u043f\u0447\u0435\u043b\u0430",
359
+ "language":"ru"
360
+ },
361
+ {
362
+ "vernacularName":"V\u010dela medonosn\u00e1",
363
+ "language":"sk"
364
+ },
365
+ {
366
+ "vernacularName":"Apis mellifera",
367
+ "language":"es"
368
+ },
369
+ {
370
+ "vernacularName":"\u0411\u0434\u0436\u043e\u043b\u0430 \u043c\u0435\u0434\u043e\u043d\u043e\u0441\u043d\u0430",
371
+ "language":"uk"
372
+ },
373
+ {
374
+ "vernacularName":"Huningbij",
375
+ "language":"fy"
376
+ }
377
+ ]
378
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "response":
3
+ {
4
+ "message":"Success"
5
+ }
6
+ }
@@ -0,0 +1,36 @@
1
+ {
2
+ "results":
3
+ [
4
+ {
5
+ "title":"Ursus",
6
+ "id":14349,
7
+ "content":"Ursus Linnaeus, 1758",
8
+ "link":"http://www.eol.org/pages/14349"
9
+ },
10
+ {
11
+ "title":"Megathymus ursus ursus Poling 1902",
12
+ "id":2683230,
13
+ "content":"Megathymus ursus ursus Poling 1902",
14
+ "link":"http://www.eol.org/pages/2683230"
15
+ },
16
+ {
17
+ "title":"Ursus arctor",
18
+ "id":10695434,
19
+ "content":"Ursus arctor\n\n",
20
+ "link":"http://www.eol.org/pages/10695434"
21
+ },
22
+ {
23
+ "title":"Ursus ingressus",
24
+ "id":12136362,
25
+ "content":"Ursus ingressus\n\n",
26
+ "link":"http://www.eol.org/pages/12136362"
27
+ }
28
+ ],
29
+ "totalResults":126,
30
+ "self":"http://www.eol.org/api/search/Ursus.json?page=1",
31
+ "itemsPerPage":30,
32
+ "last":"http://www.eol.org/api/search/Ursus.json?page=5",
33
+ "startIndex":1,
34
+ "first":"http://www.eol.org/api/search/Ursus.json?page=1",
35
+ "next":"http://www.eol.org/api/search/Ursus.json?page=2"
36
+ }
@@ -0,0 +1,25 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+ require 'rspec'
4
+ require 'eoflife'
5
+ require 'webmock/rspec'
6
+ require 'json'
7
+
8
+ # Requires supporting files with custom matchers and macros, etc,
9
+ # in ./support/ and its subdirectories.
10
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
11
+
12
+ RSpec.configure do |config|
13
+
14
+ end
15
+
16
+ def fixture_file(filename)
17
+ return '' if filename == ''
18
+ file_path = File.expand_path(File.dirname(__FILE__) + '/fixtures/' + filename)
19
+ JSON.parse(File.read(file_path))
20
+ end
21
+
22
+ def stub_endpoint(endpoint, expected_data)
23
+ stub_request(:get, endpoint)
24
+ .to_return(:status => 200, :body => fixture_file(expected_data), :headers => {})
25
+ end
metadata ADDED
@@ -0,0 +1,181 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: eoflife
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: 6
5
+ version: 0.1.0.pre
6
+ platform: ruby
7
+ authors:
8
+ - Marc Chung
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-03-12 00:00:00 -07:00
14
+ default_executable:
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: httparty
18
+ requirement: &id001 !ruby/object:Gem::Requirement
19
+ none: false
20
+ requirements:
21
+ - - ~>
22
+ - !ruby/object:Gem::Version
23
+ version: "0.7"
24
+ type: :runtime
25
+ prerelease: false
26
+ version_requirements: *id001
27
+ - !ruby/object:Gem::Dependency
28
+ name: hashie
29
+ requirement: &id002 !ruby/object:Gem::Requirement
30
+ none: false
31
+ requirements:
32
+ - - ~>
33
+ - !ruby/object:Gem::Version
34
+ version: 1.0.0
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: *id002
38
+ - !ruby/object:Gem::Dependency
39
+ name: rspec
40
+ requirement: &id003 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 2.3.0
46
+ type: :development
47
+ prerelease: false
48
+ version_requirements: *id003
49
+ - !ruby/object:Gem::Dependency
50
+ name: yard
51
+ requirement: &id004 !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ~>
55
+ - !ruby/object:Gem::Version
56
+ version: 0.6.0
57
+ type: :development
58
+ prerelease: false
59
+ version_requirements: *id004
60
+ - !ruby/object:Gem::Dependency
61
+ name: cucumber
62
+ requirement: &id005 !ruby/object:Gem::Requirement
63
+ none: false
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: "0"
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: *id005
71
+ - !ruby/object:Gem::Dependency
72
+ name: bundler
73
+ requirement: &id006 !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ~>
77
+ - !ruby/object:Gem::Version
78
+ version: 1.0.0
79
+ type: :development
80
+ prerelease: false
81
+ version_requirements: *id006
82
+ - !ruby/object:Gem::Dependency
83
+ name: jeweler
84
+ requirement: &id007 !ruby/object:Gem::Requirement
85
+ none: false
86
+ requirements:
87
+ - - ~>
88
+ - !ruby/object:Gem::Version
89
+ version: 1.5.2
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: *id007
93
+ - !ruby/object:Gem::Dependency
94
+ name: rcov
95
+ requirement: &id008 !ruby/object:Gem::Requirement
96
+ none: false
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: "0"
101
+ type: :development
102
+ prerelease: false
103
+ version_requirements: *id008
104
+ - !ruby/object:Gem::Dependency
105
+ name: webmock
106
+ requirement: &id009 !ruby/object:Gem::Requirement
107
+ none: false
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: 1.6.2
112
+ type: :development
113
+ prerelease: false
114
+ version_requirements: *id009
115
+ description: Programmatic access to the Encylopedia of Life's API
116
+ email: mchung@gmail.com
117
+ executables: []
118
+
119
+ extensions: []
120
+
121
+ extra_rdoc_files:
122
+ - LICENSE.txt
123
+ - README.rdoc
124
+ files:
125
+ - .document
126
+ - .rspec
127
+ - .rvmrc
128
+ - Gemfile
129
+ - Gemfile.lock
130
+ - LICENSE.txt
131
+ - README.rdoc
132
+ - Rakefile
133
+ - examples/pages.rb
134
+ - examples/ping.rb
135
+ - examples/search.rb
136
+ - lib/eoflife.rb
137
+ - lib/eoflife/client.rb
138
+ - lib/eoflife/error.rb
139
+ - lib/eoflife/version.rb
140
+ - spec/eoflife_spec.rb
141
+ - spec/fixtures/pages.json
142
+ - spec/fixtures/ping.json
143
+ - spec/fixtures/search.json
144
+ - spec/spec_helper.rb
145
+ has_rdoc: true
146
+ homepage: http://github.com/mchung/eoflife
147
+ licenses:
148
+ - MIT
149
+ post_install_message:
150
+ rdoc_options: []
151
+
152
+ require_paths:
153
+ - lib
154
+ required_ruby_version: !ruby/object:Gem::Requirement
155
+ none: false
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ hash: -719393837
160
+ segments:
161
+ - 0
162
+ version: "0"
163
+ required_rubygems_version: !ruby/object:Gem::Requirement
164
+ none: false
165
+ requirements:
166
+ - - ">"
167
+ - !ruby/object:Gem::Version
168
+ version: 1.3.1
169
+ requirements: []
170
+
171
+ rubyforge_project:
172
+ rubygems_version: 1.5.2
173
+ signing_key:
174
+ specification_version: 3
175
+ summary: API for the Encylopedia of Life
176
+ test_files:
177
+ - examples/pages.rb
178
+ - examples/ping.rb
179
+ - examples/search.rb
180
+ - spec/eoflife_spec.rb
181
+ - spec/spec_helper.rb