choctop 0.9.2 → 0.9.3

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,10 @@
1
+ == 0.9.3 2009-01-29
2
+
3
+ * install_choctop generates a ReleaseNotes.txt file
4
+ * 'rake feed' converts ReleaseNotes.txt into release_notes.html file for upload
5
+ * #name is the project's folder name if info_plist['CFBundleExecutable'] == "${EXECUTABLE}"
6
+ * builder of xml feed flushes immediately now so no more 0 length xml feeds
7
+
1
8
  == 0.9.2 2009-01-29
2
9
 
3
10
  * fixed instances of "SUFeedURLKey" to "SUFeedURL" due to f@#$-up error message in Sparkle code that led me astray
data/Manifest.txt CHANGED
@@ -4,6 +4,8 @@ README.rdoc
4
4
  Rakefile
5
5
  app_generators/install_choctop/install_choctop_generator.rb
6
6
  app_generators/install_choctop/templates/Rakefile.erb
7
+ app_generators/install_choctop/templates/ReleaseNotes.txt.erb
8
+ app_generators/install_choctop/templates/release_notes_template.html.erb
7
9
  assets/DefaultVolumeIcon.icns
8
10
  assets/sky.jpg
9
11
  assets/sky_background.jpg
data/Rakefile CHANGED
@@ -9,7 +9,8 @@ $hoe = Hoe.new('choctop', ChocTop::VERSION) do |p|
9
9
  p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
10
10
  p.extra_deps = [
11
11
  ['activesupport'],
12
- ['builder','>= 2.1.2']
12
+ ['builder','>= 2.1.2'],
13
+ ['RedCloth', '>=4.1.1']
13
14
  ]
14
15
  p.extra_dev_deps = [
15
16
  ['newgem', ">= #{::Newgem::VERSION}"]
@@ -17,7 +17,9 @@ class InstallChoctopGenerator < RubiGen::Base
17
17
  record do |m|
18
18
  %w( appcast/build ).each { |path| m.directory path }
19
19
 
20
- m.template "Rakefile.erb", "Rakefile", :collision => :skip
20
+ m.template "Rakefile.erb", "Rakefile"
21
+ m.template "ReleaseNotes.txt.erb", "ReleaseNotes.txt"
22
+ m.file "release_notes_template.html.erb", "release_notes_template.html.erb"
21
23
  end
22
24
  end
23
25
 
@@ -0,0 +1,5 @@
1
+ h1. <span><%= Date.today %></span> Release <%= version %>
2
+
3
+ h2. Initial release
4
+
5
+ Yay! First release.
@@ -0,0 +1,13 @@
1
+ <html>
2
+ <head>
3
+ <title>Release Notes</title>
4
+ <style>
5
+ * { font-family: serif;}
6
+ h1 { font-family: sans-serif; background-color: #ABABFF; padding: 10px;}
7
+ h1 span { font-size: 75%; font-weight: normal; float: right;}
8
+ </style>
9
+ </head>
10
+ <body>
11
+ <%= release_notes_html %>
12
+ </body>
13
+ </html>
@@ -1,9 +1,9 @@
1
- Feature: Setup a Cocoa app with sparkle-ruby
1
+ Feature: Setup a Cocoa app with choctop
2
2
  In order to reduce cost of using Sparkle to generate appcasts
3
3
  As a Cocoa developer or Cocoa application deployer
4
4
  I want a generator to install rake tasks that make using Sparkle easy-peasy
5
5
 
6
- Scenario: Install sparkle-ruby into an app that has no existing Rakefile
6
+ Scenario: Install choctop into an app that has no existing Rakefile
7
7
  Given a Cocoa app that does not have an existing Rakefile
8
8
  When I run local executable 'install_choctop' with arguments '.'
9
9
  And Rakefile wired to use development code instead of installed RubyGem
@@ -11,7 +11,7 @@ Feature: Setup a Cocoa app with sparkle-ruby
11
11
  And output does match /rake build/
12
12
  And output does match /rake upload/
13
13
 
14
- Scenario: Install sparkle-ruby into an app that has an existing Rakefile
14
+ Scenario: Install choctop into an app that has an existing Rakefile
15
15
  Given a Cocoa app that does have an existing Rakefile
16
16
  When I run local executable 'install_choctop' with arguments '.'
17
17
  And Rakefile wired to use development code instead of installed RubyGem
@@ -23,4 +23,10 @@ Feature: Setup a Cocoa app with sparkle-ruby
23
23
  Given a Cocoa app that does not have an existing Rakefile
24
24
  When I run local executable 'install_choctop' with arguments ''
25
25
  Then output does match /USAGE: install_choctop path\/to\/CocoaApp/
26
-
26
+
27
+ Scenario: Install choctop and generate a ReleaseNotes file
28
+ Given a Cocoa app that does not have an existing Rakefile
29
+ When I run local executable 'install_choctop' with arguments '.'
30
+ Then file 'ReleaseNotes.txt' is created
31
+ And contents of file 'ReleaseNotes.txt' does match /Initial release/
32
+
@@ -15,10 +15,10 @@ Feature: Rake tasks are available to build and deploy Cocoa apps with Sparkle
15
15
 
16
16
  Scenario: rake task to upload the appcast file to the server
17
17
  Given a Cocoa app with choctop installed
18
- And task 'rake feed' is invoked
18
+ And task 'rake dmg feed' is invoked
19
19
  And ChocTop config is configured for local rsync
20
20
  When task 'rake upload' is invoked
21
- Then remote file 'linker_appcast.xml' is created
21
+ Then remote file 'my_feed.xml' is created
22
22
  Then remote file 'SampleApp-0.1.0.dmg' is created
23
23
  Then remote file 'index.php' is created
24
24
 
@@ -6,7 +6,7 @@ Feature: Generate an XML file for Sparkle to use for updates
6
6
  Scenario: rake task to create/update the appcast file
7
7
  Given a Cocoa app with choctop installed
8
8
  And ChocTop config is configured for remote Sparkle
9
- When task 'rake feed' is invoked
9
+ When task 'rake dmg feed' is invoked
10
10
  Then file 'appcast/build/my_feed.xml' is created
11
11
  And contents of file 'appcast/build/my_feed.xml' does match /<channel>/
12
12
  And contents of file 'appcast/build/my_feed.xml' does match /</channel>/
@@ -18,7 +18,21 @@ Feature: Generate an XML file for Sparkle to use for updates
18
18
  And file 'appcast/build/index.php' is created
19
19
  And contents of file 'appcast/build/index.php' does match /Location/
20
20
  And contents of file 'appcast/build/index.php' does match /SampleApp-0.1.0.dmg/
21
+ And file 'appcast/build/release_notes.html' is created
22
+ And contents of file 'appcast/build/release_notes.html' does match /0.1.0/
23
+ And contents of file 'appcast/build/release_notes.html' does match /<h2>Initial release</h2>/
24
+ And contents of file 'appcast/build/release_notes.html' does match /<p>Yay! First release.</p>/
25
+ And contents of file 'appcast/build/release_notes.html' does match /<html>/
21
26
 
22
-
27
+ Scenario: generate default release notes if no ReleaseNotes.txt
28
+ Given a Cocoa app with choctop installed
29
+ And ChocTop config is configured for remote Sparkle
30
+ And file 'ReleaseNotes.txt' is deleted
31
+ When task 'rake dmg feed' is invoked
32
+ Then file 'appcast/build/release_notes.html' is created
33
+ And contents of file 'appcast/build/release_notes.html' does match /0.1.0/
34
+ And contents of file 'appcast/build/release_notes.html' does match /<h2>Another awesome release!</h2>/
35
+ And contents of file 'appcast/build/release_notes.html' does match /<html>/
36
+
37
+
23
38
 
24
-
@@ -50,6 +50,12 @@ Given %r{'(.*)' folder is deleted} do |folder|
50
50
  end
51
51
  end
52
52
 
53
+ Given %r{file '(.*)' is deleted} do |file|
54
+ in_project_folder do
55
+ FileUtils.rm_rf file
56
+ end
57
+ end
58
+
53
59
  When %r{^'(.*)' generator is invoked with arguments '(.*)'$} do |generator, arguments|
54
60
  @stdout = StringIO.new
55
61
  FileUtils.chdir(@active_project_folder) do
@@ -1,5 +1,6 @@
1
1
  require File.dirname(__FILE__) + "/../../lib/choctop"
2
2
 
3
+ require "rubygems"
3
4
  gem 'cucumber'
4
5
  require 'cucumber'
5
6
  gem 'rspec'
@@ -1,6 +1,6 @@
1
1
  Given /^a Cocoa app that does not have an existing Rakefile$/ do
2
2
  Given "a safe folder"
3
- setup_active_project_folder "sample_app"
3
+ setup_active_project_folder "SampleApp"
4
4
  end
5
5
 
6
6
  Given /^a Cocoa app that does have an existing Rakefile$/ do
data/lib/choctop.rb CHANGED
@@ -3,16 +3,17 @@ $:.unshift(File.dirname(__FILE__)) unless
3
3
 
4
4
  require "fileutils"
5
5
  require "yaml"
6
- require "rubygems"
7
6
  require "builder"
8
- require "active_support"
7
+ require "erb"
9
8
  require "osx/cocoa"
9
+ require "active_support"
10
+ require "RedCloth"
10
11
 
11
12
  class ChocTop
12
- VERSION = '0.9.2'
13
+ VERSION = '0.9.3'
13
14
 
14
15
  # The name of the Cocoa application
15
- # Default: info_plist['CFBundleExecutable']
16
+ # Default: info_plist['CFBundleExecutable'] or project folder name if "${EXECUTABLE}"
16
17
  attr_accessor :name
17
18
 
18
19
  # The version of the Cocoa application
@@ -33,10 +34,21 @@ class ChocTop
33
34
  @base_url ||= "http://#{host}"
34
35
  end
35
36
 
36
- # The url to display the release notes for the latest release
37
+ # The file name for generated release notes for the latest release
37
38
  # Default: release_notes.html
38
39
  attr_accessor :release_notes
39
40
 
41
+ # The path for an HTML template into which the ReleaseNotes.txt are inserted
42
+ # after conversion to HTML
43
+ #
44
+ # The template file is an ERb template, with <%= yield %> as the placeholder
45
+ # for the generated release notes.
46
+ #
47
+ # Currently, any CSS or JavaScript must be inline
48
+ #
49
+ # Default: release_notes_template.html.erb, which was generated by install_choctop into each project
50
+ attr_accessor :release_notes_template
51
+
40
52
  # The name of the local xml file containing the Sparkle item details
41
53
  # Default: info_plist['SUFeedURL'] or linker_appcast.xml
42
54
  attr_accessor :appcast_filename
@@ -119,11 +131,13 @@ class ChocTop
119
131
 
120
132
  # Defaults
121
133
  @name = info_plist['CFBundleExecutable']
134
+ @name = File.basename(File.expand_path(".")) if name == "${EXECUTABLE}"
122
135
  @version = info_plist['CFBundleVersion']
123
136
  @target = "#{name}.app"
124
137
  @appcast_filename = info_plist['SUFeedURL'] ? File.basename(info_plist['SUFeedURL']) : 'linker_appcast.xml'
125
138
  @release_notes = 'release_notes.html'
126
- @rsync_args = '-aCv'
139
+ @release_notes_template = "release_notes_template.html.erb"
140
+ @rsync_args = '-aCv --progress'
127
141
 
128
142
  @background_file = File.dirname(__FILE__) + "/../assets/sky_background.jpg"
129
143
  @app_icon_position = [175, 65]
@@ -156,9 +170,10 @@ class ChocTop
156
170
  end
157
171
 
158
172
  desc "Create/update the appcast file"
159
- task :feed => :dmg do
173
+ task :feed do
160
174
  make_appcast
161
175
  make_index_redirect
176
+ make_release_notes
162
177
  end
163
178
 
164
179
  desc "Upload the appcast file to the host"
@@ -7,36 +7,36 @@ module ChocTop::Appcast
7
7
  app_name = File.basename(File.expand_path('.'))
8
8
 
9
9
  FileUtils.mkdir_p "#{build_path}"
10
- appcast = File.open("#{build_path}/#{appcast_filename}", 'w')
10
+ appcast = File.open("#{build_path}/#{appcast_filename}", 'w') do |f|
11
+ xml = Builder::XmlMarkup.new(:indent => 2)
12
+ xml.instruct!
13
+ xml_string = xml.rss('xmlns:atom' => "http://www.w3.org/2005/Atom",
14
+ 'xmlns:sparkle' => "http://www.andymatuschak.org/xml-namespaces/sparkle",
15
+ :version => "2.0") do
16
+ xml.channel do
17
+ xml.title(app_name)
18
+ xml.description("#{app_name} updates")
19
+ xml.link(base_url)
20
+ xml.language('en')
21
+ xml.pubDate Time.now.to_s(:rfc822)
22
+ # xml.lastBuildDate(Time.now.rfc822)
23
+ xml.atom(:link, :href => "#{base_url}/#{appcast_filename}",
24
+ :rel => "self", :type => "application/rss+xml")
11
25
 
12
- xml = Builder::XmlMarkup.new(:target => appcast, :indent => 2)
13
-
14
- xml.instruct!
15
- xml.rss('xmlns:atom' => "http://www.w3.org/2005/Atom",
16
- 'xmlns:sparkle' => "http://www.andymatuschak.org/xml-namespaces/sparkle",
17
- :version => "2.0") do
18
- xml.channel do
19
- xml.title(app_name)
20
- xml.description("#{app_name} updates")
21
- xml.link(base_url)
22
- xml.language('en')
23
- xml.pubDate Time.now.to_s(:rfc822)
24
- # xml.lastBuildDate(Time.now.rfc822)
25
- xml.atom(:link, :href => "#{base_url}/#{appcast_filename}",
26
- :rel => "self", :type => "application/rss+xml")
27
-
28
- xml.item do
29
- xml.title("#{name} #{version}")
30
- xml.tag! "sparkle:releaseNotesLink", "#{base_url}/#{release_notes}"
31
- xml.pubDate Time.now.to_s(:rfc822) #(File.mtime(pkg))
32
- xml.guid("#{name}-#{version}", :isPermaLink => "false")
33
- xml.enclosure(:url => "#{base_url}/#{pkg_name}",
34
- :length => "#{File.size(pkg)}",
35
- :type => "application/dmg",
36
- :"sparkle:version" => version,
37
- :"sparkle:dsaSignature" => dsa_signature)
26
+ xml.item do
27
+ xml.title("#{name} #{version}")
28
+ xml.tag! "sparkle:releaseNotesLink", "#{base_url}/#{release_notes}"
29
+ xml.pubDate Time.now.to_s(:rfc822) #(File.mtime(pkg))
30
+ xml.guid("#{name}-#{version}", :isPermaLink => "false")
31
+ xml.enclosure(:url => "#{base_url}/#{pkg_name}",
32
+ :length => "#{File.size(pkg)}",
33
+ :type => "application/dmg",
34
+ :"sparkle:version" => version,
35
+ :"sparkle:dsaSignature" => dsa_signature)
36
+ end
38
37
  end
39
38
  end
39
+ f << xml_string
40
40
  end
41
41
  end
42
42
 
@@ -45,10 +45,33 @@ module ChocTop::Appcast
45
45
  f << %Q{<?php header("Location: #{pkg_relative_url}"); ?>}
46
46
  end
47
47
  end
48
+
49
+ def make_release_notes
50
+ File.open("#{build_path}/#{release_notes}", "w") do |f|
51
+ template = File.read(release_notes_template)
52
+ f << ERB.new(template).result(binding)
53
+ end
54
+ end
55
+
56
+ def release_notes_content
57
+ if File.exists?("ReleaseNotes.txt")
58
+ File.read("ReleaseNotes.txt")
59
+ else
60
+ <<-TEXTILE.gsub(/^ /, '')
61
+ h1. #{version} #{Date.today}
62
+
63
+ h2. Another awesome release!
64
+ TEXTILE
65
+ end
66
+ end
67
+
68
+ def release_notes_html
69
+ RedCloth.new(release_notes_content).to_html
70
+ end
48
71
 
49
72
  def upload_appcast
50
73
  _host = host.blank? ? "" : "#{host}:"
51
- sh %{rsync -aCv appcast/build/ #{_host}#{remote_dir}}
74
+ sh %{rsync #{rsync_args} #{build_path}/ #{_host}#{remote_dir}}
52
75
  end
53
76
 
54
77
  # Returns a file path to the dsa_priv.pem file
@@ -61,6 +84,12 @@ module ChocTop::Appcast
61
84
  `openssl gendsa dsaparam.pem -out dsa_priv.pem`
62
85
  `openssl dsa -in dsa_priv.pem -pubout -out dsa_pub.pem`
63
86
  `rm dsaparam.pem`
87
+ puts <<-EOS.gsub(/^ /, '')
88
+
89
+ WARNING: DO NOT PUT dsa_priv.pem IN YOUR SOURCE CONTROL
90
+ Remember to add it to your ignore list
91
+
92
+ EOS
64
93
  end
65
94
  File.expand_path('dsa_priv.pem')
66
95
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: choctop
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.2
4
+ version: 0.9.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dr Nic Williams
@@ -33,6 +33,16 @@ dependencies:
33
33
  - !ruby/object:Gem::Version
34
34
  version: 2.1.2
35
35
  version:
36
+ - !ruby/object:Gem::Dependency
37
+ name: RedCloth
38
+ type: :runtime
39
+ version_requirement:
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ version: 4.1.1
45
+ version:
36
46
  - !ruby/object:Gem::Dependency
37
47
  name: newgem
38
48
  type: :development
@@ -73,6 +83,8 @@ files:
73
83
  - Rakefile
74
84
  - app_generators/install_choctop/install_choctop_generator.rb
75
85
  - app_generators/install_choctop/templates/Rakefile.erb
86
+ - app_generators/install_choctop/templates/ReleaseNotes.txt.erb
87
+ - app_generators/install_choctop/templates/release_notes_template.html.erb
76
88
  - assets/DefaultVolumeIcon.icns
77
89
  - assets/sky.jpg
78
90
  - assets/sky_background.jpg