routeros-api 0.1.0 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7eb704522500000ae772fe0c97412127677a31ddbd861899ba1365f923d71f8e
4
- data.tar.gz: 5a4f49fb090e5742d93b2a3cc4e10485beff8eece3a5d4351832cf7d8e4c4c32
3
+ metadata.gz: f63f8077dd7855c9c67297abc2801872eb3de689f0fce401d37adf4edbac1d3b
4
+ data.tar.gz: 43e84dd99ef9e1ee7b8e83fddb14a730bfb35c715564c8a0bc8fc5030e9fdc65
5
5
  SHA512:
6
- metadata.gz: 8678dfcbbbcc942b98b0190d2e4ae54e0ebd90bc421d5920b8f8876b7a07c384473526b6579fb3fd6e82634c03c80399b9a64a622ae3ce93406e760f62e08442
7
- data.tar.gz: 943ac4f6b61fdc10d51a14fb10af4cdbd2d5848d36f78423d6fb2f462cac999d6a5196775b241aab10bae178ddba58ad5f2f363c5c7b7f8b467a6cffdd7974cd
6
+ metadata.gz: d2233021b902cb11e23c911dcf35112d9f2b31845b6760f140bc473498cb460e9efbbbe691ff0ac91145cfb6b76b8615fb90484ec0ee9e0d09975192eab06d2f
7
+ data.tar.gz: 3ca944848e4d942aea06f6ec8ad32c3ed2cf8d932e89ed172bda0ea6a0236f9673a80cb8afcf1e34eaa2e753633cdc17b92431c3b1f88579feae03875b0ba7d0
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.2.0] - 2024-10-16
4
+
5
+ - Parsing of known number and boolean values
6
+
3
7
  ## [0.1.0] - 2024-10-13
4
8
 
5
9
  - Initial release
data/README.md CHANGED
@@ -28,6 +28,7 @@ end
28
28
 
29
29
  - [ ] SSL support
30
30
  - [ ] Async support
31
+ - [ ] Auto deploy and auto changelog
31
32
 
32
33
  ## Development
33
34
 
@@ -37,7 +38,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
37
38
 
38
39
  ## Contributing
39
40
 
40
- Bug reports and pull requests are welcome on GitHub at https://github.com/mcbarros/routeros-api. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/mcbarros/routeros-api/blob/master/CODE_OF_CONDUCT.md).
41
+ Bug reports and pull requests are welcome on GitHub at https://github.com/mcbarros/routeros-api. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/mcbarros/routeros-api/blob/main/CODE_OF_CONDUCT.md).
41
42
 
42
43
  ## License
43
44
 
@@ -45,4 +46,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
45
46
 
46
47
  ## Code of Conduct
47
48
 
48
- Everyone interacting in the RouterOS::API project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/routeros-api/blob/master/CODE_OF_CONDUCT.md).
49
+ Everyone interacting in the RouterOS::API project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/mcbarros/routeros-api/blob/main/CODE_OF_CONDUCT.md).
data/examples/simple.rb CHANGED
@@ -1,12 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "../lib/routeros/api"
3
+ require "bundler/setup"
4
+ require "routeros/api"
4
5
 
5
6
  api = RouterOS::API.new("192.168.1.1", 8728)
6
- response = api.login("admin", "my-secret-password")
7
+ response = api.login("lupadmin", "M0N3frHsuS)6:")
7
8
  puts(response) # (OK) []
8
9
 
9
10
  if response.ok?
10
11
  response = api.command("ip/route/getall")
11
- puts(response.data) # [{ ... }]
12
+ puts(response.data) # (OK) [{ ... }]
12
13
  end
data/lib/routeros/api.rb CHANGED
@@ -8,7 +8,7 @@ require_relative "word_stream"
8
8
  module RouterOS
9
9
  # Main abstraction to connect to RouterOS
10
10
  class API
11
- VERSION = "0.1.0"
11
+ VERSION = "0.2.0"
12
12
 
13
13
  class Error < StandardError; end
14
14
 
@@ -3,6 +3,9 @@
3
3
  module RouterOS
4
4
  # Represents a parsed RouterOS response
5
5
  class Response
6
+ KNOWN_NUMBER_FIELDS = %i[scope distance target-scope]
7
+ KNOWN_BOOLEAN_VALUES = %w[true false]
8
+
6
9
  attr_reader :raw_sentences, :data, :tag
7
10
 
8
11
  def initialize(sentences)
@@ -58,7 +61,15 @@ module RouterOS
58
61
 
59
62
  def self.parse_field(word)
60
63
  key, value = word[1..].split("=", 2)
61
- [key.to_sym, value]
64
+ key = key.to_sym
65
+
66
+ if KNOWN_BOOLEAN_VALUES.include?(value)
67
+ value = value == "true"
68
+ elsif KNOWN_NUMBER_FIELDS.include?(key) && !value.nil?
69
+ value = value.to_i
70
+ end
71
+
72
+ [key, value]
62
73
  end
63
74
  end
64
75
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: routeros-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcelo Barros
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-10-13 00:00:00.000000000 Z
11
+ date: 2024-10-16 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email:
@@ -35,7 +35,7 @@ licenses:
35
35
  metadata:
36
36
  homepage_uri: https://github.com/mcbarros/routeros-api
37
37
  source_code_uri: https://github.com/mcbarros/routeros-api
38
- changelog_uri: https://github.com/mcbarros/routeros-api/CHANGELOG.md
38
+ changelog_uri: https://github.com/mcbarros/routeros-api/blob/main/CHANGELOG.md
39
39
  post_install_message:
40
40
  rdoc_options: []
41
41
  require_paths: