caselaw 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 493e52b698a4af0e3c322d186ed6e28b19ac7cf2
4
+ data.tar.gz: 580e3394c374550c997bac54a55cf41ef4202547
5
+ SHA512:
6
+ metadata.gz: bbeaef183db925d6961e3c097166540c253a302c64fcc22a341c2b0fc1aa9440bcc495818561502c83c104543babec02f4feb4406a966f416107980ee4bb3691
7
+ data.tar.gz: b06d5e855658bd5c36df0fb28575520664bf5357edbfbf17e3dc804b4e289269fb387a87aedda8686207367e49fa0395a4e04d38bd18e8f9e87d3ef8b4cda413
data/.gitignore ADDED
@@ -0,0 +1,37 @@
1
+ *.gem
2
+ *.rbc
3
+ *.swp
4
+ *.tmproj
5
+ *~
6
+ .DS_Store
7
+ .\#*
8
+ .bundle
9
+ .config
10
+ .yardoc
11
+ Gemfile.lock
12
+ \#*
13
+ _yardoc
14
+ coverage
15
+ doc/
16
+ lib/bundler/man
17
+ pkg
18
+ rdoc
19
+ spec/reports
20
+ test/tmp
21
+ test/version_tmp
22
+ tmp
23
+ tmtags/.bundle/
24
+ /.yardoc
25
+ /_yardoc/
26
+ /coverage/
27
+ /doc/
28
+ /pkg/
29
+ /spec/reports/
30
+ /tmp/
31
+
32
+ # rspec failure tracking
33
+ .rspec_status
34
+
35
+ # test files
36
+ sample-requests.txt
37
+ /examples/test.rb
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.2.2
7
+ before_install: gem install bundler -v 1.17.1
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in caselaw.gemspec
6
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 Tom Bonan
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,112 @@
1
+ # CaseLaw API Wrapper
2
+
3
+ ## Installation
4
+
5
+ Install with RubyGems
6
+
7
+ ```
8
+ gem install caselaw
9
+ ```
10
+
11
+ ## Getting started
12
+
13
+ In order to view non-whitelisted court cases, you must [register an account](https://case.law/user/register/) with Case.law and recieve an API key.
14
+
15
+ ### Setting up the Client
16
+
17
+ ``` ruby
18
+ client = Caselaw::Client.new(api_key: "KEY")
19
+ ```
20
+
21
+ or via the shorthand version
22
+
23
+ ``` ruby
24
+ client = Caselaw.new(api_key: "KEY")
25
+ ```
26
+
27
+ ### Global configuration
28
+
29
+ You can define the credentials for a client at a global level by creating an initiailize file. If using gem in Rails, add a file under `config/initializers`.
30
+
31
+ ``` ruby
32
+ Caselaw.configure(
33
+ api_key: "KEY"
34
+ )
35
+ ```
36
+
37
+ To access the global configuration:
38
+
39
+ ``` ruby
40
+ Caselaw.configuration
41
+ ```
42
+
43
+ ## Examples
44
+
45
+ ### Lookup a Jurisdiction
46
+
47
+ You can lookup a Jurisdiction by id or the full name if unknown
48
+
49
+ ```ruby
50
+ client.jurisdiction(31)
51
+ client.jurisdiction("Colorado")
52
+ ```
53
+
54
+ Or get all the Jurisdictions and related information
55
+
56
+ ```ruby
57
+ search = client.search_jurisdictions
58
+
59
+ search.results.each do |jurisdiction|
60
+ jurisdiction.id # => jurisdiction id
61
+ jurisdiction.name_long # => jurisdiction full name
62
+ jurisdiction.slug # => slug in use on the API
63
+ end
64
+ ```
65
+
66
+ ### Lookup a case instance
67
+
68
+ You can search for a case with a given case id
69
+
70
+ ```ruby
71
+ client.case(1021505)
72
+ ```
73
+
74
+ And to return the full body of the case instance, add the `true` parameter as the second argument
75
+
76
+ ```ruby
77
+ client.case(1021505, true)
78
+ ```
79
+
80
+ ### Search for Cases by Text
81
+
82
+ Search the full text of cases and return the cases that contain the search term. The second argument is the number of cases to be returned.
83
+
84
+ ```ruby
85
+ client.search_cases("insurance", 20)
86
+ ```
87
+
88
+ Or you can search multiple terms by separating the terms with a space
89
+ ```ruby
90
+ client.search_cases("insurance Peoria", 20)
91
+ ```
92
+
93
+ ## Response Structure
94
+
95
+ Each response comes in the form of a [Hashie](https://github.com/intridea/hashie) hash to make it easier to access the data. For instance, if we search case `1021505`, we can access information about it easily with Hashie:
96
+
97
+ ```ruby
98
+ c = client.case(1021505)
99
+
100
+ c.id # => 1021505
101
+ c.url # => "https://api.case.law/v1/cases/1021505/"
102
+ c.name # => "William Stone against William Boreman"
103
+ c.name_abbreviation # => "Stone v. Boreman"
104
+ c.decision_date # => "1658"
105
+ ```
106
+
107
+ As well as information about the Volume, Reporter, Court, and Jurisdiction that the case:
108
+
109
+ ```ruby
110
+ c.court.name # => "Maryland Court of Appeals"
111
+ c.jurisdiction.name_long # => "Maryland"
112
+ ```
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/caselaw.gemspec ADDED
@@ -0,0 +1,31 @@
1
+ $LOAD_PATH.push File.expand_path("../lib", __FILE__)
2
+ require "caselaw/version"
3
+
4
+ Gem::Specification.new do |spec|
5
+ spec.name = "caselaw"
6
+ spec.version = Caselaw::VERSION
7
+ spec.authors = ["tombonan"]
8
+ spec.email = ["tombonan27@gmail.com"]
9
+ spec.summary = "Case.law API wrapper"
10
+ spec.description = "Wrapper for the Caselaw Access Project API"
11
+ spec.homepage = "https://github.com/tombonan/caselaw"
12
+ spec.license = "MIT"
13
+
14
+ spec.add_development_dependency "bundler", "~> 1.17"
15
+ spec.add_development_dependency "rake", "~> 10.0"
16
+ spec.add_development_dependency "rspec", "~> 3.0"
17
+ spec.add_development_dependency "webmock", "~> 3.5"
18
+
19
+ spec.add_runtime_dependency "httparty", "~> 0.16.3"
20
+ spec.add_runtime_dependency "hashie", "~> 3.6"
21
+
22
+ spec.post_install_message = "Welcome to the Case Law party!"
23
+
24
+ all_files = `git ls-files`.split("\n")
25
+ test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
26
+
27
+ spec.files = all_files - test_files
28
+ spec.test_files = test_files
29
+ spec.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
30
+ spec.require_paths = ["lib"]
31
+ end
data/docs/README.md ADDED
@@ -0,0 +1,92 @@
1
+ ## Table of Contents
2
+
3
+ - [Jurisdictions](#jurisdictions)
4
+ - [Cases](#cases)
5
+
6
+ ## Jurisdictions
7
+
8
+ ### Specific Jurisdiction Information
9
+
10
+ You can lookup a jurisdiction by id
11
+
12
+ ```ruby
13
+ client.jurisdiction(31)
14
+ ```
15
+
16
+ or by the full name if the id is unknown
17
+
18
+ ```ruby
19
+ client.jurisdiction("Colorado")
20
+ ```
21
+
22
+ ### Returning All Jurisdiction Information
23
+
24
+ To recieve an array with all 62 jurisdictions and related information
25
+
26
+ ```ruby
27
+ search = client.search_jurisdictions
28
+ jurisdiction_array = search.results
29
+ ```
30
+
31
+ ### Jurisdiction Slugs
32
+
33
+ The Caselaw API uses jurisdiction slugs to filter requests. If you wish to find out the slug of a specific jurisdiction
34
+
35
+ ```ruby
36
+ slug = Caselaw::Jurisdiction.get_by_name("Utah") # => 'utah'
37
+ ```
38
+
39
+ or you can retrieve the slug by the jurisdiction id
40
+
41
+ ```ruby
42
+ slug = Caselaw::Jurisdiction.get_by_id(12) # => 'utah'
43
+ ```
44
+
45
+ ## Cases
46
+
47
+ ### Specific Case Instances
48
+
49
+ You can lookup a specific case by its id
50
+
51
+ ```ruby
52
+ client.case(1021505)
53
+ ```
54
+
55
+ And to return the full body of the case, add the `true` parameter as the second argument
56
+
57
+ ```ruby
58
+ client.case(1021505, true)
59
+ ```
60
+
61
+ ### Cases by Jurisdiction
62
+
63
+ To return an array of cases by jurisdiction, search either by jurisdiction id or name and enter in the number of cases you want returned as the second argument
64
+
65
+ ```ruby
66
+ client.cases_by_jurisdiciton("Colorado", 20)
67
+ client.cases_by_jurisdiciton(31, 20)
68
+ ```
69
+
70
+ This method can also return the full body of a case
71
+
72
+ ```ruby
73
+ client.cases_by_jurisdiciton("Colorado", 20, true)
74
+ client.cases_by_jurisdiciton(31, 20, true)
75
+ ```
76
+
77
+ ### Cases by Search Term
78
+
79
+ Search through cases that have a specific search term in the body of the case. The first argument is the search term and the second is the maximum number of case results you wish to return
80
+
81
+ ```ruby
82
+ client.search_cases("witchcraft", 30)
83
+ ```
84
+
85
+ You can also search through the text of cases by jurisdiction where the third argument is the jurisdiciton id or name
86
+
87
+ ```ruby
88
+ client.search_cases("witchcraft", 30, 31)
89
+ client.search_cases("witchcraft", 30, "Colorado")
90
+ ```
91
+
92
+
@@ -0,0 +1,14 @@
1
+ ## Usage
2
+ In order to run scripts:
3
+
4
+ Clone this repositiory and replace `"KEY"` with your provided API key as a string, or
5
+
6
+ Copy the script and replace the first two lines with `require 'caselaw'` after installing the gem, and then replace the API key as before
7
+
8
+ ## Examples
9
+
10
+ * [Get all Jurisdictions](jurisdictions.rb)
11
+ * Print out a list of jurisdictions and related info
12
+
13
+ * [Searching Cases by Text](witchcraft.rb)
14
+ * Print out a search of the first 40 cases that contain the word "witchcraft" in the text of the case
@@ -0,0 +1,13 @@
1
+ dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ require File.join(dir, 'caselaw')
3
+ require 'pp'
4
+
5
+ client = Caselaw::Client.new(api_key: "KEY")
6
+
7
+ search = client.search_jurisdictions
8
+
9
+ search.results.each do |jurisdiction|
10
+ pp "Name: " + jurisdiction.name_long + " | ID: " + jurisdiction.id.to_s + " | Slug: " + jurisdiction.slug
11
+ end
12
+
13
+
@@ -0,0 +1,12 @@
1
+ dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ require File.join(dir, 'caselaw')
3
+ require 'pp'
4
+
5
+ client = Caselaw::Client.new(api_key: "KEY")
6
+
7
+ cases = client.search_cases("witchcraft", 40)
8
+
9
+ cases.results.each do |c|
10
+ pp "Jurisdiction: " + c.jurisdiction.name_long + " || " + "Case Name: " + c.name
11
+ end
12
+
data/lib/caselaw.rb ADDED
@@ -0,0 +1,35 @@
1
+ require "caselaw/version"
2
+ require "caselaw/errors"
3
+ require "caselaw/request"
4
+ require "caselaw/client"
5
+ require "caselaw/jurisdiction"
6
+
7
+ module Caselaw
8
+ class << self
9
+ attr_accessor :settings
10
+ end
11
+ self.settings = {}
12
+
13
+ def self.new(params = {})
14
+ Caselaw::Client.new(params)
15
+ end
16
+
17
+ # Global configuration settings
18
+ def self.configure(params = {})
19
+ fail(ArgumentError, "API key hash required.") unless params.is_a?(Hash)
20
+
21
+ settings[:api_key] = params[:api_key]
22
+ settings
23
+ end
24
+
25
+ # Return global config hash
26
+ def self.configuration
27
+ settings
28
+ end
29
+
30
+ # Resets the global configuration
31
+ def self.reset_configuration
32
+ self.settings = {}
33
+ end
34
+
35
+ end
@@ -0,0 +1,26 @@
1
+ require "caselaw/client"
2
+ require "caselaw/client/cases"
3
+ require "caselaw/client/citations"
4
+ require "caselaw/client/courts"
5
+ require "caselaw/client/jurisdictions"
6
+ require "caselaw/client/reporters"
7
+ require "caselaw/client/volumes"
8
+
9
+ module Caselaw
10
+ class Client
11
+ include Caselaw::Request
12
+ include Caselaw::Cases
13
+ include Caselaw::Citations
14
+ include Caselaw::Courts
15
+ include Caselaw::Jurisdictions
16
+ include Caselaw::Reporters
17
+ include Caselaw::Volumes
18
+
19
+ attr_reader :api_key
20
+
21
+ def initialize(settings = {})
22
+ fail(ArgumentError, "API key hash is required.") unless settings.is_a?(Hash)
23
+ @api_key = settings[:api_key]
24
+ end
25
+ end
26
+ end