openMSX-builder 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +1 -0
- data/LICENSE +20 -0
- data/README.markdown +62 -0
- data/Rakefile +36 -0
- data/VERSION +1 -0
- data/bin/build_openmsx +25 -0
- data/lib/debug_tools.rb +9 -0
- data/lib/openmsx_builder.rb +269 -0
- data/lib/tweet_msx.rb +56 -0
- data/openMSX-builder.gemspec +66 -0
- data/spec/openMSX-builder_spec.rb +4 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +8 -0
- metadata +119 -0
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
pkg/
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2010 Filip H.F. "FiXato" Slagter
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.markdown
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
# openMSX-Builder
|
2
|
+
******************************************************************************
|
3
|
+
openMSX-Builder is used for building the latest SVN checkouts of [openMSX][1] and [openMSX-Debugger][2] from [their sourceforge repository][3].
|
4
|
+
It also supports publishing the created builds to an external location via [scp][4]. The original setup publishes to [FiXato's openMSX page][5].
|
5
|
+
Successfully published builds can also be announced via Twitter. [@openmsx_builder][6] is the official Twitter home for openMSX-Builder.
|
6
|
+
|
7
|
+
Setup of the oauth info has to be done manually at the moment, for more information on that read, about the amazing [twitter_oauth gem][7], [Twitter's oAuth Applications][8] and [Twitter's Authentication Wiki][9]
|
8
|
+
|
9
|
+
|
10
|
+
## Commandline Arguments
|
11
|
+
******************************************************************************
|
12
|
+
Currently `./build_openmsx` supports the following commandline arguments:
|
13
|
+
|
14
|
+
* --debug => Generate debug output.
|
15
|
+
* --publish => Publish the created build
|
16
|
+
* --publish-current => Only publish the current build and exit
|
17
|
+
* --publish-all => Only publish all previously created builds and exit
|
18
|
+
* --tweet => Send a tweet via @openMSX_Builder after successfully having published a build
|
19
|
+
* --dont-update => Don't update the SVN repository
|
20
|
+
* --report-build-failure => If an error occurs during build, report failure via e-mail
|
21
|
+
|
22
|
+
|
23
|
+
## ToDo
|
24
|
+
******************************************************************************
|
25
|
+
Current list of tasks is:
|
26
|
+
|
27
|
+
+ Publish gem to Gemcutter
|
28
|
+
+ Integrate with CIA.vc / Ruby-Rbot
|
29
|
+
+ Add tests
|
30
|
+
+ Refactor `#archive_for_revision` and `#dmg_for_revision` into a single method
|
31
|
+
+ Create a simple Sinatra App for [openMSX.FiXato.net][5]
|
32
|
+
+ Allow for automatic setup of the oAuth tokens.
|
33
|
+
|
34
|
+
|
35
|
+
## Notes on Patches/Pull Requests
|
36
|
+
******************************************************************************
|
37
|
+
|
38
|
+
1 Fork the project.
|
39
|
+
2 Make your feature addition or bug fix.
|
40
|
+
3 Add tests for it (even though I don't have tests myself at the moment).
|
41
|
+
This is important so I don't break it in a future version unintentionally.
|
42
|
+
4 Commit, but do not mess with Rakefile, version, history, or README.
|
43
|
+
Want to have your own version? Bump version in a separate commit!
|
44
|
+
That way I can ignored that commit when I pull.
|
45
|
+
5 Send me a pull request. Bonus points for topic branches.
|
46
|
+
|
47
|
+
|
48
|
+
## Copyright
|
49
|
+
******************************************************************************
|
50
|
+
Copyright (c) 2010 Filip H.F. "FiXato" Slagter. See LICENSE for details.
|
51
|
+
|
52
|
+
|
53
|
+
******************************************************************************
|
54
|
+
[1]: https://openmsx.svn.sourceforge.net/svnroot/openmsx/openmsx/trunk (openMSX SVN Trunk)
|
55
|
+
[2]: https://openmsx.svn.sourceforge.net/svnroot/openmsx/openmsx-debugger/trunk (openMSX-Debugger SVN Trunk)
|
56
|
+
[3]: http://openmsx.sf.net (openMSX at SourceForge.net)
|
57
|
+
[4]: http://en.wikipedia.org/wiki/Secure_copy (Secure Copy (or SCP) at Wikipedia)
|
58
|
+
[5]: http://openmsx.fixato.net (openMSX.FiXato.net ~ Home of openMSX-Builder)
|
59
|
+
[6]: http://twitter.com/openmsx_builder (openMSX-Builder's Twitter account)
|
60
|
+
[7]: http://github.com/moomerman/twitter_oauth (twitter_oauth gem's Github page)
|
61
|
+
[8]: http://twitter.com/oauth (create a Twitter oAuth Application)
|
62
|
+
[9]: http://apiwiki.twitter.com/Authentication (read the Twitter Authentication wiki on oAuth)
|
data/Rakefile
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
begin
|
2
|
+
require 'jeweler'
|
3
|
+
Jeweler::Tasks.new do |gemspec|
|
4
|
+
gemspec.name = "openMSX-builder"
|
5
|
+
gemspec.summary = "Builds the latest openMSX and openMSX-Debugger for Mac OSX from SVN and publishes it via scp while tweeting about the new release."
|
6
|
+
gemspec.description = "openMSX-Builder is used for building the latest SVN checkouts of openMSX and openMSX-Debugger from their sourceforge repository.
|
7
|
+
It also supports publishing the created builds to an external location via scp, announcing successfully published builds via Twitter and reporting build-errors via e-mail."
|
8
|
+
gemspec.email = "fixato@gmail.com"
|
9
|
+
gemspec.homepage = "http://github.com/FiXato/openMSX-builder"
|
10
|
+
gemspec.authors = ['Filip H.F. "FiXato" Slagter']
|
11
|
+
gemspec.add_development_dependency "rspec", ">= 1.2.9"
|
12
|
+
gemspec.add_dependency "twitter_oauth", ">= 0.3.3"
|
13
|
+
gemspec.add_dependency "mail", ">= 2.1.3"
|
14
|
+
gemspec.has_rdoc = false
|
15
|
+
# gemspec is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 and http://wiki.github.com/technicalpickles/jeweler/customizing-your-projects-gem-specification for additional settings
|
16
|
+
end
|
17
|
+
Jeweler::GemcutterTasks.new
|
18
|
+
rescue LoadError
|
19
|
+
puts "Jeweler not available. Install it with: gem install jeweler"
|
20
|
+
end
|
21
|
+
|
22
|
+
require 'spec/rake/spectask'
|
23
|
+
Spec::Rake::SpecTask.new(:spec) do |spec|
|
24
|
+
spec.libs << 'lib' << 'spec'
|
25
|
+
spec.spec_files = FileList['spec/**/*_spec.rb']
|
26
|
+
end
|
27
|
+
|
28
|
+
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
29
|
+
spec.libs << 'lib' << 'spec'
|
30
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
31
|
+
spec.rcov = true
|
32
|
+
end
|
33
|
+
|
34
|
+
task :spec => :check_dependencies
|
35
|
+
|
36
|
+
task :default => :spec
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.0.1
|
data/bin/build_openmsx
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Automatic builder for openMSX and openMSX-Debugger builds for Mac OSX.
|
3
|
+
# Options:
|
4
|
+
# --debug => Generate debug output.
|
5
|
+
# --publish => Publish the created build
|
6
|
+
# --publish-current => Only publish the current build and exit
|
7
|
+
# --publish-all => Only publish all previously created builds and exit
|
8
|
+
# --tweet => Send a tweet via @openMSX_Builder after successfully having published a build
|
9
|
+
# --dont-update => Don't update the SVN repository
|
10
|
+
# --report-build-failure => If an error occurs during build, report failure via e-mail
|
11
|
+
require 'rubygems'
|
12
|
+
require 'mail'
|
13
|
+
require 'yaml'
|
14
|
+
require 'twitter_oauth'
|
15
|
+
load './lib/debug_tools.rb'
|
16
|
+
require './lib/tweet_msx'
|
17
|
+
require './lib/openmsx_builder'
|
18
|
+
include DebugTools
|
19
|
+
|
20
|
+
debug('-'*50)
|
21
|
+
debug("Starting with openMSX")
|
22
|
+
OpenmsxBuilder.new(ARGV,:openmsx).run
|
23
|
+
debug('-'*50)
|
24
|
+
debug("Proceeding with openMSX-Debugger")
|
25
|
+
OpenmsxBuilder.new(ARGV,:openmsx_debugger).run
|
data/lib/debug_tools.rb
ADDED
@@ -0,0 +1,269 @@
|
|
1
|
+
load 'lib/debug_tools.rb'
|
2
|
+
class OpenmsxBuilder
|
3
|
+
include DebugTools
|
4
|
+
class NotConfigured < RuntimeError;end
|
5
|
+
CONFIG_FILENAME = File.expand_path('~/.openMSX-builder.yaml')
|
6
|
+
DEFAULTS = {
|
7
|
+
:projects => {
|
8
|
+
:openmsx => {
|
9
|
+
:source_dir => File.expand_path("~/Development/openMSX"),
|
10
|
+
:builds_subdir => 'derived/x86-darwin-opt-3rd',
|
11
|
+
:report_bcc => [],
|
12
|
+
:report_from => "openMSX auto-builder by FiXato <username@mailhost.example>",
|
13
|
+
:nice_name => 'openMSX',
|
14
|
+
:publish_location => 'ssh_host:path/to/existing/publish/dir',
|
15
|
+
:site_path => 'http://your.host.example/publish/dir',
|
16
|
+
},
|
17
|
+
:openmsx_debugger => {
|
18
|
+
:source_dir => File.expand_path("~/Development/openmsx-debugger"),
|
19
|
+
:builds_subdir => 'derived',
|
20
|
+
:report_bcc => [],
|
21
|
+
:report_from => "openMSX auto-builder by FiXato <username@mailhost.example>",
|
22
|
+
:nice_name => 'openMSX Debugger',
|
23
|
+
:publish_location => 'ssh_host:path/to/existing/publish/dir',
|
24
|
+
:site_path => 'http://your.host.example/publish/dir',
|
25
|
+
},
|
26
|
+
},
|
27
|
+
:smtp_settings => {
|
28
|
+
:address => "mail.example",
|
29
|
+
:port => 25,
|
30
|
+
:domain => 'mail.example',
|
31
|
+
:user_name => 'username@mailhost.example',
|
32
|
+
:password => '',
|
33
|
+
:authentication => :plain,
|
34
|
+
:enable_starttls_auto => true
|
35
|
+
},
|
36
|
+
}
|
37
|
+
|
38
|
+
attr_accessor :type
|
39
|
+
def initialize(options,type=:openmsx)
|
40
|
+
@type = type
|
41
|
+
@current_revision = `svnversion -n #{setting(:source_dir)}`.to_i
|
42
|
+
@options = options
|
43
|
+
@fails = 0
|
44
|
+
config
|
45
|
+
rescue NotConfigured => e
|
46
|
+
puts e.message
|
47
|
+
exit
|
48
|
+
end
|
49
|
+
|
50
|
+
def config
|
51
|
+
create_default_config unless File.exist?(CONFIG_FILENAME)
|
52
|
+
@config ||= YAML.load_file(CONFIG_FILENAME)
|
53
|
+
raise NotConfigured.new("You need to set up your config file at #{CONFIG_FILENAME} first") if @config == DEFAULTS
|
54
|
+
@config
|
55
|
+
end
|
56
|
+
|
57
|
+
def create_default_config
|
58
|
+
system("mkdir -p #{File.dirname(CONFIG_FILENAME)}")
|
59
|
+
File.open(CONFIG_FILENAME,'w') do |f|
|
60
|
+
f.write DEFAULTS.to_yaml
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def setting(key)
|
65
|
+
config[:projects][type][key]
|
66
|
+
end
|
67
|
+
|
68
|
+
def run
|
69
|
+
if @options.include?('--publish-all')
|
70
|
+
publish_all
|
71
|
+
return
|
72
|
+
end
|
73
|
+
if @options.include?('--publish-current')
|
74
|
+
publish_current
|
75
|
+
return
|
76
|
+
end
|
77
|
+
debug "openMSX is currently at #{@current_revision}."
|
78
|
+
update_svn
|
79
|
+
if @new_revision >= @current_revision
|
80
|
+
debug "Revision #{@new_revision} is not older than #{@current_revision}. Proceeding with build."
|
81
|
+
build
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
private
|
86
|
+
def archive(infile,outfile)
|
87
|
+
`cd #{File.dirname(infile)} && tar --bzip2 -cf #{outfile} #{File.basename(infile)}`
|
88
|
+
end
|
89
|
+
|
90
|
+
def dmg_for_revision?(revision)
|
91
|
+
return false unless openmsx?
|
92
|
+
files = Dir.glob(File.join(setting(:source_dir),setting(:builds_subdir),"openmsx-*-#{revision}-mac-x86-bin.dmg"))
|
93
|
+
debug files.to_yaml unless files.size == 0
|
94
|
+
files.size > 0
|
95
|
+
end
|
96
|
+
|
97
|
+
def archive_for_revision?(revision)
|
98
|
+
return false unless openmsx_debugger?
|
99
|
+
filename = File.join(setting(:source_dir),setting(:builds_subdir),"openMSX-debugger-#{revision}-mac-x86.tbz")
|
100
|
+
debug filename
|
101
|
+
File.exist?(filename)
|
102
|
+
end
|
103
|
+
|
104
|
+
def publish_build(revision,infile,outfile='',location=setting(:publish_location))
|
105
|
+
debug ""
|
106
|
+
outfile = File.basename(infile) if outfile == ''
|
107
|
+
destination = File.join(location,outfile)
|
108
|
+
debug "Will publish #{infile} to #{setting(:publish_location)} now."
|
109
|
+
publish_output = `scp -p "#{infile}" #{destination}`
|
110
|
+
debug publish_output unless publish_output.nil? || publish_output.strip == ''
|
111
|
+
url = File.join(setting(:site_path),File.basename(destination))
|
112
|
+
twitter_update = tweetmsx.update("[#{setting(:nice_name)}] Revision #{revision} is now available:\r\n #{url}") if @options.include?('--tweet')
|
113
|
+
debug(twitter_update) unless twitter_update.nil?
|
114
|
+
nil
|
115
|
+
rescue TweetMsx::NotConfigured => e
|
116
|
+
debug e.message
|
117
|
+
end
|
118
|
+
|
119
|
+
def publish
|
120
|
+
if openmsx?
|
121
|
+
archive_name = Dir.glob(File.join(setting(:source_dir),setting(:builds_subdir),"openmsx-*-#{@new_revision}-mac-x86-bin.dmg")).first
|
122
|
+
elsif openmsx_debugger?
|
123
|
+
archive_name = File.join(setting(:source_dir),setting(:builds_subdir),"openMSX-debugger-#{@new_revision}-mac-x86.tbz")
|
124
|
+
archive(File.join(setting(:source_dir),setting(:builds_subdir),'openMSX_Debugger.app'),File.basename(archive_name))
|
125
|
+
end
|
126
|
+
publish_build(@new_revision, archive_name)
|
127
|
+
nil
|
128
|
+
end
|
129
|
+
|
130
|
+
def publish_all
|
131
|
+
debug "Publishing all #{@type} builds found"
|
132
|
+
if openmsx?
|
133
|
+
files = Dir.glob(File.join(setting(:source_dir),setting(:builds_subdir),"openmsx-*-mac-x86-bin.dmg")).sort.map do |f|
|
134
|
+
if f =~ /openmsx-.+-(\d+)-mac-x86-bin.dmg$/
|
135
|
+
rev = $1
|
136
|
+
else
|
137
|
+
rev = 'unknown'
|
138
|
+
end
|
139
|
+
[rev,f]
|
140
|
+
end
|
141
|
+
elsif openmsx_debugger?
|
142
|
+
files = Dir.glob(File.join(setting(:source_dir),setting(:builds_subdir),'openMSX-debugger-*-mac-x86.tbz')).sort.map do |f|
|
143
|
+
if f =~ /openMSX-debugger-(\d+)-mac-x86.tbz$/
|
144
|
+
rev = $1
|
145
|
+
else
|
146
|
+
rev = 'unknown'
|
147
|
+
end
|
148
|
+
[rev,f]
|
149
|
+
end
|
150
|
+
end
|
151
|
+
files.each do |rev,file|
|
152
|
+
publish_build(rev,file)
|
153
|
+
end
|
154
|
+
nil
|
155
|
+
end
|
156
|
+
|
157
|
+
def publish_current
|
158
|
+
if openmsx?
|
159
|
+
archive_name = Dir.glob(File.join(setting(:source_dir),setting(:builds_subdir),"openmsx-*-#{@current_revision}-mac-x86-bin.dmg")).first
|
160
|
+
elsif openmsx_debugger?
|
161
|
+
archive_name = File.join(setting(:source_dir),setting(:builds_subdir),"openMSX-debugger-#{@current_revision}-mac-x86.tbz")
|
162
|
+
archive(File.join(setting(:source_dir),setting(:builds_subdir),'openMSX_Debugger.app'),File.basename(archive_name))
|
163
|
+
end
|
164
|
+
publish_build(@current_revision, archive_name)
|
165
|
+
nil
|
166
|
+
end
|
167
|
+
|
168
|
+
def update_svn
|
169
|
+
if @options.include?('--dont-update')
|
170
|
+
update = 'Update skipped'
|
171
|
+
else
|
172
|
+
debug "Proceeding with update."
|
173
|
+
update = `cd #{setting(:source_dir)} && svn up`
|
174
|
+
end
|
175
|
+
@new_revision = `svnversion -n #{setting(:source_dir)}`.to_i
|
176
|
+
debug update
|
177
|
+
debug "Now at revision #{@new_revision}"
|
178
|
+
nil
|
179
|
+
end
|
180
|
+
|
181
|
+
def tweetmsx
|
182
|
+
@tweetmsx ||= TweetMsx.new
|
183
|
+
end
|
184
|
+
|
185
|
+
def build
|
186
|
+
if openmsx?
|
187
|
+
if dmg_for_revision?(@new_revision)
|
188
|
+
debug "Revision already build as #{Dir.glob(File.join(setting(:source_dir),setting(:builds_subdir),"openmsx-*-#{@new_revision}-mac-x86-bin.dmg")).first}"
|
189
|
+
return nil
|
190
|
+
end
|
191
|
+
cleanup_dmg_locks
|
192
|
+
elsif openmsx_debugger?
|
193
|
+
if archive_for_revision?(@new_revision)
|
194
|
+
debug "Revision already build as #{File.join(setting(:source_dir),setting(:builds_subdir),"openMSX-debugger-#{@new_revision}-mac-x86.tbz")}"
|
195
|
+
return nil
|
196
|
+
end
|
197
|
+
end
|
198
|
+
debug("Will attempt to build revision #{@new_revision}.")
|
199
|
+
build_output = `cd #{setting(:source_dir)} && make clean && make #{'staticbindist' if openmsx?} 2>&1`
|
200
|
+
if $?.success?
|
201
|
+
debug "++++++SUCCESS++++++"
|
202
|
+
build_output.each_line do |line|
|
203
|
+
debug " %s" % line
|
204
|
+
end
|
205
|
+
publish if @options.include?('--publish')
|
206
|
+
nil
|
207
|
+
else
|
208
|
+
#Capture the weird random build error that seems to be more OSX related than openMSX related.
|
209
|
+
if build_output.include?('hdiutil: create failed - error 49168')
|
210
|
+
@fails += 1
|
211
|
+
debug build_output
|
212
|
+
debug "Weird bug (attempt #{@fails}/3)"
|
213
|
+
if @fails == 3
|
214
|
+
exit
|
215
|
+
else
|
216
|
+
return build
|
217
|
+
end
|
218
|
+
end
|
219
|
+
debug "!!!!!!FAILED!!!!!!"
|
220
|
+
build_output.each_line do |line|
|
221
|
+
debug " %s" % line
|
222
|
+
end
|
223
|
+
if @options.include?('--report-build-failure')
|
224
|
+
report_build_failure(build_output)
|
225
|
+
end
|
226
|
+
end
|
227
|
+
nil
|
228
|
+
end
|
229
|
+
|
230
|
+
def cleanup_dmg_locks
|
231
|
+
debug("Checking for existing filelocks on DMGs.")
|
232
|
+
locks = `/usr/sbin/lsof | grep #{@new_revision}-mac-x86-bin.dmg`
|
233
|
+
debug locks
|
234
|
+
locks.each_line do |lock_line|
|
235
|
+
pid = lock_line.split[1].to_i
|
236
|
+
debug "Killing pid #{pid} from lock '#{lock_line}'"
|
237
|
+
`kill -9 #{pid}`
|
238
|
+
end
|
239
|
+
end
|
240
|
+
|
241
|
+
def report_build_failure(build_output)
|
242
|
+
#TODO: Find out why I have to set these local vars due to problems with scope within Mail
|
243
|
+
revision = @new_revision
|
244
|
+
project_name = setting(:nice_name)
|
245
|
+
smtp_settings = config[:smtp_settings]
|
246
|
+
mail_from = setting(:report_from)
|
247
|
+
mail_bcc = setting(:report_bcc)
|
248
|
+
Mail.defaults do
|
249
|
+
delivery_method :smtp, smtp_settings
|
250
|
+
end
|
251
|
+
Mail.deliver do
|
252
|
+
from mail_from
|
253
|
+
to mail_from
|
254
|
+
bcc mail_bcc.join(', ')
|
255
|
+
subject "[FAIL] #{project_name} revision #{revision} failed to build"
|
256
|
+
content_type 'text/plain; charset=UTF-8'
|
257
|
+
content_transfer_encoding '8bit'
|
258
|
+
body "While trying to build revision #{revision} of #{project_name}, the daily auto-builder encountered an error. Below you will find the entire build report:\r\n\r\n" << build_output
|
259
|
+
end
|
260
|
+
end
|
261
|
+
|
262
|
+
def openmsx?
|
263
|
+
@type == :openmsx
|
264
|
+
end
|
265
|
+
|
266
|
+
def openmsx_debugger?
|
267
|
+
@type == :openmsx_debugger
|
268
|
+
end
|
269
|
+
end
|
data/lib/tweet_msx.rb
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
load 'lib/debug_tools.rb'
|
2
|
+
# Patch for Ruby 1.9.2
|
3
|
+
module Net
|
4
|
+
module HTTPHeader
|
5
|
+
alias_method :url_encode_original, :urlencode
|
6
|
+
def urlencode(str)
|
7
|
+
str = str.to_s if str.kind_of?(Symbol)
|
8
|
+
url_encode_original(str)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
class TweetMsx
|
13
|
+
include DebugTools
|
14
|
+
class NotConfigured < RuntimeError;end
|
15
|
+
CONFIG_FILENAME = File.expand_path('~/.openMSX-builder-TweetMSX.yaml')
|
16
|
+
DEFAULTS = {
|
17
|
+
:client => {
|
18
|
+
:consumer_key => '',
|
19
|
+
:consumer_secret => '',
|
20
|
+
:token => '',
|
21
|
+
:secret => '',
|
22
|
+
}
|
23
|
+
}
|
24
|
+
attr_reader :client, :twitter_down
|
25
|
+
def initialize
|
26
|
+
@client = TwitterOAuth::Client.new(config[:client])
|
27
|
+
end
|
28
|
+
|
29
|
+
def config
|
30
|
+
create_default_config unless File.exist?(CONFIG_FILENAME)
|
31
|
+
@config ||= YAML.load_file(CONFIG_FILENAME)
|
32
|
+
raise NotConfigured.new("You need to set up your config file at #{CONFIG_FILENAME} first") if @config == DEFAULTS
|
33
|
+
@config
|
34
|
+
end
|
35
|
+
|
36
|
+
def create_default_config
|
37
|
+
system("mkdir -p #{File.dirname(CONFIG_FILENAME)}")
|
38
|
+
File.open(CONFIG_FILENAME,'w') do |f|
|
39
|
+
f.write DEFAULTS.to_yaml
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def update(message)
|
44
|
+
debug "#{message} [#{message.size} chars]"
|
45
|
+
if @client.rate_limit_status == 0
|
46
|
+
debug "You've exceeded your rate limit"
|
47
|
+
return nil
|
48
|
+
end
|
49
|
+
puts message.to_yaml
|
50
|
+
@client.update(message.to_s)
|
51
|
+
nil
|
52
|
+
rescue SocketError
|
53
|
+
debug "Could not send '#{message}'. Twitter or your connection might be down."
|
54
|
+
nil
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{openMSX-builder}
|
8
|
+
s.version = "1.0.1"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Filip H.F. \"FiXato\" Slagter"]
|
12
|
+
s.date = %q{2010-03-06}
|
13
|
+
s.default_executable = %q{build_openmsx}
|
14
|
+
s.description = %q{openMSX-Builder is used for building the latest SVN checkouts of openMSX and openMSX-Debugger from their sourceforge repository.
|
15
|
+
It also supports publishing the created builds to an external location via scp, announcing successfully published builds via Twitter and reporting build-errors via e-mail.}
|
16
|
+
s.email = %q{fixato@gmail.com}
|
17
|
+
s.executables = ["build_openmsx"]
|
18
|
+
s.extra_rdoc_files = [
|
19
|
+
"LICENSE",
|
20
|
+
"README.markdown"
|
21
|
+
]
|
22
|
+
s.files = [
|
23
|
+
".gitignore",
|
24
|
+
"LICENSE",
|
25
|
+
"README.markdown",
|
26
|
+
"Rakefile",
|
27
|
+
"VERSION",
|
28
|
+
"bin/build_openmsx",
|
29
|
+
"lib/debug_tools.rb",
|
30
|
+
"lib/openmsx_builder.rb",
|
31
|
+
"lib/tweet_msx.rb",
|
32
|
+
"openMSX-builder.gemspec",
|
33
|
+
"spec/openMSX-builder_spec.rb",
|
34
|
+
"spec/spec.opts",
|
35
|
+
"spec/spec_helper.rb"
|
36
|
+
]
|
37
|
+
s.homepage = %q{http://github.com/FiXato/openMSX-builder}
|
38
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
39
|
+
s.require_paths = ["lib"]
|
40
|
+
s.rubygems_version = %q{1.3.6}
|
41
|
+
s.summary = %q{Builds the latest openMSX and openMSX-Debugger for Mac OSX from SVN and publishes it via scp while tweeting about the new release.}
|
42
|
+
s.test_files = [
|
43
|
+
"spec/openMSX-builder_spec.rb",
|
44
|
+
"spec/spec_helper.rb"
|
45
|
+
]
|
46
|
+
|
47
|
+
if s.respond_to? :specification_version then
|
48
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
49
|
+
s.specification_version = 3
|
50
|
+
|
51
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
52
|
+
s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
|
53
|
+
s.add_runtime_dependency(%q<twitter_oauth>, [">= 0.3.3"])
|
54
|
+
s.add_runtime_dependency(%q<mail>, [">= 2.1.3"])
|
55
|
+
else
|
56
|
+
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
57
|
+
s.add_dependency(%q<twitter_oauth>, [">= 0.3.3"])
|
58
|
+
s.add_dependency(%q<mail>, [">= 2.1.3"])
|
59
|
+
end
|
60
|
+
else
|
61
|
+
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
62
|
+
s.add_dependency(%q<twitter_oauth>, [">= 0.3.3"])
|
63
|
+
s.add_dependency(%q<mail>, [">= 2.1.3"])
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
data/spec/spec.opts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,119 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: openMSX-builder
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 1
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
version: 1.0.1
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Filip H.F. "FiXato" Slagter
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-03-06 00:00:00 +01:00
|
18
|
+
default_executable: build_openmsx
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: rspec
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 1
|
29
|
+
- 2
|
30
|
+
- 9
|
31
|
+
version: 1.2.9
|
32
|
+
type: :development
|
33
|
+
version_requirements: *id001
|
34
|
+
- !ruby/object:Gem::Dependency
|
35
|
+
name: twitter_oauth
|
36
|
+
prerelease: false
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
segments:
|
42
|
+
- 0
|
43
|
+
- 3
|
44
|
+
- 3
|
45
|
+
version: 0.3.3
|
46
|
+
type: :runtime
|
47
|
+
version_requirements: *id002
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: mail
|
50
|
+
prerelease: false
|
51
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
segments:
|
56
|
+
- 2
|
57
|
+
- 1
|
58
|
+
- 3
|
59
|
+
version: 2.1.3
|
60
|
+
type: :runtime
|
61
|
+
version_requirements: *id003
|
62
|
+
description: |-
|
63
|
+
openMSX-Builder is used for building the latest SVN checkouts of openMSX and openMSX-Debugger from their sourceforge repository.
|
64
|
+
It also supports publishing the created builds to an external location via scp, announcing successfully published builds via Twitter and reporting build-errors via e-mail.
|
65
|
+
email: fixato@gmail.com
|
66
|
+
executables:
|
67
|
+
- build_openmsx
|
68
|
+
extensions: []
|
69
|
+
|
70
|
+
extra_rdoc_files:
|
71
|
+
- LICENSE
|
72
|
+
- README.markdown
|
73
|
+
files:
|
74
|
+
- .gitignore
|
75
|
+
- LICENSE
|
76
|
+
- README.markdown
|
77
|
+
- Rakefile
|
78
|
+
- VERSION
|
79
|
+
- bin/build_openmsx
|
80
|
+
- lib/debug_tools.rb
|
81
|
+
- lib/openmsx_builder.rb
|
82
|
+
- lib/tweet_msx.rb
|
83
|
+
- openMSX-builder.gemspec
|
84
|
+
- spec/openMSX-builder_spec.rb
|
85
|
+
- spec/spec.opts
|
86
|
+
- spec/spec_helper.rb
|
87
|
+
has_rdoc: true
|
88
|
+
homepage: http://github.com/FiXato/openMSX-builder
|
89
|
+
licenses: []
|
90
|
+
|
91
|
+
post_install_message:
|
92
|
+
rdoc_options:
|
93
|
+
- --charset=UTF-8
|
94
|
+
require_paths:
|
95
|
+
- lib
|
96
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
segments:
|
101
|
+
- 0
|
102
|
+
version: "0"
|
103
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - ">="
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
segments:
|
108
|
+
- 0
|
109
|
+
version: "0"
|
110
|
+
requirements: []
|
111
|
+
|
112
|
+
rubyforge_project:
|
113
|
+
rubygems_version: 1.3.6
|
114
|
+
signing_key:
|
115
|
+
specification_version: 3
|
116
|
+
summary: Builds the latest openMSX and openMSX-Debugger for Mac OSX from SVN and publishes it via scp while tweeting about the new release.
|
117
|
+
test_files:
|
118
|
+
- spec/openMSX-builder_spec.rb
|
119
|
+
- spec/spec_helper.rb
|