maca 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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 354cde56cdb070aa38ceb4cca307d0bb1d4d2698a13f9694bbff5ee4f090088c
4
+ data.tar.gz: 63aea21d117ec506239c76457b3ab2c0aa498b18724b63f9b26d78eceb637c11
5
+ SHA512:
6
+ metadata.gz: 762d2de2dbb2df24df41aa278a04dcc66d1a104ae2e5a5bac23e76491f4f991c8b645ee7977806773eef254b40833a3b1a96ef107f15930475770c446b9853f4
7
+ data.tar.gz: cde0e4e55056e611b5b47a57fc99012e88fd58826a88e7d53ac3669c37e8058a45a1d6f3f7757fdfa951eb7162daaf8a662ed9c5c5c99d1d4b9511f68997829b
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2025 Taketo Takashima
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,63 @@
1
+ # Maca
2
+
3
+ maca provides a set of methods to manipulate a MAC Address.
4
+
5
+ ## Installation
6
+
7
+ Install the gem and add to the application's Gemfile by executing:
8
+
9
+ ```bash
10
+ bundle add maca
11
+ ```
12
+
13
+ If bundler is not being used to manage dependencies, install the gem by executing:
14
+
15
+ ```bash
16
+ gem install maca
17
+ ```
18
+
19
+ ## Usage
20
+
21
+ ```ruby
22
+ require 'maca'
23
+
24
+ Macaddress.new("00:00:00:00:00:00")
25
+ => #<Macaddress @macaddress="00:00:00:00:00:00">
26
+
27
+ Macaddress.new("01:23:45:67:89:ab").to_s
28
+ => "01:23:45:67:89:AB"
29
+
30
+ # Format normalization
31
+ Macaddress.new("00-00-00-00-00-00").to_s
32
+ => "00:00:00:00:00:00"
33
+
34
+ Macaddress.new("000000000000").to_s
35
+ => "00:00:00:00:00:00"
36
+
37
+ Macaddress.new("0000.0000.0000").to_s
38
+ => "00:00:00:00:00:00"
39
+
40
+ Macaddress.new("000000-000000").to_s
41
+ => "00:00:00:00:00:00"
42
+
43
+ # Comparison
44
+ Macaddress.new("00:00:00:00:00:00") == Macaddress.new("00:00:00:00:00:00")
45
+ => true
46
+
47
+ Macaddress.new("00:00:00:00:00:00") == Macaddress.new("00:00:00:00:00:01")
48
+ => false
49
+ ```
50
+
51
+ ## Development
52
+
53
+ 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.
54
+
55
+ 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 the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
56
+
57
+ ## Contributing
58
+
59
+ Bug reports and pull requests are welcome on GitHub at https://github.com/interop-tokyo-shownet/maca.
60
+
61
+ ## License
62
+
63
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :spec
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Maca
4
+ class Macaddress
5
+ REGEXP_MACADDRESS = /^([0-9A-Fa-f]{2}[:.-]?){5}([0-9A-Fa-f]{2})$/
6
+
7
+ def initialize(addr)
8
+ if Maca::Macaddress.valid?(addr)
9
+ @macaddress = addr
10
+ else
11
+ raise Maca::InvalidAddressError, "Invalid MAC Address #{addr}"
12
+ end
13
+ end
14
+
15
+ def self.valid?(addr)
16
+ REGEXP_MACADDRESS.match?(addr)
17
+ end
18
+
19
+ def to_s
20
+ @macaddress.upcase.gsub(/[-:.]/, '').scan(/.{1,2}/).join(':')
21
+ end
22
+
23
+ def ==(other)
24
+ self.to_s == other.to_s
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Maca
4
+ VERSION = "0.2.0"
5
+ end
data/lib/maca.rb ADDED
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "maca/version"
4
+ require_relative "maca/macaddress"
5
+
6
+ require_relative "macaddress"
7
+
8
+ module Maca
9
+ class Error < StandardError; end
10
+ class InvalidAddressError < ArgumentError; end
11
+ end
data/lib/macaddress.rb ADDED
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "maca/macaddress"
4
+
5
+ class Macaddress < Maca::Macaddress
6
+ end
@@ -0,0 +1,4 @@
1
+ module Macaddress
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,52 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: maca
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ platform: ruby
6
+ authors:
7
+ - Taketo Takashima
8
+ bindir: exe
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies: []
12
+ description: maca provides a set of methods to manipulate a MAC Address.
13
+ email:
14
+ - t.taketo1113@gmail.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - ".rspec"
20
+ - LICENSE.txt
21
+ - README.md
22
+ - Rakefile
23
+ - lib/maca.rb
24
+ - lib/maca/macaddress.rb
25
+ - lib/maca/version.rb
26
+ - lib/macaddress.rb
27
+ - sig/macaddress.rbs
28
+ homepage: https://github.com/interop-tokyo-shownet/maca
29
+ licenses:
30
+ - MIT
31
+ metadata:
32
+ homepage_uri: https://github.com/interop-tokyo-shownet/maca
33
+ source_code_uri: https://github.com/interop-tokyo-shownet/maca
34
+ changelog_uri: https://github.com/interop-tokyo-shownet/maca/releases
35
+ rdoc_options: []
36
+ require_paths:
37
+ - lib
38
+ required_ruby_version: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: 2.6.0
43
+ required_rubygems_version: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ requirements: []
49
+ rubygems_version: 3.6.7
50
+ specification_version: 4
51
+ summary: A class to manipulate a MAC Address in ruby
52
+ test_files: []