entinfo 0.1.0 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 24366a29f2d56be08fd44dc5fd7f7b705f4eb0ee
4
- data.tar.gz: 79a819ac6ead0da414d1dc009596d5d755b5a967
3
+ metadata.gz: 92e0a09830c2dfe16243ae68ba457930b03aa204
4
+ data.tar.gz: ba92057d5d7b3daf856af6692c3e7ad63ec1385b
5
5
  SHA512:
6
- metadata.gz: 2c00dc55e39f379a4699d0fa65470cfa5e5bed29425f380fc040c553caaf60e5df948cea8fa0bd7d406c56676ace37707d4642a5a34ed7056741cfffef3b8a01
7
- data.tar.gz: 390fdcbf27d579d290596daf5ac5710a961b68b44e7e0b73ca46196e952b260fe84b9011eb7b59c398cbbf9cb3b78494744b991ff2c98a356c5d6055d21d25ed
6
+ metadata.gz: 227f0e2e3fba1d9fd54ce372ce9cac57b6bc848c3d107c6a96c746cbb6720e3fa4cc08a3dcb946f5a1222cc9321002b16bb4fc0678b612d57352881c35a2a692
7
+ data.tar.gz: e440f7de27a449adbff2d9cd27c7f7ba76af491e7384604981ddd0317ba8e99404027666c46382a00a3f67e517bd6f03586545b4f4f123c11ce0f9973b803669
data/README.md CHANGED
@@ -1,8 +1,6 @@
1
1
  # Entinfo
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/entinfo`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
3
+ Rails gem for 创世漫道短信api
6
4
 
7
5
  ## Installation
8
6
 
@@ -22,13 +20,23 @@ Or install it yourself as:
22
20
 
23
21
  ## Usage
24
22
 
25
- TODO: Write usage instructions here
23
+ ### Initial config
24
+ `config/initializers/entinfo.rb`
26
25
 
27
- ## Development
26
+ ```ruby
27
+ Entinfo.configure do |config|
28
+ # 运营商分配给您的SN号(帐号)
29
+ config.sn = 'SDK-XXX-000-00000'
30
+ # 运营商分配给您的密码
31
+ config.pwd = '0-0_0-0'
32
+ end
33
+ ```
28
34
 
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
35
+ ### Send message
30
36
 
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
37
+ ```ruby
38
+ Entinfo.send_sms('15200000000','hello【短信签名】')
39
+ ```
32
40
 
33
41
  ## Contributing
34
42
 
@@ -0,0 +1,6 @@
1
+ module Entinfo
2
+ class Configuration
3
+ attr_accessor :sn
4
+ attr_accessor :pwd
5
+ end
6
+ end
@@ -1,3 +1,3 @@
1
1
  module Entinfo
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.5"
3
3
  end
data/lib/entinfo.rb CHANGED
@@ -1,5 +1,37 @@
1
1
  require "entinfo/version"
2
+ require 'entinfo/configuration'
3
+ require 'net/http'
4
+ require 'digest'
5
+ require 'iconv'
6
+ require 'time'
2
7
 
3
8
  module Entinfo
4
- # Your code goes here...
9
+ extend self
10
+ #config
11
+ attr_writer :config
12
+
13
+ def config
14
+ @config ||= Configuration.new
15
+ end
16
+
17
+ def configure
18
+ yield(config)
19
+ end
20
+
21
+ #send sms
22
+ URL = "http://sdk2.entinfo.cn:8061/mdsmssend.ashx"
23
+
24
+ def pwd
25
+ Digest::MD5.hexdigest(@config.sn + @config.pwd).upcase
26
+ end
27
+
28
+ def send_sms(phone, content)
29
+ result = Net::HTTP.post_form(URI.parse("#{URL}"), sn: @config.sn, pwd: self.pwd, mobile: phone, content: content)
30
+ if result.body.match '^\d{18}$'
31
+ {success: result.body}
32
+ else
33
+ {error: result.body}
34
+ end
35
+ end
36
+
5
37
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: entinfo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - saxer
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-01-16 00:00:00.000000000 Z
11
+ date: 2016-01-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -58,6 +58,7 @@ files:
58
58
  - bin/setup
59
59
  - entinfo.gemspec
60
60
  - lib/entinfo.rb
61
+ - lib/entinfo/configuration.rb
61
62
  - lib/entinfo/version.rb
62
63
  homepage: https://github.com/mumaoxi/entinfo
63
64
  licenses: