my_garage 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +53 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +18 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +35 -0
- data/LICENSE +21 -0
- data/README.md +90 -0
- data/Rakefile +8 -0
- data/SCOPE.md +25 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/my_garage/cars/base_car.rb +143 -0
- data/lib/my_garage/cars/camaro.rb +9 -0
- data/lib/my_garage/cars/mustang.rb +9 -0
- data/lib/my_garage/version.rb +3 -0
- data/lib/my_garage.rb +23 -0
- data/my_garage.gemspec +27 -0
- metadata +105 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 7b0ed4103d0edcb2125cacdf400b88c6f5d49f222aaa5d8583e200190d2f4721
|
4
|
+
data.tar.gz: 668c86632573ac7bec5548fa557270c4b700d64a123ff5cd0e122e2bdb3fb3cd
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 58bc72586679b27bfd1bc7bd0e5bf71dbef40df46b5030a4df001c58620b076fab7f74795bb8ca61ce8e6f5bb7bafcb9eb920bb2b5d2afe8c8cab65cf462d535
|
7
|
+
data.tar.gz: 6cab20ea4054ae95a787e4667bd4c9c75683b47ae6fbab7f318884f7c1a9c6aca85cb904db097d3fe8eb94f427e552924cbc8720dc36b6962163b6a9dd1245fd
|
data/.gitignore
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/spec/examples.txt
|
9
|
+
/test/tmp/
|
10
|
+
/test/version_tmp/
|
11
|
+
/tmp/
|
12
|
+
|
13
|
+
# Rubymine folder
|
14
|
+
/.idea/
|
15
|
+
|
16
|
+
# Used by dotenv library to load environment variables.
|
17
|
+
# .env
|
18
|
+
|
19
|
+
## Specific to RubyMotion:
|
20
|
+
.dat*
|
21
|
+
.repl_history
|
22
|
+
build/
|
23
|
+
*.bridgesupport
|
24
|
+
build-iPhoneOS/
|
25
|
+
build-iPhoneSimulator/
|
26
|
+
|
27
|
+
## Specific to RubyMotion (use of CocoaPods):
|
28
|
+
#
|
29
|
+
# We recommend against adding the Pods directory to your .gitignore. However
|
30
|
+
# you should judge for yourself, the pros and cons are mentioned at:
|
31
|
+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
32
|
+
#
|
33
|
+
# vendor/Pods/
|
34
|
+
|
35
|
+
## Documentation cache and generated files:
|
36
|
+
/.yardoc/
|
37
|
+
/_yardoc/
|
38
|
+
/doc/
|
39
|
+
/rdoc/
|
40
|
+
|
41
|
+
## Environment normalization:
|
42
|
+
/.bundle/
|
43
|
+
/vendor/bundle
|
44
|
+
/lib/bundler/man/
|
45
|
+
|
46
|
+
# for a library or gem, you might want to ignore these files since the code is
|
47
|
+
# intended to run in multiple environments; otherwise, check them in:
|
48
|
+
# Gemfile.lock
|
49
|
+
# .ruby-version
|
50
|
+
# .ruby-gemset
|
51
|
+
|
52
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
53
|
+
.rvmrc
|
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
my_garage
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby-2.5.0
|
data/.travis.yml
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
addons:
|
2
|
+
language: ruby
|
3
|
+
rvm:
|
4
|
+
- 2.3.1
|
5
|
+
- 2.4.3
|
6
|
+
- 2.5.0
|
7
|
+
- ruby-head
|
8
|
+
- jruby
|
9
|
+
|
10
|
+
matrix:
|
11
|
+
allow_failures:
|
12
|
+
- rvm: ruby-head
|
13
|
+
|
14
|
+
cache: bundler
|
15
|
+
|
16
|
+
before_install:
|
17
|
+
- "rm ${BUNDLE_GEMFILE}.lock"
|
18
|
+
- gem install bundler -v 1.16.1
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -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 bacrossland@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
data/Gemfile.lock
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
my_garage (0.1.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
diff-lcs (1.3)
|
10
|
+
rake (10.5.0)
|
11
|
+
rspec (3.7.0)
|
12
|
+
rspec-core (~> 3.7.0)
|
13
|
+
rspec-expectations (~> 3.7.0)
|
14
|
+
rspec-mocks (~> 3.7.0)
|
15
|
+
rspec-core (3.7.1)
|
16
|
+
rspec-support (~> 3.7.0)
|
17
|
+
rspec-expectations (3.7.0)
|
18
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
19
|
+
rspec-support (~> 3.7.0)
|
20
|
+
rspec-mocks (3.7.0)
|
21
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
22
|
+
rspec-support (~> 3.7.0)
|
23
|
+
rspec-support (3.7.1)
|
24
|
+
|
25
|
+
PLATFORMS
|
26
|
+
ruby
|
27
|
+
|
28
|
+
DEPENDENCIES
|
29
|
+
bundler (~> 1.16)
|
30
|
+
my_garage!
|
31
|
+
rake (~> 10.0)
|
32
|
+
rspec (~> 3.0)
|
33
|
+
|
34
|
+
BUNDLED WITH
|
35
|
+
1.16.1
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2018 Bryan Crossland
|
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 all
|
13
|
+
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 THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
# MyGarage
|
2
|
+
|
3
|
+
Welcome to MyGarage! This is a multi-threaded ruby application for racing cars.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'my_garage'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install my_garage
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
To go for a quick ride, at the command prompt run the following:
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
$ MyGarage.go_for_a_ride
|
27
|
+
```
|
28
|
+
|
29
|
+
To list the cars currently in the garage:
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
$ MyGarage.list_cars
|
33
|
+
```
|
34
|
+
|
35
|
+
You can also get your own instance of car.
|
36
|
+
|
37
|
+
|
38
|
+
```ruby
|
39
|
+
car = MyGarage::Camaro.new
|
40
|
+
|
41
|
+
# Methods
|
42
|
+
car.turn_on # start the car
|
43
|
+
car.drive # move the car forward
|
44
|
+
car.brake # slow the car down
|
45
|
+
car.turn_off # turn the car off
|
46
|
+
|
47
|
+
# Properties
|
48
|
+
car.brand # maker of the car
|
49
|
+
car.color # color of the car
|
50
|
+
car.max_speed # top speed of the car in mph
|
51
|
+
car.name # model of the car
|
52
|
+
|
53
|
+
# States
|
54
|
+
car.current_speed # speed the car is going in mph
|
55
|
+
car.motion # symbol of car's current motion state: :stop or :moving
|
56
|
+
```
|
57
|
+
|
58
|
+
Note: ```brand``` and ```max_speed``` are the only two properties you can change after you initialize a car instance.
|
59
|
+
All other properties have to be set at time of initialization. The states ```current_speed``` and ```motion``` are governed internally
|
60
|
+
and can't be set.
|
61
|
+
|
62
|
+
## Original Scope
|
63
|
+
|
64
|
+
This application was built to answer the questions outlined in the [SCOPE.md](https://github.com/bacrossland/my_garage/SCOPE.md) file.
|
65
|
+
|
66
|
+
## Development
|
67
|
+
|
68
|
+
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.
|
69
|
+
|
70
|
+
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).
|
71
|
+
|
72
|
+
## Contributing
|
73
|
+
|
74
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/bacrossland/my_garage. 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.
|
75
|
+
|
76
|
+
## Things to do
|
77
|
+
|
78
|
+
* Add more testing. Current test suite is lacking.
|
79
|
+
* Two cars can race each other.
|
80
|
+
* More advanced race track.
|
81
|
+
* Add more cars.
|
82
|
+
|
83
|
+
|
84
|
+
## License
|
85
|
+
|
86
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
87
|
+
|
88
|
+
## Code of Conduct
|
89
|
+
|
90
|
+
Everyone interacting in the MyGarage project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/bacrossland/my_garage/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/SCOPE.md
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
Code Scenario Requirements; Please make sure candidates are running their code to ensure it works before submitting.
|
2
|
+
|
3
|
+
Base Car Class
|
4
|
+
|
5
|
+
+ current speed (property) – default value 0
|
6
|
+
|
7
|
+
+ accelerate (method)
|
8
|
+
|
9
|
+
+ drive (method)
|
10
|
+
|
11
|
+
+ brand (property) - default value ‘unknown’
|
12
|
+
|
13
|
+
+ max speed (property) - default value 0
|
14
|
+
|
15
|
+
Camaro Car Class
|
16
|
+
|
17
|
+
+ Inherits Base Car
|
18
|
+
|
19
|
+
+ brand (property) - default value ‘Chevy’
|
20
|
+
|
21
|
+
+ max speed (property) – default value 200
|
22
|
+
|
23
|
+
Code Scenario:
|
24
|
+
|
25
|
+
In this example we will create an instance of Camaro and tell it to drive, we will assume it’s moving in a straight line and there are no other driving factors. The car will accelerate until it hits its max speed. It is required that drive will call accelerate. It is required accelerate will increment the current speed by 1. Once the Camaro reaches max speed it should stop accelerating and print that it hit the cars max speed. The execution of drive should then also stop
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "my_garage"
|
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(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,143 @@
|
|
1
|
+
module MyGarage
|
2
|
+
class BaseCar
|
3
|
+
attr_accessor :color, :max_speed
|
4
|
+
attr_reader :brand, :current_speed, :name, :motion
|
5
|
+
|
6
|
+
def initialize(hsh = {})
|
7
|
+
@brand = hsh[:brand] || 'unknown'
|
8
|
+
@color = hsh[:color] || 'unknown'
|
9
|
+
@current_speed = hsh[:current_speed] || 0
|
10
|
+
@max_speed = hsh[:max_speed] || 0
|
11
|
+
@name = self.class.name.split('::').last
|
12
|
+
@motion = :stop
|
13
|
+
@mutex = Mutex.new
|
14
|
+
@cv = ConditionVariable.new
|
15
|
+
end
|
16
|
+
|
17
|
+
def brake
|
18
|
+
unless car_on?
|
19
|
+
puts "The brake lights come on. The car isn't running. You need to turn it on first."
|
20
|
+
return
|
21
|
+
end
|
22
|
+
|
23
|
+
if motion == :stop
|
24
|
+
puts "The #{name} is already stopped. You should try drive."
|
25
|
+
return
|
26
|
+
end
|
27
|
+
brake_thread = Thread.new{
|
28
|
+
@mutex.synchronize {
|
29
|
+
puts "You apply the brake and the #{name} begins to slow..."
|
30
|
+
decelerate
|
31
|
+
@cv.signal
|
32
|
+
}
|
33
|
+
}
|
34
|
+
brake_thread.join
|
35
|
+
end
|
36
|
+
|
37
|
+
def drive
|
38
|
+
unless car_on?
|
39
|
+
puts "Nothing happens. The car isn't running. You need to turn it on first."
|
40
|
+
return
|
41
|
+
end
|
42
|
+
|
43
|
+
if current_speed != 0
|
44
|
+
puts "The #{name} is already in motion. You should apply the brake."
|
45
|
+
return
|
46
|
+
end
|
47
|
+
drive_thread = Thread.new{
|
48
|
+
@mutex.synchronize {
|
49
|
+
puts "A light push on the gas peddle causes the #{name} to roar off down the road..."
|
50
|
+
accelerate
|
51
|
+
@cv.signal
|
52
|
+
}
|
53
|
+
}
|
54
|
+
drive_thread.join
|
55
|
+
end
|
56
|
+
|
57
|
+
def go_for_a_ride
|
58
|
+
puts "You get behind the wheel of a #{color} colored #{brand} #{name} in the garage."
|
59
|
+
turn_on
|
60
|
+
sleep(2)
|
61
|
+
drive
|
62
|
+
sleep(2)
|
63
|
+
puts 'Time to slow down before you get a ticket.'
|
64
|
+
brake
|
65
|
+
sleep(2)
|
66
|
+
turn_off
|
67
|
+
end
|
68
|
+
|
69
|
+
def turn_off
|
70
|
+
unless car_on?
|
71
|
+
puts "The car if already off. Try turn_on first."
|
72
|
+
return
|
73
|
+
end
|
74
|
+
|
75
|
+
if motion == :stop
|
76
|
+
@main_thread.exit
|
77
|
+
puts "You turn the key and shuf off the #{name}'s engine."
|
78
|
+
else
|
79
|
+
puts "Turning off the engine while the car is moving is not safe. You should apply the brake first."
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
|
84
|
+
def turn_on
|
85
|
+
unless @main_thread.nil?
|
86
|
+
if @main_thread.alive?
|
87
|
+
puts "The car is already running."
|
88
|
+
return
|
89
|
+
end
|
90
|
+
end
|
91
|
+
@main_thread = Thread.new {
|
92
|
+
@mutex.synchronize {
|
93
|
+
puts "When you turn the key, the #{name}'s engine jumps to life and begins to idle."
|
94
|
+
loop do
|
95
|
+
@cv.wait(@mutex)
|
96
|
+
motion == :stop ? idle : moving
|
97
|
+
end
|
98
|
+
}
|
99
|
+
}
|
100
|
+
end
|
101
|
+
|
102
|
+
private
|
103
|
+
|
104
|
+
def accelerate
|
105
|
+
while current_speed < max_speed
|
106
|
+
@current_speed += 1
|
107
|
+
@motion = :moving
|
108
|
+
print "Current Speed: #{current_speed} \r"
|
109
|
+
$stdout.flush
|
110
|
+
sleep(0.05)
|
111
|
+
end
|
112
|
+
puts "The #{name} has hit its max speed of #{max_speed} mph."
|
113
|
+
end
|
114
|
+
|
115
|
+
def decelerate
|
116
|
+
while current_speed > 0
|
117
|
+
@current_speed -= 1
|
118
|
+
print "Current Speed: #{current_speed} \r"
|
119
|
+
$stdout.flush
|
120
|
+
sleep(0.05)
|
121
|
+
end
|
122
|
+
@motion = :stop
|
123
|
+
puts "The #{name} has reached #{current_speed} mph and come to a complete stop."
|
124
|
+
end
|
125
|
+
|
126
|
+
def car_on?
|
127
|
+
if @main_thread.nil?
|
128
|
+
false
|
129
|
+
else
|
130
|
+
@main_thread.alive?
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
def idle
|
135
|
+
puts "The #{name}'s engine idles..."
|
136
|
+
end
|
137
|
+
|
138
|
+
def moving
|
139
|
+
puts "Objects being passed are a blur as the #{name} whips down the road."
|
140
|
+
end
|
141
|
+
|
142
|
+
end
|
143
|
+
end
|
data/lib/my_garage.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'my_garage/cars/base_car'
|
3
|
+
require 'my_garage/cars/camaro'
|
4
|
+
require 'my_garage/cars/mustang'
|
5
|
+
require 'my_garage/version'
|
6
|
+
require 'thread'
|
7
|
+
|
8
|
+
module MyGarage
|
9
|
+
def self.go_for_a_ride
|
10
|
+
car = Camaro.new
|
11
|
+
car.go_for_a_ride
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.list_cars
|
15
|
+
list_of_cars = []
|
16
|
+
arr = Dir['lib/my_garage/cars/*.rb']
|
17
|
+
arr.delete('lib/my_garage/cars/base_car.rb')
|
18
|
+
arr.each do |car|
|
19
|
+
list_of_cars << car.gsub('lib/my_garage/cars/','').gsub('.rb','').gsub('_','').capitalize
|
20
|
+
end
|
21
|
+
return list_of_cars
|
22
|
+
end
|
23
|
+
end
|
data/my_garage.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "my_garage/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "my_garage"
|
8
|
+
spec.version = MyGarage::VERSION
|
9
|
+
spec.authors = ["bacrossland"]
|
10
|
+
spec.email = ["bacrossland@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{A multi-threaded Ruby application for racing cars.}
|
13
|
+
spec.description = %q{A multi-threaded Ruby application for racing cars.}
|
14
|
+
spec.homepage = "https://github.com/bacrossland/my_garage"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
|
+
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_development_dependency "bundler", "~> 1.16"
|
25
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
26
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: my_garage
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- bacrossland
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-04-10 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.16'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.16'
|
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
|
+
description: A multi-threaded Ruby application for racing cars.
|
56
|
+
email:
|
57
|
+
- bacrossland@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- ".ruby-gemset"
|
64
|
+
- ".ruby-version"
|
65
|
+
- ".travis.yml"
|
66
|
+
- CODE_OF_CONDUCT.md
|
67
|
+
- Gemfile
|
68
|
+
- Gemfile.lock
|
69
|
+
- LICENSE
|
70
|
+
- README.md
|
71
|
+
- Rakefile
|
72
|
+
- SCOPE.md
|
73
|
+
- bin/console
|
74
|
+
- bin/setup
|
75
|
+
- lib/my_garage.rb
|
76
|
+
- lib/my_garage/cars/base_car.rb
|
77
|
+
- lib/my_garage/cars/camaro.rb
|
78
|
+
- lib/my_garage/cars/mustang.rb
|
79
|
+
- lib/my_garage/version.rb
|
80
|
+
- my_garage.gemspec
|
81
|
+
homepage: https://github.com/bacrossland/my_garage
|
82
|
+
licenses:
|
83
|
+
- MIT
|
84
|
+
metadata: {}
|
85
|
+
post_install_message:
|
86
|
+
rdoc_options: []
|
87
|
+
require_paths:
|
88
|
+
- lib
|
89
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - ">="
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - ">="
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
requirements: []
|
100
|
+
rubyforge_project:
|
101
|
+
rubygems_version: 2.7.3
|
102
|
+
signing_key:
|
103
|
+
specification_version: 4
|
104
|
+
summary: A multi-threaded Ruby application for racing cars.
|
105
|
+
test_files: []
|