uscis_status 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/lib/uscis_status/version.rb +1 -1
- data/lib/uscis_status.rb +39 -30
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MmU1ZjNmOTBmMDRmZDk3MzhiYmZjZWQ1NzQ5ZjBiZDg4OGY1NWY4YQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
Mjk2NWVhYjE3ZWFkYTk1MjQwMGI0OGNmMTM1MzdhM2RmNGJhZWY0OQ==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
OTdlOTJlOTY4NDdmYzQ3OWFlNTFjY2FlNmQzNTE0NzMwYjI1ZTE5ZmMxZmY0
|
10
|
+
Y2U3NjQ5Yzc4NjA1NDQ4OWFhYmY1YzYwNzg5NjFhNDhiYWYyZGFlZGE5NjAy
|
11
|
+
YTJkNDAwOGU3NmRkYjQ1OWZjOTgzYzU4MDMzMDczODg1MDUwZDU=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
N2Y4YzVlNjQwYzJlYmZiMDNlNTkzMTQ5NjE2YzRmZDRiZWIwZWY5YzM3NGFi
|
14
|
+
NzE3NTNhM2FkMjZjZjkxMmE4Mjg1NDA0OWQ0MmJlNTMzMGZiNjNiNzRiMTAx
|
15
|
+
Njk3NTgwMDBlNTNhMzQ5YTY5ZDdhZTY5OTRjNWU0OGI4NGZlOWE=
|
data/lib/uscis_status/version.rb
CHANGED
data/lib/uscis_status.rb
CHANGED
@@ -3,55 +3,64 @@ require 'mechanize'
|
|
3
3
|
require 'nokogiri'
|
4
4
|
|
5
5
|
module USCISStatus
|
6
|
-
CURRENT_CASE = "Your Current Case Status for"
|
7
6
|
|
8
|
-
|
7
|
+
class USCISWebScraping
|
8
|
+
CURRENT_CASE = "Your Current Case Status for"
|
9
9
|
|
10
|
-
|
11
|
-
|
10
|
+
def self.check(application_numbers)
|
11
|
+
# Check if the parameter is an Array, otherwise create one
|
12
|
+
applications = application_numbers.kind_of?(Array) ? application_numbers : application_numbers.split
|
12
13
|
|
13
|
-
|
14
|
-
|
14
|
+
a = Mechanize.new
|
15
|
+
statuses = []
|
15
16
|
|
16
|
-
|
17
|
-
|
17
|
+
applications.each do |number|
|
18
|
+
next if number.nil? or number.empty?
|
18
19
|
|
19
|
-
|
20
|
+
page = a.post("https://egov.uscis.gov/cris/Dashboard/CaseStatus.do", { "appReceiptNum" => number })
|
20
21
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
22
|
+
# Look for possible errors with this application number
|
23
|
+
error = page.search('div.errorContainer > ul')
|
24
|
+
if !error.empty?
|
25
|
+
statuses << {number: number, type: '', status: error.text.strip, description: '', general_description: ''}
|
26
|
+
next
|
27
|
+
end
|
28
|
+
|
29
|
+
# Get the application type and description (eg. Form I130...)
|
30
|
+
application_type = capitalize_words(page.search('div#caseStatus>h3').text.gsub(CURRENT_CASE, ""))
|
27
31
|
|
28
|
-
|
29
|
-
|
32
|
+
# Get current application block
|
33
|
+
current_application = page.search('div.caseStatusInfo')
|
30
34
|
|
31
|
-
|
32
|
-
|
35
|
+
# Get the Status
|
36
|
+
status = current_application.search('h4').text.strip
|
33
37
|
|
34
|
-
|
35
|
-
|
38
|
+
# Get the Description
|
39
|
+
description = current_application.search('.caseStatus').text.strip
|
36
40
|
|
37
|
-
|
38
|
-
|
41
|
+
# Get the General Description for the Application
|
42
|
+
general_description = current_application.search('#bucketDesc').text.strip
|
39
43
|
|
40
|
-
|
41
|
-
|
44
|
+
statuses << {number: number, type: application_type, status: status, description: description, general_description: general_description}
|
45
|
+
|
46
|
+
end
|
42
47
|
|
43
|
-
statuses
|
48
|
+
return statuses
|
44
49
|
|
45
50
|
end
|
46
51
|
|
47
|
-
|
52
|
+
private
|
53
|
+
|
54
|
+
def self.capitalize_words(sentence)
|
55
|
+
sentence.strip.split(' ').map{ |word| word.capitalize }.join(' ')
|
56
|
+
end
|
48
57
|
|
49
58
|
end
|
50
59
|
|
51
|
-
|
60
|
+
def self.check(application_numbers)
|
61
|
+
|
62
|
+
return USCISWebScraping.check(application_numbers)
|
52
63
|
|
53
|
-
def self.capitalize_words(sentence)
|
54
|
-
sentence.strip.split(' ').map{ |word| word.capitalize }.join(' ')
|
55
64
|
end
|
56
65
|
|
57
66
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: uscis_status
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Guillermo Guerini
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-04-
|
11
|
+
date: 2013-04-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|