stable 1.18.2 → 1.19.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/lib/stable/version.rb +1 -1
- data/lib/stable.rb +2 -1
- data/lib/tasks/stable.rake +149 -0
- 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: 9c37e32ad41c2706a5759ea8c71dbaa01fdbca65a68c21a0ba4f7854d6e31536
|
4
|
+
data.tar.gz: 3f0dc4afac0758033537dbe4b3c7d30900135cf559c89a6a43648c4f4007d79c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c7834e8ea59b1c8d9d5ef50cd0540d58fdf646009c8c5320b562637a95a032dbafe7b92e31adf0d61c1f87e253b09352eab3ac6bf2bfb6617860c36de334d96
|
7
|
+
data.tar.gz: 7fb53c7055b9d1a5fb285f94aa757c91009943d1875eb183bea7a228264fa17ad0cb0147419fa57af4282b00ddc320a14bccafdcff646c3576fc204003ffd5d2
|
data/lib/stable/version.rb
CHANGED
data/lib/stable.rb
CHANGED
@@ -4,7 +4,8 @@ require_relative 'stable/version'
|
|
4
4
|
require_relative 'stable/fact'
|
5
5
|
require_relative 'stable/configuration'
|
6
6
|
|
7
|
-
if defined?(Rake)
|
7
|
+
if defined?(Rake) && !defined?(STABLE_RAKE_LOADED)
|
8
|
+
STABLE_RAKE_LOADED = true
|
8
9
|
load File.expand_path('../tasks/stable.rake', __FILE__)
|
9
10
|
end
|
10
11
|
|
@@ -0,0 +1,149 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require_relative '../stable'
|
3
|
+
require_relative '../stable/formatters/verbose'
|
4
|
+
|
5
|
+
namespace :stable do
|
6
|
+
desc "run the example verification"
|
7
|
+
task :example, [:filter] do |t, args|
|
8
|
+
require_relative '../../lib/example/calculator'
|
9
|
+
require_relative '../../lib/example/kw_calculator'
|
10
|
+
require_relative '../../lib/example/class_methods'
|
11
|
+
|
12
|
+
fact_path = File.expand_path('../../../facts/calculator.fact.example', __FILE__)
|
13
|
+
Stable.configure do |config|
|
14
|
+
config.storage_path = fact_path
|
15
|
+
end
|
16
|
+
|
17
|
+
facts = []
|
18
|
+
File.foreach(Stable.configuration.storage_path) do |line|
|
19
|
+
facts << Stable::Fact.from_jsonl(line)
|
20
|
+
end
|
21
|
+
|
22
|
+
formatter = Stable.configuration.formatter.new
|
23
|
+
puts formatter.header
|
24
|
+
|
25
|
+
_filter_facts(facts, args[:filter].to_s.strip.downcase).each do |fact|
|
26
|
+
fact.run!
|
27
|
+
puts formatter.to_s(fact)
|
28
|
+
end
|
29
|
+
|
30
|
+
puts formatter.summary
|
31
|
+
end
|
32
|
+
|
33
|
+
desc "verify facts"
|
34
|
+
task :verify, [:filter] do |t, args|
|
35
|
+
facts = _load_facts(args[:filter])
|
36
|
+
|
37
|
+
formatter = Stable.configuration.formatter.new
|
38
|
+
|
39
|
+
if facts.empty?
|
40
|
+
puts "no stable facts found"
|
41
|
+
puts formatter.summary
|
42
|
+
else
|
43
|
+
puts formatter.header
|
44
|
+
|
45
|
+
facts.each do |fact|
|
46
|
+
fact.run!
|
47
|
+
puts formatter.to_s(fact)
|
48
|
+
end
|
49
|
+
|
50
|
+
puts formatter.summary
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
desc "delete all stable fact files"
|
55
|
+
task :clear do
|
56
|
+
fact_files = Dir.glob(Stable.configuration.fact_paths)
|
57
|
+
if fact_files.empty?
|
58
|
+
puts "no stable facts found to clear"
|
59
|
+
else
|
60
|
+
puts "found the following fact files:"
|
61
|
+
fact_files.each { |f| puts "- #{f}" }
|
62
|
+
print "are you sure you want to delete them? type 'DELETE FACTS' to confirm: "
|
63
|
+
answer = STDIN.gets.chomp
|
64
|
+
if answer == 'DELETE FACTS'
|
65
|
+
fact_files.each { |f| File.delete(f) }
|
66
|
+
puts "deleted #{fact_files.count} fact file(s)."
|
67
|
+
else
|
68
|
+
puts "aborted."
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
desc "start an interactive console with all facts loaded"
|
74
|
+
task :console do
|
75
|
+
require 'irb'
|
76
|
+
|
77
|
+
def facts
|
78
|
+
@facts ||= _load_facts
|
79
|
+
end
|
80
|
+
|
81
|
+
puts "loaded #{facts.count} facts into the `facts` method"
|
82
|
+
binding.irb
|
83
|
+
end
|
84
|
+
|
85
|
+
desc "interactively update failing facts"
|
86
|
+
task :update, [:filter] do |t, args|
|
87
|
+
facts = _load_facts(args[:filter])
|
88
|
+
|
89
|
+
formatter = Stable.configuration.formatter.new
|
90
|
+
|
91
|
+
if facts.empty?
|
92
|
+
puts "no stable facts found"
|
93
|
+
puts formatter.summary
|
94
|
+
else
|
95
|
+
puts formatter.header
|
96
|
+
|
97
|
+
updated_facts = []
|
98
|
+
_filter_facts(facts, _clean_filter(args[:filter])).each do |fact|
|
99
|
+
fact.run!
|
100
|
+
if fact.status == :failed
|
101
|
+
puts formatter.to_s(fact)
|
102
|
+
print " update this fact? (y/n): "
|
103
|
+
answer = STDIN.gets
|
104
|
+
if answer && answer.chomp.downcase == 'y'
|
105
|
+
fact.update!
|
106
|
+
updated_facts << fact
|
107
|
+
puts " updated."
|
108
|
+
else
|
109
|
+
puts " skipped."
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
if updated_facts.any?
|
115
|
+
fact_files.each do |file|
|
116
|
+
File.open(file, 'w') do |f|
|
117
|
+
facts.each do |fact|
|
118
|
+
f.puts fact.to_jsonl if fact.source_file == file
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
puts "\n#{updated_facts.count} fact(s) updated."
|
123
|
+
else
|
124
|
+
puts "\nno facts updated."
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
def _load_facts(filter = nil)
|
130
|
+
_filter_facts(
|
131
|
+
Dir
|
132
|
+
.glob(Stable.configuration.fact_paths)
|
133
|
+
.flat_map do |file|
|
134
|
+
File.foreach(file).map { |line| Stable::Fact.from_jsonl(line, file) }
|
135
|
+
end,
|
136
|
+
filter.to_s.strip.downcase
|
137
|
+
)
|
138
|
+
|
139
|
+
end
|
140
|
+
|
141
|
+
def _filter_facts(facts, filter)
|
142
|
+
return facts if filter.empty?
|
143
|
+
facts.select do |fact|
|
144
|
+
fact.uuid.include?(filter) ||
|
145
|
+
fact.class_name.downcase.include?(filter) ||
|
146
|
+
fact.name.downcase.include?(filter)
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.19.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeff Lunt
|
@@ -38,6 +38,7 @@ files:
|
|
38
38
|
- lib/stable/formatters/colors.rb
|
39
39
|
- lib/stable/formatters/verbose.rb
|
40
40
|
- lib/stable/version.rb
|
41
|
+
- lib/tasks/stable.rake
|
41
42
|
homepage: https://github.com/jefflunt/stable
|
42
43
|
licenses:
|
43
44
|
- MIT
|