ragmob 0.1.0

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
+ SHA256:
3
+ metadata.gz: 8337109e1efb0e581708ad3dbea06f4b694e5fc333fb4c5f6221c800bea1e8ec
4
+ data.tar.gz: a23b8848fd005eddc5cd59d47ddefb0b84579a0adbbe7841b34c27ebbb6e7b86
5
+ SHA512:
6
+ metadata.gz: 38accbd0869b092f1e896166d820a51832041ccf82b52a9d127dbcb50c568da131f0c3a96dcd739f017e9504ec3f81b889b8cfd87fb1fa64297b9e7f675485a2
7
+ data.tar.gz: 82d619b736f0b9676b5fdbb52e8ebf87e410c8867f238ea028c66038a9e46c91eefd331214cd3278f939cdf3bab519d817a29658c441048d80fcd9bb62fa3057
@@ -0,0 +1,21 @@
1
+ name: Ruby
2
+
3
+ on: [pull_request]
4
+
5
+ jobs:
6
+ build:
7
+
8
+ runs-on: ubuntu-latest
9
+
10
+ steps:
11
+ - uses: actions/checkout@v1
12
+ - name: Set up Ruby 2.6
13
+ uses: actions/setup-ruby@v1
14
+ with:
15
+ ruby-version: 2.6.x
16
+ - name: Build and test with Rake
17
+ run: |
18
+ gem install bundler
19
+ bundle install --jobs 4 --retry 3
20
+ bundle exec rubocop
21
+ bundle exec rake
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ .tags*
data/.rubocop.yml ADDED
@@ -0,0 +1,33 @@
1
+ # The behavior of RuboCop can be controlled via the .rubocop.yml
2
+ # configuration file. It makes it possible to enable/disable
3
+ # certain cops (checks) and to alter their behavior if they accept
4
+ # any parameters. The file can be placed either in your home
5
+ # directory or in some project directory.
6
+ #
7
+ # RuboCop will start looking for the configuration file in the directory
8
+ # where the inspected file is and continue its way up to the root directory.
9
+ #
10
+ # See https://github.com/rubocop-hq/rubocop/blob/master/manual/configuration.md
11
+
12
+ Style/StringLiterals:
13
+ Enabled: false
14
+
15
+ Style/FrozenStringLiteralComment:
16
+ Enabled: false
17
+
18
+ Style/Documentation:
19
+ Enabled: false
20
+
21
+ Metrics/LineLength:
22
+ Max: 160
23
+
24
+ Layout/MultilineMethodCallIndentation:
25
+ EnforcedStyle: indented
26
+
27
+ Metrics/BlockLength:
28
+ Exclude:
29
+ - "**/*_spec.rb"
30
+ - "*.gemspec"
31
+
32
+ Naming/AccessorMethodName:
33
+ Enabled: false
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.6.3
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.6.3
7
+ before_install: gem install bundler -v 1.17.2
@@ -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 lagartoflojo@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,6 @@
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 ragmob.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,126 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ ragmob (0.1.0)
5
+ http (~> 4.2)
6
+ nokogiri-happymapper (~> 0.8)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ addressable (2.7.0)
12
+ public_suffix (>= 2.0.2, < 5.0)
13
+ ansi (1.5.0)
14
+ ast (2.4.0)
15
+ builder (3.2.3)
16
+ coderay (1.1.2)
17
+ crack (0.4.3)
18
+ safe_yaml (~> 1.0.0)
19
+ domain_name (0.5.20190701)
20
+ unf (>= 0.0.5, < 1.0.0)
21
+ ffi (1.11.2)
22
+ ffi-compiler (1.0.1)
23
+ ffi (>= 1.0.0)
24
+ rake
25
+ formatador (0.2.5)
26
+ guard (2.16.1)
27
+ formatador (>= 0.2.4)
28
+ listen (>= 2.7, < 4.0)
29
+ lumberjack (>= 1.0.12, < 2.0)
30
+ nenv (~> 0.1)
31
+ notiffany (~> 0.0)
32
+ pry (>= 0.9.12)
33
+ shellany (~> 0.0)
34
+ thor (>= 0.18.1)
35
+ guard-compat (1.2.1)
36
+ guard-minitest (2.4.6)
37
+ guard-compat (~> 1.2)
38
+ minitest (>= 3.0)
39
+ hashdiff (1.0.0)
40
+ http (4.2.0)
41
+ addressable (~> 2.3)
42
+ http-cookie (~> 1.0)
43
+ http-form_data (~> 2.0)
44
+ http-parser (~> 1.2.0)
45
+ http-cookie (1.0.3)
46
+ domain_name (~> 0.5)
47
+ http-form_data (2.1.1)
48
+ http-parser (1.2.1)
49
+ ffi-compiler (>= 1.0, < 2.0)
50
+ jaro_winkler (1.5.4)
51
+ listen (3.2.0)
52
+ rb-fsevent (~> 0.10, >= 0.10.3)
53
+ rb-inotify (~> 0.9, >= 0.9.10)
54
+ lumberjack (1.0.13)
55
+ method_source (0.9.2)
56
+ mini_portile2 (2.4.0)
57
+ minitest (5.13.0)
58
+ minitest-reporters (1.4.2)
59
+ ansi
60
+ builder
61
+ minitest (>= 5.0)
62
+ ruby-progressbar
63
+ minitest-spec-context (0.0.4)
64
+ nenv (0.3.0)
65
+ nokogiri (1.10.5)
66
+ mini_portile2 (~> 2.4.0)
67
+ nokogiri-happymapper (0.8.1)
68
+ nokogiri (~> 1.5)
69
+ notiffany (0.1.3)
70
+ nenv (~> 0.1)
71
+ shellany (~> 0.0)
72
+ parallel (1.19.1)
73
+ parser (2.6.5.0)
74
+ ast (~> 2.4.0)
75
+ pry (0.12.2)
76
+ coderay (~> 1.1.0)
77
+ method_source (~> 0.9.0)
78
+ public_suffix (4.0.1)
79
+ rainbow (3.0.0)
80
+ rake (10.5.0)
81
+ rb-fsevent (0.10.3)
82
+ rb-inotify (0.10.0)
83
+ ffi (~> 1.0)
84
+ rubocop (0.76.0)
85
+ jaro_winkler (~> 1.5.1)
86
+ parallel (~> 1.10)
87
+ parser (>= 2.6)
88
+ rainbow (>= 2.2.2, < 4.0)
89
+ ruby-progressbar (~> 1.7)
90
+ unicode-display_width (>= 1.4.0, < 1.7)
91
+ rubocop-minitest (0.5.0)
92
+ rubocop (>= 0.74)
93
+ ruby-progressbar (1.10.1)
94
+ safe_yaml (1.0.5)
95
+ shellany (0.0.1)
96
+ thor (0.20.3)
97
+ unf (0.1.4)
98
+ unf_ext
99
+ unf_ext (0.0.7.6)
100
+ unicode-display_width (1.6.0)
101
+ vcr (5.0.0)
102
+ webmock (3.7.6)
103
+ addressable (>= 2.3.6)
104
+ crack (>= 0.3.2)
105
+ hashdiff (>= 0.4.0, < 2.0.0)
106
+
107
+ PLATFORMS
108
+ ruby
109
+
110
+ DEPENDENCIES
111
+ bundler (~> 1.17)
112
+ guard (~> 2.16)
113
+ guard-minitest (~> 2.4)
114
+ minitest (~> 5.0)
115
+ minitest-reporters (~> 1.4)
116
+ minitest-spec-context (~> 0.0.4)
117
+ pry (~> 0.12)
118
+ ragmob!
119
+ rake (~> 10.0)
120
+ rubocop (~> 0.76)
121
+ rubocop-minitest (~> 0.5)
122
+ vcr (~> 5.0)
123
+ webmock (~> 3.7)
124
+
125
+ BUNDLED WITH
126
+ 1.17.2
data/Guardfile ADDED
@@ -0,0 +1,42 @@
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
+ guard :minitest do
19
+ # with Minitest::Unit
20
+ # watch(%r{^test/(.*)\/?test_(.*)\.rb$})
21
+ # watch(%r{^lib/(.*/)?([^/]+)\.rb$}) { |m| "test/#{m[1]}test_#{m[2]}.rb" }
22
+ # watch(%r{^test/test_helper\.rb$}) { 'test' }
23
+
24
+ # with Minitest::Spec
25
+ watch(%r{^spec/(.*)_spec\.rb$})
26
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
27
+ watch(%r{^spec/spec_helper\.rb$}) { 'spec' }
28
+
29
+ # Rails 4
30
+ # watch(%r{^app/(.+)\.rb$}) { |m| "test/#{m[1]}_test.rb" }
31
+ # watch(%r{^app/controllers/application_controller\.rb$}) { 'test/controllers' }
32
+ # watch(%r{^app/controllers/(.+)_controller\.rb$}) { |m| "test/integration/#{m[1]}_test.rb" }
33
+ # watch(%r{^app/views/(.+)_mailer/.+}) { |m| "test/mailers/#{m[1]}_mailer_test.rb" }
34
+ # watch(%r{^lib/(.+)\.rb$}) { |m| "test/lib/#{m[1]}_test.rb" }
35
+ # watch(%r{^test/.+_test\.rb$})
36
+ # watch(%r{^test/test_helper\.rb$}) { 'test' }
37
+
38
+ # Rails < 4
39
+ # watch(%r{^app/controllers/(.*)\.rb$}) { |m| "test/functional/#{m[1]}_test.rb" }
40
+ # watch(%r{^app/helpers/(.*)\.rb$}) { |m| "test/helpers/#{m[1]}_test.rb" }
41
+ # watch(%r{^app/models/(.*)\.rb$}) { |m| "test/unit/#{m[1]}_test.rb" }
42
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 Hernán Schmidt
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,48 @@
1
+ # Ragmob
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/ragmob`. 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 'ragmob'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install ragmob
22
+
23
+ ## Usage
24
+
25
+ ```ruby
26
+ client = Ragmob::Client.new(server_url: 'https://support.example.com', client_id: 'myID', client_secret: 'mySecret')
27
+ client.get_api_info
28
+ ```
29
+
30
+ TODO: Write better usage instructions here
31
+
32
+ ## Development
33
+
34
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
35
+
36
+ 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).
37
+
38
+ ## Contributing
39
+
40
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/ragmob. 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.
41
+
42
+ ## License
43
+
44
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
45
+
46
+ ## Code of Conduct
47
+
48
+ Everyone interacting in the Ragmob project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/ragmob/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "spec"
6
+ t.libs << "lib"
7
+ t.test_files = FileList["spec/**/*_spec.rb"]
8
+ end
9
+
10
+ task default: :test
data/bin/console ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "ragmob"
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
+ require "pry"
10
+ Pry.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/lib/ragmob.rb ADDED
@@ -0,0 +1,6 @@
1
+ require "ragmob/client"
2
+ require "ragmob/version"
3
+
4
+ module Ragmob
5
+ class Error < StandardError; end
6
+ end
@@ -0,0 +1,39 @@
1
+ require "http"
2
+ require "json"
3
+ require "uri"
4
+
5
+ module Ragmob
6
+ class Auth
7
+ def initialize(server_url:, client_id:, client_secret:)
8
+ self.server_url = server_url
9
+ self.client_id = client_id
10
+ self.client_secret = client_secret
11
+ end
12
+
13
+ def access_token
14
+ return token if token_still_valid?
15
+
16
+ response = fetch_access_token
17
+
18
+ raise 'Wrong credentials' if response.code == 401
19
+
20
+ json_response = JSON.parse(response.body.to_s)
21
+ self.expires_at = Time.at(Time.new.to_i + json_response.fetch('expires_in'))
22
+ self.token = json_response.fetch 'access_token'
23
+ end
24
+
25
+ private
26
+
27
+ attr_accessor :server_url, :client_id, :client_secret, :token, :expires_at
28
+
29
+ def token_still_valid?
30
+ expires_at && Time.new < expires_at
31
+ end
32
+
33
+ def fetch_access_token
34
+ HTTP
35
+ .basic_auth(user: client_id, pass: client_secret)
36
+ .post(URI.join(server_url, "oauth2/token"), form: { grant_type: "client_credentials" })
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,16 @@
1
+ require "ragmob/connection"
2
+ require "ragmob/command"
3
+
4
+ module Ragmob
5
+ class Client
6
+ include Ragmob::Command
7
+
8
+ def initialize(server_url:, client_id:, client_secret:)
9
+ self.connection = Ragmob::Connection.new(server_url: server_url, client_id: client_id, client_secret: client_secret)
10
+ end
11
+
12
+ private
13
+
14
+ attr_accessor :connection
15
+ end
16
+ end
@@ -0,0 +1,23 @@
1
+ require "ragmob/parsers/api_information"
2
+ require "ragmob/parsers/health_check"
3
+ require "ragmob/parsers/session_key"
4
+
5
+ module Ragmob
6
+ module Command
7
+ def get_api_info
8
+ resp = connection.get('api/command?action=get_api_info')
9
+ Ragmob::Parsers::ApiInformation.parse(resp.body.to_s, single: true)
10
+ end
11
+
12
+ def check_health
13
+ resp = connection.get('api/command?action=check_health')
14
+ Ragmob::Parsers::HealthCheck.parse(resp.body.to_s, single: true)
15
+ end
16
+
17
+ def generate_session_key(params = {})
18
+ params[:type] ||= 'support'
19
+ resp = connection.get('api/command?action=generate_session_key', params: params)
20
+ Ragmob::Parsers::SessionKey.parse(resp.body.to_s, single: true)
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,24 @@
1
+ require "http"
2
+ require "uri"
3
+ require "ragmob/auth"
4
+
5
+ module Ragmob
6
+ class Connection
7
+ def initialize(server_url:, client_id:, client_secret:)
8
+ self.server_url = server_url
9
+ self.auth = Ragmob::Auth.new(server_url: server_url, client_id: client_id, client_secret: client_secret)
10
+ end
11
+
12
+ def get(path, params: {})
13
+ http.get(URI.join(server_url, path), params: params)
14
+ end
15
+
16
+ private
17
+
18
+ attr_accessor :server_url, :auth
19
+
20
+ def http
21
+ HTTP.auth("Bearer #{auth.access_token}")
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,43 @@
1
+ require 'happymapper'
2
+
3
+ module Ragmob
4
+ module Parsers
5
+ class Permission
6
+ include HappyMapper
7
+
8
+ tag 'permission'
9
+
10
+ attribute :name, String
11
+ content :value, String
12
+
13
+ def value
14
+ return true if @value == '1'
15
+ return false if @value == '0'
16
+
17
+ @value
18
+ end
19
+ end
20
+
21
+ class ApiInformation
22
+ include HappyMapper
23
+
24
+ tag 'api_information'
25
+
26
+ element :api_version, String
27
+ element :company_name, String
28
+ element :timestamp, Integer
29
+ has_many :permissions, Permission, tag: 'permission'
30
+
31
+ def timestamp
32
+ Time.at @timestamp
33
+ end
34
+
35
+ def permissions
36
+ @permissions.each_with_object({}) do |perm, memo|
37
+ memo[perm.name] = perm.value
38
+ memo
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,49 @@
1
+ require 'happymapper'
2
+
3
+ module Ragmob
4
+ module Parsers
5
+ class Appliance
6
+ include HappyMapper
7
+
8
+ tag 'appliance'
9
+
10
+ attribute :id, String
11
+ content :name, String
12
+ end
13
+
14
+ class IP
15
+ include HappyMapper
16
+
17
+ tag 'ip'
18
+
19
+ content :ip, String
20
+ end
21
+
22
+ class HealthCheck
23
+ include HappyMapper
24
+
25
+ tag 'health_check'
26
+
27
+ element :version, String
28
+ element :failover_role, String
29
+ element :success, Boolean
30
+ element :error_message, String
31
+ element :last_data_sync_time, Time
32
+ element :last_data_sync_status, String
33
+ has_one :appliance, Appliance
34
+ has_many :enabled_shared_ips, IP, tag: 'ip'
35
+
36
+ def appliance_id
37
+ appliance.id
38
+ end
39
+
40
+ def appliance_name
41
+ appliance.name
42
+ end
43
+
44
+ def enabled_shared_ips
45
+ @enabled_shared_ips.map(&:ip)
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,39 @@
1
+ require 'happymapper'
2
+
3
+ module Ragmob
4
+ module Parsers
5
+ class Queue
6
+ include HappyMapper
7
+
8
+ tag 'queue'
9
+
10
+ content :name, String
11
+ attribute :available, Boolean
12
+ end
13
+
14
+ class SessionKey
15
+ include HappyMapper
16
+
17
+ tag 'session_key'
18
+
19
+ element :type, String
20
+ element :ttl, Integer
21
+ element :expires, Time
22
+ element :queue, Queue
23
+ element :queue_id, Integer
24
+ element :external_key, String
25
+ element :short_key, String
26
+ element :key_url, String
27
+ element :mail_subject, String
28
+ element :mail_body, String
29
+
30
+ def queue_name
31
+ @queue.name
32
+ end
33
+
34
+ def queue_available
35
+ @queue.available
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,3 @@
1
+ module Ragmob
2
+ VERSION = "0.1.0".freeze
3
+ end
data/ragmob.gemspec ADDED
@@ -0,0 +1,39 @@
1
+ lib = File.expand_path('lib', __dir__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require "ragmob/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "ragmob"
7
+ spec.version = Ragmob::VERSION
8
+ spec.authors = ["Hernán Schmidt"]
9
+ spec.email = ["lagartoflojo@gmail.com"]
10
+
11
+ spec.summary = 'A library to interact with the BeyondTrust Remote Support API.'
12
+ spec.homepage = "https://github.com/lagartoflojo/ragmob"
13
+ spec.license = "MIT"
14
+
15
+ # Specify which files should be added to the gem when it is released.
16
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
17
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
18
+ `git ls-files -z`.split("\x0").reject { |f| 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 "http", "~> 4.2"
25
+ spec.add_dependency "nokogiri-happymapper", "~> 0.8"
26
+
27
+ spec.add_development_dependency "bundler", "~> 1.17"
28
+ spec.add_development_dependency "guard", "~> 2.16"
29
+ spec.add_development_dependency "guard-minitest", "~> 2.4"
30
+ spec.add_development_dependency "minitest", "~> 5.0"
31
+ spec.add_development_dependency "minitest-reporters", "~> 1.4"
32
+ spec.add_development_dependency "minitest-spec-context", "~> 0.0.4"
33
+ spec.add_development_dependency "pry", "~> 0.12"
34
+ spec.add_development_dependency "rake", "~> 10.0"
35
+ spec.add_development_dependency "rubocop", "~> 0.76"
36
+ spec.add_development_dependency "rubocop-minitest", "~> 0.5"
37
+ spec.add_development_dependency "vcr", "~> 5.0"
38
+ spec.add_development_dependency "webmock", "~> 3.7"
39
+ end
metadata ADDED
@@ -0,0 +1,263 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ragmob
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Hernán Schmidt
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-11-29 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: http
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '4.2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '4.2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: nokogiri-happymapper
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.8'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.8'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.17'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.17'
55
+ - !ruby/object:Gem::Dependency
56
+ name: guard
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '2.16'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '2.16'
69
+ - !ruby/object:Gem::Dependency
70
+ name: guard-minitest
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '2.4'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '2.4'
83
+ - !ruby/object:Gem::Dependency
84
+ name: minitest
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '5.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '5.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: minitest-reporters
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '1.4'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '1.4'
111
+ - !ruby/object:Gem::Dependency
112
+ name: minitest-spec-context
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: 0.0.4
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: 0.0.4
125
+ - !ruby/object:Gem::Dependency
126
+ name: pry
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '0.12'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '0.12'
139
+ - !ruby/object:Gem::Dependency
140
+ name: rake
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '10.0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '10.0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: rubocop
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: '0.76'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: '0.76'
167
+ - !ruby/object:Gem::Dependency
168
+ name: rubocop-minitest
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - "~>"
172
+ - !ruby/object:Gem::Version
173
+ version: '0.5'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - "~>"
179
+ - !ruby/object:Gem::Version
180
+ version: '0.5'
181
+ - !ruby/object:Gem::Dependency
182
+ name: vcr
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - "~>"
186
+ - !ruby/object:Gem::Version
187
+ version: '5.0'
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - "~>"
193
+ - !ruby/object:Gem::Version
194
+ version: '5.0'
195
+ - !ruby/object:Gem::Dependency
196
+ name: webmock
197
+ requirement: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - "~>"
200
+ - !ruby/object:Gem::Version
201
+ version: '3.7'
202
+ type: :development
203
+ prerelease: false
204
+ version_requirements: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - "~>"
207
+ - !ruby/object:Gem::Version
208
+ version: '3.7'
209
+ description:
210
+ email:
211
+ - lagartoflojo@gmail.com
212
+ executables: []
213
+ extensions: []
214
+ extra_rdoc_files: []
215
+ files:
216
+ - ".github/workflows/ruby.yml"
217
+ - ".gitignore"
218
+ - ".rubocop.yml"
219
+ - ".ruby-version"
220
+ - ".travis.yml"
221
+ - CODE_OF_CONDUCT.md
222
+ - Gemfile
223
+ - Gemfile.lock
224
+ - Guardfile
225
+ - LICENSE.txt
226
+ - README.md
227
+ - Rakefile
228
+ - bin/console
229
+ - bin/setup
230
+ - lib/ragmob.rb
231
+ - lib/ragmob/auth.rb
232
+ - lib/ragmob/client.rb
233
+ - lib/ragmob/command.rb
234
+ - lib/ragmob/connection.rb
235
+ - lib/ragmob/parsers/api_information.rb
236
+ - lib/ragmob/parsers/health_check.rb
237
+ - lib/ragmob/parsers/session_key.rb
238
+ - lib/ragmob/version.rb
239
+ - ragmob.gemspec
240
+ homepage: https://github.com/lagartoflojo/ragmob
241
+ licenses:
242
+ - MIT
243
+ metadata: {}
244
+ post_install_message:
245
+ rdoc_options: []
246
+ require_paths:
247
+ - lib
248
+ required_ruby_version: !ruby/object:Gem::Requirement
249
+ requirements:
250
+ - - ">="
251
+ - !ruby/object:Gem::Version
252
+ version: '0'
253
+ required_rubygems_version: !ruby/object:Gem::Requirement
254
+ requirements:
255
+ - - ">="
256
+ - !ruby/object:Gem::Version
257
+ version: '0'
258
+ requirements: []
259
+ rubygems_version: 3.0.3
260
+ signing_key:
261
+ specification_version: 4
262
+ summary: A library to interact with the BeyondTrust Remote Support API.
263
+ test_files: []