globelabs_sms_logger 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.env.sample +0 -0
- data/.gitignore +14 -0
- data/.rspec +3 -0
- data/.rubocop.yml +1 -0
- data/.rubocop_todo.yml +44 -0
- data/.travis.yml +22 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +16 -0
- data/Gemfile.lock +138 -0
- data/Guardfile +75 -0
- data/LICENSE +21 -0
- data/README.md +56 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/globelabs_sms_logger.gemspec +38 -0
- data/lib/generators/globelabs_sms_logger/install_generator.rb +20 -0
- data/lib/generators/globelabs_sms_logger/templates/dash_initializer.rb +10 -0
- data/lib/globelabs_sms/logger.rb +43 -0
- data/lib/globelabs_sms_logger.rb +30 -0
- data/lib/globelabs_sms_logger/configuration.rb +37 -0
- data/lib/globelabs_sms_logger/version.rb +3 -0
- metadata +111 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 328fca7c04fecdfb68d7480588733434f465a3100ace310b9653ff03cfaf07ae
|
4
|
+
data.tar.gz: 8e54f3e17325cfe2f73e3e6e69cb626c855474779f3124d285774731e724aaa1
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d587ac57f1304ba7e6599c439b391077bacbd50059b0349b540ce01e24fecb31b0da83bd7ba46f8d1cf2997d93fafbf7f2814a46b69784732d00c83f15344197
|
7
|
+
data.tar.gz: 1ba28dcc6ee9835562eeac809e3016a470fe8e6b74e3c1d9529891b73a347cf83ff1d852e29e4f468d16a009328068cd6dd94f7c6962bb68a7c70cc9f6befd1c
|
data/.env.sample
ADDED
File without changes
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
inherit_from: .rubocop_todo.yml
|
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
# This configuration was generated by
|
2
|
+
# `rubocop --auto-gen-config`
|
3
|
+
# on 2019-01-10 16:18:22 +0800 using RuboCop version 0.62.0.
|
4
|
+
# The point is for the user to remove these configuration records
|
5
|
+
# one by one as the offenses are removed from the code base.
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
8
|
+
|
9
|
+
# Offense count: 1
|
10
|
+
# Cop supports --auto-correct.
|
11
|
+
# Configuration parameters: EnforcedStyleAlignWith, AutoCorrect, Severity.
|
12
|
+
# SupportedStylesAlignWith: keyword, variable, start_of_line
|
13
|
+
Layout/EndAlignment:
|
14
|
+
Exclude:
|
15
|
+
- 'lib/globelabs_sms_logger/configuration.rb'
|
16
|
+
|
17
|
+
# Offense count: 1
|
18
|
+
Lint/DuplicateMethods:
|
19
|
+
Exclude:
|
20
|
+
- 'lib/globelabs_sms_logger.rb'
|
21
|
+
|
22
|
+
# Offense count: 1
|
23
|
+
Metrics/AbcSize:
|
24
|
+
Max: 24
|
25
|
+
|
26
|
+
# Offense count: 1
|
27
|
+
# Configuration parameters: CountComments, ExcludedMethods.
|
28
|
+
# ExcludedMethods: refine
|
29
|
+
Metrics/BlockLength:
|
30
|
+
Max: 50
|
31
|
+
|
32
|
+
# Offense count: 2
|
33
|
+
Style/Documentation:
|
34
|
+
Exclude:
|
35
|
+
# - 'spec/**/*'
|
36
|
+
# - 'test/**/*'
|
37
|
+
# - 'lib/globelabs_sms/logger.rb'
|
38
|
+
# - 'lib/globelabs_sms_logger.rb'
|
39
|
+
|
40
|
+
# Offense count: 10
|
41
|
+
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
|
42
|
+
# URISchemes: http, https
|
43
|
+
# Metrics/LineLength:
|
44
|
+
# Max: 156
|
data/.travis.yml
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
sudo: false
|
2
|
+
language: ruby
|
3
|
+
rvm:
|
4
|
+
- 2.5.3
|
5
|
+
before_install: gem install bundler -v 1.17.1
|
6
|
+
notifications: false
|
7
|
+
|
8
|
+
env:
|
9
|
+
global:
|
10
|
+
- CC_TEST_REPORTER_ID=a3447ea2adb73c8f2f39fec720291342b44a8e8b72aca541d59476b9ea0c0db4
|
11
|
+
|
12
|
+
before_script:
|
13
|
+
- bundle exec rspec && CODECLIMATE_REPO_TOKEN=a3447ea2adb73c8f2f39fec720291342b44a8e8b72aca541d59476b9ea0c0db4
|
14
|
+
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
15
|
+
- chmod +x ./cc-test-reporter
|
16
|
+
- ./cc-test-reporter before-build
|
17
|
+
|
18
|
+
scripts:
|
19
|
+
- bundle exec rspec spec
|
20
|
+
|
21
|
+
after_script:
|
22
|
+
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at denmarkmeralpis@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
|
4
|
+
|
5
|
+
# Specify your gem's dependencies in globelabs_sms_logger.gemspec
|
6
|
+
gemspec
|
7
|
+
|
8
|
+
group :test do
|
9
|
+
gem 'byebug'
|
10
|
+
gem 'dotenv'
|
11
|
+
gem 'generator_spec'
|
12
|
+
gem 'rubocop'
|
13
|
+
gem 'simplecov'
|
14
|
+
gem 'simplecov-console'
|
15
|
+
gem 'webmock'
|
16
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,138 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
globelabs_sms_logger (0.0.1)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
actionpack (5.2.2)
|
10
|
+
actionview (= 5.2.2)
|
11
|
+
activesupport (= 5.2.2)
|
12
|
+
rack (~> 2.0)
|
13
|
+
rack-test (>= 0.6.3)
|
14
|
+
rails-dom-testing (~> 2.0)
|
15
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
16
|
+
actionview (5.2.2)
|
17
|
+
activesupport (= 5.2.2)
|
18
|
+
builder (~> 3.1)
|
19
|
+
erubi (~> 1.4)
|
20
|
+
rails-dom-testing (~> 2.0)
|
21
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
22
|
+
activesupport (5.2.2)
|
23
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
24
|
+
i18n (>= 0.7, < 2)
|
25
|
+
minitest (~> 5.1)
|
26
|
+
tzinfo (~> 1.1)
|
27
|
+
addressable (2.5.2)
|
28
|
+
public_suffix (>= 2.0.2, < 4.0)
|
29
|
+
ansi (1.5.0)
|
30
|
+
ast (2.4.0)
|
31
|
+
builder (3.2.3)
|
32
|
+
byebug (10.0.2)
|
33
|
+
concurrent-ruby (1.1.4)
|
34
|
+
crack (0.4.3)
|
35
|
+
safe_yaml (~> 1.0.0)
|
36
|
+
crass (1.0.4)
|
37
|
+
diff-lcs (1.3)
|
38
|
+
docile (1.3.1)
|
39
|
+
dotenv (2.6.0)
|
40
|
+
erubi (1.8.0)
|
41
|
+
generator_spec (0.9.4)
|
42
|
+
activesupport (>= 3.0.0)
|
43
|
+
railties (>= 3.0.0)
|
44
|
+
hashdiff (0.3.8)
|
45
|
+
hirb (0.7.3)
|
46
|
+
i18n (1.5.1)
|
47
|
+
concurrent-ruby (~> 1.0)
|
48
|
+
jaro_winkler (1.5.2)
|
49
|
+
json (2.1.0)
|
50
|
+
loofah (2.2.3)
|
51
|
+
crass (~> 1.0.2)
|
52
|
+
nokogiri (>= 1.5.9)
|
53
|
+
method_source (0.9.2)
|
54
|
+
mini_portile2 (2.4.0)
|
55
|
+
minitest (5.11.3)
|
56
|
+
nokogiri (1.10.0)
|
57
|
+
mini_portile2 (~> 2.4.0)
|
58
|
+
parallel (1.12.1)
|
59
|
+
parser (2.5.3.0)
|
60
|
+
ast (~> 2.4.0)
|
61
|
+
powerpack (0.1.2)
|
62
|
+
public_suffix (3.0.3)
|
63
|
+
rack (2.0.6)
|
64
|
+
rack-test (1.1.0)
|
65
|
+
rack (>= 1.0, < 3)
|
66
|
+
rails-dom-testing (2.0.3)
|
67
|
+
activesupport (>= 4.2.0)
|
68
|
+
nokogiri (>= 1.6)
|
69
|
+
rails-html-sanitizer (1.0.4)
|
70
|
+
loofah (~> 2.2, >= 2.2.2)
|
71
|
+
railties (5.2.2)
|
72
|
+
actionpack (= 5.2.2)
|
73
|
+
activesupport (= 5.2.2)
|
74
|
+
method_source
|
75
|
+
rake (>= 0.8.7)
|
76
|
+
thor (>= 0.19.0, < 2.0)
|
77
|
+
rainbow (3.0.0)
|
78
|
+
rake (10.5.0)
|
79
|
+
rspec (3.8.0)
|
80
|
+
rspec-core (~> 3.8.0)
|
81
|
+
rspec-expectations (~> 3.8.0)
|
82
|
+
rspec-mocks (~> 3.8.0)
|
83
|
+
rspec-core (3.8.0)
|
84
|
+
rspec-support (~> 3.8.0)
|
85
|
+
rspec-expectations (3.8.2)
|
86
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
87
|
+
rspec-support (~> 3.8.0)
|
88
|
+
rspec-mocks (3.8.0)
|
89
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
90
|
+
rspec-support (~> 3.8.0)
|
91
|
+
rspec-support (3.8.0)
|
92
|
+
rubocop (0.62.0)
|
93
|
+
jaro_winkler (~> 1.5.1)
|
94
|
+
parallel (~> 1.10)
|
95
|
+
parser (>= 2.5, != 2.5.1.1)
|
96
|
+
powerpack (~> 0.1)
|
97
|
+
rainbow (>= 2.2.2, < 4.0)
|
98
|
+
ruby-progressbar (~> 1.7)
|
99
|
+
unicode-display_width (~> 1.4.0)
|
100
|
+
ruby-progressbar (1.10.0)
|
101
|
+
safe_yaml (1.0.4)
|
102
|
+
simplecov (0.16.1)
|
103
|
+
docile (~> 1.1)
|
104
|
+
json (>= 1.8, < 3)
|
105
|
+
simplecov-html (~> 0.10.0)
|
106
|
+
simplecov-console (0.4.2)
|
107
|
+
ansi
|
108
|
+
hirb
|
109
|
+
simplecov
|
110
|
+
simplecov-html (0.10.2)
|
111
|
+
thor (0.20.3)
|
112
|
+
thread_safe (0.3.6)
|
113
|
+
tzinfo (1.2.5)
|
114
|
+
thread_safe (~> 0.1)
|
115
|
+
unicode-display_width (1.4.1)
|
116
|
+
webmock (3.5.1)
|
117
|
+
addressable (>= 2.3.6)
|
118
|
+
crack (>= 0.3.2)
|
119
|
+
hashdiff
|
120
|
+
|
121
|
+
PLATFORMS
|
122
|
+
ruby
|
123
|
+
|
124
|
+
DEPENDENCIES
|
125
|
+
bundler (~> 1.17)
|
126
|
+
byebug
|
127
|
+
dotenv
|
128
|
+
generator_spec
|
129
|
+
globelabs_sms_logger!
|
130
|
+
rake (~> 10.0)
|
131
|
+
rspec (~> 3.0)
|
132
|
+
rubocop
|
133
|
+
simplecov
|
134
|
+
simplecov-console
|
135
|
+
webmock
|
136
|
+
|
137
|
+
BUNDLED WITH
|
138
|
+
1.17.1
|
data/Guardfile
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
## Uncomment and set this to only include directories you want to watch
|
5
|
+
# directories %w(app lib config test spec features) \
|
6
|
+
# .select{|d| Dir.exist?(d) ? d : UI.warning("Directory #{d} does not exist")}
|
7
|
+
|
8
|
+
## Note: if you are using the `directories` clause above and you are not
|
9
|
+
## watching the project directory ('.'), then you will want to move
|
10
|
+
## the Guardfile to a watched dir and symlink it back, e.g.
|
11
|
+
#
|
12
|
+
# $ mkdir config
|
13
|
+
# $ mv Guardfile config/
|
14
|
+
# $ ln -s config/Guardfile .
|
15
|
+
#
|
16
|
+
# and, you'll have to watch "config/Guardfile" instead of "Guardfile"
|
17
|
+
|
18
|
+
# Note: The cmd option is now required due to the increasing number of ways
|
19
|
+
# rspec may be run, below are examples of the most common uses.
|
20
|
+
# * bundler: 'bundle exec rspec'
|
21
|
+
# * bundler binstubs: 'bin/rspec'
|
22
|
+
# * spring: 'bin/rspec' (This will use spring if running and you have
|
23
|
+
# installed the spring binstubs per the docs)
|
24
|
+
# * zeus: 'zeus rspec' (requires the server to be started separately)
|
25
|
+
# * 'just' rspec: 'rspec'
|
26
|
+
|
27
|
+
guard :rspec, cmd: 'bundle exec rspec' do
|
28
|
+
require 'guard/rspec/dsl'
|
29
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
30
|
+
|
31
|
+
# Feel free to open issues for suggestions and improvements
|
32
|
+
|
33
|
+
# RSpec files
|
34
|
+
rspec = dsl.rspec
|
35
|
+
watch(rspec.spec_helper) { rspec.spec_dir }
|
36
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
37
|
+
watch(rspec.spec_files)
|
38
|
+
|
39
|
+
# Ruby files
|
40
|
+
ruby = dsl.ruby
|
41
|
+
dsl.watch_spec_files_for(ruby.lib_files)
|
42
|
+
|
43
|
+
# Rails files
|
44
|
+
rails = dsl.rails(view_extensions: %w[erb haml slim])
|
45
|
+
dsl.watch_spec_files_for(rails.app_files)
|
46
|
+
dsl.watch_spec_files_for(rails.views)
|
47
|
+
|
48
|
+
watch(rails.controllers) do |m|
|
49
|
+
[
|
50
|
+
rspec.spec.call("routing/#{m[1]}_routing"),
|
51
|
+
rspec.spec.call("controllers/#{m[1]}_controller"),
|
52
|
+
rspec.spec.call("acceptance/#{m[1]}")
|
53
|
+
]
|
54
|
+
end
|
55
|
+
|
56
|
+
# Rails config changes
|
57
|
+
watch(rails.spec_helper) { rspec.spec_dir }
|
58
|
+
watch(rails.routes) { "#{rspec.spec_dir}/routing" }
|
59
|
+
watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }
|
60
|
+
|
61
|
+
# Capybara features specs
|
62
|
+
watch(rails.view_dirs) { |m| rspec.spec.call("features/#{m[1]}") }
|
63
|
+
watch(rails.layouts) { |m| rspec.spec.call("features/#{m[1]}") }
|
64
|
+
|
65
|
+
# Turnip features and steps
|
66
|
+
watch(%r{^spec/acceptance/(.+)\.feature$})
|
67
|
+
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
|
68
|
+
Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance'
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
# guard :rubocop do
|
73
|
+
# watch(/.+\.rb$/)
|
74
|
+
# watch(%r{(?:.+/)?\.rubocop(?:_todo)?\.yml$}) { |m| File.dirname(m[0]) }
|
75
|
+
# end
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2019 Nujian Den Mark Meralpis
|
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 all
|
13
|
+
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 THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
[![Build Status](https://travis-ci.org/denmarkmeralpis/globelabs_sms_logger.svg?branch=master)](https://travis-ci.org/denmarkmeralpis/globelabs_sms_logger)
|
2
|
+
[![Test Coverage](https://api.codeclimate.com/v1/badges/26978dbc15878f486bd6/test_coverage)](https://codeclimate.com/github/denmarkmeralpis/globelabs_sms_logger/test_coverage)
|
3
|
+
[![Maintainability](https://api.codeclimate.com/v1/badges/26978dbc15878f486bd6/maintainability)](https://codeclimate.com/github/denmarkmeralpis/globelabs_sms_logger/maintainability)
|
4
|
+
# Globe Labs Sms Logger
|
5
|
+
|
6
|
+
It's a simple logger which consumes the Globelabs SMS Dashboard API(See Globelabs SMS Dasbhoard).
|
7
|
+
|
8
|
+
## Requirements
|
9
|
+
|
10
|
+
Ruby 2.x.x
|
11
|
+
|
12
|
+
## Installation
|
13
|
+
|
14
|
+
Add this line to your application's Gemfile:
|
15
|
+
|
16
|
+
```ruby
|
17
|
+
gem 'globelabs_sms_logger'
|
18
|
+
```
|
19
|
+
|
20
|
+
And then execute:
|
21
|
+
|
22
|
+
$ bundle
|
23
|
+
|
24
|
+
Or install it yourself as:
|
25
|
+
|
26
|
+
$ gem install globelabs_sms_logger
|
27
|
+
|
28
|
+
Then generate initializer:
|
29
|
+
|
30
|
+
$ rails g globelabs_sms_logger:install initializer
|
31
|
+
|
32
|
+
then edit the file `config/initializers/globelabs_sms_logger.rb`
|
33
|
+
|
34
|
+
## Usage
|
35
|
+
|
36
|
+
Construct a `GlobelabsSms::Logger` object and use the `#send` method to send a request to Globelabs Dashboard. Example:
|
37
|
+
|
38
|
+
```ruby
|
39
|
+
require 'globelabs_sms_logger'
|
40
|
+
|
41
|
+
logger = GlobelabsSms::Logger.new
|
42
|
+
logger.send(address: '917XXXXXXX', content: 'Cheers!')
|
43
|
+
|
44
|
+
# You can also speicfy the api_token & app_identifier as args
|
45
|
+
# Example:
|
46
|
+
logger = GlobelabsSms::Logger.new(api_token: 'zxvcjeyxi1j1smplsmple', identifier: 'TST')
|
47
|
+
logger.send(address: '917XXXXXXX', content: 'Hello!')
|
48
|
+
```
|
49
|
+
|
50
|
+
## Contributing
|
51
|
+
|
52
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/denmarkmeralpis/globelabs_sms_logger. 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.
|
53
|
+
|
54
|
+
## Code of Conduct
|
55
|
+
|
56
|
+
Everyone interacting in the GlobelabsSmsLogger project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/denmarkmeralpis/globelabs_sms_logger/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'globelabs_sms_logger'
|
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(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
lib = File.expand_path('lib', __dir__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'globelabs_sms_logger/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'globelabs_sms_logger'
|
7
|
+
spec.version = GlobelabsSmsLogger::VERSION
|
8
|
+
spec.authors = ['Nujian Den Mark Meralpis']
|
9
|
+
spec.email = ['denmarkmeralpis@gmail.com']
|
10
|
+
|
11
|
+
spec.summary = "It's a logger for Globelabs Dashboard"
|
12
|
+
spec.description = 'Consuming Globelabs SMS Dashboards API'
|
13
|
+
spec.homepage = 'https://github.com/denmarkmeralpis/globelabs_sms_logger'
|
14
|
+
|
15
|
+
if spec.respond_to?(:metadata)
|
16
|
+
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
17
|
+
|
18
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
19
|
+
spec.metadata['source_code_uri'] = 'https://github.com/denmarkmeralpis/globelabs_sms_logger'
|
20
|
+
spec.metadata['changelog_uri'] = 'https://github.com/denmarkmeralpis/globelabs_sms_logger/blob/master/README.md'
|
21
|
+
else
|
22
|
+
raise 'RubyGems 2.0 or newer is required to protect against ' \
|
23
|
+
'public gem pushes.'
|
24
|
+
end
|
25
|
+
|
26
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
27
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
28
|
+
f.match(%r{^(test|spec|features)/})
|
29
|
+
end
|
30
|
+
end
|
31
|
+
spec.bindir = 'exe'
|
32
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
33
|
+
spec.require_paths = ['lib']
|
34
|
+
|
35
|
+
spec.add_development_dependency 'bundler', '~> 1.17'
|
36
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
37
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
38
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
|
3
|
+
# Module
|
4
|
+
module GlobelabsSmsLogger
|
5
|
+
# Generators
|
6
|
+
module Generators
|
7
|
+
# Class
|
8
|
+
class InstallGenerator < Rails::Generators::NamedBase
|
9
|
+
source_root File.expand_path('templates', __dir__)
|
10
|
+
desc 'Creates globelabs_sms_logger.rb initializer for your application'
|
11
|
+
|
12
|
+
def copy_initializer
|
13
|
+
template 'dash_initializer.rb',
|
14
|
+
'config/initializers/globelabs_sms_logger.rb'
|
15
|
+
puts 'Done! Configure the file in
|
16
|
+
config/initializers/globelabs_sms_logger.rb'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
GlobelabsSmsLogger.configure do |config|
|
2
|
+
# Get the creds at Globelabs SMS Dashboard
|
3
|
+
config.api_token = ENV['DASH_API_TOKEN']
|
4
|
+
|
5
|
+
# uncomment this line if you want to change your host
|
6
|
+
# config.host = 'https://smsdash.nueca.net'
|
7
|
+
|
8
|
+
# Use default app identifier found in GLabs SMS Dashboard
|
9
|
+
config.app_identifier = ENV['DASH_APP_IDENTIFIER']
|
10
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
# Module
|
5
|
+
class GlobelabsSms
|
6
|
+
# Class
|
7
|
+
class Logger
|
8
|
+
attr_accessor :api_token, :identifier, :host, :address, :content
|
9
|
+
|
10
|
+
ENDPOINT = '/api/v1/messages'.freeze
|
11
|
+
|
12
|
+
def initialize(opts = {})
|
13
|
+
@host = GlobelabsSmsLogger.configuration.host
|
14
|
+
@api_token = opts.fetch(:api_token,
|
15
|
+
GlobelabsSmsLogger.configuration.api_token)
|
16
|
+
@identifier = opts.fetch(:identifier,
|
17
|
+
GlobelabsSmsLogger.configuration.app_identifier)
|
18
|
+
end
|
19
|
+
|
20
|
+
def send(opts = {})
|
21
|
+
@address = opts.fetch(:address, address)
|
22
|
+
@content = opts.fetch(:content, content)
|
23
|
+
|
24
|
+
perform_sending
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def perform_sending
|
30
|
+
uri = URI(host + ENDPOINT)
|
31
|
+
req = Net::HTTP::Post.new(uri.path)
|
32
|
+
req['Gem-Version'] = GlobelabsSmsLogger::VERSION
|
33
|
+
req.basic_auth(identifier, api_token)
|
34
|
+
req.set_form_data(content: content, address: address)
|
35
|
+
res = Net::HTTP.start(uri.host, uri.port,
|
36
|
+
use_ssl: uri.scheme == 'https') do |http|
|
37
|
+
http.request(req)
|
38
|
+
end
|
39
|
+
|
40
|
+
{ code: res.code, body: res.body }
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'globelabs_sms_logger/version'
|
2
|
+
require 'globelabs_sms_logger/configuration'
|
3
|
+
require 'globelabs_sms/logger'
|
4
|
+
require 'generators/globelabs_sms_logger/install_generator'
|
5
|
+
|
6
|
+
# Module
|
7
|
+
module GlobelabsSmsLogger
|
8
|
+
class Error < StandardError; end
|
9
|
+
|
10
|
+
class << self
|
11
|
+
attr_accessor :configuration
|
12
|
+
attr_accessor :testr
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.testr
|
16
|
+
puts GlobelabsSmsLogger::InstallGenerator
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.configuration
|
20
|
+
@configuration ||= Configuration.new
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.reset
|
24
|
+
@configuration = Configuration.new
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.configure
|
28
|
+
yield(configuration)
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# Module
|
2
|
+
module GlobelabsSmsLogger
|
3
|
+
# class cofiguration
|
4
|
+
class Configuration
|
5
|
+
attr_writer :api_token, :app_identifier, :host
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
@api_token = nil
|
9
|
+
@app_identifier = nil
|
10
|
+
@host = nil
|
11
|
+
end
|
12
|
+
|
13
|
+
def api_token
|
14
|
+
unless @api_token
|
15
|
+
raise GlobelabsSmsLogger::Error,
|
16
|
+
'Globelabs SMS Dashboard api_token is missing!
|
17
|
+
See documentation for configuration settings.'
|
18
|
+
end
|
19
|
+
|
20
|
+
@api_token
|
21
|
+
end
|
22
|
+
|
23
|
+
def app_identifier
|
24
|
+
unless @app_identifier
|
25
|
+
raise GlobelabsSmsLogger::Error,
|
26
|
+
'Globelabs SMS Dashboard api_token is missing!
|
27
|
+
See documentation for configuration settings.'
|
28
|
+
end
|
29
|
+
|
30
|
+
@app_identifier
|
31
|
+
end
|
32
|
+
|
33
|
+
def host
|
34
|
+
@host || 'https://smsdash.nueca.net'
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
metadata
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: globelabs_sms_logger
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Nujian Den Mark Meralpis
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-01-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.17'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.17'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
description: Consuming Globelabs SMS Dashboards API
|
56
|
+
email:
|
57
|
+
- denmarkmeralpis@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".env.sample"
|
63
|
+
- ".gitignore"
|
64
|
+
- ".rspec"
|
65
|
+
- ".rubocop.yml"
|
66
|
+
- ".rubocop_todo.yml"
|
67
|
+
- ".travis.yml"
|
68
|
+
- CODE_OF_CONDUCT.md
|
69
|
+
- Gemfile
|
70
|
+
- Gemfile.lock
|
71
|
+
- Guardfile
|
72
|
+
- LICENSE
|
73
|
+
- README.md
|
74
|
+
- Rakefile
|
75
|
+
- bin/console
|
76
|
+
- bin/setup
|
77
|
+
- globelabs_sms_logger.gemspec
|
78
|
+
- lib/generators/globelabs_sms_logger/install_generator.rb
|
79
|
+
- lib/generators/globelabs_sms_logger/templates/dash_initializer.rb
|
80
|
+
- lib/globelabs_sms/logger.rb
|
81
|
+
- lib/globelabs_sms_logger.rb
|
82
|
+
- lib/globelabs_sms_logger/configuration.rb
|
83
|
+
- lib/globelabs_sms_logger/version.rb
|
84
|
+
homepage: https://github.com/denmarkmeralpis/globelabs_sms_logger
|
85
|
+
licenses: []
|
86
|
+
metadata:
|
87
|
+
allowed_push_host: https://rubygems.org
|
88
|
+
homepage_uri: https://github.com/denmarkmeralpis/globelabs_sms_logger
|
89
|
+
source_code_uri: https://github.com/denmarkmeralpis/globelabs_sms_logger
|
90
|
+
changelog_uri: https://github.com/denmarkmeralpis/globelabs_sms_logger/blob/master/README.md
|
91
|
+
post_install_message:
|
92
|
+
rdoc_options: []
|
93
|
+
require_paths:
|
94
|
+
- lib
|
95
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
100
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
requirements: []
|
106
|
+
rubyforge_project:
|
107
|
+
rubygems_version: 2.7.8
|
108
|
+
signing_key:
|
109
|
+
specification_version: 4
|
110
|
+
summary: It's a logger for Globelabs Dashboard
|
111
|
+
test_files: []
|