flex-station-data 1.0.0 → 1.0.1
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 +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +1 -1
- data/bin/flex-station +32 -11
- data/bin/flex-station-linear-regression +4 -3
- data/lib/flex_station_data/concerns/callable.rb +33 -0
- data/lib/flex_station_data/concerns/presenter.rb +2 -18
- data/lib/flex_station_data/concerns/service.rb +2 -18
- data/lib/flex_station_data/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1763fb10b625dcca4d933df8282802bc385298724270981ce178cd8bc8ff61f5
|
4
|
+
data.tar.gz: 27a12f5bbe2ecedc562b8c710b2211a74ab02c7b5fb4e02a9c7be3017df647bd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e4a73af64d380f23083a029a87592074f99fdc88b83235111815687915423fccd05949a8354d13ed6ad546f60f22aa96a1cd68771ab564e1930889c9cd0c0c9c
|
7
|
+
data.tar.gz: c508621a8a1b89770dac4fdf2b5ab2bb897020f4c25128b3b721433a667a21acc24750627a5acefc48a09900ba13282808e396310e0dfb36c1a090e962ba500c
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/bin/flex-station
CHANGED
@@ -1,16 +1,37 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
require "pathname"
|
4
|
+
require "flex_station_data/concerns/callable"
|
4
5
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
6
|
+
class App
|
7
|
+
include FlexStationData::Concerns::Callable[:run]
|
8
|
+
|
9
|
+
attr_reader :command, :args
|
10
|
+
|
11
|
+
def initialize(command = "help", *args)
|
12
|
+
@command = command
|
13
|
+
@args = args
|
14
|
+
end
|
15
|
+
|
16
|
+
def dir_path
|
17
|
+
Pathname(__dir__)
|
18
|
+
end
|
19
|
+
|
20
|
+
def linear_regression_path
|
21
|
+
dir_path.join("flex-station-linear-regression")
|
22
|
+
end
|
23
|
+
|
24
|
+
def run
|
25
|
+
case command
|
26
|
+
when "linear-regression"
|
27
|
+
exec(linear_regression_path.to_path, *args)
|
28
|
+
when "help", "--help"
|
29
|
+
puts "USAGE: flex-station <command>"
|
30
|
+
else
|
31
|
+
$stderr.puts "Unrecognised command: #{command}"
|
32
|
+
exit(1)
|
33
|
+
end
|
34
|
+
end
|
16
35
|
end
|
36
|
+
|
37
|
+
App.run(*ARGV)
|
@@ -1,11 +1,12 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
+
require "flex_station_data/concerns/callable"
|
3
4
|
require "flex_station_data/services/load_plates"
|
4
5
|
require "flex_station_data/presenters/plates_hash"
|
5
6
|
|
6
7
|
module FlexStationData
|
7
8
|
class LinearRegressionApp
|
8
|
-
include Concerns::
|
9
|
+
include Concerns::Callable[:run]
|
9
10
|
|
10
11
|
OPTION_RE = /\A--(\w+(?:-\w+)*)(?:=(.*))?\z/.freeze
|
11
12
|
|
@@ -78,7 +79,7 @@ module FlexStationData
|
|
78
79
|
[ hash.keys, *hash.values.transpose ]
|
79
80
|
end
|
80
81
|
|
81
|
-
def
|
82
|
+
def run
|
82
83
|
CSV do |out|
|
83
84
|
csv.each do |row|
|
84
85
|
out << row
|
@@ -88,4 +89,4 @@ module FlexStationData
|
|
88
89
|
end
|
89
90
|
end
|
90
91
|
|
91
|
-
FlexStationData::LinearRegressionApp.
|
92
|
+
FlexStationData::LinearRegressionApp.run(*ARGV)
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module FlexStationData
|
2
|
+
module Concerns
|
3
|
+
module Callable
|
4
|
+
class << self
|
5
|
+
def [](verb)
|
6
|
+
@@__callable_modules[verb] ||= Module.new.tap { |mod| __make_callable(mod, verb) }
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def __make_callable(mod, verb)
|
12
|
+
class_methods = Module.new do
|
13
|
+
define_method verb do |*args, &block|
|
14
|
+
new(*args).send(verb, &block)
|
15
|
+
end
|
16
|
+
|
17
|
+
define_method :to_proc do
|
18
|
+
Proc.new(&method(verb))
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
mod.singleton_class.define_method :included do |base|
|
23
|
+
base.extend class_methods
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
__make_callable(self, :call)
|
29
|
+
|
30
|
+
@@__callable_modules = { call: self }
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -1,23 +1,7 @@
|
|
1
|
-
|
1
|
+
require_relative "callable"
|
2
2
|
|
3
3
|
module FlexStationData
|
4
4
|
module Concerns
|
5
|
-
|
6
|
-
extend ActiveSupport::Concern
|
7
|
-
|
8
|
-
def to_proc
|
9
|
-
Proc.new(&method(:present))
|
10
|
-
end
|
11
|
-
|
12
|
-
class_methods do
|
13
|
-
def present(*args, &block)
|
14
|
-
new(*args).present(&block)
|
15
|
-
end
|
16
|
-
|
17
|
-
def to_proc
|
18
|
-
Proc.new(&method(:present))
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
5
|
+
Presenter = Callable[:present]
|
22
6
|
end
|
23
7
|
end
|
@@ -1,23 +1,7 @@
|
|
1
|
-
|
1
|
+
require_relative "callable"
|
2
2
|
|
3
3
|
module FlexStationData
|
4
4
|
module Concerns
|
5
|
-
|
6
|
-
extend ActiveSupport::Concern
|
7
|
-
|
8
|
-
def to_proc
|
9
|
-
Proc.new(&method(:call))
|
10
|
-
end
|
11
|
-
|
12
|
-
class_methods do
|
13
|
-
def call(*args, &block)
|
14
|
-
new(*args).call(&block)
|
15
|
-
end
|
16
|
-
|
17
|
-
def to_proc
|
18
|
-
Proc.new(&method(:call))
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
5
|
+
Service = Callable
|
22
6
|
end
|
23
7
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flex-station-data
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Carney
|
@@ -117,6 +117,7 @@ files:
|
|
117
117
|
- bin/flex-station-linear-regression
|
118
118
|
- flex-station-data.gemspec
|
119
119
|
- lib/flex_station_data.rb
|
120
|
+
- lib/flex_station_data/concerns/callable.rb
|
120
121
|
- lib/flex_station_data/concerns/presenter.rb
|
121
122
|
- lib/flex_station_data/concerns/service.rb
|
122
123
|
- lib/flex_station_data/default_sample_map.rb
|