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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4d52b3f420b75858d98ddeaf771f032854b13852
4
- data.tar.gz: a2f65448e5e6224a51ef6707d4f31c96268ed409
3
+ metadata.gz: 0a824c5fbcf5d296983c8cc5e660001d09157f5c
4
+ data.tar.gz: 6e3f2419927ff4e04a44a48029851062c86305c4
5
5
  SHA512:
6
- metadata.gz: 7ae5a9c83d52c4854ae27eb2e252d5635e468769dd50d08be369c7992b96bc484262d83544849a187980d14ed752be8be476d53af9281bfc95dcbdfde655413f
7
- data.tar.gz: 2dbb8080ba11a63833b9e8357b242ffbd61fe2355aef8f9547aa144954fe90ca45e7028295abf44ef1bd14f6219f9743adc5709503282447f39816cd270530cc
6
+ metadata.gz: 7272c578ebc454ad63a78bc53efc7e895fd68301aac811dc51e99e192668b276b1b148194278614cd88d3492904dc9a41f7bf14e0006dff9eb2e406ef6930adc
7
+ data.tar.gz: f476ce7f5d08bb4f13533cd3f2de6bbe145569e801a3f27bf3ae77b3f2582fc1d7d5b534167ff39a48babd1969642ec41cfd4442e9b9b9333fa1b41f48558143
@@ -1,9 +1,9 @@
1
- image: ruby:2.3.1
1
+ image: ruby:2.4.4
2
2
 
3
- before_script:
3
+ before_script:
4
4
  - gem install bundler
5
5
  - bundle install
6
6
 
7
7
  test:
8
8
  script:
9
- - bundle exec rspec
9
+ - bundle exec rake spec
data/README.md CHANGED
@@ -1,12 +1,59 @@
1
- ## What does CarGem do?
1
+ # Cargem
2
2
 
3
- CarGem allows the author of a ruby script to instantiate convieniently configured Car objects in various versions.
3
+ Cargem allows the user instantiate convieniently configured Car objects in various versions.
4
4
 
5
- Here's an example use, where we generate a Camaro and tell it to drive.
5
+ Completed as a technical exercise during interview process for Best Buy.
6
6
 
7
- `irb> require 'cargem' && Camaro.new.drive `
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
- * `Camaro#accelerate # Increments current_speed by 1`
12
- * `Camaro#drive # Drive calls accelerate until it hits max speed`
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 "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
3
 
4
- RSpec::Core::RakeTask.new(:spec) do |task|
5
- task.rspec_opts = ['--color', '--format', 'nested']
6
- end
4
+ RSpec::Core::RakeTask.new(:spec)
7
5
 
8
- task :default => :spec
6
+ task default: :spec
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'cargem'
4
+
5
+ car = Cargem::Camaro.new
6
+ car.drive
File without changes
data/bin/setup CHANGED
File without changes
@@ -1,41 +1,26 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
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 = "cargem"
7
+ spec.name = 'cargem'
8
8
  spec.version = Cargem::VERSION
9
- spec.authors = ["Keifer Furzland"]
10
- spec.email = ["kfrz.code@gmail.com"]
9
+ spec.authors = ['Keifer Furzland']
10
+ spec.email = ['kfrz.code@gmail.com']
11
11
 
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://github.com/kfrz/cargem"
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
- # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
17
- # to allow pushing to a single host or delete this section to allow pushing to any host.
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.files = `git ls-files -z`.split("\x0").reject do |f|
26
- f.match(%r{^(test|spec|features)/})
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 "bundler", "~> 1.13"
33
- spec.add_development_dependency "rake", "~> 10.0"
34
- spec.add_development_dependency "rspec", "~> 3.0"
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
@@ -1,6 +1,4 @@
1
- require "cargem/version"
2
- require "cargem/car"
3
- require "cargem/camaro"
1
+ require 'cargem/version'
4
2
 
5
- module Cargem
6
- end
3
+ require 'cargem/car'
4
+ require 'cargem/camaro'
@@ -2,8 +2,7 @@ module Cargem
2
2
  class Camaro < Car
3
3
  def initialize
4
4
  super
5
- @make = "Chevy"
6
- @model = "Camaro"
5
+ @brand = "Chevy"
7
6
  @max_speed = 200
8
7
  end
9
8
  end
@@ -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
- @make = "unknown"
5
- @model = "unknown"
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 "The #{@make} #{@model} has hit its max speed of #{@max_speed} and will now stop accelerating."
16
+ print stopped_acceleration_message
28
17
  end
29
18
 
30
- def make
31
- @make
19
+ def accelerate
20
+ @current_speed += 1
32
21
  end
33
22
 
34
- def model
35
- @model
36
- end
23
+ private
37
24
 
38
- def max_speed
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
@@ -1,3 +1,3 @@
1
1
  module Cargem
2
- VERSION = "0.1.0"
2
+ VERSION = '0.2.0'
3
3
  end
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.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Keifer Furzland
8
8
  autorequire:
9
- bindir: exe
9
+ bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-08 00:00:00.000000000 Z
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.13'
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.13'
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
- - !ruby/object:Gem::Dependency
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://github.com/kfrz/cargem
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.5.1
97
+ rubygems_version: 2.6.14.1
182
98
  signing_key:
183
99
  specification_version: 4
184
- summary: '"This is a simple car-generation gem"'
100
+ summary: "'This is a simple car-generation gem'"
185
101
  test_files: []
@@ -1,7 +0,0 @@
1
- class Camaro < Car
2
- def initialize
3
- super
4
- @brand = "Chevy"
5
- @max_speed = 200
6
- end
7
- end