Class: Zwite::AppcastRelease

Inherits:
Object
  • Object
show all
Defined in:
lib/zwite/plugins/appcast.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app, path, signature_key) ⇒ AppcastRelease

Initialization



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
# File 'lib/zwite/plugins/appcast.rb', line 53

def initialize(app, path, signature_key)
  self.app = app
  self.path = path
  
  Zwite::Utils.parse_date_and_slug(self.path.basename.to_s) do |date, slug|
    self.date = date
    self.slug = slug
  end
  
  rel_path = (self.path.parent + self.slug).relative_path_from(self.app.path).to_s
  self.output_path = self.app.output_path + rel_path
  self.url = self.app.url + rel_path + "/"
  
  Zwite::Utils.((self.path + "release.md").read) do |, markdown|
    self. = 
    self.notes = markdown
  end
  
  self.name = self.["name"]
  self.version = self.["version"]
  self.build = self.["build"]
  
  self.file_path = self.path + self.["file"]
  self.file_name = self.file_path.basename.to_s
  self.file_url = self.url + self.file_path.basename.to_s
  self.file_size = self.file_path.size
  self.file_size_mb = "%.2f" % (self.file_size / 1024.0 / 1024.0)
  
  signature = OpenSSL::Digest::SHA1.new
  self.file_path.open("r") do |h|
    while buffer = h.read(1024)
      signature << buffer
    end
  end

  self.file_signature = Base64.strict_encode64(signature_key.syssign(signature.digest))
  
end

Instance Attribute Details

#appObject

Properties



9
10
11
# File 'lib/zwite/plugins/appcast.rb', line 9

def app
  @app
end

#buildObject

Returns the value of attribute build.



23
24
25
# File 'lib/zwite/plugins/appcast.rb', line 23

def build
  @build
end

#dateObject

Returns the value of attribute date.



12
13
14
# File 'lib/zwite/plugins/appcast.rb', line 12

def date
  @date
end

#file_nameObject

Returns the value of attribute file_name.



26
27
28
# File 'lib/zwite/plugins/appcast.rb', line 26

def file_name
  @file_name
end

#file_pathObject

Returns the value of attribute file_path.



25
26
27
# File 'lib/zwite/plugins/appcast.rb', line 25

def file_path
  @file_path
end

#file_signatureObject

Returns the value of attribute file_signature.



30
31
32
# File 'lib/zwite/plugins/appcast.rb', line 30

def file_signature
  @file_signature
end

#file_sizeObject

Returns the value of attribute file_size.



28
29
30
# File 'lib/zwite/plugins/appcast.rb', line 28

def file_size
  @file_size
end

#file_size_mbObject

Returns the value of attribute file_size_mb.



29
30
31
# File 'lib/zwite/plugins/appcast.rb', line 29

def file_size_mb
  @file_size_mb
end

#file_urlObject

Returns the value of attribute file_url.



27
28
29
# File 'lib/zwite/plugins/appcast.rb', line 27

def file_url
  @file_url
end

#metadataObject

Returns the value of attribute metadata.



18
19
20
# File 'lib/zwite/plugins/appcast.rb', line 18

def 
  @metadata
end

#nameObject

Returns the value of attribute name.



21
22
23
# File 'lib/zwite/plugins/appcast.rb', line 21

def name
  @name
end

#notesObject

Returns the value of attribute notes.



19
20
21
# File 'lib/zwite/plugins/appcast.rb', line 19

def notes
  @notes
end

#output_pathObject

Returns the value of attribute output_path.



15
16
17
# File 'lib/zwite/plugins/appcast.rb', line 15

def output_path
  @output_path
end

#pathObject

Returns the value of attribute path.



10
11
12
# File 'lib/zwite/plugins/appcast.rb', line 10

def path
  @path
end

#slugObject

Returns the value of attribute slug.



13
14
15
# File 'lib/zwite/plugins/appcast.rb', line 13

def slug
  @slug
end

#urlObject

Returns the value of attribute url.



16
17
18
# File 'lib/zwite/plugins/appcast.rb', line 16

def url
  @url
end

#versionObject

Returns the value of attribute version.



22
23
24
# File 'lib/zwite/plugins/appcast.rb', line 22

def version
  @version
end

Instance Method Details

#<=>(other) ⇒ Object

Actions



96
97
98
99
100
101
# File 'lib/zwite/plugins/appcast.rb', line 96

def <=>(other)
  if other.class == self.class
    return other.date <=> self.date
  end
  return nil
end

#to_liquidObject



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/zwite/plugins/appcast.rb', line 32

def to_liquid
  return {
    "date" => self.date,
    "slug" => self.slug,
    "url" => self.url,
    "metadata" => self.,
    "notes" => self.notes,
    "name" => self.name,
    "version" => self.version,
    "file_name" => self.file_name,
    "file_url" => self.file_url,
    "file_size" => self.file_size,
    "file_size_mb" => self.file_size_mb,
    "file_signature" => self.file_signature
  }
end