Merge pull request #461 from knu/user-defined-event_description

Improve event_description of EventFormattingAgent and WebsiteAgent.

Akinori MUSHA 10 年之前
父節點
當前提交
aa94c119d6
共有 2 個文件被更改,包括 18 次插入2 次删除
  1. 13 1
      app/models/agents/event_formatting_agent.rb
  2. 5 1
      app/models/agents/website_agent.rb

+ 13 - 1
app/models/agents/event_formatting_agent.rb

@@ -80,7 +80,19 @@ module Agents
80 80
           }
81 81
     MD
82 82
 
83
-    event_description "User defined"
83
+    event_description do
84
+      "Events will have the following fields%s:\n\n    %s" % [
85
+        case options['mode'].to_s
86
+        when 'merged'
87
+          ', merged with the original contents'
88
+        when /\{/
89
+          ', conditionally merged with the original contents'
90
+        end,
91
+        Utils.pretty_print(Hash[options['instructions'].keys.map { |key|
92
+          [key, "..."]
93
+        }])
94
+      ]
95
+    end
84 96
 
85 97
     after_save :clear_matchers
86 98
 

+ 5 - 1
app/models/agents/website_agent.rb

@@ -78,7 +78,11 @@ module Agents
78 78
     MD
79 79
 
80 80
     event_description do
81
-      "Events will have the fields you specified.  Your options look like:\n\n    #{Utils.pretty_print interpolated['extract']}"
81
+      "Events will have the following fields:\n\n    %s" % [
82
+        Utils.pretty_print(Hash[options['extract'].keys.map { |key|
83
+          [key, "..."]
84
+        }])
85
+      ]
82 86
     end
83 87
 
84 88
     def working?