cargem 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitlab-ci.yml +3 -3
- data/README.md +53 -6
- data/Rakefile +4 -6
- data/bin/cargem-drive-camaro +6 -0
- data/bin/console +0 -0
- data/bin/setup +0 -0
- data/cargem.gemspec +15 -30
- data/lib/cargem.rb +3 -5
- data/lib/cargem/camaro.rb +1 -2
- data/lib/cargem/car.rb +11 -24
- data/lib/cargem/version.rb +1 -1
- metadata +13 -97
- data/lib/cargem/cargem.rb +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0a824c5fbcf5d296983c8cc5e660001d09157f5c
|
4
|
+
data.tar.gz: 6e3f2419927ff4e04a44a48029851062c86305c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7272c578ebc454ad63a78bc53efc7e895fd68301aac811dc51e99e192668b276b1b148194278614cd88d3492904dc9a41f7bf14e0006dff9eb2e406ef6930adc
|
7
|
+
data.tar.gz: f476ce7f5d08bb4f13533cd3f2de6bbe145569e801a3f27bf3ae77b3f2582fc1d7d5b534167ff39a48babd1969642ec41cfd4442e9b9b9333fa1b41f48558143
|
data/.gitlab-ci.yml
CHANGED
data/README.md
CHANGED
@@ -1,12 +1,59 @@
|
|
1
|
-
|
1
|
+
# Cargem
|
2
2
|
|
3
|
-
|
3
|
+
Cargem allows the user instantiate convieniently configured Car objects in various versions.
|
4
4
|
|
5
|
-
|
5
|
+
Completed as a technical exercise during interview process for Best Buy.
|
6
6
|
|
7
|
-
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Install this gem directly with:
|
10
|
+
|
11
|
+
`$ gem install compensate`
|
12
|
+
|
13
|
+
## Usage
|
14
|
+
|
15
|
+
### Command-line
|
16
|
+
|
17
|
+
This gem includes a packaged bin/ executable that demonstrates behavior, for convenience.
|
18
|
+
|
19
|
+
After installation, call `cargem-drive-camaro` at the command line to see a Camaro in action!
|
20
|
+
|
21
|
+
### Ruby script
|
22
|
+
|
23
|
+
Here's an example use, where we generate a Camaro-type Car object and tell it to drive.
|
24
|
+
|
25
|
+
After the gem is installed, initialize a script for our code to live in:
|
26
|
+
|
27
|
+
`$ touch main.rb`
|
28
|
+
|
29
|
+
Edit this script to include the following code snippet:
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
#!/usr/bin/env ruby
|
33
|
+
|
34
|
+
require 'cargem'
|
35
|
+
|
36
|
+
car = Cargem::Camaro.new
|
37
|
+
car.drive
|
38
|
+
```
|
39
|
+
|
40
|
+
Save the file, and change the permissions to make it executable:
|
41
|
+
|
42
|
+
`$ chmod +x main.rb`
|
43
|
+
|
44
|
+
Then run the script:
|
45
|
+
|
46
|
+
`$ ./main.rb`
|
47
|
+
|
48
|
+
You should see output of the car accelerating up to its maximum speed.
|
8
49
|
|
9
50
|
### Class methods
|
10
51
|
|
11
|
-
* `
|
12
|
-
* `
|
52
|
+
* `Car#accelerate # Increments current_speed by 1`
|
53
|
+
* `Car#drive # Drive calls accelerate until it hits max speed`
|
54
|
+
|
55
|
+
## Development
|
56
|
+
|
57
|
+
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.
|
58
|
+
|
59
|
+
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).
|
data/Rakefile
CHANGED
@@ -1,8 +1,6 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rspec/core/rake_task'
|
3
3
|
|
4
|
-
RSpec::Core::RakeTask.new(:spec)
|
5
|
-
task.rspec_opts = ['--color', '--format', 'nested']
|
6
|
-
end
|
4
|
+
RSpec::Core::RakeTask.new(:spec)
|
7
5
|
|
8
|
-
task :
|
6
|
+
task default: :spec
|
data/bin/console
CHANGED
File without changes
|
data/bin/setup
CHANGED
File without changes
|
data/cargem.gemspec
CHANGED
@@ -1,41 +1,26 @@
|
|
1
|
-
|
2
|
-
lib = File.expand_path('
|
1
|
+
|
2
|
+
lib = File.expand_path('lib', __dir__)
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
4
|
require 'cargem/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
7
|
+
spec.name = 'cargem'
|
8
8
|
spec.version = Cargem::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
9
|
+
spec.authors = ['Keifer Furzland']
|
10
|
+
spec.email = ['kfrz.code@gmail.com']
|
11
11
|
|
12
|
-
spec.summary = %q
|
13
|
-
spec.description = %q
|
14
|
-
spec.homepage =
|
12
|
+
spec.summary = %q('This is a simple car-generation gem')
|
13
|
+
spec.description = %q('This is meant to be an example of how to build a simple Ruby gem.')
|
14
|
+
spec.homepage = 'https://gitlab.com/kfrz/cargem'
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
if spec.respond_to?(:metadata)
|
19
|
-
spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
|
20
|
-
else
|
21
|
-
raise "RubyGems 2.0 or newer is required to protect against " \
|
22
|
-
"public gem pushes."
|
16
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
17
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
23
18
|
end
|
24
19
|
|
25
|
-
spec.
|
26
|
-
|
27
|
-
end
|
28
|
-
spec.bindir = "exe"
|
29
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
30
|
-
spec.require_paths = ["lib"]
|
20
|
+
spec.executables << 'cargem-drive-camaro'
|
21
|
+
spec.require_paths = ['lib']
|
31
22
|
|
32
|
-
spec.add_development_dependency
|
33
|
-
spec.add_development_dependency
|
34
|
-
spec.add_development_dependency
|
35
|
-
spec.add_development_dependency "rspec-nc"
|
36
|
-
spec.add_development_dependency "guard"
|
37
|
-
spec.add_development_dependency "guard-rspec"
|
38
|
-
spec.add_development_dependency "pry"
|
39
|
-
spec.add_development_dependency "pry-remote"
|
40
|
-
spec.add_development_dependency "pry-nav"
|
23
|
+
spec.add_development_dependency 'bundler', '~> 1.16'
|
24
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
25
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
41
26
|
end
|
data/lib/cargem.rb
CHANGED
data/lib/cargem/camaro.rb
CHANGED
data/lib/cargem/car.rb
CHANGED
@@ -1,42 +1,29 @@
|
|
1
1
|
module Cargem
|
2
2
|
class Car
|
3
|
+
attr_accessor :brand, :current_speed, :max_speed
|
4
|
+
|
3
5
|
def initialize
|
4
|
-
@
|
5
|
-
@
|
6
|
-
@max_speed = 0
|
7
|
-
@current_speed = 0
|
8
|
-
end
|
9
|
-
|
10
|
-
def accelerate
|
11
|
-
@current_speed += 1
|
6
|
+
@brand = brand ||'unknown'
|
7
|
+
@current_speed = current_speed || 0
|
8
|
+
@max_speed = max_speed || 0
|
12
9
|
end
|
13
|
-
|
14
|
-
def brand
|
15
|
-
@make + @model
|
16
|
-
end
|
17
|
-
|
18
|
-
def current_speed
|
19
|
-
@current_speed
|
20
|
-
end
|
21
10
|
|
22
11
|
def drive
|
23
12
|
while @current_speed <= @max_speed
|
24
13
|
puts "#{@current_speed}"
|
25
14
|
accelerate
|
26
15
|
end
|
27
|
-
print
|
16
|
+
print stopped_acceleration_message
|
28
17
|
end
|
29
18
|
|
30
|
-
def
|
31
|
-
@
|
19
|
+
def accelerate
|
20
|
+
@current_speed += 1
|
32
21
|
end
|
33
22
|
|
34
|
-
|
35
|
-
@model
|
36
|
-
end
|
23
|
+
private
|
37
24
|
|
38
|
-
def
|
39
|
-
@max_speed
|
25
|
+
def stopped_acceleration_message
|
26
|
+
"The #{brand} has hit its max speed of #{@max_speed} and will now stop accelerating."
|
40
27
|
end
|
41
28
|
end
|
42
29
|
end
|
data/lib/cargem/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cargem
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Keifer Furzland
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-06-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1.
|
19
|
+
version: '1.16'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '1.
|
26
|
+
version: '1.16'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,94 +52,11 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '3.0'
|
55
|
-
|
56
|
-
name: rspec-nc
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: guard
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - "~>"
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - "~>"
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: guard-rspec
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - "~>"
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '0'
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - "~>"
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '0'
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: pry
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - "~>"
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: '0'
|
104
|
-
type: :development
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - "~>"
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: '0'
|
111
|
-
- !ruby/object:Gem::Dependency
|
112
|
-
name: pry-remote
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
114
|
-
requirements:
|
115
|
-
- - "~>"
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: '0'
|
118
|
-
type: :development
|
119
|
-
prerelease: false
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
requirements:
|
122
|
-
- - "~>"
|
123
|
-
- !ruby/object:Gem::Version
|
124
|
-
version: '0'
|
125
|
-
- !ruby/object:Gem::Dependency
|
126
|
-
name: pry-nav
|
127
|
-
requirement: !ruby/object:Gem::Requirement
|
128
|
-
requirements:
|
129
|
-
- - "~>"
|
130
|
-
- !ruby/object:Gem::Version
|
131
|
-
version: '0'
|
132
|
-
type: :development
|
133
|
-
prerelease: false
|
134
|
-
version_requirements: !ruby/object:Gem::Requirement
|
135
|
-
requirements:
|
136
|
-
- - "~>"
|
137
|
-
- !ruby/object:Gem::Version
|
138
|
-
version: '0'
|
139
|
-
description: '"This is meant to be an example of how to build a simple Ruby gem."'
|
55
|
+
description: "'This is meant to be an example of how to build a simple Ruby gem.'"
|
140
56
|
email:
|
141
57
|
- kfrz.code@gmail.com
|
142
|
-
executables:
|
58
|
+
executables:
|
59
|
+
- cargem-drive-camaro
|
143
60
|
extensions: []
|
144
61
|
extra_rdoc_files: []
|
145
62
|
files:
|
@@ -150,18 +67,17 @@ files:
|
|
150
67
|
- Guardfile
|
151
68
|
- README.md
|
152
69
|
- Rakefile
|
70
|
+
- bin/cargem-drive-camaro
|
153
71
|
- bin/console
|
154
72
|
- bin/setup
|
155
73
|
- cargem.gemspec
|
156
74
|
- lib/cargem.rb
|
157
75
|
- lib/cargem/camaro.rb
|
158
76
|
- lib/cargem/car.rb
|
159
|
-
- lib/cargem/cargem.rb
|
160
77
|
- lib/cargem/version.rb
|
161
|
-
homepage: https://
|
78
|
+
homepage: https://gitlab.com/kfrz/cargem
|
162
79
|
licenses: []
|
163
|
-
metadata:
|
164
|
-
allowed_push_host: https://rubygems.org
|
80
|
+
metadata: {}
|
165
81
|
post_install_message:
|
166
82
|
rdoc_options: []
|
167
83
|
require_paths:
|
@@ -178,8 +94,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
178
94
|
version: '0'
|
179
95
|
requirements: []
|
180
96
|
rubyforge_project:
|
181
|
-
rubygems_version: 2.
|
97
|
+
rubygems_version: 2.6.14.1
|
182
98
|
signing_key:
|
183
99
|
specification_version: 4
|
184
|
-
summary: '
|
100
|
+
summary: "'This is a simple car-generation gem'"
|
185
101
|
test_files: []
|