Module: Fanforce::Factory::DeveloperConfig

Defined in:
lib/fanforce/factory/developer_config.rb

Class Method Summary collapse

Class Method Details

.app(addon) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/fanforce/factory/developer_config.rb', line 3

def self.app(addon)
  response = <<-eos
  "public_urls": {
      "marketplace_img": "http://${PRIMARY_DOMAIN}/assets/marketplace.png",
      "icon_16": "http://${PRIMARY_DOMAIN}/assets/icon-16.png",
      "icon_32": "http://${PRIMARY_DOMAIN}/assets/icon-32.png",
      "icon_42": "http://${PRIMARY_DOMAIN}/assets/icon-42.png"
  },
  "staffer_ui_urls": {
      "dashboard": "http://${PRIMARY_DOMAIN}/dashboard.html"
  },
  "callback_urls": {
      "install": "http://${PRIMARY_DOMAIN}/install",
      "uninstall": "http://${PRIMARY_DOMAIN}/uninstall"
  },
  "plugin_dependencies": []
  eos
  strip(response)
end

.plugin(addon) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/fanforce/factory/developer_config.rb', line 24

def self.plugin(addon)
  plugin_type = addon.plugin_type

  response  = "    \"type\": \"#{plugin_type}\",\n"
  response += "    \"#{plugin_type}_config\": {\n"
  if plugin_type == :data_connector
    response += <<-eos
    "category_id": "bulk_messaging"
    eos
  elsif plugin_type == :data_processor
  elsif plugin_type == :broadcaster
    response += <<-eos
    "new_button_label": "#{addon._id.humanize.titleize}"
    eos
  elsif plugin_type == :identifier
  elsif plugin_type == :behavior
    response += <<-eos
    "nouns": {
        "common": "action"
    },
    "verbs": {
        "simple": "do",
        "progressive": "doing",
        "perfect": "did"
    },
    "default_total_steps": 1,
    "valuerank_formula": [],
    "engagement_js_url": "http://${PRIMARY_DOMAIN}/assets/engage.js"
    eos
  end
  response += "    },\n"

  response += <<-eos
  "public_urls": {
    "icon_16": "http://${PRIMARY_DOMAIN}/assets/icon-16.png",
    "icon_32": "http://${PRIMARY_DOMAIN}/assets/icon-32.png",
    "icon_42": "http://${PRIMARY_DOMAIN}/assets/icon-42.png"
  },
  eos

  response += "    \"staffer_ui_urls\": {\n"
  if plugin_type == :data_connector
    response += <<-eos
    "add_source": "http://${PRIMARY_DOMAIN}/add_source.html",
    "source_details": "http://${PRIMARY_DOMAIN}/source_details.html"
    eos
  elsif plugin_type == :data_processor
  elsif plugin_type == :broadcaster
    response += <<-eos
    "new_message": "http://${PRIMARY_DOMAIN}/new_message.html"
    eos
  elsif plugin_type == :identifier
  elsif plugin_type == :behavior
    response += <<-eos
    "add_initiative": "http://${PRIMARY_DOMAIN}/add_initiative.html",
    "edit_initiative": "http://${PRIMARY_DOMAIN}/edit_initiative.html",
    "new_message": "http://${PRIMARY_DOMAIN}/new_message.html"
    eos
  end
  response += "    },\n"

  response += "    \"staffer_js_urls\": {\n"
  if plugin_type == :data_connector
    response += <<-eos
    "add_source": "http://${PRIMARY_DOMAIN}/assets/add_source_popup.js"
    eos
  elsif plugin_type == :data_processor
  elsif plugin_type == :broadcaster
  elsif plugin_type == :identifier
  elsif plugin_type == :behavior
  end
  response += "    },\n"

  response += <<-eos
  "callback_urls": {
    "install": "http://${PRIMARY_DOMAIN}/install",
    "uninstall": "http://${PRIMARY_DOMAIN}/uninstall"
  },
  eos
  response += '    "widget_dependencies": []' if plugin_type == :behavior

  strip response.gsub(/,\s*\z/, '')
end

.strip(data) ⇒ Object



108
109
110
# File 'lib/fanforce/factory/developer_config.rb', line 108

def self.strip(data)
  data.gsub(/^    /, '')
end