fasten 0.5.4 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,18 +0,0 @@
1
- require 'fasten/ui/console'
2
- require 'fasten/ui/curses'
3
-
4
- module Fasten
5
- module UI
6
- def ui
7
- @ui ||= STDIN.tty? && STDOUT.tty? ? Fasten::UI::Curses.new(executor: self) : Fasten::UI::Console.new(executor: self)
8
- end
9
-
10
- def run_ui
11
- ui.update
12
-
13
- yield
14
- ensure
15
- ui.cleanup
16
- end
17
- end
18
- end
@@ -1,48 +0,0 @@
1
- module Fasten
2
- module Yaml
3
- def transform_params(params)
4
- params.keys.each do |k|
5
- val = params[k]
6
-
7
- if val.is_a?(String) && (match = %r{^/(.+)/$}.match(val))
8
- val = Regexp.new(match[1])
9
- end
10
-
11
- params[k.to_sym] = val
12
- params.delete(k)
13
- end
14
- end
15
-
16
- def load_yaml(path)
17
- items = YAML.safe_load(File.read(path)).each do |name, params|
18
- if params.is_a? String
19
- params = { after: params }
20
- elsif params.is_a? Hash
21
- transform_params(params)
22
- else
23
- params = {}
24
- end
25
-
26
- add Fasten::Task.new({ name: name }.merge(params))
27
- end
28
-
29
- log_info "Loaded #{items.count} tasks from #{path}"
30
- end
31
-
32
- def save_yaml(path)
33
- keys = %i[after shell]
34
-
35
- items = task_list.map do |task|
36
- data = task.to_h.select do |key, _val|
37
- keys.include? key
38
- end
39
-
40
- [task.name, data]
41
- end.to_h
42
-
43
- File.write path, items.to_yaml
44
-
45
- log_info "Loaded #{items.count} tasks into #{path}"
46
- end
47
- end
48
- end