Module: AbideDevUtils::Jira::DryRun
- Included in:
- Client, Helper
- Defined in:
- lib/abide_dev_utils/jira/dry_run.rb
Defined Under Namespace
Classes: Dummy, DummyIssue, DummyProject, DummySubtask
Instance Method Summary
collapse
Instance Method Details
#dry_run(*method_names) ⇒ Object
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/abide_dev_utils/jira/dry_run.rb', line 8
def dry_run(*method_names)
method_names.each do |method_name|
proxy = Module.new do
define_method(method_name) do |*args, **kwargs|
if !!@dry_run
case method_name
when %r{^create}
AbideDevUtils::Output.simple("DRY RUN: #{self.class.name}##{method_name}(#{args[0]}, #{kwargs.map { |k, v| "#{k}: #{v.inspect}" }.join(', ')})")
sleep 0.1
return DummyIssue.new if args[0].match?(%r{^issue$})
return DummySubtask.new if args[0].match?(%r{^subtask$})
when %r{^find}
AbideDevUtils::Output.simple("DRY RUN: #{self.class.name}##{method_name}(#{args[0]}, #{kwargs.inspect})")
return DummyIssue.new if args[0].match?(%r{^issue$})
return DummySubtask.new if args[0].match?(%r{^subtask$})
return DummyProject.new if args[0].match?(%r{^project$})
return [] if args[0].match?(%r{^issues_by_jql$})
"Dummy #{args[0].capitalize}"
else
AbideDevUtils::Output.simple("DRY RUN: #{self.class.name}##{method_name}(#{args.map(&:inspect).join(', ')}, #{kwargs.map { |k, v| "#{k}: #{v.inspect}" }.join(', ')})")
end
else
super(*args, **kwargs)
end
end
end
self.prepend(proxy)
end
end
|
#dry_run_return_false(*method_names) ⇒ Object
65
66
67
68
69
70
71
72
73
74
75
76
|
# File 'lib/abide_dev_utils/jira/dry_run.rb', line 65
def dry_run_return_false(*method_names)
method_names.each do |method_name|
proxy = Module.new do
define_method(method_name) do |*args, **kwargs|
return false if !!@dry_run
super(*args, **kwargs)
end
end
self.prepend(proxy)
end
end
|
#dry_run_return_true(*method_names) ⇒ Object
52
53
54
55
56
57
58
59
60
61
62
63
|
# File 'lib/abide_dev_utils/jira/dry_run.rb', line 52
def dry_run_return_true(*method_names)
method_names.each do |method_name|
proxy = Module.new do
define_method(method_name) do |*args, **kwargs|
return true if !!@dry_run
super(*args, **kwargs)
end
end
self.prepend(proxy)
end
end
|
#dry_run_simple(*method_names) ⇒ Object
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/abide_dev_utils/jira/dry_run.rb', line 39
def dry_run_simple(*method_names)
method_names.each do |method_name|
proxy = Module.new do
define_method(method_name) do |*args, **kwargs|
return if !!@dry_run
super(*args, **kwargs)
end
end
self.prepend(proxy)
end
end
|