uss-enterprise 0.0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/bin/enterprise +3 -0
- data/lib/enterprise/blueprint.rb +66 -0
- data/lib/enterprise/interactions.rb +93 -0
- data/lib/enterprise/schematics.rb +144 -0
- data/lib/enterprise/ship_builders.rb +48 -0
- data/lib/enterprise/ship_chooser.rb +35 -0
- data/lib/enterprise.rb +41 -0
- data/lib/test.rb +14 -0
- data/readme.md +1 -0
- metadata +54 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0fb7f2971ebb17b739504d6e6a7b75c5730d583e
|
4
|
+
data.tar.gz: 5107afb2df7acc9d266c0b80a5561ce5ce36938f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 164677b8e437ca9ec1cd5c63f34e2c35bfd608103de74123b3b460b17c6915409745eeff1b83cbecc629254fcb363a79734d15bff72d538355232dd61334f494
|
7
|
+
data.tar.gz: fd992de5bd9defefa0e2adfe9a24514344170da9d85527ce5f488175f4deb467bb2680b7fc0d34d493402e97f9be7b3dd557af467d0bcb4d2b8bec481351a922
|
data/bin/enterprise
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
require_relative 'schematics.rb'
|
2
|
+
|
3
|
+
module Blueprints
|
4
|
+
|
5
|
+
class Blueprints
|
6
|
+
include ShipSchematics
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
@schematics = Schematics.new
|
10
|
+
@blueprints = Hash.new
|
11
|
+
# Haven't decided if the parent object should have *all* the schematics, or none...
|
12
|
+
# @blueprints = {
|
13
|
+
# 'Sloop' => @schematics.sloop,
|
14
|
+
# 'Carrier' => @schematics.carrier,
|
15
|
+
# 'Spaceshuttle' => @schematics.spaceshuttle,
|
16
|
+
# 'NX' => @schematics.ss_nx,
|
17
|
+
# 'Constitution' => @schematics.ss_constitution,
|
18
|
+
# 'Constitution - refit' => @schematics.ss_const_refit,
|
19
|
+
# 'Excelsior' => @schematics.ss_excelsior,
|
20
|
+
# 'Ambassador' => @schematics.ss_ambassador,
|
21
|
+
# 'Galaxy' => @schematics.ss_galaxy,
|
22
|
+
# 'Sovereign' => @schematics.ss_sovereign
|
23
|
+
# }
|
24
|
+
end
|
25
|
+
|
26
|
+
def gimme
|
27
|
+
@blueprints
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
class SeaShipBlueprints < Blueprints
|
32
|
+
def initialize
|
33
|
+
super
|
34
|
+
@blueprints = {
|
35
|
+
'Sloop' => @schematics.sloop,
|
36
|
+
'Carrier' => @schematics.carrier
|
37
|
+
}
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
class OrbitalShipBlueprints < Blueprints
|
42
|
+
def initialize
|
43
|
+
shuttle =
|
44
|
+
super
|
45
|
+
@blueprints = {
|
46
|
+
'Spaceshuttle' => @schematics.spaceshuttle
|
47
|
+
}
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
class StarShipBlueprints < Blueprints
|
52
|
+
def initialize
|
53
|
+
super
|
54
|
+
@blueprints = {
|
55
|
+
'NX' => @schematics.ss_nx,
|
56
|
+
'Constitution' => @schematics.ss_constitution,
|
57
|
+
'Constitution - refit' => @schematics.ss_const_refit,
|
58
|
+
'Excelsior' => @schematics.ss_excelsior,
|
59
|
+
'Ambassador' => @schematics.ss_ambassador,
|
60
|
+
'Galaxy' => @schematics.ss_galaxy,
|
61
|
+
'Sovereign' => @schematics.ss_sovereign
|
62
|
+
}
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
module UserInput
|
2
|
+
|
3
|
+
def prompt
|
4
|
+
print "> "
|
5
|
+
response = $stdin.gets.chomp
|
6
|
+
return response
|
7
|
+
end
|
8
|
+
|
9
|
+
def define_cli_flags
|
10
|
+
@flags = {
|
11
|
+
'-c' => "ship class",
|
12
|
+
'-g' => "ship group (starship, seaship, orbitalship)",
|
13
|
+
'-C' => "captain",
|
14
|
+
'-i' => "interactive",
|
15
|
+
'-r' => "random",
|
16
|
+
'-n' => "number (of ships)",
|
17
|
+
'-l' => "letter"
|
18
|
+
}
|
19
|
+
@flags
|
20
|
+
end
|
21
|
+
|
22
|
+
def define_class_to_group
|
23
|
+
@class_to_group = {
|
24
|
+
'sovereign' => 'StarShip',
|
25
|
+
'galaxy' => 'StarShip',
|
26
|
+
'ambassador' => 'StarShip',
|
27
|
+
'excelsior' => 'StarShip',
|
28
|
+
'constitution' => 'StarShip',
|
29
|
+
'constitution - refit' => 'StarShip',
|
30
|
+
'nx' => 'StarShip',
|
31
|
+
'spaceshuttle' => 'OrbitalShip',
|
32
|
+
'carrier' => 'SeaShip',
|
33
|
+
'sloop' => 'SeaShip'
|
34
|
+
}
|
35
|
+
@class_to_group
|
36
|
+
end
|
37
|
+
|
38
|
+
def look_up_class_group(s_class)
|
39
|
+
s_class = s_class.downcase
|
40
|
+
group = @class_to_group[s_class]
|
41
|
+
return group
|
42
|
+
end
|
43
|
+
|
44
|
+
def define_groups
|
45
|
+
@groups = {
|
46
|
+
'star' => 'StarShip',
|
47
|
+
'sea' => 'SeaShip',
|
48
|
+
'orbital' => 'OrbitalShip'
|
49
|
+
}
|
50
|
+
@groups
|
51
|
+
end
|
52
|
+
|
53
|
+
def classes
|
54
|
+
@classes = {
|
55
|
+
|
56
|
+
}
|
57
|
+
end
|
58
|
+
|
59
|
+
def define_letter_to_class
|
60
|
+
@letter_to_class = {
|
61
|
+
'rev' => 'Sloop',
|
62
|
+
'cvn' => 'Carrier',
|
63
|
+
'ov' => 'Spaceshuttle',
|
64
|
+
'nx' => 'NX',
|
65
|
+
'none' => 'Constitution',
|
66
|
+
'a' => 'Constitution - refit',
|
67
|
+
'b' => 'Excelsior',
|
68
|
+
'c' => 'Ambassador',
|
69
|
+
'd' => 'Galaxy',
|
70
|
+
'e' => 'Sovereign'
|
71
|
+
}
|
72
|
+
@letter_to_class
|
73
|
+
end
|
74
|
+
|
75
|
+
def look_up_letter_class(letter)
|
76
|
+
s_class = @letter_to_class[letter]
|
77
|
+
return s_class
|
78
|
+
end
|
79
|
+
|
80
|
+
def print_options(options)
|
81
|
+
# handle arrays and hashes as input
|
82
|
+
# call .each_with_index and output the options
|
83
|
+
end
|
84
|
+
|
85
|
+
def l_flag
|
86
|
+
index_of_requested_letter = @params.find_index('-l') + 1
|
87
|
+
ship_letter = @params[index_of_requested_letter]
|
88
|
+
ship_class = look_up_letter_class(ship_letter)
|
89
|
+
ship_group = look_up_class_group(ship_class)
|
90
|
+
self.build_ship(ship_group, ship_class)
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|
@@ -0,0 +1,144 @@
|
|
1
|
+
module ShipSchematics
|
2
|
+
|
3
|
+
class Schematics
|
4
|
+
attr_reader :sloop, :carrier, :spaceshuttle, :ss_nx, :ss_constitution, :ss_const_refit, :ss_excelsior, :ss_ambassador, :ss_galaxy, :ss_sovereign
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
@sloop = """
|
8
|
+
| | |
|
9
|
+
)_) )_) )_)
|
10
|
+
)___))___))___)\\
|
11
|
+
)____)____)_____)\\
|
12
|
+
_____|____|____|____\\\__
|
13
|
+
---------\\ /---------
|
14
|
+
^^^^^ ^^^^^^^^^^^^^^^^^^^^^
|
15
|
+
^^^^ ^^^^ ^^^ ^^
|
16
|
+
^^^^ ^^^
|
17
|
+
"""
|
18
|
+
|
19
|
+
@carrier = """
|
20
|
+
|
|
21
|
+
-+-
|
22
|
+
---#---
|
23
|
+
__|_|__ __
|
24
|
+
\\_____/ ||\\________
|
25
|
+
__ __ __ \\_____/ ^---------^
|
26
|
+
||\\__||\\__||\\__|___ | '-O-`
|
27
|
+
-^---------^--^----^___.-------------.___.--------.___.------
|
28
|
+
`-------------|-------------------------------|-------------'
|
29
|
+
\\___ | \\ o O o / | ___/
|
30
|
+
\\____/ \\ / \\____/
|
31
|
+
| \\ / |
|
32
|
+
| \\|/ |
|
33
|
+
| | |
|
34
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
35
|
+
"""
|
36
|
+
|
37
|
+
@spaceshuttle = """
|
38
|
+
_________
|
39
|
+
(=========)
|
40
|
+
|=========|
|
41
|
+
|====_====|
|
42
|
+
|== / \\ ==|
|
43
|
+
|= / _ \\ =|
|
44
|
+
_ |=| ( ) |=|
|
45
|
+
/=\\ |=| |=| /=\\
|
46
|
+
|=| |=| USA |=| |=|
|
47
|
+
|=| |=| _ |=| |=|
|
48
|
+
|=| |=| | | |=| |=|
|
49
|
+
|=| |=| | | |=| |=|
|
50
|
+
|=| |=| | | |=| |=|
|
51
|
+
|=| |/ | | \\| |=|
|
52
|
+
|=|/ | | \\|=|
|
53
|
+
|=/NASA |_| NASA\\=|
|
54
|
+
|(_______________)|
|
55
|
+
|=| |_|__|__|_| |=|
|
56
|
+
|=| ( ) ( ) |=|
|
57
|
+
/===\\ /===\\
|
58
|
+
||||||| |||||||
|
59
|
+
------- -------
|
60
|
+
(~~~) (~~~)
|
61
|
+
"""
|
62
|
+
@ss_nx = <<HEREDOC
|
63
|
+
___
|
64
|
+
,.-"---------''''''''''''''| : `. __
|
65
|
+
\() (===== ====== ======) |-+-- ) __.--'--`.___
|
66
|
+
`.---------..............|_:_.' ___...---'''____.....----:::--.._
|
67
|
+
`. + \\ __o./ __..--''' """ ''-.
|
68
|
+
`._+_\\_..--'' -----='----+-------------------------+---`--.
|
69
|
+
<___ `______________|_____\__'''''''""'''''''';...----'''''`
|
70
|
+
"" `" '--.__ __ __.--''
|
71
|
+
`--'
|
72
|
+
HEREDOC
|
73
|
+
@ss_constitution = """
|
74
|
+
_ ___________________________=====____
|
75
|
+
__--__ / || =<==== NCC-1701 ======= /
|
76
|
+
___________---______---___________ \\_||__________________________________/
|
77
|
+
\\________________________________/ | |
|
78
|
+
\\______/ \\__ .. : \\ | |
|
79
|
+
`--' \\_ : \\ | |
|
80
|
+
__-`------`-----____| |
|
81
|
+
\\ |||_ .::. : |_|--_
|
82
|
+
-)=|__ =<=======-- :. |_\\
|
83
|
+
/ ||| __________---'
|
84
|
+
------------
|
85
|
+
"""
|
86
|
+
|
87
|
+
@ss_const_refit = """
|
88
|
+
___________________ _-_
|
89
|
+
\\__(==========/_=_/ ____.---'---`---.____
|
90
|
+
\\_ \\ \\----._________.----/
|
91
|
+
\\ \\ / / `-_-'
|
92
|
+
__,--`.`-'..'-_
|
93
|
+
/____ ||
|
94
|
+
`--.____,-'
|
95
|
+
"""
|
96
|
+
|
97
|
+
@ss_excelsior = """
|
98
|
+
.-----.__________________________.------. ___.--.__________.--._
|
99
|
+
========================================= `\\_ ____.------'-----`-----.____
|
100
|
+
`------------------------._____.--------' [================================
|
101
|
+
_____ _.-| |---.__ |=========| `-----'
|
102
|
+
.-||| `--'---|___|------`--------'----------|
|
103
|
+
'--------------------._ ------==== O> /
|
104
|
+
`-. /
|
105
|
+
\\ __.-'
|
106
|
+
\\____.-----'
|
107
|
+
"""
|
108
|
+
|
109
|
+
@ss_ambassador = """
|
110
|
+
________
|
111
|
+
___---'--------`--..____
|
112
|
+
,-------------------.============================
|
113
|
+
(__________________<|_) `--.._______..--'
|
114
|
+
| | ___,--' - _ /
|
115
|
+
,--' `--' |
|
116
|
+
~~~~~~~`-._ |
|
117
|
+
`-.______,-'
|
118
|
+
"""
|
119
|
+
|
120
|
+
@ss_galaxy = """
|
121
|
+
____
|
122
|
+
__...---~' `~~~----...__
|
123
|
+
_===============================
|
124
|
+
,----------------._/' `---..._______...---'
|
125
|
+
(_______________||_) . . ,--'
|
126
|
+
/ /.---' `/
|
127
|
+
'--------_- - - - - _/
|
128
|
+
`--------'
|
129
|
+
"""
|
130
|
+
|
131
|
+
@ss_sovereign = """
|
132
|
+
_____________________________,----,__
|
133
|
+
|==============================<| /___\\ ____,-------------.____
|
134
|
+
`------------------.-----.---.___.--' __.--'-----------------------`--.__
|
135
|
+
`._ `. =============================================
|
136
|
+
____`.___`._____,----' `--------,----------------'
|
137
|
+
/_|___________-----< ========,'
|
138
|
+
`-. ,'
|
139
|
+
`----.______,--'
|
140
|
+
|
141
|
+
"""
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require_relative 'blueprint.rb'
|
2
|
+
|
3
|
+
class ShipBuilder
|
4
|
+
include Blueprints
|
5
|
+
|
6
|
+
attr_reader :available_blueprints
|
7
|
+
|
8
|
+
def initialize(type = nil)
|
9
|
+
case type
|
10
|
+
when nil
|
11
|
+
@available_blueprints = Blueprints.new.gimme
|
12
|
+
when 'SeaShip'
|
13
|
+
@available_blueprints = SeaShipBlueprints.new.gimme
|
14
|
+
when 'OrbitalShip'
|
15
|
+
@available_blueprints = OrbitalShipBlueprints.new.gimme
|
16
|
+
when 'StarShip'
|
17
|
+
@available_blueprints = StarShipBlueprints.new.gimme
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def define_blueprint(type)
|
22
|
+
@blueprint = @available_blueprints[type]
|
23
|
+
end
|
24
|
+
|
25
|
+
def build_it
|
26
|
+
puts @blueprint
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
class SeaShipBuilder < ShipBuilder
|
31
|
+
|
32
|
+
## TODO: This... there has to be a better way to go super without overwriting what I need. Problem is, I need to run line 1 here, then line 2 in super... what about `yield`?
|
33
|
+
def initialize
|
34
|
+
super('SeaShip')
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
class OrbitalShipBuilder < ShipBuilder
|
39
|
+
def initialize
|
40
|
+
super('OrbitalShip')
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
class StarShipBuilder < ShipBuilder
|
45
|
+
def initialize
|
46
|
+
super('StarShip')
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require_relative 'ship_builders.rb'
|
2
|
+
|
3
|
+
class ShipChooser
|
4
|
+
def initialize
|
5
|
+
@ship_group_options = {
|
6
|
+
'StarShip' => StarShipBuilder.new,
|
7
|
+
'SeaShip' => SeaShipBuilder.new,
|
8
|
+
'OrbitalShip' => OrbitalShipBuilder.new
|
9
|
+
}
|
10
|
+
end
|
11
|
+
|
12
|
+
def choose_ship_group(request)
|
13
|
+
if request == 'random'
|
14
|
+
group = @ship_group_options.keys.sample
|
15
|
+
else
|
16
|
+
group = request
|
17
|
+
end
|
18
|
+
|
19
|
+
@ship_builder = @ship_group_options[group]
|
20
|
+
end
|
21
|
+
|
22
|
+
def choose_ship_class(request)
|
23
|
+
if request == 'random'
|
24
|
+
# chooses a random key from the available blueprints
|
25
|
+
@ship_class = @ship_builder.available_blueprints.keys.sample
|
26
|
+
else
|
27
|
+
@ship_class = request
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def commission_construction
|
32
|
+
@ship_builder.define_blueprint(@ship_class)
|
33
|
+
@ship_builder.build_it
|
34
|
+
end
|
35
|
+
end
|
data/lib/enterprise.rb
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
require_relative 'enterprise/interactions.rb'
|
2
|
+
require_relative 'enterprise/ship_chooser.rb'
|
3
|
+
|
4
|
+
|
5
|
+
class Runner
|
6
|
+
include UserInput
|
7
|
+
|
8
|
+
def initialize(params = nil)
|
9
|
+
@params = params
|
10
|
+
@flags = self.define_cli_flags
|
11
|
+
@letter_to_class = self.define_letter_to_class
|
12
|
+
@class_to_group = self.define_class_to_group
|
13
|
+
end
|
14
|
+
|
15
|
+
def build_ship(s_group, s_class)
|
16
|
+
ship = ShipChooser.new
|
17
|
+
ship.choose_ship_group(s_group)
|
18
|
+
ship.choose_ship_class(s_class)
|
19
|
+
ship.commission_construction
|
20
|
+
end
|
21
|
+
|
22
|
+
def handle_args
|
23
|
+
if @params.length == 0
|
24
|
+
self.build_ship('random', 'random')
|
25
|
+
elsif @params.include? '-l'
|
26
|
+
self.l_flag
|
27
|
+
else
|
28
|
+
self.gently_correct_usage
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def gently_correct_usage
|
33
|
+
puts "uh oh"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# runner = Runner.new(ARGV)
|
38
|
+
# runner.check_for_args
|
39
|
+
|
40
|
+
make = Runner.new(ARGV)
|
41
|
+
make.handle_args
|
data/lib/test.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
ship = <<HEREDOC
|
2
|
+
___
|
3
|
+
,.-"---------''''''''''''''| : `. __
|
4
|
+
\() (===== ====== ======) |-+-- ) __.--'--`.___
|
5
|
+
`.---------..............|_:_.' ___...---'''____.....----:::--.._
|
6
|
+
`. + \\ __o./ __..--''' """ ''-.
|
7
|
+
`._+_\\_..--'' -----='----+-------------------------+---`--.
|
8
|
+
<___ `______________|_____\__'''''''""'''''''';...----'''''`
|
9
|
+
"" `" '--.__ __ __.--''
|
10
|
+
`--'
|
11
|
+
HEREDOC
|
12
|
+
|
13
|
+
|
14
|
+
puts ship
|
data/readme.md
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
Sources for ASCII art: https://startrekasciiart.blogspot.co.uk
|
metadata
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: uss-enterprise
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2.3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Sean DMR
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-02-03 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Outputs ASCII art of different Enterprises
|
14
|
+
email:
|
15
|
+
- sn@grz.li
|
16
|
+
executables:
|
17
|
+
- enterprise
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- bin/enterprise
|
22
|
+
- lib/enterprise.rb
|
23
|
+
- lib/enterprise/blueprint.rb
|
24
|
+
- lib/enterprise/interactions.rb
|
25
|
+
- lib/enterprise/schematics.rb
|
26
|
+
- lib/enterprise/ship_builders.rb
|
27
|
+
- lib/enterprise/ship_chooser.rb
|
28
|
+
- lib/test.rb
|
29
|
+
- readme.md
|
30
|
+
homepage: https://github.com/flyinggrizzly/enterprise
|
31
|
+
licenses:
|
32
|
+
- GPL-3.0
|
33
|
+
metadata: {}
|
34
|
+
post_install_message:
|
35
|
+
rdoc_options: []
|
36
|
+
require_paths:
|
37
|
+
- lib
|
38
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0'
|
43
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
requirements: []
|
49
|
+
rubyforge_project:
|
50
|
+
rubygems_version: 2.6.8
|
51
|
+
signing_key:
|
52
|
+
specification_version: 4
|
53
|
+
summary: Outputs ASCII art of different Enterprises
|
54
|
+
test_files: []
|