瀏覽代碼

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
           }
     MD
 
-    event_description "User defined"
+    event_description do
+      "Events will have the following fields%s:\n\n    %s" % [
+        case options['mode'].to_s
+        when 'merged'
+          ', merged with the original contents'
+        when /\{/
+          ', conditionally merged with the original contents'
+        end,
+        Utils.pretty_print(Hash[options['instructions'].keys.map { |key|
+          [key, "..."]
+        }])
+      ]
+    end
 
     after_save :clear_matchers
 

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

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