businessdotgov 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
@@ -0,0 +1,21 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## PROJECT::SPECIFIC
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Chip Castle
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.
@@ -0,0 +1,36 @@
1
+ = businessdotgov
2
+
3
+ Ruby library for the following Business.gov Search API
4
+ http://www.business.gov/about/features/api/loans-grants/state-industry.html
5
+
6
+ Examples:
7
+
8
+ industries = BusinessDotGov::LoansGrants::INDUSTRIES
9
+ @industry = industries[rand(industries.length)]
10
+ @state_abbreviation = 'FL'
11
+
12
+ # format is :json by default
13
+ results = BusinessDotGov::LoansGrants.new.search({:industry => @industry, :state_abbreviation => @state_abbreviation})
14
+ puts "Found #{results.size} results for #{@industry} within #{@state_abbreviation}"
15
+ # :json format
16
+ puts "First result title #{results.first['title']}"
17
+
18
+ # specify if :xml format is desired
19
+ results = BusinessDotGov::LoansGrants.new.search({:industry => @industry, :state_abbreviation => @state_abbreviation, :format => :xml})
20
+ # :xml format
21
+ puts "First result title #{results['grant_loans'][0]['title']}"
22
+
23
+
24
+ == Note on Patches/Pull Requests
25
+
26
+ * Fork the project.
27
+ * Make your feature addition or bug fix.
28
+ * Add tests for it. This is important so I don't break it in a
29
+ future version unintentionally.
30
+ * Commit, do not mess with rakefile, version, or history.
31
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
32
+ * Send me a pull request. Bonus points for topic branches.
33
+
34
+ == Copyright
35
+
36
+ Copyright (c) 2010 Chip Castle. See LICENSE for details.
@@ -0,0 +1,54 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "businessdotgov"
8
+ gem.summary = %Q{Ruby gem for the Business.gov Search API}
9
+ gem.description = %Q{Ruby gem for the Business.gov Search API}
10
+ gem.email = "chip@chipcastle.com"
11
+ gem.homepage = "http://github.com/chip/businessdotgov"
12
+ gem.authors = ["Chip Castle"]
13
+ gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
14
+ gem.add_dependency "weary", ">= 0.7.2"
15
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
16
+ end
17
+ Jeweler::GemcutterTasks.new
18
+ rescue LoadError
19
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
20
+ end
21
+
22
+ require 'rake/testtask'
23
+ Rake::TestTask.new(:test) do |test|
24
+ test.libs << 'lib' << 'test'
25
+ test.pattern = 'test/**/test_*.rb'
26
+ test.verbose = true
27
+ end
28
+
29
+ begin
30
+ require 'rcov/rcovtask'
31
+ Rcov::RcovTask.new do |test|
32
+ test.libs << 'test'
33
+ test.pattern = 'test/**/test_*.rb'
34
+ test.verbose = true
35
+ end
36
+ rescue LoadError
37
+ task :rcov do
38
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
39
+ end
40
+ end
41
+
42
+ task :test => :check_dependencies
43
+
44
+ task :default => :test
45
+
46
+ require 'rake/rdoctask'
47
+ Rake::RDocTask.new do |rdoc|
48
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
49
+
50
+ rdoc.rdoc_dir = 'rdoc'
51
+ rdoc.title = "businessdotgov #{version}"
52
+ rdoc.rdoc_files.include('README*')
53
+ rdoc.rdoc_files.include('lib/**/*.rb')
54
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
@@ -0,0 +1,57 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{businessdotgov}
8
+ s.version = "0.0.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Chip Castle"]
12
+ s.date = %q{2010-10-09}
13
+ s.description = %q{Ruby gem for the Business.gov Search API}
14
+ s.email = %q{chip@chipcastle.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".gitignore",
22
+ "LICENSE",
23
+ "README.rdoc",
24
+ "Rakefile",
25
+ "VERSION",
26
+ "businessdotgov.gemspec",
27
+ "lib/businessdotgov.rb",
28
+ "test/helper.rb",
29
+ "test/test_businessdotgov.rb"
30
+ ]
31
+ s.homepage = %q{http://github.com/chip/businessdotgov}
32
+ s.rdoc_options = ["--charset=UTF-8"]
33
+ s.require_paths = ["lib"]
34
+ s.rubygems_version = %q{1.3.7}
35
+ s.summary = %q{Ruby gem for the Business.gov Search API}
36
+ s.test_files = [
37
+ "test/helper.rb",
38
+ "test/test_businessdotgov.rb"
39
+ ]
40
+
41
+ if s.respond_to? :specification_version then
42
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
43
+ s.specification_version = 3
44
+
45
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
46
+ s.add_development_dependency(%q<thoughtbot-shoulda>, [">= 0"])
47
+ s.add_runtime_dependency(%q<weary>, [">= 0.7.2"])
48
+ else
49
+ s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
50
+ s.add_dependency(%q<weary>, [">= 0.7.2"])
51
+ end
52
+ else
53
+ s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
54
+ s.add_dependency(%q<weary>, [">= 0.7.2"])
55
+ end
56
+ end
57
+
@@ -0,0 +1,124 @@
1
+ require 'rubygems'
2
+ require 'weary'
3
+
4
+ module BusinessDotGov
5
+ class LoansGrants
6
+ attr_accessor :state_abbreviation, :industry, :data_format
7
+
8
+ API_URL = 'http://api.business.gov/loans_grants/STATE ABBREVIATION/for_profit/INDUSTRY/nil.FORMAT'
9
+ US_STATES = {
10
+ 'ALABAMA' => 'AL',
11
+ 'ALASKA' => 'AK',
12
+ 'AMERICAN SAMOA' => 'AS',
13
+ 'ARIZONA' => 'AZ',
14
+ 'ARKANSAS' => 'AR',
15
+ 'CALIFORNIA' => 'CA',
16
+ 'COLORADO' => 'CO',
17
+ 'CONNECTICUT' => 'CT',
18
+ 'DELAWARE' => 'DE',
19
+ 'DISTRICT' => 'OF',
20
+ 'COLUMBIA' => 'DC',
21
+ 'FEDERATED STATES' => 'OF',
22
+ 'MICRONESIA' => 'FM',
23
+ 'FLORIDA' => 'FL',
24
+ 'GEORGIA' => 'GA',
25
+ 'GUAM' => 'GU',
26
+ 'HAWAII' => 'HI',
27
+ 'IDAHO' => 'ID',
28
+ 'ILLINOIS' => 'IL',
29
+ 'INDIANA' => 'IN',
30
+ 'IOWA' => 'IA',
31
+ 'KANSAS' => 'KS',
32
+ 'KENTUCKY' => 'KY',
33
+ 'LOUISIANA' => 'LA',
34
+ 'MAINE' => 'ME',
35
+ 'MARSHALL ISLANDS' => 'MH',
36
+ 'MARYLAND' => 'MD',
37
+ 'MASSACHUSETTS' => 'MA',
38
+ 'MICHIGAN' => 'MI',
39
+ 'MINNESOTA' => 'MN',
40
+ 'MISSISSIPPI' => 'MS',
41
+ 'MISSOURI' => 'MO',
42
+ 'MONTANA' => 'MT',
43
+ 'NEBRASKA' => 'NE',
44
+ 'NEVADA' => 'NV',
45
+ 'NEW HAMPSHIRE' => 'NH',
46
+ 'NEW JERSEY' => 'NJ',
47
+ 'NEW MEXICO' => 'NM',
48
+ 'NEW YORK' => 'NY',
49
+ 'NORTH CAROLINA' => 'NC',
50
+ 'NORTH DAKOTA' => 'ND',
51
+ 'NORTHERN MARIANA ISLANDS' => 'MP',
52
+ 'OHIO' => 'OH',
53
+ 'OKLAHOMA' => 'OK',
54
+ 'OREGON' => 'OR',
55
+ 'PALAU' => 'PW',
56
+ 'PENNSYLVANIA' => 'PA',
57
+ 'PUERTO RICO' => 'PR',
58
+ 'RHODE ISLAND' => 'RI',
59
+ 'SOUTH CAROLINA' => 'SC',
60
+ 'SOUTH DAKOTA' => 'SD',
61
+ 'TENNESSEE' => 'TN',
62
+ 'TEXAS' => 'TX',
63
+ 'UTAH' => 'UT',
64
+ 'VERMONT' => 'VT',
65
+ 'VIRGIN ISLANDS' => 'VI',
66
+ 'VIRGINIA' => 'VA',
67
+ 'WASHINGTON' => 'WA',
68
+ 'WEST VIRGINIA' => 'WV',
69
+ 'WISCONSIN' => 'WI',
70
+ 'WYOMING' => 'WY'
71
+ }
72
+ MILITARY_STATES = {
73
+ 'Armed Forces Africa' => 'AE',
74
+ 'Armed Forces Americas (except Canada)' => 'AA',
75
+ 'Armed Forces Canada' => 'AE',
76
+ 'Armed Forces Europe' => 'AE',
77
+ 'Armed Forces Middle East' => 'AE',
78
+ 'Armed Forces Pacific' => 'AP'
79
+ }
80
+ STATES = US_STATES # MILITARY_STATES
81
+
82
+ INDUSTRIES = [
83
+ 'Agriculture',
84
+ 'Child Care',
85
+ 'Environmental Management',
86
+ 'Health Care',
87
+ 'Manufacturing',
88
+ 'Technology',
89
+ 'Tourism'
90
+ ]
91
+
92
+ DATA_FORMATS = [:xml, :json]
93
+
94
+ def initialize(format = :json)
95
+ @format = format
96
+ @industry, @state_abbreviation = nil
97
+ end
98
+
99
+ def search(options = {})
100
+ @industry ||= options[:industry]
101
+ @state_abbreviation ||= options[:state_abbreviation]
102
+ @format ||= options[:format]
103
+ if @industry.nil?
104
+ raise ArgumentError, "Oops, an industry wasn't provided. Please provide one of the following industries: #{INDUSTRIES.join(', ')}"
105
+ end
106
+ if @state_abbreviation.nil?
107
+ raise ArgumentError, "Oops, an US state wasn't provided. Please provide one of the following US states: #{STATES.values.join(', ')}"
108
+ end
109
+ api_call = URI.escape(API_URL.sub(/STATE ABBREVIATION/, @state_abbreviation).sub(/INDUSTRY/, @industry).sub(/FORMAT/, @format.to_s))
110
+ puts "api_call = #{api_call}"
111
+ response = Weary.get(api_call).perform
112
+ if response.success?
113
+ return response.parse
114
+ else
115
+ raise "Something went wrong. Request failed with #{response.code}: #{response.message}"
116
+ end
117
+ end
118
+ end
119
+ end
120
+
121
+ # b = BusinessDotGov::LoansGrants.new
122
+ # b.industry = 'Technology'
123
+ # b.state_abbreviation = 'FL'
124
+ # b.search
@@ -0,0 +1,10 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'shoulda'
4
+
5
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
7
+ require 'businessdotgov'
8
+
9
+ class Test::Unit::TestCase
10
+ end
@@ -0,0 +1,7 @@
1
+ require 'helper'
2
+
3
+ class TestBusinessdotgov < Test::Unit::TestCase
4
+ should "probably rename this file and start testing for real" do
5
+ flunk "hey buddy, you should probably rename this file and start testing for real"
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,107 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: businessdotgov
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Chip Castle
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-10-09 00:00:00 -05:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: thoughtbot-shoulda
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
32
+ version: "0"
33
+ type: :development
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: weary
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ hash: 7
44
+ segments:
45
+ - 0
46
+ - 7
47
+ - 2
48
+ version: 0.7.2
49
+ type: :runtime
50
+ version_requirements: *id002
51
+ description: Ruby gem for the Business.gov Search API
52
+ email: chip@chipcastle.com
53
+ executables: []
54
+
55
+ extensions: []
56
+
57
+ extra_rdoc_files:
58
+ - LICENSE
59
+ - README.rdoc
60
+ files:
61
+ - .document
62
+ - .gitignore
63
+ - LICENSE
64
+ - README.rdoc
65
+ - Rakefile
66
+ - VERSION
67
+ - businessdotgov.gemspec
68
+ - lib/businessdotgov.rb
69
+ - test/helper.rb
70
+ - test/test_businessdotgov.rb
71
+ has_rdoc: true
72
+ homepage: http://github.com/chip/businessdotgov
73
+ licenses: []
74
+
75
+ post_install_message:
76
+ rdoc_options:
77
+ - --charset=UTF-8
78
+ require_paths:
79
+ - lib
80
+ required_ruby_version: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ hash: 3
86
+ segments:
87
+ - 0
88
+ version: "0"
89
+ required_rubygems_version: !ruby/object:Gem::Requirement
90
+ none: false
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ hash: 3
95
+ segments:
96
+ - 0
97
+ version: "0"
98
+ requirements: []
99
+
100
+ rubyforge_project:
101
+ rubygems_version: 1.3.7
102
+ signing_key:
103
+ specification_version: 3
104
+ summary: Ruby gem for the Business.gov Search API
105
+ test_files:
106
+ - test/helper.rb
107
+ - test/test_businessdotgov.rb