Class: ZenPush::Runner
- Inherits:
-
Boson::Runner
- Object
- Boson::Runner
- ZenPush::Runner
- Defined in:
- lib/zenpush/runner.rb
Instance Method Summary collapse
- #categories(options = {}) ⇒ Object
- #exists?(options = {}) ⇒ Boolean
- #forums(options = {}) ⇒ Object
- #push(options = {}) ⇒ Object
- #topics(options = {}) ⇒ Object
Instance Method Details
#categories(options = {}) ⇒ Object
9 10 11 |
# File 'lib/zenpush/runner.rb', line 9 def categories( = {}) ap ZenPush.z.categories end |
#exists?(options = {}) ⇒ Boolean
26 27 28 29 30 |
# File 'lib/zenpush/runner.rb', line 26 def exists?( = {}) category_name, forum_name, topic_title = ZenPush.file_to_category_forum_topic([:file]) topic = ZenPush.z.find_topic(category_name, forum_name, topic_title) ap !!topic end |
#forums(options = {}) ⇒ Object
14 15 16 |
# File 'lib/zenpush/runner.rb', line 14 def forums( = {}) ap ZenPush.z.forums end |
#push(options = {}) ⇒ Object
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 |
# File 'lib/zenpush/runner.rb', line 35 def push( = {}) category_name, forum_name, topic_title = ZenPush.file_to_category_forum_topic([:file]) topic_body = if [:file].end_with?('.md') || [:file].end_with?('.markdown') ZenPush::Markdown.to_zendesk_html([:file], [:flavor]) else File.read([:file]) end topic = ZenPush.z.find_topic(category_name, forum_name, topic_title) if topic # UPDATE THE TOPIC ap ZenPush.z.put_topic(topic['id'], topic_body) else forum = ZenPush.z.find_or_create_forum(category_name, forum_name) if forum # CREATE THE TOPIC ap ZenPush.z.post_topic(forum['id'], topic_title, topic_body) else ap "Could not find a forum named '#{forum_name}' in the category '#{category_name}'" exit(-1) end end end |
#topics(options = {}) ⇒ Object
20 21 22 |
# File 'lib/zenpush/runner.rb', line 20 def topics( = {}) ap ZenPush.z.topics([:forum_id]) end |