mps 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/Gemfile.lock +1 -1
- data/lib/mps/cli/commands/list.rb +9 -4
- data/lib/mps/cli/commands/stats.rb +16 -4
- data/lib/mps/cli/commands/tags.rb +35 -11
- data/lib/mps/cli/commands/update.rb +14 -11
- data/lib/mps/mps.rb +3 -1
- data/lib/mps/ref_resolver.rb +1 -0
- data/lib/mps/store.rb +1 -1
- data/lib/mps/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 96b0eac30435621ea7ca9d0575d3a3285a074cb2707d453075ced7e1535ca288
|
|
4
|
+
data.tar.gz: 647d49ad9cffd798858318dd712d4653df718e37d05a8f52803be367e423c17c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e1204e48c493e45f0dc226b1a7a4de0751b4821774ab5984c54f56cf53e91ac99cb09a17fb5cf777de0cf665ebefd69289913de935baf5655d3afd76f80da9bf
|
|
7
|
+
data.tar.gz: bbb938d0b337b652c07cca9983949a830c13fd9180ab037df87bd75feda68a6e11dfbc091689fa96546edc1e6f5f02e770b98a6d896c32b90de2b95b0fcaae00
|
data/Gemfile.lock
CHANGED
|
@@ -20,11 +20,16 @@ MPS::CLI::MPS.class_eval do
|
|
|
20
20
|
def list(datesign = "today")
|
|
21
21
|
init
|
|
22
22
|
begin
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
all_dates = store.all_files
|
|
24
|
+
.map { |f| Date.strptime(File.basename(f)[0, 8], "%Y%m%d") }
|
|
25
|
+
.uniq.sort
|
|
26
|
+
dates = if options[:all] && options[:since]
|
|
27
|
+
since_date = ::MPS.get_date(options[:since]).to_date
|
|
28
|
+
all_dates.select { |d| d >= since_date }
|
|
29
|
+
elsif options[:all]
|
|
30
|
+
all_dates
|
|
25
31
|
elsif options[:since]
|
|
26
|
-
|
|
27
|
-
date_range(options[:since], date)
|
|
32
|
+
date_range(options[:since], ::MPS.get_date(datesign))
|
|
28
33
|
else
|
|
29
34
|
[::MPS.get_date(datesign).to_date]
|
|
30
35
|
end
|
|
@@ -2,13 +2,25 @@
|
|
|
2
2
|
|
|
3
3
|
MPS::CLI::MPS.class_eval do
|
|
4
4
|
desc "stats [DATESIGN]", "Show element counts and log durations"
|
|
5
|
-
method_option :since,
|
|
6
|
-
|
|
5
|
+
method_option :since, type: :string, aliases: "-S", desc: "Stats from SINCE up to DATESIGN"
|
|
6
|
+
method_option :all, type: :boolean, aliases: "-a", default: false,
|
|
7
|
+
desc: "Stats across all dates"
|
|
7
8
|
def stats(datesign = "today")
|
|
8
9
|
init
|
|
9
10
|
begin
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
dates = if options[:all] && options[:since]
|
|
12
|
+
since_date = ::MPS.get_date(options[:since]).to_date
|
|
13
|
+
store.all_files.map { |f| Date.strptime(File.basename(f)[0, 8], "%Y%m%d") }
|
|
14
|
+
.uniq.sort.select { |d| d >= since_date }
|
|
15
|
+
elsif options[:all]
|
|
16
|
+
store.all_files.map { |f| Date.strptime(File.basename(f)[0, 8], "%Y%m%d") }.uniq.sort
|
|
17
|
+
elsif options[:since]
|
|
18
|
+
date = ::MPS.get_date(datesign)
|
|
19
|
+
date_range(options[:since], date)
|
|
20
|
+
else
|
|
21
|
+
date = ::MPS.get_date(datesign)
|
|
22
|
+
[date.to_date]
|
|
23
|
+
end
|
|
12
24
|
|
|
13
25
|
total = Hash.new(0)
|
|
14
26
|
total_log_mins = 0
|
|
@@ -1,17 +1,28 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
MPS::CLI::MPS.class_eval do
|
|
4
|
-
desc "tags [DATESIGN]", "Show tag usage
|
|
5
|
-
method_option :type,
|
|
6
|
-
method_option :since,
|
|
7
|
-
method_option :status, type: :string,
|
|
4
|
+
desc "tags [DATESIGN]", "Show tag usage table with frequency bars"
|
|
5
|
+
method_option :type, type: :string, aliases: "-t", desc: "Filter by element type"
|
|
6
|
+
method_option :since, type: :string, aliases: "-S", desc: "From SINCE up to DATESIGN"
|
|
7
|
+
method_option :status, type: :string, aliases: "-s", desc: "Filter tasks by status"
|
|
8
|
+
method_option :all, type: :boolean, aliases: "-a", default: false,
|
|
9
|
+
desc: "Count tags across all dates"
|
|
8
10
|
def tags(datesign = "today")
|
|
9
11
|
init
|
|
10
12
|
begin
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
dates = if options[:all] && options[:since]
|
|
14
|
+
since_date = ::MPS.get_date(options[:since]).to_date
|
|
15
|
+
store.all_files.map { |f| Date.strptime(File.basename(f)[0, 8], "%Y%m%d") }
|
|
16
|
+
.uniq.sort.select { |d| d >= since_date }
|
|
17
|
+
elsif options[:all]
|
|
18
|
+
store.all_files.map { |f| Date.strptime(File.basename(f)[0, 8], "%Y%m%d") }.uniq.sort
|
|
19
|
+
elsif options[:since]
|
|
20
|
+
date_range(options[:since], ::MPS.get_date(datesign))
|
|
21
|
+
else
|
|
22
|
+
[::MPS.get_date(datesign).to_date]
|
|
23
|
+
end
|
|
14
24
|
|
|
25
|
+
q = ::MPS::Query.new(options)
|
|
15
26
|
counts = Hash.new(0)
|
|
16
27
|
dates.each do |d|
|
|
17
28
|
q.apply(store.parse_date(d)).each_value do |el|
|
|
@@ -21,11 +32,24 @@ MPS::CLI::MPS.class_eval do
|
|
|
21
32
|
|
|
22
33
|
if counts.empty?
|
|
23
34
|
say set_color("(no tags found)", :yellow)
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
35
|
+
return
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
sorted = counts.sort_by { |_, v| -v }
|
|
39
|
+
max_cnt = sorted.first[1]
|
|
40
|
+
max_tag = sorted.map(&:first).map(&:length).max
|
|
41
|
+
bar_max = 24
|
|
42
|
+
|
|
43
|
+
say set_color(" #{"Tag".ljust(max_tag)} Count Frequency", :white)
|
|
44
|
+
say set_color(" #{"-" * max_tag} ----- #{"-" * bar_max}", :white)
|
|
45
|
+
sorted.each do |tag, n|
|
|
46
|
+
bar_len = (n.to_f / max_cnt * bar_max).ceil
|
|
47
|
+
bar = set_color("█" * bar_len, :cyan)
|
|
48
|
+
say " #{set_color(tag.ljust(max_tag), :white)} #{n.to_s.rjust(5)} #{bar}"
|
|
28
49
|
end
|
|
50
|
+
total = counts.values.sum
|
|
51
|
+
say ""
|
|
52
|
+
say set_color(" #{sorted.size} tag#{sorted.size == 1 ? '' : 's'}, #{total} total uses", :white)
|
|
29
53
|
rescue StandardError => e
|
|
30
54
|
raise Thor::Error, e
|
|
31
55
|
end
|
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
# Collect all schema-declared attribute flags for the update command.
|
|
4
|
-
# This runs at class-load time so options are available to Thor.
|
|
5
|
-
_all_schema_attrs = ::MPS::Elements.constants
|
|
6
|
-
.map { |k| ::MPS::Elements.const_get(k) }
|
|
7
|
-
.select { |x| x.class == Class }
|
|
8
|
-
.flat_map { |klass| klass.schema.to_a }
|
|
9
|
-
.uniq { |name, _| name }
|
|
10
|
-
.select { |_, defn| defn[:flag] }
|
|
11
|
-
|
|
12
3
|
MPS::CLI::MPS.class_eval do
|
|
4
|
+
# Returns all schema-declared attribute definitions across every element type.
|
|
5
|
+
# Called at class-load time (for method_option registration) and at call time
|
|
6
|
+
# (inside the update method body). A class method survives both contexts.
|
|
7
|
+
def self._schema_update_attrs
|
|
8
|
+
::MPS::Elements.constants
|
|
9
|
+
.map { |k| ::MPS::Elements.const_get(k) }
|
|
10
|
+
.select { |x| x.class == Class }
|
|
11
|
+
.flat_map { |klass| klass.schema.to_a }
|
|
12
|
+
.uniq { |name, _| name }
|
|
13
|
+
.select { |_, defn| defn[:flag] }
|
|
14
|
+
end
|
|
15
|
+
|
|
13
16
|
desc "update REFPATH", "Update an element's attributes in-place"
|
|
14
|
-
|
|
17
|
+
_schema_update_attrs.each do |_name, defn|
|
|
15
18
|
method_option defn[:flag], type: :string, desc: "Set #{defn[:flag]}"
|
|
16
19
|
end
|
|
17
20
|
method_option :date, type: :string, aliases: "-d",
|
|
@@ -21,7 +24,7 @@ MPS::CLI::MPS.class_eval do
|
|
|
21
24
|
begin
|
|
22
25
|
date = options[:date] ? ::MPS.get_date(options[:date]).to_date : Date.today
|
|
23
26
|
new_attrs = {}
|
|
24
|
-
|
|
27
|
+
self.class._schema_update_attrs.each do |name, defn|
|
|
25
28
|
flag_sym = defn[:flag].tr("-", "_").to_sym
|
|
26
29
|
new_attrs[name] = options[flag_sym] if options[flag_sym]
|
|
27
30
|
end
|
data/lib/mps/mps.rb
CHANGED
data/lib/mps/ref_resolver.rb
CHANGED
data/lib/mps/store.rb
CHANGED
|
@@ -140,7 +140,7 @@ module MPS
|
|
|
140
140
|
new_args = (new_attr_parts + existing_tags).join(", ")
|
|
141
141
|
|
|
142
142
|
if raw.empty?
|
|
143
|
-
old_pat = /@#{Regexp.escape(type)}\s*\{/
|
|
143
|
+
old_pat = /@#{Regexp.escape(type)}(?:\[\])?\s*\{/
|
|
144
144
|
new_open = "@#{type}[#{new_args}]{"
|
|
145
145
|
else
|
|
146
146
|
old_pat = /@#{Regexp.escape(type)}\[#{Regexp.escape(raw)}\]\s*\{/
|
data/lib/mps/version.rb
CHANGED