openrain-scenarios 0.2.2 → 0.3.2

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.
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :patch: 2
3
3
  :major: 0
4
- :minor: 2
4
+ :minor: 3
@@ -26,6 +26,20 @@ class Scenario
26
26
  end
27
27
  alias to_s name
28
28
 
29
+ # returns a formatted string, showing information
30
+ # about this current scenario
31
+ def info
32
+ str = <<INFO
33
+ Scenario: #{ name }
34
+ Summary: #{ summary }
35
+ Description: #{ description_without_summary }
36
+ INFO
37
+ variables.each do |key, value|
38
+ str << "#{ key }: #{ value.inspect }\n"
39
+ end
40
+ str
41
+ end
42
+
29
43
  # if the first line of the scenario's source code
30
44
  # is a comment, we use it as the scenario's summary
31
45
  #
@@ -63,6 +77,12 @@ class Scenario
63
77
  header.gsub(/^#* ?/, '').gsub(/^---.*/m, '').strip # gets rid of comment hashes and yaml
64
78
  end
65
79
 
80
+ def description_without_summary
81
+ parts = description.split("\n")
82
+ parts.shift
83
+ parts.join("\n")
84
+ end
85
+
66
86
  # evaluates the code of the scenario
67
87
  def load
68
88
  self.class.load self # pass the loading off to the class
@@ -12,7 +12,7 @@ task :scenarios do
12
12
  puts "there are no scenarios. add some to one of the Scenario.load_paths: #{ Scenario.load_paths.inspect }"
13
13
  else
14
14
  Scenario.all.each do |scenario|
15
- puts "#{ scenario.name }: #{ scenario.description }"
15
+ puts "#{ scenario.name }: #{ scenario.summary }"
16
16
  end
17
17
  end
18
18
  end
@@ -24,10 +24,7 @@ namespace :scenarios do
24
24
  puts "called scenarios:load" if Scenario.verbose
25
25
  if ENV['NAME']
26
26
  names = ENV['NAME'].split(',')
27
- names.each do |scenario_name|
28
- puts "Scenario.load #{scenario_name}"
29
- Scenario.load scenario_name
30
- end
27
+ Scenario.load *names
31
28
  else
32
29
  puts "you need to pass NAME=scenario_name to load a scenario"
33
30
  end
@@ -38,7 +35,12 @@ namespace :scenarios do
38
35
  if ENV['NAME']
39
36
  names = ENV['NAME'].split(',')
40
37
  names.each do |scenario_name|
41
- puts "this would puts out some kindof information / description for #{ scenario_name }"
38
+ if scenario = Scenario[scenario_name]
39
+ puts scenario.info
40
+ puts ('-' * 40)
41
+ else
42
+ puts "Scenario not found: #{ scenario_name }"
43
+ end
42
44
  end
43
45
  else
44
46
  puts "you need to pass NAME=scenario_name to load a scenario"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openrain-scenarios
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - remi