uss-enterprise 0.0.3.2 → 0.0.3.5

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: 96a61a0ce1b07c4592c6b39ab387d87b7797a38f
4
- data.tar.gz: 258023f7791b65179543e90fddc834001b021af2
3
+ metadata.gz: b4562e0ee087b5a2b3bd0151e60974698ce64581
4
+ data.tar.gz: 0127c1fbcd608ab63de12a07c0489f0be9c81101
5
5
  SHA512:
6
- metadata.gz: 752c57920f1e37584f4f891cadf8a49423d82c966d400cba56dab718a00be93f8d96658e5d6417a5e228c8569ca1eff28576f48828c804639699141a449187ff
7
- data.tar.gz: 8f864b94bd406bf17ad80afb2116d4dc90a18beea28017abdbc05c64bc426aca0244df4b3a0980c8ca84ab0d09f0ff09f89841864a1488c03822ad94ab35c463
6
+ metadata.gz: fa70b862a50d1d1460e00e53f64e35b35aebcae6e22b5c4cab87d10fe2277c87189cf7a975d01f99f6189a96659c0441dda79ffcbf7ed1c05edfdd364b197172
7
+ data.tar.gz: d00428531eeb7841a42bc8e3b55887f040e68509cbdd1f3e7e3bd48ae68ffd7b3b74318411c6dee618c58e5e521eb8265778b4bc15ac03b51e02f4ecb2145dc6
@@ -3,7 +3,7 @@ require_relative 'blueprint.rb'
3
3
  class ShipBuilder
4
4
  include Blueprints
5
5
 
6
- attr_reader :available_blueprints
6
+ attr_reader :available_blueprints, :blueprint
7
7
 
8
8
  def initialize(type = nil)
9
9
  case type
@@ -1,6 +1,8 @@
1
1
  require_relative 'ship_builders.rb'
2
2
 
3
3
  class ShipChooser
4
+ attr_reader :ship_group_options, :ship_builder, :ship_class
5
+
4
6
  def initialize
5
7
  @ship_group_options = {
6
8
  'StarShip' => StarShipBuilder.new,
data/readme.md CHANGED
@@ -35,6 +35,7 @@ Acceptable arguments produce the following ships:
35
35
  - `c # => Enterprise NCC-1701-C`
36
36
  - `d # => Enterprise NCC-1701-D`
37
37
  - `e # => Enterprise NCC-1701-E`
38
+ - `voy # => Voyager NCC-74656`
38
39
 
39
40
  Incorrect parameters cause it to supply usage instructions.
40
41
 
@@ -0,0 +1,46 @@
1
+ require 'test/unit'
2
+ require 'uss-enterprise/blueprint.rb'
3
+ require 'uss-enterprise/schematics.rb'
4
+
5
+ class TestBlueprints < Test::Unit::TestCase
6
+ include ShipSchematics
7
+ include Blueprints
8
+
9
+ def test_sea_ship_blueprints
10
+ schematics = Schematics.new
11
+
12
+ expectation = {
13
+ 'Sloop' => schematics.sloop,
14
+ 'Carrier' => schematics.carrier
15
+ }
16
+
17
+ assert_equal(expectation, SeaShipBlueprints.new.gimme)
18
+ end
19
+
20
+ def test_orbital_ship_blueprints
21
+ schematics = Schematics.new
22
+
23
+ expectation = {
24
+ 'Spaceshuttle' => schematics.spaceshuttle
25
+ }
26
+
27
+ assert_equal(expectation, OrbitalShipBlueprints.new.gimme)
28
+ end
29
+
30
+ def test_star_ship_blueprints
31
+ schematics = Schematics.new
32
+
33
+ expectation = {
34
+ 'NX' => schematics.ss_nx,
35
+ 'Constitution' => schematics.ss_constitution,
36
+ 'Constitution - refit' => schematics.ss_const_refit,
37
+ 'Excelsior' => schematics.ss_excelsior,
38
+ 'Ambassador' => schematics.ss_ambassador,
39
+ 'Galaxy' => schematics.ss_galaxy,
40
+ 'Sovereign' => schematics.ss_sovereign,
41
+ 'Intrepid' => schematics.ss_intrepid
42
+ }
43
+
44
+ assert_equal(expectation, StarShipBlueprints.new.gimme)
45
+ end
46
+ end
@@ -0,0 +1 @@
1
+ # TODO
@@ -0,0 +1,85 @@
1
+ require 'test/unit'
2
+ require 'uss-enterprise/blueprint.rb' # has its own test
3
+
4
+ # testing this
5
+ require 'uss-enterprise/ship_builders.rb'
6
+
7
+ class TestShipBuilder < Test::Unit::TestCase
8
+ include Blueprints
9
+
10
+ def test_initialize
11
+
12
+ #test initializing ShipBuilder with each of its possible inputs
13
+ expected_types = {
14
+ nil => Blueprints.new.gimme,
15
+ 'SeaShip' => SeaShipBlueprints.new.gimme,
16
+ 'OrbitalShip' => OrbitalShipBlueprints.new.gimme,
17
+ 'StarShip' => StarShipBlueprints.new.gimme
18
+ }
19
+
20
+ expected_types.each do |type, b_prints|
21
+ ship_builder = ShipBuilder.new(type)
22
+
23
+ assert_equal(b_prints, ship_builder.available_blueprints)
24
+ end
25
+
26
+ # test bad input
27
+ ship_builder = ShipBuilder.new('foo')
28
+ assert_equal(nil, ship_builder.available_blueprints)
29
+ end
30
+
31
+ def test_define_blueprint
32
+
33
+ # test on sea subtype
34
+ sea_possible_prints = SeaShipBlueprints.new.gimme
35
+ sea_possible_prints.each do |name, b_print|
36
+
37
+ ship_builder = SeaShipBuilder.new
38
+ ship_builder.define_blueprint(name)
39
+
40
+ assert_equal(b_print, ship_builder.blueprint)
41
+ end
42
+
43
+ # test on orbital subtype
44
+ orb_possible_prints = OrbitalShipBlueprints.new.gimme
45
+ orb_possible_prints.each do |name, b_print|
46
+
47
+ ship_builder = OrbitalShipBuilder.new
48
+ ship_builder.define_blueprint(name)
49
+
50
+ assert_equal(b_print, ship_builder.blueprint)
51
+ end
52
+
53
+ # test on star subtype
54
+ star_possible_prints = StarShipBlueprints.new.gimme
55
+ star_possible_prints.each do |name, b_print|
56
+
57
+ ship_builder = StarShipBuilder.new
58
+ ship_builder.define_blueprint(name)
59
+
60
+ assert_equal(b_print, ship_builder.blueprint)
61
+ end
62
+ end
63
+
64
+ def test_build_it
65
+ expected_prints = {
66
+ 'SeaShip' => SeaShipBlueprints.new.gimme,
67
+ 'OrbitalShip' => OrbitalShipBlueprints.new.gimme,
68
+ 'StarShip' => StarShipBlueprints.new.gimme
69
+ }
70
+
71
+ expected_prints.each do |type, possible_prints|
72
+ ship_builder = ShipBuilder.new(type)
73
+
74
+ possible_prints.each do |s_class, b_print|
75
+ ship_builder.define_blueprint(s_class)
76
+
77
+ out = capture_output do
78
+ ship_builder.build_it
79
+ end
80
+
81
+ assert_equal(b_print.chomp, out[0].chomp)
82
+ end
83
+ end
84
+ end
85
+ end
@@ -0,0 +1,58 @@
1
+ require 'test/unit'
2
+ require 'uss-enterprise/ship_builders.rb'
3
+
4
+ require 'uss-enterprise/ship_chooser.rb'
5
+
6
+ class TestShipChooser < Test::Unit::TestCase
7
+
8
+ def setup
9
+ @chooser = ShipChooser.new
10
+ end
11
+
12
+ def test_choose_ship_group
13
+
14
+ requests = {
15
+ #'random' => , # not sure how to test this
16
+ 'StarShip' => StarShipBuilder.new,
17
+ 'SeaShip' => SeaShipBuilder.new,
18
+ 'OrbitalShip' => OrbitalShipBuilder.new
19
+ }
20
+
21
+ requests.each do |group, builder|
22
+ # assert against the available_blueprints attribute, because we don't want to assert that the addresses in memory are equal, just the values chosen by the choose_ship_group method
23
+ assert_equal(builder.available_blueprints, @chooser.choose_ship_group(group).available_blueprints)
24
+ end
25
+
26
+ # assert_include(requests.values, @chooser.choose_ship_group('random'))
27
+ end
28
+
29
+ def test_choose_ship_class
30
+ sea_classes = ['Sloop', 'Carrier']
31
+ orbital_classes = ['Spaceshuttle']
32
+ star_classes = ['NX', 'Constitution', 'Constitution - refit', 'Excelsior', 'Ambassador', 'Galaxy', 'Sovereign', 'Intrepid']
33
+
34
+ ship_groups = {
35
+ 'SeaShip' => sea_classes,
36
+ 'OrbitalShip' => orbital_classes,
37
+ 'StarShip' => star_classes
38
+ }
39
+
40
+ ship_groups.each do |group, classes|
41
+ @chooser.choose_ship_group(group)
42
+ classes.each do |c|
43
+ @chooser.choose_ship_class(c)
44
+
45
+ assert_equal(c, @chooser.ship_class)
46
+ end
47
+ end
48
+
49
+ # test random ship class
50
+ ship_groups.each do |group, classes|
51
+ @chooser.choose_ship_group(group)
52
+ @chooser.choose_ship_class('random')
53
+
54
+ assert_include(classes, @chooser.ship_class)
55
+ end
56
+ end
57
+
58
+ end
@@ -0,0 +1 @@
1
+ # TODO
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uss-enterprise
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3.2
4
+ version: 0.0.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean DMR
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-05 00:00:00.000000000 Z
11
+ date: 2017-02-10 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Outputs ASCII art of different Enterprises
14
14
  email:
@@ -19,14 +19,18 @@ extensions: []
19
19
  extra_rdoc_files: []
20
20
  files:
21
21
  - bin/enterprise
22
- - lib/test.rb
22
+ - lib/uss-enterprise.rb
23
23
  - lib/uss-enterprise/blueprint.rb
24
24
  - lib/uss-enterprise/interactions.rb
25
25
  - lib/uss-enterprise/schematics.rb
26
26
  - lib/uss-enterprise/ship_builders.rb
27
27
  - lib/uss-enterprise/ship_chooser.rb
28
- - lib/uss-enterprise.rb
29
28
  - readme.md
29
+ - tests/test_blueprint.rb
30
+ - tests/test_interactions.rb
31
+ - tests/test_ship_builders.rb
32
+ - tests/test_ship_chooser.rb
33
+ - tests/test_uss-enterprise.rb
30
34
  homepage: https://github.com/flyinggrizzly/uss-enterprise
31
35
  licenses:
32
36
  - GPL-3.0
@@ -37,18 +41,23 @@ require_paths:
37
41
  - lib
38
42
  required_ruby_version: !ruby/object:Gem::Requirement
39
43
  requirements:
40
- - - '>='
44
+ - - ">="
41
45
  - !ruby/object:Gem::Version
42
46
  version: '0'
43
47
  required_rubygems_version: !ruby/object:Gem::Requirement
44
48
  requirements:
45
- - - '>='
49
+ - - ">="
46
50
  - !ruby/object:Gem::Version
47
51
  version: '0'
48
52
  requirements: []
49
53
  rubyforge_project:
50
- rubygems_version: 2.0.14.1
54
+ rubygems_version: 2.6.8
51
55
  signing_key:
52
56
  specification_version: 4
53
57
  summary: Outputs ASCII art of different Enterprises
54
- test_files: []
58
+ test_files:
59
+ - tests/test_blueprint.rb
60
+ - tests/test_ship_builders.rb
61
+ - tests/test_interactions.rb
62
+ - tests/test_ship_chooser.rb
63
+ - tests/test_uss-enterprise.rb
@@ -1,18 +0,0 @@
1
- ship = <<HEREDOC
2
- __
3
- _.-~` `~-.
4
- _.--~~~---,.__ _.,;; . -=(@'`\\
5
- .-` ``~~~~--~~` ';;; ____)
6
- _.' '. ';;;;; '`_.'
7
- .-~;` `\\ ' ';;;;;__.~`
8
- .' .' `'. | / /;''
9
- \\/ .---'''``) /'-._____.--'\\ \\
10
- _/| (` / /` `\\ \\__
11
- ', `/- \\ \\ __/ (_ /-\\-\\-`
12
- `;'-..___) | `/-\\-\\-`
13
- `-. .'
14
- `~~~~``
15
- HEREDOC
16
-
17
-
18
- puts ship