space_station 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 55f0e00e14ddfe756805d903dfb32e7ced4a410c
4
- data.tar.gz: 850cf4305a58aecb63371bf21f01e6ae2d0dcc8f
3
+ metadata.gz: d905781df0dcd51970885bb4bbd620325372cd63
4
+ data.tar.gz: 5c2fcd742c5ba382ed6e7bb89cb2643aa4596847
5
5
  SHA512:
6
- metadata.gz: 92b19e16638189442ccadb4c33836f1d5e0e0c568cd502c8e8eaaf63eab617c05431d46127bd28a74871712c9afda48000cad3e628069ef869c49172c67bebcd
7
- data.tar.gz: 1beed2cad32fea0fb40e4171385f9d101cc1a6734525600815b22402c8bdbc0cf891b09faa0932eb57e49cc2c0432075ef4de612e56d92818d318797fa20085b
6
+ metadata.gz: 53151669ac8013c4fe6c828fe42736da7b4afe4287743007197b13922b7d6c77c122dfd0a2c0bd308a13ae8594a31398e3dcb7381a020cd173428b7ab0321969
7
+ data.tar.gz: 0f86b5843924a077fcaafbb08819e8f5cf6690a2be9a7ea45d9600fe3d86b65ebf7703bd2d74aa92b97a99c2eee644cd951aba4048241c3e4d94fb6a0a737d85
data/lib/space_station.rb CHANGED
@@ -1,30 +1,42 @@
1
1
  require "space_station/version"
2
2
 
3
3
  module SpaceStation
4
- class SpaceStation
5
- ASCII_PATH = File.join(File.dirname(__FILE__), '/space_station/ascii/')
4
+ ASCII_PATH = File.join(File.dirname(__FILE__), '/space_station/ascii').freeze
6
5
 
7
- def initialize(app)
8
- @app = app
6
+ class Station
7
+ def initialize(app, options = {})
8
+ @app = app
9
+ @ascii_art =
10
+ self.class.name.split('::').last.gsub(/([a-z\d])([A-Z])/,'\1_\2').downcase
11
+ @msg = options.fetch(:msg, nil)
9
12
  end
10
13
 
11
14
  def call(env)
12
- write_before_response
15
+ to_write = @msg || IO.read("#{SpaceStation::ASCII_PATH}/#{@ascii_art}") rescue ''
16
+ log_before_response(to_write)
13
17
 
14
18
  @app.call(env)
15
19
  end
16
20
 
17
- def write_before_response
18
- ""
21
+ protected
22
+
23
+ def log_before_response(to_write)
24
+ puts "*" * 69
25
+ puts self.class.name
26
+ puts "VS"
27
+ puts @ascii_art
28
+ puts to_write
29
+ # begin
30
+ # puts IO.read("#{SpaceStation::ASCII_PATH}/#{to_write}")
31
+ # rescue
32
+ # puts ''
33
+ # end
19
34
  end
20
35
  end
21
- end
22
36
 
23
- require 'space_station/space_shuttle'
24
- require 'space_station/f16'
25
- require 'space_station/airplane'
26
- require 'space_station/ufo'
27
- require 'space_station/apollo'
28
- require 'space_station/darth_vader'
29
- require 'space_station/middle_finger'
30
- require 'space_station/unicorn'
37
+ Dir.entries(ASCII_PATH).select { |f| !File.directory? f }.each do |ascii_file|
38
+ klass = Class.new(SpaceStation::Station)
39
+ klass_name = ascii_file.to_s.split('_').collect(&:capitalize).join
40
+ SpaceStation.const_set(klass_name, klass)
41
+ end
42
+ end
@@ -1,3 +1,3 @@
1
1
  module SpaceStation
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -6,12 +6,12 @@ require 'space_station/version'
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "space_station"
8
8
  spec.version = SpaceStation::VERSION
9
- spec.authors = ["aaooki"]
10
- spec.email = ["aaooki7@gmail.com"]
9
+ spec.authors = ["aaoiki"]
10
+ spec.email = ["aaoiki7@gmail.com"]
11
11
 
12
12
  spec.summary = %q{Transform your rack app into a space station!}
13
13
  spec.description = %q{A toy gem dedicated to clients and project managers who make silly and unrealistic requirements}
14
- spec.homepage = "https://github.com/aaooki/space_station"
14
+ spec.homepage = "https://github.com/aaoiki/space_station"
15
15
  spec.license = "MIT"
16
16
 
17
17
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: space_station
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
- - aaooki
7
+ - aaoiki
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-01-08 00:00:00.000000000 Z
11
+ date: 2017-06-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -55,7 +55,7 @@ dependencies:
55
55
  description: A toy gem dedicated to clients and project managers who make silly and
56
56
  unrealistic requirements
57
57
  email:
58
- - aaooki7@gmail.com
58
+ - aaoiki7@gmail.com
59
59
  executables: []
60
60
  extensions: []
61
61
  extra_rdoc_files: []
@@ -70,8 +70,6 @@ files:
70
70
  - bin/console
71
71
  - bin/setup
72
72
  - lib/space_station.rb
73
- - lib/space_station/airplane.rb
74
- - lib/space_station/apollo.rb
75
73
  - lib/space_station/ascii/airplane
76
74
  - lib/space_station/ascii/apollo
77
75
  - lib/space_station/ascii/darth_vader
@@ -80,16 +78,10 @@ files:
80
78
  - lib/space_station/ascii/space_shuttle
81
79
  - lib/space_station/ascii/ufo
82
80
  - lib/space_station/ascii/unicorn
83
- - lib/space_station/darth_vader.rb
84
- - lib/space_station/f16.rb
85
- - lib/space_station/middle_finger.rb
86
- - lib/space_station/space_shuttle.rb
87
- - lib/space_station/ufo.rb
88
- - lib/space_station/unicorn.rb
89
81
  - lib/space_station/version.rb
90
82
  - space_station.gemspec
91
83
  - ufo_example.png
92
- homepage: https://github.com/aaooki/space_station
84
+ homepage: https://github.com/aaoiki/space_station
93
85
  licenses:
94
86
  - MIT
95
87
  metadata: {}
@@ -109,7 +101,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
109
101
  version: '0'
110
102
  requirements: []
111
103
  rubyforge_project:
112
- rubygems_version: 2.5.1
104
+ rubygems_version: 2.6.11
113
105
  signing_key:
114
106
  specification_version: 4
115
107
  summary: Transform your rack app into a space station!
@@ -1,8 +0,0 @@
1
- module SpaceStation
2
- class Airplane < SpaceStation
3
- def write_before_response
4
- puts IO.read("#{ASCII_PATH}/airplane")
5
- end
6
- end
7
- end
8
-
@@ -1,8 +0,0 @@
1
- module SpaceStation
2
- class Apollo < SpaceStation
3
- def write_before_response
4
- puts IO.read("#{ASCII_PATH}/apollo")
5
- end
6
- end
7
- end
8
-
@@ -1,8 +0,0 @@
1
- module SpaceStation
2
- class DarthVader < SpaceStation
3
- def write_before_response
4
- puts IO.read("#{ASCII_PATH}/darth_vader")
5
- end
6
- end
7
- end
8
-
@@ -1,8 +0,0 @@
1
- module SpaceStation
2
- class F16 < SpaceStation
3
- def write_before_response
4
- puts IO.read("#{ASCII_PATH}/f16")
5
- end
6
- end
7
- end
8
-
@@ -1,8 +0,0 @@
1
- module SpaceStation
2
- class MiddleFinger < SpaceStation
3
- def write_before_response
4
- puts IO.read("#{ASCII_PATH}/middle_finger")
5
- end
6
- end
7
- end
8
-
@@ -1,7 +0,0 @@
1
- module SpaceStation
2
- class SpaceShuttle < SpaceStation
3
- def write_before_response
4
- puts IO.read("#{ASCII_PATH}/space_shuttle")
5
- end
6
- end
7
- end
@@ -1,9 +0,0 @@
1
- module SpaceStation
2
- class UFO < SpaceStation
3
- def write_before_response
4
- puts IO.read("#{ASCII_PATH}/ufo")
5
- end
6
- end
7
- end
8
-
9
-
@@ -1,8 +0,0 @@
1
- module SpaceStation
2
- class Unicorn < SpaceStation
3
- def write_before_response
4
- puts IO.read("#{ASCII_PATH}/unicorn")
5
- end
6
- end
7
- end
8
-