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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZGEwMmFlNjY1YTRhOTg4ZjhkODNhOWY5OGE3NGQ2MzM0NjIwNjBlNw==
4
+ MmU1ZjNmOTBmMDRmZDk3MzhiYmZjZWQ1NzQ5ZjBiZDg4OGY1NWY4YQ==
5
5
  data.tar.gz: !binary |-
6
- NWI1NDM0MTk4MjhlOWZiZjg3NTRiMDQyNmQ0ZTMwMjY2ZGVmOTBhZg==
6
+ Mjk2NWVhYjE3ZWFkYTk1MjQwMGI0OGNmMTM1MzdhM2RmNGJhZWY0OQ==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- YjIyMzMwYmJkNDgxYjYyODViYWQxZDZmZjhhYzRiNTU1YTBiYzhmOTNkZmY1
10
- YzE2OTdkYzFjMzYwYzhhYzU3Y2M1NmUzM2M1ODU5NzQ0OGFlM2Y3NWYzN2M3
11
- ZmMzNmU3MjlkOTIxOWQ0MzE3NzUwY2NhZmY0Yjk5MjQyYzg3YzM=
9
+ OTdlOTJlOTY4NDdmYzQ3OWFlNTFjY2FlNmQzNTE0NzMwYjI1ZTE5ZmMxZmY0
10
+ Y2U3NjQ5Yzc4NjA1NDQ4OWFhYmY1YzYwNzg5NjFhNDhiYWYyZGFlZGE5NjAy
11
+ YTJkNDAwOGU3NmRkYjQ1OWZjOTgzYzU4MDMzMDczODg1MDUwZDU=
12
12
  data.tar.gz: !binary |-
13
- NzVkYTExY2UwNDFiZWNkNjg5YjUyMTM1MDYzZmUwMTg3NWUzN2ZmMmU0MDE5
14
- YzUxYTM2ZmM0YzUwMWQyYTc2ODZkNGU3ZjhlMGJjN2MyNzkxYWEwM2YzOGEz
15
- N2ExMzNkMDY5MWUzMWE1OWYzNTNiMTNhOWQyZDg5ZGQ1NGY0ZTY=
13
+ N2Y4YzVlNjQwYzJlYmZiMDNlNTkzMTQ5NjE2YzRmZDRiZWIwZWY5YzM3NGFi
14
+ NzE3NTNhM2FkMjZjZjkxMmE4Mjg1NDA0OWQ0MmJlNTMzMGZiNjNiNzRiMTAx
15
+ Njk3NTgwMDBlNTNhMzQ5YTY5ZDdhZTY5OTRjNWU0OGI4NGZlOWE=
@@ -1,3 +1,3 @@
1
1
  module USCISStatus
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
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
- def self.check(application_numbers)
7
+ class USCISWebScraping
8
+ CURRENT_CASE = "Your Current Case Status for"
9
9
 
10
- # Check if the parameter is an Array, otherwise create one
11
- applications = application_numbers.kind_of?(Array) ? application_numbers : application_numbers.split
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
- a = Mechanize.new
14
- statuses = []
14
+ a = Mechanize.new
15
+ statuses = []
15
16
 
16
- applications.each do |number|
17
- next if number.nil? or number.empty?
17
+ applications.each do |number|
18
+ next if number.nil? or number.empty?
18
19
 
19
- page = a.post("https://egov.uscis.gov/cris/Dashboard/CaseStatus.do", { "appReceiptNum" => number })
20
+ page = a.post("https://egov.uscis.gov/cris/Dashboard/CaseStatus.do", { "appReceiptNum" => number })
20
21
 
21
- # Look for possible errors with this application number
22
- error = page.search('div.errorContainer > ul')
23
- if !error.empty?
24
- statuses << {number: number, type: '', status: error.text.strip, description: '', general_description: ''}
25
- next
26
- end
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
- # Get the application type and description (eg. Form I130...)
29
- application_type = capitalize_words(page.search('div#caseStatus>h3').text.gsub(CURRENT_CASE, ""))
32
+ # Get current application block
33
+ current_application = page.search('div.caseStatusInfo')
30
34
 
31
- # Get current application block
32
- current_application = page.search('div.caseStatusInfo')
35
+ # Get the Status
36
+ status = current_application.search('h4').text.strip
33
37
 
34
- # Get the Status
35
- status = current_application.search('h4').text.strip
38
+ # Get the Description
39
+ description = current_application.search('.caseStatus').text.strip
36
40
 
37
- # Get the Description
38
- description = current_application.search('.caseStatus').text.strip
41
+ # Get the General Description for the Application
42
+ general_description = current_application.search('#bucketDesc').text.strip
39
43
 
40
- # Get the General Description for the Application
41
- general_description = current_application.search('#bucketDesc').text.strip
44
+ statuses << {number: number, type: application_type, status: status, description: description, general_description: general_description}
45
+
46
+ end
42
47
 
43
- statuses << {number: number, type: application_type, status: status, description: description, general_description: general_description}
48
+ return statuses
44
49
 
45
50
  end
46
51
 
47
- return statuses
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
- private
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.1.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-06 00:00:00.000000000 Z
11
+ date: 2013-04-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler