WebService-CIA-1.4004075500017510000120000000000001074577407600121205ustar ianwwwWebService-CIA-1.4/webservice-cia-makedbm.pl010044400017510000120000000106541074577407600170230ustar ianwww#!/usr/bin/perl -w use strict; use WebService::CIA::Source::Web; use WebService::CIA::Source::DBM; my $dbm = WebService::CIA::Source::DBM->new({ DBM => 'factbook.dbm', Mode => 'readwrite' }); my $web = WebService::CIA::Source::Web->new(); chomp (my @data = ); for (my $i = 0; $i < scalar @data; $i++) { next unless $data[$i]; my ($cc, $name) = split /:/, $data[$i]; printf "%3d/%3d %s (%s) ... ", $i + 1, scalar @data, $name, $cc; my $vals = $web->all($cc); if (scalar keys %$vals > 0) { $dbm->set($cc, $vals); print "done\n"; } else { print "no data found\n"; } } __DATA__ af:Afghanistan al:Albania ag:Algeria aq:American Samoa an:Andorra ao:Angola av:Anguilla ay:Antarctica ac:Antigua and Barbuda xq:Arctic Ocean ar:Argentina am:Armenia aa:Aruba at:Ashmore and Cartier Islands zh:Atlantic Ocean as:Australia au:Austria aj:Azerbaijan bf:Bahamas, The ba:Bahrain fq:Baker Island bg:Bangladesh bb:Barbados bs:Bassas da India bo:Belarus be:Belgium bh:Belize bn:Benin bd:Bermuda bt:Bhutan bl:Bolivia bk:Bosnia and Herzegovina bc:Botswana bv:Bouvet Island br:Brazil io:British Indian Ocean Territory vi:British Virgin Islands bx:Brunei bu:Bulgaria uv:Burkina Faso bm:Burma by:Burundi cb:Cambodia cm:Cameroon ca:Canada cv:Cape Verde cj:Cayman Islands ct:Central African Republic cd:Chad ci:Chile ch:China kt:Christmas Island ip:Clipperton Island ck:Cocos (Keeling) Islands co:Colombia cn:Comoros cg:Congo, Democratic Republic of the cf:Congo, Republic of the cw:Cook Islands cr:Coral Sea Islands cs:Costa Rica iv:Cote d'Ivoire hr:Croatia cu:Cuba cy:Cyprus ez:Czech Republic da:Denmark dj:Djibouti do:Dominica dr:Dominican Republic tt:East Timor ec:Ecuador eg:Egypt es:El Salvador ek:Equatorial Guinea er:Eritrea en:Estonia et:Ethiopia eu:Europa Island fk:Falkland Islands (Islas Malvinas) fo:Faroe Islands fj:Fiji fi:Finland fr:France fg:French Guiana fp:French Polynesia fs:French Southern and Antarctic Lands gb:Gabon ga:Gambia, The gz:Gaza Strip gg:Georgia gm:Germany gh:Ghana gi:Gibraltar go:Glorioso Islands gr:Greece gl:Greenland gj:Grenada gp:Guadeloupe gq:Guam gt:Guatemala gk:Guernsey gv:Guinea pu:Guinea-Bissau gy:Guyana ha:Haiti hm:Heard Island and McDonald Islands vt:Holy See (Vatican City) ho:Honduras hk:Hong Kong hq:Howland Island hu:Hungary ic:Iceland in:India xo:Indian Ocean id:Indonesia ir:Iran iz:Iraq ei:Ireland is:Israel it:Italy jm:Jamaica jn:Jan Mayen ja:Japan dq:Jarvis Island je:Jersey jq:Johnston Atoll jo:Jordan ju:Juan de Nova Island kz:Kazakhstan ke:Kenya kq:Kingman Reef kr:Kiribati kn:Korea, North ks:Korea, South ku:Kuwait kg:Kyrgyzstan la:Laos lg:Latvia le:Lebanon lt:Lesotho li:Liberia ly:Libya ls:Liechtenstein lh:Lithuania lu:Luxembourg mc:Macau mk:Macedonia, The Former Yugoslav Republic of ma:Madagascar mi:Malawi my:Malaysia mv:Maldives ml:Mali mt:Malta im:Man, Isle of rm:Marshall Islands mb:Martinique mr:Mauritania mp:Mauritius mf:Mayotte mx:Mexico fm:Micronesia, Federated States of mq:Midway Islands md:Moldova mn:Monaco mg:Mongolia mh:Montserrat mo:Morocco mz:Mozambique wa:Namibia nr:Nauru bq:Navassa Island np:Nepal nl:Netherlands nt:Netherlands Antilles nc:New Caledonia nz:New Zealand nu:Nicaragua ng:Niger ni:Nigeria ne:Niue nf:Norfolk Island cq:Northern Mariana Islands no:Norway mu:Oman zn:Pacific Ocean pk:Pakistan ps:Palau lq:Palmyra Atoll pm:Panama pp:Papua New Guinea pf:Paracel Islands pa:Paraguay pe:Peru rp:Philippines pc:Pitcairn Islands pl:Poland po:Portugal rq:Puerto Rico qa:Qatar re:Reunion ro:Romania rs:Russia rw:Rwanda sh:Saint Helena sc:Saint Kitts and Nevis st:Saint Lucia sb:Saint Pierre and Miquelon vc:Saint Vincent and the Grenadines ws:Samoa sm:San Marino tp:Sao Tome and Principe sa:Saudi Arabia sg:Senegal yi:Serbia and Montenegro se:Seychelles sl:Sierra Leone sn:Singapore lo:Slovakia si:Slovenia bp:Solomon Islands so:Somalia sf:South Africa sx:South Georgia and the South Sandwich Islands oo:Southern Ocean sp:Spain pg:Spratly Islands ce:Sri Lanka su:Sudan ns:Suriname sv:Svalbard wz:Swaziland sw:Sweden sz:Switzerland sy:Syria ti:Tajikistan tz:Tanzania th:Thailand to:Togo tl:Tokelau tn:Tonga td:Trinidad and Tobago te:Tromelin Island ts:Tunisia tu:Turkey tx:Turkmenistan tk:Turks and Caicos Islands tv:Tuvalu ug:Uganda up:Ukraine tc:United Arab Emirates uk:United Kingdom us:United States uy:Uruguay uz:Uzbekistan nh:Vanuatu ve:Venezuela vm:Vietnam vq:Virgin Islands wq:Wake Island wf:Wallis and Futuna we:West Bank wi:Western Sahara xx:World ym:Yemen za:Zambia zi:Zimbabwe tw:Taiwan WebService-CIA-1.4/Changes010044400017510000120000000024301074577407600134640ustar ianwww0.02 2006-07-30 - Added call to env_proxy for web access. [rt.cpan.org #17083, thanks to Gary Ashton-Jones] - Changed web source to use HTTPS URLs. [rt.cpan.org #20762, thanks to Graham Stead] 1.0 2006-08-07 - Added README. - Added POD and POD coverage tests. - Fixed 0.02 release date in Changes. - Bumped version to 1.0, because 0.0x just gets silly after a while. 1.1 2007-03-02 - Fixed some HTTP URLs I'd missed (mostly in POD). [Thanks to Robert Henniger] - Fixed distribution tar file. - Added some examples, shipped POD tests, and other Kwalitee-improving changes. 1.2 2007-06-03 - Fixed URLs (Factbook had moved). - Added $WebService::CIA::base_url and changed modules to use it. - Added tests for generated URLs (flag URL, etc.) - Renamed some tests. - Fixed typo, email address, and copyright. 1.3 2007-12-03 - Minor tweaks from Perl::Critic - Added "use warnings" to WebService::CIA::Source::DBM - Fixed error in documentation for WebService::CIA::Source::DBM 1.4 2008-01-16 - Fixed incorrect print URLs - Added last_response() method to WebService::CIA::Source::Web - Added option to submit own user agent for web source - Restructured tests to use TEST_INTERNET env var rather than build option WebService-CIA-1.4/t004075500017510000120000000000001074577407600123635ustar ianwwwWebService-CIA-1.4/t/webservice-cia-source-web.t010044400017510000120000000060151074577407600175650ustar ianwwwuse strict; use Test::More tests => 30; use lib qw( t/lib ); use WCUA; use Module::Build; my $build = Module::Build->current(); BEGIN { use_ok('WebService::CIA::Source::Web'); } my $source; eval { $source = WebService::CIA::Source::Web->new( 'foo' ); }; ok( $@ ); ok( $@ =~ /^\QArguments to new() must be a hashref\E/ ); $source = WebService::CIA::Source::Web->new; ok( defined $source, 'new() - returns something' ); ok( $source->isa('WebService::CIA::Source::Web'), 'new() - returns a WebService::CIA::Source::Web object' ); ok( ref $source->ua eq 'LWP::UserAgent', 'ua() - returns LWP::UserAgent object' ); is( ref $source->ua( WCUA->new ), 'WCUA', 'ua() returns set object' ); is( ref $source->ua(), 'WCUA', 'ua() stores object correctly' ); $source = WebService::CIA::Source::Web->new( { user_agent => WCUA->new } ); is( ref $source->ua(), 'WCUA', 'new() takes user_agent arg correctly' ); ok( ref $source->parser eq 'WebService::CIA::Parser', 'parser() - returns WebService::CIA::Parser object' ); ok( $source->cached eq '', 'cached() - returns empty string after new()' ); ok( scalar keys %{$source->cache} == 0, 'cache() returns empty hashref after new()' ); $source->cached('testcountry'); ok( $source->cached eq 'testcountry', 'cached() - set data' ); $source->cache({'Test' => 'Wombat'}); ok( exists $source->cache->{'Test'} && $source->cache->{'Test'} eq 'Wombat', 'cache() - set data' ); ok( $source->value('testcountry','Test') eq 'Wombat', 'value() (manually set data) - valid args - return test string' ); ok( ! defined $source->value('testcountry','Blah'), 'value() (manually set data) - invalid args - return undef' ); ok( scalar keys %{$source->all('testcountry')} == 1 && exists $source->all('testcountry')->{'Test'} && $source->all('testcountry')->{'Test'} eq 'Wombat', 'all() (manually set data) - return expected values' ); ok( $source->get('testcountry') == 0, 'get() on bad country - returns 0' ); my $resp = $source->last_response; ok( $resp, "Stores last response" ); is( ref $resp, "HTTP::Response", "Right object" ); is( $resp->code, 404, "Right response" ); ok( $source->get('uk') == 1, 'get() - returns 1' ); $resp = $source->last_response; is( $resp->code, 200, "Right response" ); ok( $source->cached eq 'uk', 'cached() - cached country set correctly after get()' ); ok( scalar keys %{$source->cache} > 0 && exists $source->cache->{'Background'} && $source->cache->{'Background'}, 'cache() - cache contains values' ); ok( $source->value('uk','Background'), 'value() - valid args - returns a value' ); ok( ! defined $source->value('uk','Test'), 'value() (cached info) - invalid args - returns undef' ); ok( ! defined $source->value('testcountry', 'Test'), 'value() (non-cached info) - invalid args - returns undef' ); ok( scalar keys %{$source->all('uk')} > 0 && exists $source->all('uk')->{'Background'} && $source->all('uk')->{'Background'}, 'all() - valid args - returns hashref' ); ok( scalar keys %{$source->all('testcountry')} == 0, 'all() - invalid args - returns empty hashref' ); WebService-CIA-1.4/t/webservice-cia-source.t010044400017510000120000000014551074577407600170150ustar ianwwwuse strict; use Test::More tests => 7; #1 BEGIN { use_ok('WebService::CIA::Source'); } my $source = WebService::CIA::Source->new; #2 ok ( defined $source, 'new() - returns something' ); #3 ok ( $source->isa('WebService::CIA::Source'), 'new() - returns a WebService::CIA::Source object' ); #4 ok( ! defined $source->value('zz', 'Test'), 'value() - invalid args - returns undef' ); #5 ok( $source->value('testcountry', 'Test') eq 'Wombat', 'value() - valid args - returns test string' ); #6 ok( scalar keys %{$source->all('zz')} == 0, 'all() - invalid args - returns empty hashref' ); #7 ok( scalar keys %{$source->all('testcountry')} == 1 && exists $source->all('testcountry')->{'Test'} && $source->all('testcountry')->{'Test'} eq 'Wombat', 'all() - valid args - returns hashref with test value'); WebService-CIA-1.4/t/lib004075500017510000120000000000001074577407600131315ustar ianwwwWebService-CIA-1.4/t/lib/WCUA.pm010044400017510000120000001626771074577407600143230ustar ianwwwpackage WCUA; use strict; use warnings; use HTTP::Response; use base qw( LWP::UserAgent ); sub get { my ( $self, $url ) = @_; if ( $url =~ /uk\.html$/ ) { my $content = join "", ; return HTTP::Response->new( 200, "OK", undef, $content ); } else { return HTTP::Response->new( 404, "Meh" ); } } 1; __DATA__ CIA - The World Factbook -- United Kingdom
 
CIA Seal  World Factbook Seal United Kingdom
Flag of United Kingdom
Map of United Kingdom
Introduction United Kingdom
Background:
As the dominant industrial and maritime power of the 19th century, the United Kingdom of Great Britain and Ireland played a leading role in developing parliamentary democracy and in advancing literature and science. At its zenith, the British Empire stretched over one-fourth of the earth's surface. The first half of the 20th century saw the UK's strength seriously depleted in two World Wars and the Irish republic withdraw from the union. The second half witnessed the dismantling of the Empire and the UK rebuilding itself into a modern and prosperous European nation. As one of five permanent members of the UN Security Council, a founding member of NATO, and of the Commonwealth, the UK pursues a global approach to foreign policy; it currently is weighing the degree of its integration with continental Europe. A member of the EU, it chose to remain outside the Economic and Monetary Union for the time being. Constitutional reform is also a significant issue in the UK. The Scottish Parliament, the National Assembly for Wales, and the Northern Ireland Assembly were established in 1999, but the latter was suspended until May 2007 due to wrangling over the peace process.
Geography United Kingdom
Location:
Western Europe, islands including the northern one-sixth of the island of Ireland between the North Atlantic Ocean and the North Sea, northwest of France
Geographic coordinates:
54 00 N, 2 00 W
Map references:
Europe
Area:
total: 244,820 sq km
land: 241,590 sq km
water: 3,230 sq km
note: includes Rockall and Shetland Islands
Area - comparative:
slightly smaller than Oregon
Land boundaries:
total: 360 km
border countries: Ireland 360 km
Coastline:
12,429 km
Maritime claims:
territorial sea: 12 nm
exclusive fishing zone: 200 nm
continental shelf: as defined in continental shelf orders or in accordance with agreed upon boundaries
Climate:
temperate; moderated by prevailing southwest winds over the North Atlantic Current; more than one-half of the days are overcast
Terrain:
mostly rugged hills and low mountains; level to rolling plains in east and southeast
Elevation extremes:
lowest point: The Fens -4 m
highest point: Ben Nevis 1,343 m
Natural resources:
coal, petroleum, natural gas, iron ore, lead, zinc, gold, tin, limestone, salt, clay, chalk, gypsum, potash, silica sand, slate, arable land
Land use:
arable land: 23.23%
permanent crops: 0.2%
other: 76.57% (2005)
Irrigated land:
1,700 sq km (2003)
Total renewable water resources:
160.6 cu km (2005)
Freshwater withdrawal (domestic/industrial/agricultural):
Total: 11.75 cu km/yr (22%/75%/3%)
Per capita: 197 cu m/yr (1994)
Natural hazards:
winter windstorms; floods
Environment - current issues:
continues to reduce greenhouse gas emissions (has met Kyoto Protocol target of a 12.5% reduction from 1990 levels and intends to meet the legally binding target and move toward a domestic goal of a 20% cut in emissions by 2010); by 2005 the government reduced the amount of industrial and commercial waste disposed of in landfill sites to 85% of 1998 levels and recycled or composted at least 25% of household waste, increasing to 33% by 2015
Environment - international agreements:
party to: Air Pollution, Air Pollution-Nitrogen Oxides, Air Pollution-Persistent Organic Pollutants, Air Pollution-Sulfur 94, Air Pollution-Volatile Organic Compounds, Antarctic-Environmental Protocol, Antarctic-Marine Living Resources, Antarctic Seals, Antarctic Treaty, Biodiversity, Climate Change, Climate Change-Kyoto Protocol, Desertification, Endangered Species, Environmental Modification, Hazardous Wastes, Law of the Sea, Marine Dumping, Marine Life Conservation, Ozone Layer Protection, Ship Pollution, Tropical Timber 83, Tropical Timber 94, Wetlands, Whaling
signed, but not ratified: none of the selected agreements
Geography - note:
lies near vital North Atlantic sea lanes; only 35 km from France and linked by tunnel under the English Channel; because of heavily indented coastline, no location is more than 125 km from tidal waters
People United Kingdom
Population:
60,776,238 (July 2007 est.)
Age structure:
0-14 years: 17.2% (male 5,349,053/female 5,095,837)
15-64 years: 67% (male 20,605,031/female 20,104,313)
65 years and over: 15.8% (male 4,123,464/female 5,498,540) (2007 est.)
Median age:
total: 39.6 years
male: 38.5 years
female: 40.7 years (2007 est.)
Population growth rate:
0.275% (2007 est.)
Birth rate:
10.67 births/1,000 population (2007 est.)
Death rate:
10.09 deaths/1,000 population (2007 est.)
Net migration rate:
2.17 migrant(s)/1,000 population (2007 est.)
Sex ratio:
at birth: 1.05 male(s)/female
under 15 years: 1.05 male(s)/female
15-64 years: 1.025 male(s)/female
65 years and over: 0.75 male(s)/female
total population: 0.98 male(s)/female (2007 est.)
Infant mortality rate:
total: 5.01 deaths/1,000 live births
male: 5.58 deaths/1,000 live births
female: 4.4 deaths/1,000 live births (2007 est.)
Life expectancy at birth:
total population: 78.7 years
male: 76.23 years
female: 81.3 years (2007 est.)
Total fertility rate:
1.66 children born/woman (2007 est.)
HIV/AIDS - adult prevalence rate:
0.2% (2001 est.)
HIV/AIDS - people living with HIV/AIDS:
51,000 (2001 est.)
HIV/AIDS - deaths:
less than 500 (2003 est.)
Nationality:
noun: Briton(s), British (collective plural)
adjective: British
Ethnic groups:
white (of which English 83.6%, Scottish 8.6%, Welsh 4.9%, Northern Irish 2.9%) 92.1%, black 2%, Indian 1.8%, Pakistani 1.3%, mixed 1.2%, other 1.6% (2001 census)
Religions:
Christian (Anglican, Roman Catholic, Presbyterian, Methodist) 71.6%, Muslim 2.7%, Hindu 1%, other 1.6%, unspecified or none 23.1% (2001 census)
Languages:
English, Welsh (about 26% of the population of Wales), Scottish form of Gaelic (about 60,000 in Scotland)
Literacy:
definition: age 15 and over has completed five or more years of schooling
total population: 99%
male: 99%
female: 99% (2003 est.)
Government United Kingdom
Country name:
conventional long form: United Kingdom of Great Britain and Northern Ireland; note - Great Britain includes England, Scotland, and Wales
conventional short form: United Kingdom
abbreviation: UK
Government type:
constitutional monarchy
Capital:
name: London
geographic coordinates: 51 30 N, 0 10 W
time difference: UTC 0 (5 hours ahead of Washington, DC during Standard Time)
daylight saving time: +1hr, begins last Sunday in March; ends last Sunday in October
Administrative divisions:
England: 34 two-tier counties, 32 London boroughs and 1 City of London or Greater London, 36 metropolitan counties, 46 unitary authorities
two-tier counties: Bedfordshire, Buckinghamshire, Cambridgeshire, Cheshire, Cornwall and Isles of Scilly, Cumbria, Derbyshire, Devon, Dorset, Durham, East Sussex, Essex, Gloucestershire, Hampshire, Hertfordshire, Kent, Lancashire, Leicestershire, Lincolnshire, Norfolk, North Yorkshire, Northamptonshire, Northumberland, Nottinghamshire, Oxfordshire, Shropshire, Somerset, Staffordshire, Suffolk, Surrey, Warwickshire, West Sussex, Wiltshire, Worcestershire
London boroughs and City of London or Greater London: Barking and Dagenham, Barnet, Bexley, Brent, Bromley, Camden, Croydon, Ealing, Enfield, Greenwich, Hackney, Hammersmith and Fulham, Haringey, Harrow, Havering, Hillingdon, Hounslow, Islington, Kensington and Chelsea, Kingston upon Thames, Lambeth, Lewisham, City of London, Merton, Newham, Redbridge, Richmond upon Thames, Southwark, Sutton, Tower Hamlets, Waltham Forest, Wandsworth, Westminster
metropolitan counties: Barnsley, Birmingham, Bolton, Bradford, Bury, Calderdale, Coventry, Doncaster, Dudley, Gateshead, Kirklees, Knowlsey, Leeds, Liverpool, Manchester, Newcastle upon Tyne, North Tyneside, Oldham, Rochdale, Rotherham, Salford, Sandwell, Sefton, Sheffield, Solihull, South Tyneside, St. Helens, Stockport, Sunderland, Tameside, Trafford, Wakefield, Walsall, Wigan, Wirral, Wolverhampton
unitary authorities: Bath and North East Somerset, Blackburn with Darwen, Blackpool, Bournemouth, Bracknell Forest, Brighton and Hove, City of Bristol, Darlington, Derby, East Riding of Yorkshire, Halton, Hartlepool, County of Herefordshire, Ile of Wight, City of Kingston upon Hull, Leicester, Luton, Medway, Middlesbrough, Milton Keynes, North East Lincolnshire, North Lincolnshire, North Somerset, Nottingham, Peterborough, Plymouth, Poole, Portsmouth, Reading, Redcar and Cleveland, Rutland, Slough, South Gloucestershire, Southampton, Southend-on-Sea, Stockton-on-Tees, Stoke-on-Trent, Swindon, Telford and Wrekin, Thurrock, Torbay, Warrington, West Berkshire, Windsor and Maidenhead, Wokingham, York
Northern Ireland: 26 district council areas
district council areas: Antrim, Ards, Armagh, Ballymena, Ballymoney, Banbridge, Belfast, Carrickfergus, Castlereagh, Coleraine, Cookstown, Craigavon, Derry, Down, Dungannon, Fermanagh, Larne, Limavady, Lisburn, Magherafelt, Moyle, Newry and Mourne, Newtownabbey, North Down, Omagh, Strabane
Scotland: 32 unitary authorities
unitary authorities: Aberdeen City, Aberdeenshire, Angus, Argyll and Bute, Clackmannanshire, Dumfries and Galloway, Dundee City, East Ayrshire, East Dunbartonshire, East Lothian, East Renfrewshire, City of Edinburgh, Eilean Siar (Western Isles), Falkirk, Fife, Glasgow City, Highland, Inverclyde, Midlothian, Moray, North Ayrshire, North Lanarkshire, Orkney Islands, Perth and Kinross, Renfrewshire, Shetland Islands, South Ayrshire, South Lanarkshire, Stirling, The Scottish Borders, West Dunbartonshire, West Lothian
Wales: 22 unitary authorities
unitary authorities: Blaenau Gwent; Bridgend; Caerphilly; Cardiff; Carmarthenshire; Ceredigion; Conwy; Denbighshire; Flintshire; Gwynedd; Isle of Anglesey; Merthyr Tydfil; Monmouthshire; Neath Port Talbot; Newport; Pembrokeshire; Powys; Rhondda, Cynon, Taff; Swansea; The Vale of Glamorgan; Torfaen; Wrexham
Dependent areas:
Anguilla, Bermuda, British Indian Ocean Territory, British Virgin Islands, Cayman Islands, Falkland Islands, Gibraltar, Montserrat, Pitcairn Islands, Saint Helena, South Georgia and the South Sandwich Islands, Turks and Caicos Islands
Independence:
England has existed as a unified entity since the 10th century; the union between England and Wales, begun in 1284 with the Statute of Rhuddlan, was not formalized until 1536 with an Act of Union; in another Act of Union in 1707, England and Scotland agreed to permanently join as Great Britain; the legislative union of Great Britain and Ireland was implemented in 1801, with the adoption of the name the United Kingdom of Great Britain and Ireland; the Anglo-Irish treaty of 1921 formalized a partition of Ireland; six northern Irish counties remained part of the United Kingdom as Northern Ireland and the current name of the country, the United Kingdom of Great Britain and Northern Ireland, was adopted in 1927
National holiday:
the UK does not celebrate one particular national holiday
Constitution:
unwritten; partly statutes, partly common law and practice
Legal system:
based on common law tradition with early Roman and modern continental influences; has nonbinding judicial review of Acts of Parliament under the Human Rights Act of 1998; accepts compulsory ICJ jurisdiction, with reservations
Suffrage:
18 years of age; universal
Executive branch:
chief of state: Queen ELIZABETH II (since 6 February 1952); Heir Apparent Prince CHARLES (son of the queen, born 14 November 1948)
head of government: Prime Minister Gordon BROWN (since 27 June 2007)
cabinet: Cabinet of Ministers appointed by the prime minister
elections: none; the monarchy is hereditary; following legislative elections, the leader of the majority party or the leader of the majority coalition is usually the prime minister
Legislative branch:
bicameral Parliament consists of House of Lords (618 seats; consisting of approximately 500 life peers, 92 hereditary peers, and 26 clergy) and House of Commons (646 seats since 2005 elections; members are elected by popular vote to serve five-year terms unless the House is dissolved earlier)
elections: House of Lords - no elections (note - in 1999, as provided by the House of Lords Act, elections were held in the House of Lords to determine the 92 hereditary peers who would remain there; elections are held only as vacancies in the hereditary peerage arise); House of Commons - last held 5 May 2005 (next to be held by May 2010)
election results: House of Commons - percent of vote by party - Labor 35.2%, Conservative 32.3%, Liberal Democrats 22%, other 10.5%; seats by party - Labor 355, Conservative 198, Liberal Democrat 62, other 31; seats by party in the House of Commons as of 23 November 2007 - Labor 353, Conservative 194, Liberal Democrat 63, Scottish National Party/Plaid Cymru 9, Democratic Unionist 9, Sinn Fein 5, other 14
note: in 1998 elections were held for a Northern Ireland Assembly (because of unresolved disputes among existing parties, the transfer of power from London to Northern Ireland came only at the end of 1999 and has been suspended four times, the latest occurring in October 2002 and lasting until 8 May 2007); in 1999, the UK held the first elections for a Scottish Parliament and a Welsh Assembly, the most recent of which were held in May 2007
Judicial branch:
House of Lords (highest court of appeal; several Lords of Appeal in Ordinary are appointed by the monarch for life); Supreme Courts of England, Wales, and Northern Ireland (comprising the Courts of Appeal, the High Courts of Justice, and the Crown Courts); Scotland's Court of Session and Court of the Justiciary
Political parties and leaders:
Conservative [David CAMERON]; Democratic Unionist Party (Northern Ireland) [Rev. Ian PAISLEY]; Labor Party [Gordon BROWN]; Liberal Democrats [acting leader Vince CABLE]; Party of Wales (Plaid Cymru) [Ieuan Wyn JONES]; Scottish National Party or SNP [Alex SALMOND]; Sinn Fein (Northern Ireland) [Gerry ADAMS]; Social Democratic and Labor Party or SDLP (Northern Ireland) [Mark DURKAN]; Ulster Unionist Party (Northern Ireland) [Sir Reg EMPEY]
Political pressure groups and leaders:
Campaign for Nuclear Disarmament; Confederation of British Industry; National Farmers' Union; Trades Union Congress
International organization participation:
AfDB, Arctic Council (observer), AsDB, Australia Group, BIS, C, CBSS (observer), CDB, CE, CERN, EAPC, EBRD, EIB, ESA, EU, FAO, G-5, G-7, G-8, G-10, IADB, IAEA, IBRD, ICAO, ICC, ICCt, ICRM, IDA, IEA, IFAD, IFC, IFRCS, IHO, ILO, IMF, IMO, IMSO, Interpol, IOC, IOM, IPU, ISO, ITSO, ITU, MIGA, MONUC, NATO, NEA, NSG, OAS (observer), OECD, OPCW, OSCE, Paris Club, PCA, PIF (partner), SECI (observer), UN, UN Security Council, UNCTAD, UNESCO, UNFICYP, UNHCR, UNIDO, UNMIL, UNMIS, UNMOVIC, UNOMIG, UNRWA, UNWTO, UPU, WCO, WEU, WHO, WIPO, WMO, WTO, ZC
Diplomatic representation in the US:
chief of mission: Ambassador Sir Nigel E. SHEINWALD
chancery: 3100 Massachusetts Avenue NW, Washington, DC 20008
telephone: [1] (202) 588-6500
FAX: [1] (202) 588-7870
consulate(s) general: Atlanta, Boston, Chicago, Houston, Los Angeles, Miami, New York, San Francisco
consulate(s): Denver, Orlando
Diplomatic representation from the US:
chief of mission: Ambassador Robert Holmes TUTTLE
embassy: 24 Grosvenor Square, London, W1A 1AE
mailing address: PSC 801, Box 40, FPO AE 09498-4040
telephone: [44] (0) 20 7499-9000
FAX: [44] (0) 20 7629-9124
consulate(s) general: Belfast, Edinburgh
Flag description:
blue field with the red cross of Saint George (patron saint of England) edged in white superimposed on the diagonal red cross of Saint Patrick (patron saint of Ireland), which is superimposed on the diagonal white cross of Saint Andrew (patron saint of Scotland); properly known as the Union Flag, but commonly called the Union Jack; the design and colors (especially the Blue Ensign) have been the basis for a number of other flags including other Commonwealth countries and their constituent states or provinces, and British overseas territories
Economy United Kingdom
Economy - overview:
The UK, a leading trading power and financial center, is one of the quintet of trillion dollar economies of Western Europe. Over the past two decades, the government has greatly reduced public ownership and contained the growth of social welfare programs. Agriculture is intensive, highly mechanized, and efficient by European standards, producing about 60% of food needs with less than 2% of the labor force. The UK has large coal, natural gas, and oil reserves; primary energy production accounts for 10% of GDP, one of the highest shares of any industrial nation. Services, particularly banking, insurance, and business services, account by far for the largest proportion of GDP while industry continues to decline in importance. Since emerging from recession in 1992, Britain's economy has enjoyed the longest period of expansion on record; growth has remained in the 2-3% range since 2004, outpacing most of Europe. The economy's strength has complicated the Labor government's efforts to make a case for Britain to join the European Economic and Monetary Union (EMU). Critics point out that the economy is doing well outside of EMU, and public opinion polls show a majority of Britons are opposed to the euro. The BROWN government has been speeding up the improvement of education, health services, and affordable housing at a cost in higher taxes and a widening public deficit.
GDP (purchasing power parity):
$2.147 trillion (2007 est.)
GDP (official exchange rate):
$2.472 trillion (2007 est.)
GDP - real growth rate:
2.9% (2007 est.)
GDP - per capita (PPP):
$35,300 (2007 est.)
GDP - composition by sector:
agriculture: 0.9%
industry: 23.6%
services: 75.5% (2007 est.)
Labor force:
30.71 million (2007 est.)
Labor force - by occupation:
agriculture: 1.4%
industry: 18.2%
services: 80.4% (2006 est.)
Unemployment rate:
5.4% (2007 est.)
Population below poverty line:
14% (2006 est.)
Household income or consumption by percentage share:
lowest 10%: 2.1%
highest 10%: 28.5% (1999)
Distribution of family income - Gini index:
34 (2005)
Inflation rate (consumer prices):
2.4% (2007 est.)
Investment (gross fixed):
18.3% of GDP (2007 est.)
Budget:
revenues: $1.155 trillion
expenditures: $1.237 trillion (2007 est.)
Public debt:
43.3% of GDP (2007 est.)
Agriculture - products:
cereals, oilseed, potatoes, vegetables; cattle, sheep, poultry; fish
Industries:
machine tools, electric power equipment, automation equipment, railroad equipment, shipbuilding, aircraft, motor vehicles and parts, electronics and communications equipment, metals, chemicals, coal, petroleum, paper and paper products, food processing, textiles, clothing, other consumer goods
Industrial production growth rate:
0.7% (2007 est.)
Electricity - production:
372.6 billion kWh (2005)
Electricity - production by source:
fossil fuel: 73.8%
hydro: 0.9%
nuclear: 23.7%
other: 1.6% (2001)
Electricity - consumption:
348.7 billion kWh (2005)
Electricity - exports:
2.839 billion kWh (2005)
Electricity - imports:
11.16 billion kWh (2005)
Oil - production:
1.861 million bbl/day (2005 est.)
Oil - consumption:
1.82 million bbl/day (2005 est.)
Oil - exports:
1.956 million bbl/day (2004)
Oil - imports:
1.654 million bbl/day (2004)
Oil - proved reserves:
4.029 billion bbl (1 January 2006 est.)
Natural gas - production:
84.16 billion cu m (2005 est.)
Natural gas - consumption:
91.16 billion cu m (2005 est.)
Natural gas - exports:
8.843 billion cu m (2005 est.)
Natural gas - imports:
15.84 billion cu m (2005)
Natural gas - proved reserves:
509.2 billion cu m (1 January 2006 est.)
Current account balance:
-$111 billion (2007 est.)
Exports:
$415.6 billion f.o.b. (2007 est.)
Exports - commodities:
manufactured goods, fuels, chemicals; food, beverages, tobacco
Exports - partners:
US 13.9%, Germany 10.9%, France 10.4%, Ireland 7.1%, Netherlands 6.3%, Belgium 5.2%, Spain 4.5% (2006)
Imports:
$595.6 billion f.o.b. (2007 est.)
Imports - partners:
Germany 12.8%, US 8.9%, France 6.9%, Netherlands 6.6%, China 5.3%, Norway 4.9%, Belgium 4.5% (2006)
Economic aid - donor:
ODA, $10.7 billion (2005)
Reserves of foreign exchange and gold:
$47.04 billion (2006 est.)
Debt - external:
$10.45 trillion (30 June 2007)
Stock of direct foreign investment - at home:
$1.135 trillion (2006 est.)
Stock of direct foreign investment - abroad:
$1.487 trillion (2006 est.)
Market value of publicly traded shares:
$3.058 trillion (2005)
Currency (code):
British pound (GBP)
Currency code:
GBP
Exchange rates:
British pounds per US dollar - 0.4993 (2007), 0.5418 (2006), 0.5493 (2005), 0.5462 (2004), 0.6125 (2003)
Fiscal year:
6 April - 5 April
Communications United Kingdom
Telephones - main lines in use:
33.602 million (2006)
Telephones - mobile cellular:
69.657 million (2006)
Telephone system:
general assessment: technologically advanced domestic and international system
domestic: equal mix of buried cables, microwave radio relay, and fiber-optic systems
international: country code - 44; 40 coaxial submarine cables; satellite earth stations - 10 Intelsat (7 Atlantic Ocean and 3 Indian Ocean), 1 Inmarsat (Atlantic Ocean region), and 1 Eutelsat; at least 8 large international switching centers
Radio broadcast stations:
AM 219, FM 431, shortwave 3 (1998)
Radios:
84.5 million (1997)
Television broadcast stations:
228 (plus 3,523 repeaters) (1995)
Televisions:
30.5 million (1997)
Internet country code:
.uk
Internet hosts:
5.118 million (2007)
Internet Service Providers (ISPs):
more than 400 (2000)
Internet users:
33.534 million (2006)
Transportation United Kingdom
Airports:
449 (2007)
Airports - with paved runways:
total: 310
over 3,047 m: 8
2,438 to 3,047 m: 33
1,524 to 2,437 m: 131
914 to 1,523 m: 79
under 914 m: 59 (2007)
Airports - with unpaved runways:
total: 139
2,438 to 3,047 m: 1
1,524 to 2,437 m: 2
914 to 1,523 m: 23
under 914 m: 113 (2007)
Heliports:
11 (2007)
Pipelines:
condensate 565 km; condensate/gas 6 km; gas 21,575 km; liquid petroleum gas 59 km; oil 5,094 km; oil/gas/water 161 km; refined products 4,444 km (2006)
Railways:
total: 16,567 km
broad gauge: 303 km 1.600-m gauge (in Northern Ireland)
standard gauge: 16,264 km 1.435-m gauge (5,361 km electrified) (2006)
Roadways:
total: 388,008 km
paved: 388,008 km (includes 3,520 km of expressways) (2005)
Waterways:
3,200 km (620 km used for commerce) (2003)
Merchant marine:
total: 474 ships (1000 GRT or over) 11,723,618 GRT/12,315,588 DWT
by type: bulk carrier 26, cargo 60, carrier 4, chemical tanker 56, container 156, liquefied gas 18, passenger 10, passenger/cargo 62, petroleum tanker 27, refrigerated cargo 17, roll on/roll off 24, vehicle carrier 14
foreign-owned: 242 (Australia 1, Cyprus 1, Denmark 61, Finland 1, France 9, Germany 71, Greece 6, Hong Kong 2, Ireland 1, Italy 4, Japan 1, Netherlands 2, NZ 1, Norway 33, South Africa 4, Sweden 19, Switzerland 1, Taiwan 11, Turkey 2, US 11)
registered in other countries: 412 (Algeria 12, Antigua and Barbuda 4, Argentina 4, Australia 2, Bahamas 68, Barbados 3, Bermuda 20, Brunei 8, Cape Verde 1, Cayman Islands 9, Cyprus 21, Faroe Islands 1, Gibraltar 3, Greece 15, Hong Kong 32, India 1, Indonesia 3, Italy 7, South Korea 1, Liberia 74, Luxembourg 7, Malta 12, Marshall Islands 17, Netherlands 7, Norway 9, Panama 35, Papua New Guinea 6, Singapore 13, Slovakia 1, St Vincent and The Grenadines 9, Sweden 2, Thailand 3, Tonga 1, US 1, unknown 1) (2007)
Ports and terminals:
Dover, Felixstowe, Forth Ports, Hound Point, Immingham, Liverpool, London, Milford Haven, Southampton, Teesport
Military United Kingdom
Military branches:
Army, Royal Navy (includes Royal Marines), Royal Air Force
Military service age and obligation:
16-33 years of age (officers 17-28) for voluntary military service (with parental consent under 18); women serve in military services, but are excluded from ground combat positions and some naval postings; must be citizen of the UK, Commonwealth, or Republic of Ireland; reservists serve a minimum of 3 years, to age 45 or 55 (2007)
Manpower available for military service:
males age 16-49: 14,607,724
females age 16-49: 14,028,738 (2005 est.)
Manpower fit for military service:
males age 16-49: 12,046,268
females age 16-49: 11,555,893 (2005 est.)
Military expenditures - percent of GDP:
2.4% (2005 est.)
Transnational Issues United Kingdom
Disputes - international:
in 2002, Gibraltar residents voted overwhelmingly by referendum to reject any "shared sovereignty" arrangement between the UK and Spain; the Government of Gibraltar insists on equal participation in talks between the two countries; Spain disapproves of UK plans to grant Gibraltar greater autonomy; Mauritius and Seychelles claim the Chagos Archipelago (British Indian Ocean Territory), and its former inhabitants since their eviction in 1965; most Chagossians reside in Mauritius, and in 2001 were granted UK citizenship, where some have since resettled; in May 2006, the High Court of London reversed the UK Government's 2004 orders of council that banned habitation on the islands; UK rejects sovereignty talks requested by Argentina, which still claims the Falkland Islands (Islas Malvinas) and South Georgia and the South Sandwich Islands; territorial claim in Antarctica (British Antarctic Territory) overlaps Argentine claim and partially overlaps Chilean claim; Iceland, the UK, and Ireland dispute Denmark's claim that the Faroe Islands' continental shelf extends beyond 200 nm
Illicit drugs:
producer of limited amounts of synthetic drugs and synthetic precursor chemicals; major consumer of Southwest Asian heroin, Latin American cocaine, and synthetic drugs; money-laundering center

This page was last updated on 17 January, 2008


 
WebService-CIA-1.4/t/webservice-cia.t010044400017510000120000000030161074577407600155120ustar ianwwwuse strict; use Test::More tests => 11; #1 BEGIN { use_ok('WebService::CIA'); } #2 ok( !eval {WebService::CIA->new()}, "new() - no source - dies" ); use WebService::CIA::Source; my $source = WebService::CIA::Source->new; my $cia = WebService::CIA->new({'Source' => $source}); #3 ok( defined $cia, 'new() returns something' ); #4 ok( $cia->isa('WebService::CIA'), 'new() returns a WebService::CIA object' ); #5 ok( ref $cia->source eq 'WebService::CIA::Source', 'source() - returns source object' ); #6 ok( $cia->get('testcountry', 'Test') eq 'Wombat', 'get() - valid args - returns test string' ); #7 ok( ! defined $cia->get('zz', 'Test'), 'get() - invalid args - returns undef' ); #8 ok( exists $cia->get_all_hashref(['testcountry'])->{'testcountry'}->{'Test'} && $cia->get_all_hashref(['testcountry'])->{'testcountry'}->{'Test'} eq 'Wombat', 'get_all_hashref() - valid args - returns test hashref' ); #9 ok( scalar keys %{$cia->get_all_hashref(['zz'])->{'Test'}} == 0, 'get_all_hashref() - invalid args - returns empty hashref' ); #10 my $data = $cia->get_hashref(['testcountry'],['Test', 'Foo']); ok( $data->{'testcountry'}->{'Test'} eq 'Wombat' && ! defined $data->{'testcountry'}->{'Foo'}, 'get_hashref() (multiple fields) - mix of valid/invalid args - returns test hashref' ); #11 $data = $cia->get_hashref(['testcountry', 'zz'],['Test']); ok( $data->{'testcountry'}->{'Test'} eq 'Wombat' && ! defined $data->{'zz'}->{'Test'}, 'get_hashref() (multiple countries) - mix of valid/invalid args - returns test hashref' ); WebService-CIA-1.4/t/webservice-cia-source-web-internet.t010044400017510000120000000022231074577407600214100ustar ianwwwuse strict; use Test::More; use Module::Build; if ( $ENV{ TEST_INTERNET } ) { plan tests => 8; } else { plan skip_all => 'Skipping internet-based tests - set TEST_INTERNET to run these tests'; } use WebService::CIA::Source::Web; my $source = WebService::CIA::Source::Web->new; ok( $source->get('uk') == 1, 'get() - returns 1' ); ok( $source->cached eq 'uk', 'cached() - cached country set correctly after get()' ); ok( scalar keys %{$source->cache} > 0 && exists $source->cache->{'Background'} && $source->cache->{'Background'}, 'cache() - cache contains values' ); ok( $source->value('uk','Background'), 'value() - valid args - returns a value' ); ok( ! defined $source->value('uk','Test'), 'value() (cached info) - invalid args - returns undef' ); ok( ! defined $source->value('testcountry', 'Test'), 'value() (non-cached info) - invalid args - returns undef' ); ok( scalar keys %{$source->all('uk')} > 0 && exists $source->all('uk')->{'Background'} && $source->all('uk')->{'Background'}, 'all() - valid args - returns hashref' ); ok( scalar keys %{$source->all('testcountry')} == 0, 'all() - invalid args - returns empty hashref' ); WebService-CIA-1.4/t/pod-coverage.t010044400017510000120000000002551074577407600151770ustar ianwwwuse strict; use Test::More; eval "use Test::Pod::Coverage 1.00"; plan skip_all => "Test::Pod::Coverage 1.00 required for testing POD coverage" if $@; all_pod_coverage_ok(); WebService-CIA-1.4/t/webservice-cia-source-dbm.t010044400017510000120000000034701074577407600175540ustar ianwwwuse strict; use Test::More tests => 14; #1 BEGIN { use_ok('WebService::CIA::Source::DBM') } if (-e './t/test.dbm') { unlink './t/test.dbm'; } #2 my $source = eval { WebService::CIA::Source::DBM->new({DBM => './t/test.dbm'}); }; ok( ! $source, q(Shouldn't be able to create DBM in read-only mode) ); #3 $source = WebService::CIA::Source::DBM->new({DBM => './t/test.dbm', Mode => 'readwrite'}); ok( $source, 'new() - returns something' ); #4 ok( $source->isa('WebService::CIA::Source::DBM'), 'new() - returns WebService::CIA::Source::DBM object' ); #5 ok( ref $source->dbm eq 'HASH', 'dbm() - returns hashref' ); #6 ok( eval { $source->set('testcountry', {'Test' => 'Wombat'}); }, 'set() - write to the DBM' ); #7 ok( $source->value('testcountry', 'Test') eq 'Wombat', 'value() - valid args - returns previous set() value' ); #8 ok( ! defined $source->value('zz','Test'), 'value() - invalid args - returns undef' ); #9 ok( scalar keys %{$source->all('testcountry')} == 1 && exists $source->all('testcountry')->{'Test'} && $source->all('testcountry')->{'Test'} eq 'Wombat', 'all() - valid args - returns test string' ); #10 ok( scalar keys %{$source->all('zz')} == 0, 'all() - invalid args - returns empty hashref' ); #11 undef $source; $source = eval { WebService::CIA::Source::DBM->new({DBM => './t/test.dbm', Mode => 'read'}); }; ok( $source, 'new() - open existing DBM readonly' ); #12 ok( $source->isa('WebService::CIA::Source::DBM'), 'new() - open existing DBM - returns WebService::CIA::Source::DBM object' ); #13 ok( $source->value('testcountry', 'Test') eq 'Wombat', 'value() - valid args - returns value set in previous session' ); #14 $source->set('testcountry', {'Test' => 'Platypus'}); ok( $source->value('testcountry','Test') eq 'Wombat', 'DBM opened read only is read only' ); unlink './t/test.dbm'; WebService-CIA-1.4/t/webservice-cia-parser.t010044400017510000120000000024351074577407600170100ustar ianwwwuse strict; use Test::More tests => 9; use Module::Build; #1 BEGIN { use_ok('WebService::CIA::Parser'); } #2 my $parser = WebService::CIA::Parser->new(); ok( defined $parser, 'new() returns something' ); #3 ok( $parser->isa('WebService::CIA::Parser'), 'new() returns a WebService::CIA::Parser object' ); my $data = $parser->parse('zz', q(
Test:
Wombat )); #4 ok( exists $data->{Test} && $data->{Test} eq 'Wombat', 'parse() - sets field data correctly' ); #5 ok( exists $data->{URL} && $data->{URL} eq $WebService::CIA::base_url . 'geos/zz.html', 'parse() - sets URL data correctly' ); SKIP: { skip 'Skipping internet-based tests - set TEST_INTERNET to run these tests', 4 if ! $ENV{ TEST_INTERNET }; require LWP::UserAgent; require Crypt::SSLeay; my $ua = LWP::UserAgent->new(); my $data = $parser->parse( 'uk', '' ); for ( "URL - Flag", "URL - Map", "URL", "URL - Print" ) { my $resp = $ua->get( $data->{ $_ } ); is( $resp->code, 200, "$_ OK" ); } } WebService-CIA-1.4/t/pod.t010044400017510000120000000002151074577407600134020ustar ianwwwuse strict; use Test::More; eval "use Test::Pod 1.00"; plan skip_all => "Test::Pod 1.00 required for testing POD" if $@; all_pod_files_ok(); WebService-CIA-1.4/MANIFEST010044400017510000120000000007621074577407600133300ustar ianwwwBuild.PL Changes examples/from_dbm.pl examples/from_web.pl lib/WebService/CIA.pm lib/WebService/CIA/Parser.pm lib/WebService/CIA/Source.pm lib/WebService/CIA/Source/DBM.pm lib/WebService/CIA/Source/Web.pm Makefile.PL MANIFEST This list of files META.yml README t/lib/WCUA.pm t/pod-coverage.t t/pod.t t/webservice-cia-parser.t t/webservice-cia-source-dbm.t t/webservice-cia-source-web-internet.t t/webservice-cia-source-web.t t/webservice-cia-source.t t/webservice-cia.t webservice-cia-makedbm.pl WebService-CIA-1.4/examples004075500017510000120000000000001074577407600137365ustar ianwwwWebService-CIA-1.4/examples/from_dbm.pl010044400017510000120000000007321074577407600161340ustar ianwwwuse strict; use warnings; use WebService::CIA; use WebService::CIA::Source::DBM; # Get data from a pre-compiled DBM file # The webservice-cia-makedbm.pl script can make such a DBM # for you my $source = WebService::CIA::Source::DBM->new({ DBM => "factbook.dbm" }); # Create the WebService::CIA object, and tell it to use the # DBM source my $cia = WebService::CIA->new({ Source => $source }); # Get your data my $fact = $cia->get("uk", "Population"); print $fact; WebService-CIA-1.4/examples/from_web.pl010044400017510000120000000006611074577407600161500ustar ianwwwuse strict; use warnings; use WebService::CIA; use WebService::CIA::Source::Web; # Get data straight from the CIA Factbook web site # Good for one-off fetches, testing, etc. my $source = WebService::CIA::Source::Web->new(); # Create the WebService::CIA object, and tell it to use the # DBM source my $cia = WebService::CIA->new({ Source => $source }); # Get your data my $fact = $cia->get("uk", "Population"); print $fact; WebService-CIA-1.4/lib004075500017510000120000000000001074577407600126665ustar ianwwwWebService-CIA-1.4/lib/WebService004075500017510000120000000000001074577407600147245ustar ianwwwWebService-CIA-1.4/lib/WebService/CIA004075500017510000120000000000001074577407600153205ustar ianwwwWebService-CIA-1.4/lib/WebService/CIA/Parser.pm010044400017510000120000000063721074577407600171740ustar ianwwwpackage WebService::CIA::Parser; require 5.005_62; use strict; use warnings; use WebService::CIA; our $VERSION = '1.4'; sub new { my $proto = shift; my $source = shift; my $class = ref($proto) || $proto; my $self = {}; bless ($self, $class); return $self; } sub parse { my ($self, $cc, $html) = @_; my $data = { 'URL - Flag' => $WebService::CIA::base_url . 'flags/' . $cc . '-flag.gif', 'URL - Map' => $WebService::CIA::base_url . 'maps/' . $cc . '-map.gif', 'URL' => $WebService::CIA::base_url . 'geos/' . $cc . '.html', 'URL - Print' => $WebService::CIA::base_url . 'print/' . $cc . '.html' }; while ($html =~ m# ]+ class="FieldLabel">.*? (.+?): .*?.*? .*? ]+> (.*?) (|) #xsg) { my $field = $1; my $value = $2; $field =~ s/\s+/ /sg; $field =~ s/^\s*(.*?)\s*$/$1/; $value =~ s/\s+/ /sg; $value =~ s/^\s*(.*?)\s*$/$1/; $value =~ s/\s*
\s*/\n/g; $value =~ s/<\/?[^>+]>//g; $data->{$field} = $value; } return $data; } 1; __END__ =head1 NAME WebService::CIA::Parser - Parse pages from the CIA World Factbook =head1 SYNOPSIS use WebService::CIA::Parser; my $parser = WebService::CIA::Parser->new; my $data = $parser->parse($string); =head1 DESCRIPTION WebService::CIA::Parser takes a string of HTML and parses it. It will only give sensible output if the string is the HTML for a page whose URL matches C This parsing is somewhat fragile, since it assumes a certain page structure. It'll work just as long as the CIA don't choose to alter their pages. =head1 METHODS =over 4 =item C Creates a new WebService::CIA::Parser object. It takes no arguments. =item C Parses a string of HTML take from the CIA World Factbook. It takes a single string as its argument and returns a hashref of fields and values. The values are stripped of all HTML. CbrE> tags are replaced by newlines. It also creates four extra fields: "URL", "URL - Print", "URL - Flag", and "URL - Map" which are the URLs of the country's Factbook page, the printable version of that page, a GIF map of the country, and a GIF flag of the country respectively. =back =head1 EXAMPLE use WebService::CIA::Parser; use LWP::Simple qw(get); $html = get( "https://www.cia.gov/library/publications/the-world-factbook/print/uk.html" ); $parser = WebService::CIA::Parser->new; $data = $parser->parse($html); print $data->{"Population"}; =head1 AUTHOR Ian Malpass (ian-cpan@indecorous.com) =head1 COPYRIGHT Copyright 2003-2007, Ian Malpass This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The CIA World Factbook's copyright information page (L) states: The Factbook is in the public domain. Accordingly, it may be copied freely without permission of the Central Intelligence Agency (CIA). =head1 SEE ALSO WebService::CIA =cut WebService-CIA-1.4/lib/WebService/CIA/Source.pm010044400017510000120000000037441074577407600172000ustar ianwwwpackage WebService::CIA::Source; require 5.005_62; use strict; use warnings; our $VERSION = '1.4'; # Preloaded methods go here. sub new { my $proto = shift; my $source = shift; my $class = ref($proto) || $proto; my $self = {}; bless ($self, $class); return $self; } sub value { my $self = shift; my ($cc, $f) = @_; if ($cc eq 'testcountry' and $f eq 'Test') { return 'Wombat'; } else { return; } } sub all { my $self = shift; my $cc = shift; if ($cc eq 'testcountry') { return {'Test' => 'Wombat'}; } else { return {}; } } 1; __END__ =head1 NAME WebService::CIA::Source - A base class for WebService::CIA sources =head1 SYNOPSIS use WebService::CIA::Source; my $source = WebService::CIA::Source->new(); =head1 DESCRIPTION WebService::CIA::Source is a base class for WebService::CIA sources, such as WebService::CIA::Source::DBM and WebService::CIA::Source::Web. It could be used as a source in its own right, but it won't get you very far. =head1 METHODS =over 4 =item C This method creates a new WebService::CIA::Source object. It takes no arguments. =item C Retrieve a value. Always returns C. =item C Retrieve all fields and values. Always returns an empty hashref. =back =head1 AUTHOR Ian Malpass (ian-cpan@indecorous.com) =head1 COPYRIGHT Copyright 2003-2007, Ian Malpass This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The CIA World Factbook's copyright information page (L) states: The Factbook is in the public domain. Accordingly, it may be copied freely without permission of the Central Intelligence Agency (CIA). =head1 SEE ALSO WebService::CIA, WebService::CIA::Parser, WebService::CIA::Source::DBM, WebService::CIA::Source::Web =cut WebService-CIA-1.4/lib/WebService/CIA/Source004075500017510000120000000000001074577407600165605ustar ianwwwWebService-CIA-1.4/lib/WebService/CIA/Source/DBM.pm010044400017510000120000000107601074577407600175760ustar ianwwwpackage WebService::CIA::Source::DBM; require 5.005_62; use strict; use warnings; use Fcntl; use MLDBM qw(DB_File Storable); use Carp; use WebService::CIA::Source; @WebService::CIA::Source::DBM::ISA = ("WebService::CIA::Source"); our $VERSION = '1.4'; sub new { my $proto = shift; my $opts = shift; my $class = ref($proto) || $proto; my $self = {}; unless (exists $opts->{DBM}) { croak("WebService::CIA::Source::DBM: No DBM file specified"); } my $mode; if (exists $opts->{Mode} && $opts->{Mode} eq "readwrite") { tie %{$self->{DBM}}, "MLDBM", $opts->{DBM}, O_CREAT|O_RDWR, 0640 or croak "WebService::CIA::Source::DBM: Can't open DBM: $!"; ## no critic (ProhibitLeadingZeros) } elsif (-e $opts->{DBM}) { tie %{$self->{DBM}}, "MLDBM", $opts->{DBM}, O_RDONLY, 0440 or croak "WebService::CIA::Source::DBM: Can't open DBM: $!"; ## no critic (ProhibitLeadingZeros) } else { croak "WebService::CIA::Source::DBM: $opts->{DBM}: $!"; } bless ($self, $class); return $self; } sub value { my $self = shift; my ($country, $field) = @_; if (exists $self->dbm->{$country} and exists $self->dbm->{$country}->{$field}) { return $self->dbm->{$country}->{$field}; } else { return; } } sub all { my $self = shift; my $cc = shift; if (exists $self->dbm->{$cc}) { return $self->dbm->{$cc}; } else { return {}; } } sub set { my $self = shift; my ($cc, $data) = @_; $self->dbm->{$cc} = $data; } sub dbm { my $self = shift; return $self->{DBM}; } 1; __END__ =head1 NAME WebService::CIA::Source::DBM - An interface to a DBM copy of the CIA World Factbook =head1 SYNOPSIS use WebService::CIA::Source::DBM; my $source = WebService::CIA::Source::DBM->new({ DBM => 'factbook.dbm', Mode => 'read' }); =head1 DESCRIPTION WebService::CIA::Source::DBM is an interface to a pre-compiled DBM copy of the CIA World Factbook. The module can also be used to make the DBM file, taking data from WebService::CIA::Parser (or WebService::CIA::Source::Web) and inserting it into a DBM. A script to do this - webservice-cia-makedbm.pl - should be included in this module's distribution. =head1 METHODS Apart from C, these methods are normally accessed via a WebService::CIA object. =over 4 =item C This method creates a new WebService::CIA::Source::DBM object. It takes a hashref of options. Valid keys are "DBM" and "Mode". DBM is mandatory and should be the location of the DBM file to be used. Mode is optional and can be either "read" or "readwrite". It defaults to "read". =item C Retrieve a value from the DBM. C<$country_code> should be the FIPS 10-4 country code as defined in L. C<$field> should be the name of the field whose value you want to retrieve, as defined in L. (WebService::CIA::Parser also creates four extra fields: "URL", "URL - Print", "URL - Flag", and "URL - Map" which are the URLs of the country's Factbook page, the printable version of that page, a GIF map of the country, and a GIF flag of the country respectively.) =item C Returns a hashref of field-value pairs for C<$country_code> or an empty hashref if C<$country_code> isn't in the DBM. =item C Insert or update data in the DBM. C<$country_code> should be as described above. C<$data> is a hashref of the data to store (as Field =E Value). C B any data already in the DBM under C<$country_code>. =item C Returns a reference to the DBM file in use. =back =head1 AUTHOR Ian Malpass (ian-cpan@indecorous.com) =head1 COPYRIGHT Copyright 2003-2007, Ian Malpass This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The CIA World Factbook's copyright information page (L) states: The Factbook is in the public domain. Accordingly, it may be copied freely without permission of the Central Intelligence Agency (CIA). =head1 SEE ALSO WebService::CIA, WebService::CIA::Parser, WebService::CIA::Source::Web =cut WebService-CIA-1.4/lib/WebService/CIA/Source/Web.pm010044400017510000120000000136431074577407600177140ustar ianwwwpackage WebService::CIA::Source::Web; require 5.005_62; use strict; use warnings; use Carp; use LWP::UserAgent; use Crypt::SSLeay; use WebService::CIA; use WebService::CIA::Parser; use WebService::CIA::Source; @WebService::CIA::Source::Web::ISA = ("WebService::CIA::Source"); our $VERSION = '1.4'; # Preloaded methods go here. sub new { my $proto = shift; my $class = ref($proto) || $proto; my $args = shift || {}; if ( ! ref $args || ref $args ne "HASH" ) { croak "Arguments to new() must be a hashref"; } my $self = {}; $self->{CACHED} = ""; $self->{CACHE} = {}; $self->{PARSER} = WebService::CIA::Parser->new; bless ($self, $class); if ( exists $args->{ user_agent } ) { $self->ua( $args->{ user_agent } ); } return $self; } sub value { my $self = shift; my ($cc, $f) = @_; unless ($self->cached eq $cc) { unless ($self->get($cc)) { return; } } if (exists $self->cache->{$f}) { return $self->cache->{$f}; } else { return; } } sub all { my $self = shift; my $cc = shift; unless ($self->cached eq $cc) { unless ($self->get($cc)) { return {}; } } return $self->cache; } sub get { my $self = shift; my $cc = shift; my $response = $self->ua->get($WebService::CIA::base_url . "print/$cc.html"); $self->last_response( $response ); if ($response->is_success) { my $data = $self->parser->parse($cc, $response->content); $self->cache($data); $self->cached($cc); return 1; } else { return 0; } } sub ua { my ( $self, $ua ) = @_; if ( defined $ua ) { $self->{ UA } = $ua; } if ( ! defined $self->{ UA } ) { $self->{ UA } = LWP::UserAgent->new; $self->{ UA }->env_proxy; } return $self->{UA}; } sub parser { my $self = shift; return $self->{PARSER}; } sub cached { my $self = shift; if (@_) { $self->{CACHED} = shift; } return $self->{CACHED}; } sub cache { my $self = shift; if (@_) { $self->{CACHE} = shift; } return $self->{CACHE}; } sub last_response { my ( $self, $response ) = @_; if ( defined $response ) { $self->{ LAST_RESPONSE } = $response; } return $self->{ LAST_RESPONSE }; } 1; __END__ =head1 NAME WebService::CIA::Source::Web - An interface to the online CIA World Factbook =head1 SYNOPSIS use WebService::CIA::Source::Web; my $source = WebService::CIA::Source::DBM->new(); =head1 DESCRIPTION WebService::CIA::Source::Web is an interface to the live, online version of the CIA World Factbook. It's a very slow way of doing things, but requires no pre-compiled DBM. It's more likely to be useful for proving concepts or testing. =head1 METHODS Apart from C, these methods are normally accessed via a WebService::CIA object. =over 4 =item C my $source = WebService::CIA::Source::Web->new(); $source = WebService::CIA::Source::Web->new( { user_agent => $ua } ); This method creates a new WebService::CIA::Source::Web object. It takes an optional hashref of arguments. =over 4 =item C A user agent object to use. This must implement the same user interface as C (or, at least, a C method). =back =item C Retrieve a value from the web. C<$country_code> should be the FIPS 10-4 country code as defined in L. C<$field> should be the name of the field whose value you want to retrieve, as defined in L. (WebService::CIA::Parser also creates four extra fields: "URL", "URL - Print", "URL - Flag", and "URL - Map" which are the URLs of the country's Factbook page, the printable version of that page, a GIF map of the country, and a GIF flag of the country respectively.) C will return C if the country or field cannot be found, or if there is an error GETing the page. This isn't ideal, but I can't think of the best way around it right now. =item C Returns a hashref of field-value pairs for C<$country_code> or an empty hashref if C<$country_code> isn't available from the Factbook. =item C Retrieve and cache the data for a country. Returns 1 if successful, 0 if not. =item C Get/set the country code whose data is cached. =item C Get/set a hashref of data for the current country. =item C Returns a reference to the WebService::CIA::Parser object being used. =item C Returns a reference to the user agent object being used. By default this is an C object, but you can pass a different object in if you wish. =item C Returns the C object from the last request. =back =head1 CACHING In order to make some small improvement in efficiency, WebService::CIA::Source::Web keeps a copy of the data for the last country downloaded in memory. =head1 TO DO =over 4 =item File system based caching of pages. =item User-definable stack of cached countries, rather than just one. =item Caching of last-modified headers; conditional GET. =back =head1 AUTHOR Ian Malpass (ian-cpan@indecorous.com) =head1 COPYRIGHT Copyright 2003-2007, Ian Malpass This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The CIA World Factbook's copyright information page (L) states: The Factbook is in the public domain. Accordingly, it may be copied freely without permission of the Central Intelligence Agency (CIA). =head1 SEE ALSO WebService::CIA, WebService::CIA::Parser, WebService::CIA::Source::DBM =cut WebService-CIA-1.4/lib/WebService/CIA.pm010044400017510000120000000121731074577407600157340ustar ianwwwpackage WebService::CIA; require 5.005_62; use strict; use warnings; use Carp; our $VERSION = '1.4'; $WebService::CIA::base_url = "https://www.cia.gov/library/publications/the-world-factbook/"; sub new { my $proto = shift; my $opts = shift; my $class = ref($proto) || $proto; my $self = {}; unless (exists $opts->{Source}) { croak("WebService::CIA: No source object specified"); } $self->{SOURCE} = $opts->{Source}; bless ($self, $class); return $self; } sub get { my $self = shift; my ($cc, $f) = @_; my $value = $self->source->value($cc, $f); return $value; } sub get_all_hashref { my $self = shift; my $country = shift; my $data = {}; foreach my $cc (@$country) { $data->{$cc} = $self->source->all($cc); } return $data; } sub get_hashref { my $self = shift; my ($country, $field) = @_; my $data = {}; foreach my $cc (@$country) { $data->{$cc} = {}; foreach my $f (@$field) { $data->{$cc}->{$f} = $self->source->value($cc, $f); } } return $data; } sub source { my $self = shift; return $self->{SOURCE}; } 1; __END__ =head1 NAME WebService::CIA - Get information from the CIA World Factbook. =head1 SYNOPSIS use WebService::CIA; use WebService::CIA::Source::DBM; use WebService::CIA::Source::Web; # Get data from a pre-compiled DBM file my $source = WebService::CIA::Source::DBM->new({ DBM => "factbook.dbm" }); my $cia = WebService::CIA->new({ Source => $source }); $fact = $cia->get("uk", "Population"); print $fact; # Get data direct from the CIA World Factbook my $source = WebService::CIA::Source::Web->new(); my $cia = WebService::CIA->new({ Source => $source }); $fact = $cia->get("uk", "Population"); print $fact; =head1 DESCRIPTION A module which gets information from the CIA World Factbook. =head1 Crypt::SSLeay The most recent version of the CIA World Factbook uses HTTPS to access its web pages. As such, WebService::CIA requires Crypt::SSLeay which suffers from the usual cryptographic export restriction mumbo jumbo. Sorry about that. Users of ActiveState's ActivePerl should see L for instructions on downloading a PPM of Crypt::SSLeay. =head1 METHODS =over 4 =item C Creates a new WebService::CIA object. Takes a hashref, which must contain a "Source" key whose value is a WebService::CIA::Storage object. =item C This method retrieves information from the store. It takes two arguments: a country code (as defined in FIPS 10-4 on L, e.g. "uk", "us") and a field name (as defined in L, e.g. "Population", "Agriculture - products"). (WebService::CIA::Parser also creates four extra fields: "URL", "URL - Print", "URL - Flag", and "URL - Map" which are the URLs of the country's Factbook page, the printable version of that page, a GIF map of the country, and a GIF flag of the country respectively.) The field name is very case and punctuation sensitive. It returns the value of the field, or C if the field or country isn't in the store. Note that when using WebService::CIA::Store::Web, C will also return C if there is an error getting the page. =item C This method takes two arguments: an arrayref of country codes and an arrayref of field names. It returns a hashref of the form { 'country1' => { 'field1' => 'value', 'field2' => 'value' }, 'country2' => { 'field1' => 'value', 'field2' => 'value' } } =item C Get all the fields available for countries. It takes one argument, an arrayref of country codes. It returns a hashref similar to the one from C above, containing all the fields available for each country. =item C Get a reference to the WebService::CIA::Source object in use. =back =head1 CONFIGURATION VARIABLES =over 4 =item C<$WebService::CIA::base_url> Sets the base URL for the Factbook (currently "https://www.cia.gov/library/publications/the-world-factbook/"). If the Factbook changes location, this can be changed to point to the new location (assuming the relative structure of the Factbook is unchanged). =back =head1 AUTHOR Ian Malpass (ian-cpan@indecorous.com) =head1 COPYRIGHT Copyright 2003-2007, Ian Malpass This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The CIA World Factbook's copyright information page (L) states: The Factbook is in the public domain. Accordingly, it may be copied freely without permission of the Central Intelligence Agency (CIA). =head1 SEE ALSO WebService::CIA::Parser, WebService::CIA::Source::DBM, WebService::CIA::Source::Web =cut WebService-CIA-1.4/META.yml010044400017510000120000000016241074577407600134460ustar ianwww--- name: WebService-CIA version: 1.4 author: - Ian Malpass (ian-cpan@indecorous.com) abstract: Get information from the CIA World Factbook. license: perl resources: license: http://dev.perl.org/licenses/ requires: Crypt::SSLeay: 0 DB_File: 1.8 LWP::UserAgent: 2.0 MLDBM: 2.01 Storable: 2.0 build_requires: Module::Build: 0 Test::More: 0 provides: WebService::CIA: file: lib/WebService/CIA.pm version: 1.4 WebService::CIA::Parser: file: lib/WebService/CIA/Parser.pm version: 1.4 WebService::CIA::Source: file: lib/WebService/CIA/Source.pm version: 1.4 WebService::CIA::Source::DBM: file: lib/WebService/CIA/Source/DBM.pm version: 1.4 WebService::CIA::Source::Web: file: lib/WebService/CIA/Source/Web.pm version: 1.4 generated_by: Module::Build version 0.2806 meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.2.html version: 1.2 WebService-CIA-1.4/Makefile.PL010044400017510000120000000021151074577407600141430ustar ianwww# Note: this file was auto-generated by Module::Build::Compat version 0.03 unless (eval "use Module::Build::Compat 0.02; 1" ) { print "This module requires Module::Build to install itself.\n"; require ExtUtils::MakeMaker; my $yn = ExtUtils::MakeMaker::prompt (' Install Module::Build now from CPAN?', 'y'); unless ($yn =~ /^y/i) { die " *** Cannot install without Module::Build. Exiting ...\n"; } require Cwd; require File::Spec; require CPAN; # Save this 'cause CPAN will chdir all over the place. my $cwd = Cwd::cwd(); CPAN::Shell->install('Module::Build::Compat'); CPAN::Shell->expand("Module", "Module::Build::Compat")->uptodate or die "Couldn't install Module::Build, giving up.\n"; chdir $cwd or die "Cannot chdir() back to $cwd: $!"; } eval "use Module::Build::Compat 0.02; 1" or die $@; Module::Build::Compat->run_build_pl(args => \@ARGV); require Module::Build; Module::Build::Compat->write_makefile(build_class => 'Module::Build'); WebService-CIA-1.4/Build.PL010044400017510000120000000013361074577407600134710ustar ianwwwuse strict; use Module::Build; my $build = Module::Build->new( module_name => 'WebService::CIA', license => 'perl', script_files => ['webservice-cia-makedbm.pl'], requires => { 'MLDBM' => '2.01', 'Storable' => '2.0', 'DB_File' => '1.8', 'LWP::UserAgent' => '2.0', 'Crypt::SSLeay' => '0', }, build_requires => { 'Test::More' => '0', 'Module::Build' => '0', }, create_makefile_pl => 'passthrough', ); #print "Some tests require an internet connection\n"; #$build->notes('internet' => ($build->y_n("Run internet-based tests?", "y")?"yes":"no")); $build->notes('internet' => "no"); $build->create_build_script; WebService-CIA-1.4/README010044400017510000120000000016251074577407600130560ustar ianwwwWebService::CIA --------------- This is the README file for WebService::CIA, a Perl module for accessing data from the CIA World Factbook. Documentation for WebService::CIA is available online at http://search.cpan.org/perldoc?WebService::CIA or by doing perldoc WebService::CIA at the command line. Crypt::SSLeay ------------- The most recent version of the CIA World Factbook uses HTTPS to access its web pages. As such, WebService::CIA requires Crypt::SSLeay which suffers from the usual cryptographic export restriction mumbo jumbo. Sorry about that. Users of ActiveState's ActivePerl should see http://aspn.activestate.com/ASPN/Downloads/ActivePerl/PPM/Repository for instructions on downloading a PPM of Crypt::SSLeay. Installation ------------ This module uses Module::Build. The installation process is therefore perl Build.PL ./Build ./Build test ./Build install