alidayu_sms 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +1 -0
- data/.idea/.rakeTasks +7 -0
- data/.idea/alidayu_sms.iml +27 -0
- data/.idea/misc.xml +14 -0
- data/.idea/modules.xml +8 -0
- data/.idea/vcs.xml +6 -0
- data/.idea/workspace.xml +41 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +33 -0
- data/README.md +39 -0
- data/Rakefile +12 -0
- data/alidayu_sms.gemspec +26 -0
- data/bin/alidayu_sms +82 -0
- data/lib/alidayu_sms/alidayu.rb +70 -0
- data/lib/alidayu_sms/version.rb +3 -0
- data/lib/alidayu_sms.rb +76 -0
- data/lib/tasks/alidayu_sms.rake +7 -0
- data/lib/templates/alidayu_sms.yml +14 -0
- data/pkg/alidayu_sms-0.1.0.gem +0 -0
- metadata +133 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 358c8f0763bf15466b7511b60bbfa562e72c03fe
|
4
|
+
data.tar.gz: b379d22e05ec0358492615c4dd17ced744b7c399
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: efbad6893b6901a6044ac289755260fd2dadd62576ad6b44c8d97dc76aeb379c28620017d086b0942a5428461456221c49414ae1023666167d19d3ddcbadcb87
|
7
|
+
data.tar.gz: 890070ebc7a1c983e4b50f1d301336f861d4732bfee2b3663c94b30163ddeb1f308ab2d85b67bd263110f4964a997a6ecd641bfdd801ab402a334ed6f9cafd58
|
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
*~
|
data/.idea/.rakeTasks
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<Settings><!--This file was automatically generated by Ruby plugin.
|
3
|
+
You are allowed to:
|
4
|
+
1. Remove rake task
|
5
|
+
2. Add existing rake tasks
|
6
|
+
To add existing rake tasks automatically delete this file and reload the project.
|
7
|
+
--><RakeGroup description="" fullCmd="" taksId="rake"><RakeTask description="Build alidayu_sms-0.1.0.gem into the pkg directory" fullCmd="build" taksId="build" /><RakeTask description="Build and install alidayu_sms-0.1.0.gem into system gems" fullCmd="install" taksId="install" /><RakeGroup description="" fullCmd="" taksId="install"><RakeTask description="Build and install alidayu_sms-0.1.0.gem into system gems without network access" fullCmd="install:local" taksId="local" /></RakeGroup><RakeTask description="Create tag v0.1.0 and build and push alidayu_sms-0.1.0.gem to Rubygems" fullCmd="release" taksId="release" /><RakeTask description="Run tests" fullCmd="test" taksId="test" /><RakeGroup description="" fullCmd="" taksId="alidayu_sms"><RakeTask description="" fullCmd="alidayu_sms:create_default_config_file" taksId="create_default_config_file" /></RakeGroup><RakeTask description="" fullCmd="default" taksId="default" /><RakeGroup description="" fullCmd="" taksId="release"><RakeTask description="" fullCmd="release:guard_clean" taksId="guard_clean" /><RakeTask description="" fullCmd="release:rubygem_push" taksId="rubygem_push" /><RakeTask description="" fullCmd="release:source_control_push" taksId="source_control_push" /></RakeGroup></RakeGroup></Settings>
|
@@ -0,0 +1,27 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<module type="RUBY_MODULE" version="4">
|
3
|
+
<component name="FacetManager">
|
4
|
+
<facet type="gem" name="Ruby Gem">
|
5
|
+
<configuration>
|
6
|
+
<option name="GEM_APP_ROOT_PATH" value="$MODULE_DIR$" />
|
7
|
+
<option name="GEM_APP_TEST_PATH" value="$MODULE_DIR$/test" />
|
8
|
+
<option name="GEM_APP_LIB_PATH" value="$MODULE_DIR$/lib" />
|
9
|
+
</configuration>
|
10
|
+
</facet>
|
11
|
+
</component>
|
12
|
+
<component name="NewModuleRootManager">
|
13
|
+
<content url="file://$MODULE_DIR$">
|
14
|
+
<sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
|
15
|
+
</content>
|
16
|
+
<orderEntry type="inheritedJdk" />
|
17
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
18
|
+
<orderEntry type="library" scope="PROVIDED" name="activesupport (v4.1.14.1, RVM: ruby-2.1.5) [gem]" level="application" />
|
19
|
+
<orderEntry type="library" scope="PROVIDED" name="i18n (v0.7.0, RVM: ruby-2.1.5) [gem]" level="application" />
|
20
|
+
<orderEntry type="library" scope="PROVIDED" name="json (v1.8.3, RVM: ruby-2.1.5) [gem]" level="application" />
|
21
|
+
<orderEntry type="library" scope="PROVIDED" name="minitest (v5.8.4, RVM: ruby-2.1.5) [gem]" level="application" />
|
22
|
+
<orderEntry type="library" scope="PROVIDED" name="rack (v1.6.4, RVM: ruby-2.1.5) [gem]" level="application" />
|
23
|
+
<orderEntry type="library" scope="PROVIDED" name="rake (v10.5.0, RVM: ruby-2.1.5) [gem]" level="application" />
|
24
|
+
<orderEntry type="library" scope="PROVIDED" name="thread_safe (v0.3.5, RVM: ruby-2.1.5) [gem]" level="application" />
|
25
|
+
<orderEntry type="library" scope="PROVIDED" name="tzinfo (v1.2.2, RVM: ruby-2.1.5) [gem]" level="application" />
|
26
|
+
</component>
|
27
|
+
</module>
|
data/.idea/misc.xml
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<project version="4">
|
3
|
+
<component name="ProjectLevelVcsManager" settingsEditedManually="false">
|
4
|
+
<OptionsSetting value="true" id="Add" />
|
5
|
+
<OptionsSetting value="true" id="Remove" />
|
6
|
+
<OptionsSetting value="true" id="Checkout" />
|
7
|
+
<OptionsSetting value="true" id="Update" />
|
8
|
+
<OptionsSetting value="true" id="Status" />
|
9
|
+
<OptionsSetting value="true" id="Edit" />
|
10
|
+
<ConfirmationsSetting value="0" id="Add" />
|
11
|
+
<ConfirmationsSetting value="0" id="Remove" />
|
12
|
+
</component>
|
13
|
+
<component name="ProjectRootManager" version="2" project-jdk-name="RVM: ruby-2.1.5" project-jdk-type="RUBY_SDK" />
|
14
|
+
</project>
|
data/.idea/modules.xml
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<project version="4">
|
3
|
+
<component name="ProjectModuleManager">
|
4
|
+
<modules>
|
5
|
+
<module fileurl="file://$PROJECT_DIR$/.idea/alidayu_sms.iml" filepath="$PROJECT_DIR$/.idea/alidayu_sms.iml" />
|
6
|
+
</modules>
|
7
|
+
</component>
|
8
|
+
</project>
|
data/.idea/vcs.xml
ADDED
data/.idea/workspace.xml
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<project version="4">
|
3
|
+
<component name="ChangeListManager">
|
4
|
+
<option name="TRACKING_ENABLED" value="true" />
|
5
|
+
<option name="SHOW_DIALOG" value="false" />
|
6
|
+
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
7
|
+
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
8
|
+
<option name="LAST_RESOLUTION" value="IGNORE" />
|
9
|
+
</component>
|
10
|
+
<component name="ChangesViewManager" flattened_view="true" show_ignored="false" />
|
11
|
+
<component name="CreatePatchCommitExecutor">
|
12
|
+
<option name="PATCH_PATH" value="" />
|
13
|
+
</component>
|
14
|
+
<component name="NamedScopeManager">
|
15
|
+
<order />
|
16
|
+
</component>
|
17
|
+
<component name="ProjectLevelVcsManager" settingsEditedManually="false">
|
18
|
+
<OptionsSetting value="true" id="Add" />
|
19
|
+
<OptionsSetting value="true" id="Remove" />
|
20
|
+
<OptionsSetting value="true" id="Checkout" />
|
21
|
+
<OptionsSetting value="true" id="Update" />
|
22
|
+
<OptionsSetting value="true" id="Status" />
|
23
|
+
<OptionsSetting value="true" id="Edit" />
|
24
|
+
<ConfirmationsSetting value="0" id="Add" />
|
25
|
+
<ConfirmationsSetting value="0" id="Remove" />
|
26
|
+
</component>
|
27
|
+
<component name="ShelveChangesManager" show_recycled="false" />
|
28
|
+
<component name="TaskManager">
|
29
|
+
<task active="true" id="Default" summary="Default task">
|
30
|
+
<option name="number" value="Default" />
|
31
|
+
</task>
|
32
|
+
<servers />
|
33
|
+
</component>
|
34
|
+
<component name="VcsContentAnnotationSettings">
|
35
|
+
<option name="myLimit" value="2678400000" />
|
36
|
+
</component>
|
37
|
+
<component name="XDebuggerManager">
|
38
|
+
<breakpoint-manager />
|
39
|
+
<watches-manager />
|
40
|
+
</component>
|
41
|
+
</project>
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
alidayu_sms (0.1.0)
|
5
|
+
i18n
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
activesupport (4.1.14.1)
|
11
|
+
i18n (~> 0.6, >= 0.6.9)
|
12
|
+
json (~> 1.7, >= 1.7.7)
|
13
|
+
minitest (~> 5.1)
|
14
|
+
thread_safe (~> 0.1)
|
15
|
+
tzinfo (~> 1.1)
|
16
|
+
i18n (0.7.0)
|
17
|
+
json (1.8.3)
|
18
|
+
minitest (5.8.4)
|
19
|
+
rack (1.6.4)
|
20
|
+
rake (10.5.0)
|
21
|
+
thread_safe (0.3.5)
|
22
|
+
tzinfo (1.2.2)
|
23
|
+
thread_safe (~> 0.1)
|
24
|
+
|
25
|
+
PLATFORMS
|
26
|
+
ruby
|
27
|
+
|
28
|
+
DEPENDENCIES
|
29
|
+
activesupport (~> 4.1.12)
|
30
|
+
alidayu_sms!
|
31
|
+
bundler (~> 1.9)
|
32
|
+
rack
|
33
|
+
rake (~> 10.0)
|
data/README.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# alidayu_sms
|
2
|
+
阿里大鱼的短信发送api
|
3
|
+
|
4
|
+
# Gemfile add
|
5
|
+
gem 'alidayu_sms', git: 'git@github.com:wangping0105/alidayu_sms.git'
|
6
|
+
|
7
|
+
# start
|
8
|
+
##生成配置文件示例!(my :app_key and :app_secret, Valid to 2016.02.22)
|
9
|
+
rake alidayu_sms:create_default_config_file
|
10
|
+
```ruby
|
11
|
+
defaults: &defaults
|
12
|
+
alidayu:
|
13
|
+
app_key: 23304964
|
14
|
+
app_secret: "12b083a7c5e89ce3093067ddd65c4b5a"
|
15
|
+
post_url: 'http://gw.api.taobao.com/router/rest'
|
16
|
+
|
17
|
+
development:
|
18
|
+
<<: *defaults
|
19
|
+
|
20
|
+
test:
|
21
|
+
<<: *defaults
|
22
|
+
|
23
|
+
production:
|
24
|
+
<<: *defaults
|
25
|
+
```
|
26
|
+
## hello world!
|
27
|
+
```ruby
|
28
|
+
options = {
|
29
|
+
code: 1314520, # 模板的{code}字段
|
30
|
+
phones: "1520122011,1591251515", # 手机号码
|
31
|
+
product: "王平爱王玲", # 模板的{product}字段
|
32
|
+
extend: '', # 公共回传参数,在“消息返回”中会透传回该参数;举例:用户可以传入自己下级的会员ID,在消息返回时,该会员ID会包含在内,用户可以根据该会员ID识别是哪位会员使用了你的应用
|
33
|
+
sms_free_sign_name: "注册验证", # 短信签名
|
34
|
+
sms_template_code: "SMS_5045503" # 短信模板
|
35
|
+
}
|
36
|
+
result = AlidayuSmsSender.new.batchSendSms(options)
|
37
|
+
|
38
|
+
# 返回码参考 阿里大鱼 api文档
|
39
|
+
```
|
data/Rakefile
ADDED
data/alidayu_sms.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'alidayu_sms/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "alidayu_sms"
|
8
|
+
spec.version = AlidayuSms::VERSION
|
9
|
+
spec.authors = ["jack ping"]
|
10
|
+
spec.email = ["525399584@qq.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{alidayu_sms send.}
|
13
|
+
spec.description = %q{alidayu_sms send.}
|
14
|
+
spec.homepage = "https://github.com/wangping0105/alidayu_sms"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.bindir = "bin"
|
18
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency 'i18n'
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.9"
|
23
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
+
spec.add_development_dependency "activesupport", "~> 4.1.12"
|
25
|
+
spec.add_development_dependency 'rack'
|
26
|
+
end
|
data/bin/alidayu_sms
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "optparse"
|
4
|
+
require "pp"
|
5
|
+
require 'rack'
|
6
|
+
|
7
|
+
$:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
|
8
|
+
require 'alidayu_sms'
|
9
|
+
|
10
|
+
options = {method: 'batchSendSms'}
|
11
|
+
attributes = {}
|
12
|
+
|
13
|
+
OptionParser.new do |o|
|
14
|
+
o.banner = <<-EOF
|
15
|
+
Usage:
|
16
|
+
Starting:
|
17
|
+
alidayu_sms [-p <phone>] [-c <code>] [-m <model>] [-t <type>]
|
18
|
+
|
19
|
+
Querying:
|
20
|
+
alidayu_sms -v
|
21
|
+
|
22
|
+
Options:
|
23
|
+
EOF
|
24
|
+
|
25
|
+
o.on("-p", "--phones=phones", String, "send alidayu_sms phones") do |x|
|
26
|
+
options[:phones] = x
|
27
|
+
end
|
28
|
+
|
29
|
+
o.on("-c", "--code=code", String, "send alidayu_sms code") do |x|
|
30
|
+
options[:code] = x
|
31
|
+
end
|
32
|
+
|
33
|
+
o.on("-s", "--source=source", String, "send alidayu_sms source [zucp|taobao] (Default: zucp)") do |x|
|
34
|
+
options[:source] = x
|
35
|
+
end
|
36
|
+
|
37
|
+
o.on("-m", "--m=method", String, "send alidayu_sms method [batch] (Default: batch)") do |x|
|
38
|
+
options[:method] = x
|
39
|
+
end
|
40
|
+
|
41
|
+
o.on("-a", "--a=attributes", String, "attributes: ()") do |x|
|
42
|
+
attributes = Rack::Utils.parse_nested_query(x)
|
43
|
+
end
|
44
|
+
|
45
|
+
o.on("-h", "--help", "Show help documentation") do |x|
|
46
|
+
puts o
|
47
|
+
exit
|
48
|
+
end
|
49
|
+
|
50
|
+
o.on("-v", "--version", "Show alidayu_sms version") do |x|
|
51
|
+
puts "Version: #{AlidayuSms::VERSION}"
|
52
|
+
exit
|
53
|
+
end
|
54
|
+
end.parse!
|
55
|
+
|
56
|
+
options.merge!(attributes)
|
57
|
+
|
58
|
+
#测试用的, 不过我的key可能无效了哦
|
59
|
+
options = options.merge(
|
60
|
+
:code=> 1314520,
|
61
|
+
:product => "王平爱王玲",
|
62
|
+
:extend => '',
|
63
|
+
:sms_free_sign_name=> "注册验证",
|
64
|
+
:sms_template_code=> "SMS_5045503"
|
65
|
+
)
|
66
|
+
sys_options = {
|
67
|
+
app_key: 23304964,
|
68
|
+
app_secret: "12b083a7c5e89ce3093067ddd65c4b5a",
|
69
|
+
post_url: 'http://gw.api.taobao.com/router/rest'
|
70
|
+
}
|
71
|
+
|
72
|
+
begin
|
73
|
+
puts options.inspect
|
74
|
+
puts AlidayuSmsSender.new(sys_options).send(options[:method], options)
|
75
|
+
rescue => e
|
76
|
+
puts 'Uncaught exception'
|
77
|
+
puts e.message
|
78
|
+
puts e.backtrace.join("\n")
|
79
|
+
end
|
80
|
+
|
81
|
+
# sms -p 13262902619 -s taobao -a 'app_secret=5aff003ac3c7243da65adef1e7c9c363&app_key=23272925&sms_free_sign_name=爱客验证码&sms_template_code=SMS_2575137&sms_param[code]=xxx&sms_param[product]=ddd'
|
82
|
+
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
|
3
|
+
module AlidayuSms
|
4
|
+
class Alidayu
|
5
|
+
attr_accessor :app_key, :app_secret, :post_url
|
6
|
+
|
7
|
+
def initialize(options = {})
|
8
|
+
self.app_key = options['app_key']
|
9
|
+
self.app_secret = options['app_secret']
|
10
|
+
self.post_url = options['post_url']
|
11
|
+
end
|
12
|
+
|
13
|
+
def standard_send_msg(arg = [])
|
14
|
+
code, product, _phones, _extend, _sms_free_sign_name, _sms_template_code = arg
|
15
|
+
|
16
|
+
_sms_param = "{'code':'#{code}','product':'#{product}'}"
|
17
|
+
_timestamp = Time.now.strftime("%F %T")
|
18
|
+
options = {
|
19
|
+
app_key: self.app_key,
|
20
|
+
format: 'json',
|
21
|
+
method: 'alibaba.aliqin.fc.sms.num.send',
|
22
|
+
partner_id: 'apidoc',
|
23
|
+
sign_method: 'md5',
|
24
|
+
timestamp: _timestamp,
|
25
|
+
v: '2.0',
|
26
|
+
extend: _extend,
|
27
|
+
rec_num: _phones,
|
28
|
+
sms_free_sign_name: _sms_free_sign_name,
|
29
|
+
sms_param: _sms_param,
|
30
|
+
sms_template_code: _sms_template_code,
|
31
|
+
sms_type: 'normal'
|
32
|
+
}
|
33
|
+
|
34
|
+
options = sort_options(options)
|
35
|
+
puts "options: #{options}"
|
36
|
+
|
37
|
+
md5_str = 加密(options)
|
38
|
+
response = post(self.post_url, options.merge(sign: md5_str))
|
39
|
+
puts "phones: #{_phones}, #{_sms_param}, and respone: #{response}"
|
40
|
+
response
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
def sort_options(**arg)
|
45
|
+
arg.sort_by{|k,v| k}.to_h
|
46
|
+
end
|
47
|
+
|
48
|
+
def 加密(**arg)
|
49
|
+
_arg = arg.map{|k,v| "#{k}#{v}"}
|
50
|
+
md5("#{self.app_secret}#{_arg.join("")}#{self.app_secret}").upcase
|
51
|
+
end
|
52
|
+
|
53
|
+
def md5(arg)
|
54
|
+
Digest::MD5.hexdigest(arg)
|
55
|
+
end
|
56
|
+
|
57
|
+
def post(uri, options)
|
58
|
+
response = ""
|
59
|
+
url = URI.parse(uri)
|
60
|
+
Net::HTTP.start(url.host, url.port) do |http|
|
61
|
+
req = Net::HTTP::Post.new(url.path)
|
62
|
+
req.set_form_data(options)
|
63
|
+
response = http.request(req).body
|
64
|
+
end
|
65
|
+
JSON(response)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
|
data/lib/alidayu_sms.rb
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
$:.unshift File.expand_path('../../lib', __FILE__)
|
2
|
+
|
3
|
+
require 'pp'
|
4
|
+
require "active_support/all"
|
5
|
+
|
6
|
+
require "alidayu_sms/version"
|
7
|
+
require "alidayu_sms/alidayu"
|
8
|
+
|
9
|
+
require 'yaml' unless defined? YMAL
|
10
|
+
|
11
|
+
def load_config
|
12
|
+
if defined? ::Rails
|
13
|
+
@sms_config ||= HashWithIndifferentAccess.new(YAML.load_file("#{::Rails.root}/config/alidayu_sms.yml")[::Rails.env] || {})
|
14
|
+
else
|
15
|
+
{}
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
class AlidayuSmsSender
|
20
|
+
attr_accessor :source, :template_code
|
21
|
+
|
22
|
+
def initialize(options = {})
|
23
|
+
if load_config.present? && load_config[:alidayu].present?
|
24
|
+
options = load_config[:alidayu].merge(options)
|
25
|
+
end
|
26
|
+
options = HashWithIndifferentAccess.new(options)
|
27
|
+
check_system_params(options)
|
28
|
+
|
29
|
+
@source = AlidayuSms::Alidayu.new(options)
|
30
|
+
end
|
31
|
+
|
32
|
+
# 发送短信
|
33
|
+
def batchSendSms(options = {})
|
34
|
+
options = HashWithIndifferentAccess.new(options)
|
35
|
+
|
36
|
+
arr = %w(code product phones extend sms_free_sign_name sms_template_code)
|
37
|
+
attr, flag = [], false
|
38
|
+
arr.each do |a|
|
39
|
+
flag = true unless options[a]
|
40
|
+
attr << options[a]
|
41
|
+
end
|
42
|
+
|
43
|
+
check_params(flag, options)
|
44
|
+
puts "传入参数为:#{attr}"
|
45
|
+
|
46
|
+
@source.standard_send_msg(attr)
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
def check_params(flag, options)
|
51
|
+
raise "自定义参数不全!\n你传入的: #{options.map{|k,v| k.to_sym}}\n需要传入: [:code :product :phones :extend :sms_free_sign_name :sms_template_code]" if flag
|
52
|
+
end
|
53
|
+
|
54
|
+
def check_system_params(options)
|
55
|
+
arr = %w(app_key app_secret post_url)
|
56
|
+
attr, flag = [], false
|
57
|
+
arr.each do |a|
|
58
|
+
flag = true unless options[a]
|
59
|
+
attr << options[a]
|
60
|
+
end
|
61
|
+
raise "系统参数不全!\n你传入的: #{options.map{|k,v| k.to_sym}}\n需要传入: [:app_key, :app_secret, :post_url]\n请配置 alidayu_sms.yml" if flag
|
62
|
+
puts "系统参数检测完毕!"
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
if defined? ::Rails
|
67
|
+
module AlidayuSms
|
68
|
+
module Rails
|
69
|
+
class Railtie < ::Rails::Railtie
|
70
|
+
rake_tasks do
|
71
|
+
load "tasks/alidayu_sms.rake"
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
Binary file
|
metadata
ADDED
@@ -0,0 +1,133 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: alidayu_sms
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- jack ping
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-02-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: i18n
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.9'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.9'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: activesupport
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 4.1.12
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 4.1.12
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rack
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: alidayu_sms send.
|
84
|
+
email:
|
85
|
+
- 525399584@qq.com
|
86
|
+
executables:
|
87
|
+
- alidayu_sms
|
88
|
+
extensions: []
|
89
|
+
extra_rdoc_files: []
|
90
|
+
files:
|
91
|
+
- ".gitignore"
|
92
|
+
- ".idea/.rakeTasks"
|
93
|
+
- ".idea/alidayu_sms.iml"
|
94
|
+
- ".idea/misc.xml"
|
95
|
+
- ".idea/modules.xml"
|
96
|
+
- ".idea/vcs.xml"
|
97
|
+
- ".idea/workspace.xml"
|
98
|
+
- Gemfile
|
99
|
+
- Gemfile.lock
|
100
|
+
- README.md
|
101
|
+
- Rakefile
|
102
|
+
- alidayu_sms.gemspec
|
103
|
+
- bin/alidayu_sms
|
104
|
+
- lib/alidayu_sms.rb
|
105
|
+
- lib/alidayu_sms/alidayu.rb
|
106
|
+
- lib/alidayu_sms/version.rb
|
107
|
+
- lib/tasks/alidayu_sms.rake
|
108
|
+
- lib/templates/alidayu_sms.yml
|
109
|
+
- pkg/alidayu_sms-0.1.0.gem
|
110
|
+
homepage: https://github.com/wangping0105/alidayu_sms
|
111
|
+
licenses: []
|
112
|
+
metadata: {}
|
113
|
+
post_install_message:
|
114
|
+
rdoc_options: []
|
115
|
+
require_paths:
|
116
|
+
- lib
|
117
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
118
|
+
requirements:
|
119
|
+
- - ">="
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: '0'
|
122
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
123
|
+
requirements:
|
124
|
+
- - ">="
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: '0'
|
127
|
+
requirements: []
|
128
|
+
rubyforge_project:
|
129
|
+
rubygems_version: 2.4.6
|
130
|
+
signing_key:
|
131
|
+
specification_version: 4
|
132
|
+
summary: alidayu_sms send.
|
133
|
+
test_files: []
|