Class: Rabbit::Task::SlideShare

Inherits:
Object
  • Object
show all
Includes:
GetText
Defined in:
lib/rabbit/slideshare.rb

Defined Under Namespace

Classes: Error

Constant Summary collapse

BASE_URL =
"https://www.slideshare.net"
API_PATH_PREFIX =
"/api/2"
API_KEY =
"NB1B0IzS"
SHARED_SECRET =
"iuTFlPzU"

Constants included from GetText

GetText::DOMAIN

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from GetText

included

Constructor Details

#initialize(logger) ⇒ SlideShare

Returns a new instance of SlideShare.


41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/rabbit/slideshare.rb', line 41

def initialize(logger)
  @logger = logger
  @user = nil
  @pdf_path = nil
  @id = nil
  @title = nil
  @description = nil
  @tags = []
  @connection = Faraday.new(:url => BASE_URL) do |builder|
    builder.request  :multipart
    builder.request  :url_encoded
    builder.response :logger, @logger
    builder.adapter  :net_http
  end
end

Instance Attribute Details

#descriptionObject

Returns the value of attribute description.


40
41
42
# File 'lib/rabbit/slideshare.rb', line 40

def description
  @description
end

#idObject

Returns the value of attribute id.


40
41
42
# File 'lib/rabbit/slideshare.rb', line 40

def id
  @id
end

#pdf_pathObject

Returns the value of attribute pdf_path.


40
41
42
# File 'lib/rabbit/slideshare.rb', line 40

def pdf_path
  @pdf_path
end

#tagsObject

Returns the value of attribute tags.


40
41
42
# File 'lib/rabbit/slideshare.rb', line 40

def tags
  @tags
end

#titleObject

Returns the value of attribute title.


40
41
42
# File 'lib/rabbit/slideshare.rb', line 40

def title
  @title
end

#userObject

Returns the value of attribute user.


40
41
42
# File 'lib/rabbit/slideshare.rb', line 40

def user
  @user
end

Instance Method Details

#uploadObject


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
# File 'lib/rabbit/slideshare.rb', line 57

def upload
  slideshow_id = nil
  begin
    slideshow_id = upload_slide
  rescue Error
    @logger.error(_("Feailed to upload: %s") % $!.message)
    return nil
  end

  begin
    edit_title(slideshow_id)
  rescue Error
    @logger.error(_("Feailed to edit title: %s") % $!.message)
    return nil
  end

  url = nil
  begin
    url = slide_url(slideshow_id)
  rescue Error
    @logger.error(_("Feailed to get slide URL: %s") % $!.message)
    return nil
  end
  url
end