sg 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 +9 -0
- data/.rspec +2 -0
- data/.rubocop.yml +34 -0
- data/.travis.yml +4 -0
- data/CODE_OF_CONDUCT.md +49 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +39 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/exe/sg +4 -0
- data/lib/sg.rb +36 -0
- data/lib/sg/version.rb +6 -0
- data/sg.gemspec +31 -0
- metadata +150 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 82732360828cab23d974a31339ae0cf92559c1f9
|
4
|
+
data.tar.gz: fccc5163a71d88252763e51c16f770a39a30a773
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 450aba729809d6546a76afd56e5a355509bc3b8ff8b541c224f78f19a91a777a6dadd6b16de17597eab272ddf24a4fb4bed4d07efdb8f2f6f5b565a0f96a9e69
|
7
|
+
data.tar.gz: 405610df86a8885d0d505b8614f2819f6959bd6bb9419cc8b6485ecb1f521502c0eb092fd05484058eefc062f6aa6d4174bf8ffe41422e5f19deb0eda2be6a86
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# # Let prefix of method name set_ and get_
|
2
|
+
# AccessorMethodName:
|
3
|
+
# Enabled: false
|
4
|
+
#
|
5
|
+
# Change limitation of method length
|
6
|
+
MethodLength:
|
7
|
+
CountComments: true # count full line comments?
|
8
|
+
Max: 20
|
9
|
+
|
10
|
+
# # Change limitation of module length
|
11
|
+
# ModuleLength:
|
12
|
+
# Max: 600
|
13
|
+
#
|
14
|
+
# # Change limitation of the number of params
|
15
|
+
# ParameterLists:
|
16
|
+
# Max: 8
|
17
|
+
# CountKeywordArgs: false
|
18
|
+
#
|
19
|
+
# Change limitation of AbcSize
|
20
|
+
AbcSize:
|
21
|
+
Max: 27
|
22
|
+
|
23
|
+
# # Change numeric literals
|
24
|
+
# NumericLiterals:
|
25
|
+
# MinDigits: 20
|
26
|
+
#
|
27
|
+
# # Disable force module and class style
|
28
|
+
# ClassAndModuleChildren:
|
29
|
+
# Enabled: false
|
30
|
+
#
|
31
|
+
# # Change limitation of the class length
|
32
|
+
# ClassLength:
|
33
|
+
# CountComments: false # count full line comments?
|
34
|
+
# Max: 180
|
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, and in the interest of
|
4
|
+
fostering an open and welcoming community, we pledge to respect all people who
|
5
|
+
contribute through reporting issues, posting feature requests, updating
|
6
|
+
documentation, submitting pull requests or patches, and other activities.
|
7
|
+
|
8
|
+
We are committed to making participation in this project a harassment-free
|
9
|
+
experience for everyone, regardless of level of experience, gender, gender
|
10
|
+
identity and expression, sexual orientation, disability, personal appearance,
|
11
|
+
body size, race, ethnicity, age, religion, or nationality.
|
12
|
+
|
13
|
+
Examples of unacceptable behavior by participants include:
|
14
|
+
|
15
|
+
* The use of sexualized language or imagery
|
16
|
+
* Personal attacks
|
17
|
+
* Trolling or insulting/derogatory comments
|
18
|
+
* Public or private harassment
|
19
|
+
* Publishing other's private information, such as physical or electronic
|
20
|
+
addresses, without explicit permission
|
21
|
+
* Other unethical or unprofessional conduct
|
22
|
+
|
23
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
24
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
25
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
26
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
27
|
+
threatening, offensive, or harmful.
|
28
|
+
|
29
|
+
By adopting this Code of Conduct, project maintainers commit themselves to
|
30
|
+
fairly and consistently applying these principles to every aspect of managing
|
31
|
+
this project. Project maintainers who do not follow or enforce the Code of
|
32
|
+
Conduct may be permanently removed from the project team.
|
33
|
+
|
34
|
+
This code of conduct applies both within project spaces and in public spaces
|
35
|
+
when an individual is representing the project or its community.
|
36
|
+
|
37
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
38
|
+
reported by contacting a project maintainer at awwa500@gmail.com. All
|
39
|
+
complaints will be reviewed and investigated and will result in a response that
|
40
|
+
is deemed necessary and appropriate to the circumstances. Maintainers are
|
41
|
+
obligated to maintain confidentiality with regard to the reporter of an
|
42
|
+
incident.
|
43
|
+
|
44
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
45
|
+
version 1.3.0, available at
|
46
|
+
[http://contributor-covenant.org/version/1/3/0/][version]
|
47
|
+
|
48
|
+
[homepage]: http://contributor-covenant.org
|
49
|
+
[version]: http://contributor-covenant.org/version/1/3/0/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 awwa500@gmail.com
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# sg
|
2
|
+
|
3
|
+
`sg` gem allows you to access SendGrid API v3 endpoints from command line interface.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
You can install the `sg` via gem command:
|
8
|
+
|
9
|
+
$ gem install sg
|
10
|
+
|
11
|
+
## Usage
|
12
|
+
|
13
|
+
### Setup
|
14
|
+
|
15
|
+
`sg` loads your SendGrid API Key from `SENDGRID_API_KEY` environment variable if you do not specify. So set your API Key to your environment variable.
|
16
|
+
|
17
|
+
$ env | grep SENDGRID_API_KEY
|
18
|
+
SENDGRID_API_KEY=SG...
|
19
|
+
|
20
|
+
### Basic Usage
|
21
|
+
|
22
|
+
See help.
|
23
|
+
|
24
|
+
$ bundle exec sg client help
|
25
|
+
|
26
|
+
## Development
|
27
|
+
|
28
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. Run `bundle exec sg` to use the gem in this directory, ignoring other installed copies of this gem.
|
29
|
+
|
30
|
+
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`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
31
|
+
|
32
|
+
## Contributing
|
33
|
+
|
34
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/sg. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
35
|
+
|
36
|
+
|
37
|
+
## License
|
38
|
+
|
39
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'sg'
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require 'irb'
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/exe/sg
ADDED
data/lib/sg.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'sendgrid-ruby'
|
3
|
+
require 'sg/version'
|
4
|
+
|
5
|
+
module Sg
|
6
|
+
#
|
7
|
+
# SendGrid Command Line Interface Class
|
8
|
+
#
|
9
|
+
class CLI < Thor
|
10
|
+
desc 'client', 'Call SendGrid Web API v3 from command line interface'
|
11
|
+
option(
|
12
|
+
:apikey,
|
13
|
+
aliases: '-k',
|
14
|
+
desc: 'API Key. Use env variable "SENDGRID_API_KEY" if not specified.'
|
15
|
+
)
|
16
|
+
option :request_body, aliases: '-b', desc: 'Request Body'
|
17
|
+
option :query_params, aliases: '-q', desc: 'Query String of the request'
|
18
|
+
option :response_header, aliases: '-h', desc: 'Output response header'
|
19
|
+
option :response_status, aliases: '-s', desc: 'Output reponse status code'
|
20
|
+
option :version, aliases: '-v', desc: 'Output gem version'
|
21
|
+
def client(*args)
|
22
|
+
return puts Sg::VERSION if options[:version]
|
23
|
+
api_key = options[:apikey]
|
24
|
+
api_key ||= ENV['SENDGRID_API_KEY']
|
25
|
+
sg = SendGrid::API.new(api_key: api_key)
|
26
|
+
idx = 0
|
27
|
+
response = args.inject(sg.client) do |c, arg|
|
28
|
+
idx += 1
|
29
|
+
(args.length == idx + 1) ? c.send(arg, options) : c.send(arg)
|
30
|
+
end
|
31
|
+
puts response.status_code if options[:response_status]
|
32
|
+
puts response.headers if options[:response_header]
|
33
|
+
puts response.body
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/lib/sg/version.rb
ADDED
data/sg.gemspec
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'sg/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'sg'
|
8
|
+
spec.version = Sg::VERSION
|
9
|
+
spec.authors = ['awwa500@gmail.com']
|
10
|
+
spec.email = ['awwa500@gmail.com']
|
11
|
+
|
12
|
+
spec.summary = 'Call SendGrid API v3 from the command line interface.'
|
13
|
+
spec.description = 'Call SendGrid API v3 from the command line interface.'
|
14
|
+
spec.homepage = 'https://github.com/awwa/sg/'
|
15
|
+
spec.license = 'MIT'
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
|
+
f.match(%r{^(test|spec|features)/})
|
19
|
+
end
|
20
|
+
spec.bindir = 'exe'
|
21
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
+
spec.require_paths = ['lib']
|
23
|
+
|
24
|
+
spec.add_dependency('thor', '~> 0.19.1')
|
25
|
+
spec.add_dependency('sendgrid-ruby', '~> 3.0.0')
|
26
|
+
|
27
|
+
spec.add_development_dependency('rubocop', '>=0.29.0', '<0.34.3')
|
28
|
+
spec.add_development_dependency('bundler', '~> 1.11')
|
29
|
+
spec.add_development_dependency('rake', '~> 10.0')
|
30
|
+
spec.add_development_dependency('rspec', '~> 3.0')
|
31
|
+
end
|
metadata
ADDED
@@ -0,0 +1,150 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sg
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- awwa500@gmail.com
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-07-05 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: thor
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.19.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.19.1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: sendgrid-ruby
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 3.0.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 3.0.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rubocop
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.29.0
|
48
|
+
- - "<"
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: 0.34.3
|
51
|
+
type: :development
|
52
|
+
prerelease: false
|
53
|
+
version_requirements: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: 0.29.0
|
58
|
+
- - "<"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: 0.34.3
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: bundler
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - "~>"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '1.11'
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - "~>"
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '1.11'
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: rake
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - "~>"
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '10.0'
|
82
|
+
type: :development
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - "~>"
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '10.0'
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: rspec
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - "~>"
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '3.0'
|
96
|
+
type: :development
|
97
|
+
prerelease: false
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - "~>"
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '3.0'
|
103
|
+
description: Call SendGrid API v3 from the command line interface.
|
104
|
+
email:
|
105
|
+
- awwa500@gmail.com
|
106
|
+
executables:
|
107
|
+
- sg
|
108
|
+
extensions: []
|
109
|
+
extra_rdoc_files: []
|
110
|
+
files:
|
111
|
+
- ".gitignore"
|
112
|
+
- ".rspec"
|
113
|
+
- ".rubocop.yml"
|
114
|
+
- ".travis.yml"
|
115
|
+
- CODE_OF_CONDUCT.md
|
116
|
+
- Gemfile
|
117
|
+
- LICENSE.txt
|
118
|
+
- README.md
|
119
|
+
- Rakefile
|
120
|
+
- bin/console
|
121
|
+
- bin/setup
|
122
|
+
- exe/sg
|
123
|
+
- lib/sg.rb
|
124
|
+
- lib/sg/version.rb
|
125
|
+
- sg.gemspec
|
126
|
+
homepage: https://github.com/awwa/sg/
|
127
|
+
licenses:
|
128
|
+
- MIT
|
129
|
+
metadata: {}
|
130
|
+
post_install_message:
|
131
|
+
rdoc_options: []
|
132
|
+
require_paths:
|
133
|
+
- lib
|
134
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
140
|
+
requirements:
|
141
|
+
- - ">="
|
142
|
+
- !ruby/object:Gem::Version
|
143
|
+
version: '0'
|
144
|
+
requirements: []
|
145
|
+
rubyforge_project:
|
146
|
+
rubygems_version: 2.5.1
|
147
|
+
signing_key:
|
148
|
+
specification_version: 4
|
149
|
+
summary: Call SendGrid API v3 from the command line interface.
|
150
|
+
test_files: []
|