vodem_sms 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5176b4aac23ede9ff330081f287e4e6e93fda884
4
+ data.tar.gz: 149184c916dd31cab504eea5e6a65ca8a7bfa192
5
+ SHA512:
6
+ metadata.gz: cd0cd09f9ba20c4caf8f913df90594bbf44253f0a570bc7f2ef5614f77818296d8406fa4ab0b16ad2af2fa424b37690513dfc492a4945dc8fcd300325321596a
7
+ data.tar.gz: 16b3001ea548acda6c35e3e6bf874b80c1b5df7b89b3c7675e4462efb35152825f2de8e00027dfd4ca3f8965bd8425af34eee6f47ed7d840cb7c13b088ba2740
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.0
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in vodem_sms.gemspec
4
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,77 @@
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
+
7
+ ## Uncomment to clear the screen before every task
8
+ # clearing :on
9
+
10
+ ## Guard internally checks for changes in the Guardfile and exits.
11
+ ## If you want Guard to automatically start up again, run guard in a
12
+ ## shell loop, e.g.:
13
+ ##
14
+ ## $ while bundle exec guard; do echo "Restarting Guard..."; done
15
+ ##
16
+ ## Note: if you are using the `directories` clause above and you are not
17
+ ## watching the project directory ('.'), then you will want to move
18
+ ## the Guardfile to a watched dir and symlink it back, e.g.
19
+ #
20
+ # $ mkdir config
21
+ # $ mv Guardfile config/
22
+ # $ ln -s config/Guardfile .
23
+ #
24
+ # and, you'll have to watch "config/Guardfile" instead of "Guardfile"
25
+
26
+ # Note: The cmd option is now required due to the increasing number of ways
27
+ # rspec may be run, below are examples of the most common uses.
28
+ # * bundler: 'bundle exec rspec'
29
+ # * bundler binstubs: 'bin/rspec'
30
+ # * spring: 'bin/rspec' (This will use spring if running and you have
31
+ # installed the spring binstubs per the docs)
32
+ # * zeus: 'zeus rspec' (requires the server to be started separately)
33
+ # * 'just' rspec: 'rspec'
34
+
35
+ guard :rspec, cmd: "bundle exec rspec" do
36
+ require "guard/rspec/dsl"
37
+ dsl = Guard::RSpec::Dsl.new(self)
38
+
39
+ # Feel free to open issues for suggestions and improvements
40
+
41
+ # RSpec files
42
+ rspec = dsl.rspec
43
+ watch(rspec.spec_helper) { rspec.spec_dir }
44
+ watch(rspec.spec_support) { rspec.spec_dir }
45
+ watch(rspec.spec_files)
46
+
47
+ # Ruby files
48
+ ruby = dsl.ruby
49
+ dsl.watch_spec_files_for(ruby.lib_files)
50
+
51
+ # Rails files
52
+ rails = dsl.rails(view_extensions: %w(erb haml slim))
53
+ dsl.watch_spec_files_for(rails.app_files)
54
+ dsl.watch_spec_files_for(rails.views)
55
+
56
+ watch(rails.controllers) do |m|
57
+ [
58
+ rspec.spec.("routing/#{m[1]}_routing"),
59
+ rspec.spec.("controllers/#{m[1]}_controller"),
60
+ rspec.spec.("acceptance/#{m[1]}")
61
+ ]
62
+ end
63
+
64
+ # Rails config changes
65
+ watch(rails.spec_helper) { rspec.spec_dir }
66
+ watch(rails.routes) { "#{rspec.spec_dir}/routing" }
67
+ watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }
68
+
69
+ # Capybara features specs
70
+ watch(rails.view_dirs) { |m| rspec.spec.("features/#{m[1]}") }
71
+
72
+ # Turnip features and steps
73
+ watch(%r{^spec/acceptance/(.+)\.feature$})
74
+ watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
75
+ Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance"
76
+ end
77
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Patrick Davey
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
+ # VodemSms
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/vodem_sms`. 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
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'vodem_sms'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install vodem_sms
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
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.
30
+
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).
32
+
33
+ ## Contributing
34
+
35
+ 1. Fork it ( https://github.com/[my-github-username]/vodem_sms/fork )
36
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
37
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
38
+ 4. Push to the branch (`git push origin my-new-feature`)
39
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "vodem_sms"
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
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
data/changelog.md ADDED
@@ -0,0 +1,5 @@
1
+ ## 0.0.1 [April 2015]
2
+
3
+ * Initial beta release of the vodem_sms gem.
4
+ Doesn't actually do SMS's yet ;) But it does connect and disconnect (and check status)
5
+ correctly. Which is great.
@@ -0,0 +1,54 @@
1
+ module VodemSms
2
+ class Commands
3
+ WEBSERVER_SET_STATUS_URL = "http://192.168.9.1/goform/goform_set_cmd_process"
4
+ WEBSERVER_HOST_HEADER = "192.168.9.1"
5
+ AGENT_HEADER = "User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:37.0) Gecko/20100101 Firefox/37.0'"
6
+ LANGUAGE_HEADER= "en-US,en;q=0.5"
7
+ ENCODING_HEADER = 'gzip, deflate'
8
+ CACHE_CONTROL_HEADER = 'no-cache'
9
+ CONNECTION_HEADER = 'keep-alive'
10
+ CONTENT_TYPE_HEADER = 'application/x-www-form-urlencoded; charset=UTF-8'
11
+ PRAGMA_HEADER = 'no-cache'
12
+ X_REQUESTED_WITH_HEADER = 'XMLHttpRequest'
13
+ REFERRER_HEADER = 'http://192.168.9.1/home.htm'
14
+
15
+ def connect!
16
+ Typhoeus.post(
17
+ WEBSERVER_SET_STATUS_URL,
18
+ headers: {
19
+ Host: WEBSERVER_HOST_HEADER,
20
+ "User-Agent" => AGENT_HEADER,
21
+ "Accept-Language" => LANGUAGE_HEADER,
22
+ "Accept-Encoding" => ENCODING_HEADER,
23
+ "Cache-Control" => CACHE_CONTROL_HEADER,
24
+ "Pragma" => PRAGMA_HEADER,
25
+ "x-requested-with" => X_REQUESTED_WITH_HEADER,
26
+ "Referer" => REFERRER_HEADER,
27
+ Accept: "application/json"
28
+ },
29
+ body: {goformId: "CONNECT_NETWORK"},
30
+ )
31
+ sleep 10
32
+ end
33
+
34
+ def disconnect!
35
+ Typhoeus.post(
36
+ WEBSERVER_SET_STATUS_URL,
37
+ headers: {
38
+ Host: WEBSERVER_HOST_HEADER,
39
+ "User-Agent" => AGENT_HEADER,
40
+ "Accept-Language" => LANGUAGE_HEADER,
41
+ "Accept-Encoding" => ENCODING_HEADER,
42
+ "Cache-Control" => CACHE_CONTROL_HEADER,
43
+ "Pragma" => PRAGMA_HEADER,
44
+ "x-requested-with" => X_REQUESTED_WITH_HEADER,
45
+ "Referer" => REFERRER_HEADER,
46
+ Accept: "application/json"
47
+ },
48
+ body: {goformId: "DISCONNECT_NETWORK"},
49
+ )
50
+
51
+ sleep 2
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,56 @@
1
+ module VodemSms
2
+ class StatusChecker
3
+ WEBSERVER_STATUS_URL = "http://192.168.9.1/goform/goform_get_cmd_process"
4
+ WEBSERVER_HOST_HEADER = "192.168.9.1"
5
+ AGENT_HEADER = "User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:37.0) Gecko/20100101 Firefox/37.0'"
6
+ LANGUAGE_HEADER= "en-US,en;q=0.5"
7
+ ENCODING_HEADER = 'gzip, deflate'
8
+ X_REQUESTED_WITH_HEADER = 'XMLHttpRequest'
9
+ REFERRER_HEADER = 'http://192.168.9.1/home.htm'
10
+ STATUS_FIELD = 'ppp_status'
11
+
12
+ class Status
13
+ CONNECTED = "ppp_connected"
14
+ DISCONNECTED = "ppp_disconnected"
15
+ CONNECTING = "ppp_connecting"
16
+
17
+ def initialize(status)
18
+ @status = status
19
+ end
20
+
21
+ def connected?
22
+ status == CONNECTED
23
+ end
24
+
25
+ def disconnected?
26
+ status == DISCONNECTED
27
+ end
28
+
29
+ def connecting?
30
+ status == CONNECTING
31
+ end
32
+
33
+
34
+ private
35
+
36
+ attr_reader :status
37
+ end
38
+
39
+ def get_status
40
+ response = Typhoeus.get(
41
+ WEBSERVER_STATUS_URL,
42
+ headers: {
43
+ Host: WEBSERVER_HOST_HEADER,
44
+ "User-Agent" => AGENT_HEADER,
45
+ "Accept-Language" => LANGUAGE_HEADER,
46
+ "Accept-Encoding" => ENCODING_HEADER,
47
+ "x-requested-with" => X_REQUESTED_WITH_HEADER,
48
+ "Referer" => REFERRER_HEADER,
49
+ Accept: "application/json"
50
+ },
51
+ params: {cmd: "ppp_status"},
52
+ )
53
+ Status.new(JSON.parse(response.body)[STATUS_FIELD])
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,3 @@
1
+ module VodemSms
2
+ VERSION = "0.0.1"
3
+ end
data/lib/vodem_sms.rb ADDED
@@ -0,0 +1,24 @@
1
+ require "vodem_sms/version"
2
+ require "vodem_sms/status_checker"
3
+ require "vodem_sms/commands"
4
+ require "typhoeus"
5
+ require "pry"
6
+ require "json"
7
+
8
+ module VodemSms
9
+ class Vodem
10
+ extend Forwardable
11
+ def_delegators :status, :connected?, :disconnected?, :connecting?
12
+ def_delegators :commands, :connect!, :disconnect!
13
+
14
+ private
15
+
16
+ def status
17
+ StatusChecker.new.get_status
18
+ end
19
+
20
+ def commands
21
+ Commands.new
22
+ end
23
+ end
24
+ end
data/vodem_sms.gemspec ADDED
@@ -0,0 +1,32 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'vodem_sms/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "vodem_sms"
8
+ spec.version = VodemSms::VERSION
9
+ spec.authors = ["Patrick Davey"]
10
+ spec.email = ["patrick.davey@gmail.com"]
11
+
12
+ spec.summary = %q{Some helper commands for use with a vodafone modem.}
13
+ spec.description = %q{Adds the ability to get the status and bring a connection up and down.}
14
+ spec.homepage = "https://github.com/patrickdavey/vodem_sms"
15
+ spec.license = "MIT"
16
+ spec.required_ruby_version = '>= 2.0'
17
+
18
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
19
+ spec.bindir = "exe"
20
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.8"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+ spec.add_development_dependency "rspec", "~> 3.0"
26
+ spec.add_development_dependency "pry", ">= 0.9.12"
27
+ spec.add_development_dependency "rspec-its", "~> 1.1.0"
28
+ spec.add_development_dependency "webmock", "~> 1.2"
29
+ spec.add_development_dependency "rspec-html-matchers", "~> 0.6.1"
30
+ spec.add_development_dependency "guard-rspec", "~> 4.3"
31
+ spec.add_runtime_dependency "typhoeus", "~> 0.7.1"
32
+ end
metadata ADDED
@@ -0,0 +1,186 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vodem_sms
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Patrick Davey
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-04-26 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.8'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.8'
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
+ - !ruby/object:Gem::Dependency
56
+ name: pry
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: 0.9.12
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: 0.9.12
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec-its
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 1.1.0
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 1.1.0
83
+ - !ruby/object:Gem::Dependency
84
+ name: webmock
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '1.2'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '1.2'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec-html-matchers
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 0.6.1
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 0.6.1
111
+ - !ruby/object:Gem::Dependency
112
+ name: guard-rspec
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '4.3'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '4.3'
125
+ - !ruby/object:Gem::Dependency
126
+ name: typhoeus
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: 0.7.1
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: 0.7.1
139
+ description: Adds the ability to get the status and bring a connection up and down.
140
+ email:
141
+ - patrick.davey@gmail.com
142
+ executables: []
143
+ extensions: []
144
+ extra_rdoc_files: []
145
+ files:
146
+ - ".gitignore"
147
+ - ".rspec"
148
+ - ".travis.yml"
149
+ - Gemfile
150
+ - Guardfile
151
+ - LICENSE.txt
152
+ - README.md
153
+ - Rakefile
154
+ - bin/console
155
+ - bin/setup
156
+ - changelog.md
157
+ - lib/vodem_sms.rb
158
+ - lib/vodem_sms/commands.rb
159
+ - lib/vodem_sms/status_checker.rb
160
+ - lib/vodem_sms/version.rb
161
+ - vodem_sms.gemspec
162
+ homepage: https://github.com/patrickdavey/vodem_sms
163
+ licenses:
164
+ - MIT
165
+ metadata: {}
166
+ post_install_message:
167
+ rdoc_options: []
168
+ require_paths:
169
+ - lib
170
+ required_ruby_version: !ruby/object:Gem::Requirement
171
+ requirements:
172
+ - - ">="
173
+ - !ruby/object:Gem::Version
174
+ version: '2.0'
175
+ required_rubygems_version: !ruby/object:Gem::Requirement
176
+ requirements:
177
+ - - ">="
178
+ - !ruby/object:Gem::Version
179
+ version: '0'
180
+ requirements: []
181
+ rubyforge_project:
182
+ rubygems_version: 2.4.6
183
+ signing_key:
184
+ specification_version: 4
185
+ summary: Some helper commands for use with a vodafone modem.
186
+ test_files: []