utility 0.1.9 → 0.1.11
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 +4 -4
- data/README.md +6 -0
- data/lib/utility.rb +1 -0
- data/lib/utility/callerloc.rb +25 -0
- data/lib/utility/computer.rb +1 -2
- data/lib/utility/try.rb +0 -1
- data/lib/utility/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8d74cffd346611abbd5a1c881f50d170c8754b10
|
4
|
+
data.tar.gz: 854d6c7d89f5be379ee50327696a9d8ed20ddbaa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 88dc6041c8f4c85ad468f24029f11a6077beb3ab6f986d7c145710caf1dffbba9ec2485d5e6d9b17a155f3378b389c5485eb6793204369d72cf47be4f8f27253
|
7
|
+
data.tar.gz: 96221b8bc8694ba3d9eed5d11d56a77e49ce6b3436aa32025610cb0541e107a7394cf8849c7e160b2ca67240f4f06558a915895f7096b7709adb084c98cf982a
|
data/README.md
CHANGED
@@ -99,5 +99,11 @@ Utility.try{ Date.current.year.size } #=> nil
|
|
99
99
|
#=> nil
|
100
100
|
```
|
101
101
|
|
102
|
+
#### others ####
|
103
|
+
```ruby
|
104
|
+
# mobile caller location query (China)
|
105
|
+
Utility.mobile_caller_location 13812345678 #=> "江苏连云港 中国移动 GSM"
|
106
|
+
```
|
107
|
+
|
102
108
|
### License ###
|
103
109
|
Released under the [MIT](http://opensource.org/licenses/MIT) license. See LICENSE file for details.
|
data/lib/utility.rb
CHANGED
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'uri'
|
2
|
+
require 'json'
|
3
|
+
require 'net/http'
|
4
|
+
|
5
|
+
module Utility::Callerloc
|
6
|
+
API_URL = 'http://sj.apidata.cn'
|
7
|
+
MUNICIPALITIES = %w(北京 上海 天津 重庆)
|
8
|
+
|
9
|
+
def mobile_caller_location(number)
|
10
|
+
uri = URI API_URL
|
11
|
+
params = {:mobile => number}
|
12
|
+
uri.query = URI.encode_www_form(params)
|
13
|
+
|
14
|
+
res = Net::HTTP.get_response(uri)
|
15
|
+
result = JSON.load res.body
|
16
|
+
data = result['data']
|
17
|
+
if result['status'].to_i == 1 #successed
|
18
|
+
output = data['province'] unless MUNICIPALITIES.include?(data['province'])
|
19
|
+
output.to_s + data['city'] + " " + data['types']
|
20
|
+
else
|
21
|
+
data['message']
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
data/lib/utility/computer.rb
CHANGED
data/lib/utility/try.rb
CHANGED
data/lib/utility/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: utility
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cenxky
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-08-
|
11
|
+
date: 2017-08-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: macaddr
|
@@ -98,6 +98,7 @@ files:
|
|
98
98
|
- bin/setup
|
99
99
|
- lib/utility.rb
|
100
100
|
- lib/utility/base64.rb
|
101
|
+
- lib/utility/callerloc.rb
|
101
102
|
- lib/utility/computer.rb
|
102
103
|
- lib/utility/digest.rb
|
103
104
|
- lib/utility/hmac.rb
|