sdn_test_simple_car 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: 53b49bdbac04dae0f2ccf0d0ebe6ea82f947a333e36082eece3d215e9ce2ab7c
4
+ data.tar.gz: 2f347ba4ffc702edfa2c9e0955c45660710eeb1788ddd6b2648acf2676dc0027
5
+ SHA512:
6
+ metadata.gz: 7e745d8cf6af3aa7635e6de2ebde4c2fbbbc36b300a659e681721b3bcf116c65c0f216197057021c1364152239e791ee66b2ca1f61cfca4a09629beb156306d2
7
+ data.tar.gz: 7043cd44f5657acf8c369411164788ebb9cf50f486eacd181ffa6444740ab7fd5169412fac2fdc5b0c67564c2d914e2471845d1099f83f14f688c01ff61cf28c
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,8 @@
1
+ AllCops:
2
+ TargetRubyVersion: 3.1
3
+
4
+ Style/StringLiterals:
5
+ EnforcedStyle: double_quotes
6
+
7
+ Style/StringLiteralsInInterpolation:
8
+ EnforcedStyle: double_quotes
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2026 Graftcode
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,74 @@
1
+ # SimpleCar
2
+
3
+ A minimal Ruby class that represents a car and its running state.
4
+
5
+ ## What it provides
6
+
7
+ - Auto-generated UUID `id` (or custom `id`)
8
+ - Car metadata: `make`, `model`, `year`
9
+ - Engine state control: `start`, `stop`, `is_running`
10
+ - String representation via `to_s`
11
+
12
+ ## Requirements
13
+
14
+ - Ruby 3.1+
15
+
16
+ ## Import
17
+
18
+ Use one of the following approaches:
19
+
20
+ ```ruby
21
+ require "simple_car"
22
+ ```
23
+
24
+ or, when loading directly from the repository:
25
+
26
+ ```ruby
27
+ require_relative "lib/simple_car"
28
+ ```
29
+
30
+ ## Quick Start
31
+
32
+ ```ruby
33
+ require "simple_car"
34
+
35
+ car = SimpleCar.new("Toyota", "Corolla", 2020)
36
+
37
+ puts car.id # generated UUID
38
+ puts car.make # "Toyota"
39
+ puts car.model # "Corolla"
40
+ puts car.year # 2020
41
+ puts car.wheels # 4
42
+ puts car.is_running # false
43
+
44
+ car.start
45
+ puts car.is_running # true
46
+
47
+ car.stop
48
+ puts car.is_running # false
49
+
50
+ puts car.to_s
51
+ # => "<id> 2020 Toyota Corolla (SimpleCar) Not Running"
52
+ ```
53
+
54
+ ## Custom ID
55
+
56
+ ```ruby
57
+ car = SimpleCar.new("Ford", "Mustang", 1968, "car-001")
58
+ puts car.id # "car-001"
59
+ ```
60
+
61
+ If `id` is `nil` or empty, `SimpleCar` generates a UUID automatically.
62
+
63
+ ## API Reference
64
+
65
+ - `SimpleCar.new(make, model, year, id = nil)`
66
+ - `id` -> `String`
67
+ - `make` -> `String`
68
+ - `model` -> `String`
69
+ - `year` -> `Integer` (or any value passed in)
70
+ - `wheels` -> `4`
71
+ - `is_running` -> `true` / `false`
72
+ - `start` -> sets running state to `true`
73
+ - `stop` -> sets running state to `false`
74
+ - `to_s` -> `"<id> <year> <make> <model> (SimpleCar) <Running|Not Running>"`
data/Rakefile ADDED
@@ -0,0 +1,12 @@
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
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module GrftTestSimpleCar
4
+ VERSION = "0.1.0"
5
+ end
data/lib/simple_car.rb ADDED
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "securerandom"
4
+
5
+ class SimpleCar
6
+ attr_reader :id, :make, :model, :year
7
+
8
+ def initialize(make, model, year, id = nil)
9
+ @id = id.nil? || id.strip.empty? ? SecureRandom.uuid : id
10
+ @make = make
11
+ @model = model
12
+ @year = year
13
+ @is_running = false
14
+ end
15
+
16
+ def wheels
17
+ 4
18
+ end
19
+
20
+ def is_running
21
+ @is_running
22
+ end
23
+
24
+ def start
25
+ @is_running = true
26
+ end
27
+
28
+ def stop
29
+ @is_running = false
30
+ end
31
+
32
+ def to_s
33
+ "#{@id} #{@year} #{@make} #{@model} (SimpleCar) #{@is_running ? "Running" : "Not Running"}"
34
+ end
35
+ end
metadata ADDED
@@ -0,0 +1,49 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sdn_test_simple_car
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - GraftCode
8
+ bindir: exe
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies: []
12
+ description: Provides a lightweight SimpleCar class with make/model/year data, auto-generated
13
+ IDs, engine start/stop state, and a readable string representation.
14
+ email:
15
+ - info@graftcode.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - ".rspec"
21
+ - ".rubocop.yml"
22
+ - LICENSE.txt
23
+ - README.md
24
+ - Rakefile
25
+ - lib/grft_test_simple_car/version.rb
26
+ - lib/simple_car.rb
27
+ homepage: https://graftcode.com
28
+ licenses:
29
+ - MIT
30
+ metadata:
31
+ homepage_uri: https://graftcode.com
32
+ rdoc_options: []
33
+ require_paths:
34
+ - lib
35
+ required_ruby_version: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: 3.1.0
40
+ required_rubygems_version: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ version: '0'
45
+ requirements: []
46
+ rubygems_version: 3.6.9
47
+ specification_version: 4
48
+ summary: A minimal SimpleCar model with runtime state management.
49
+ test_files: []