AutoZest 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG ADDED
@@ -0,0 +1,4 @@
1
+ = 0.0.1
2
+ === Monday December 10, 2007
3
+
4
+ * Initial Release
data/COPYING ADDED
@@ -0,0 +1,55 @@
1
+ AutoZest is copyrighted free software by Wayne E. Seguin
2
+ <wayneeseguin at gmail dot com> You can redistribute it and/or modify it under
3
+ either the terms of the MIT or the conditions below:
4
+
5
+ 1. You may make and give away verbatim copies of the source form of the
6
+ software without restriction, provided that you duplicate all of the
7
+ original copyright notices and associated disclaimers.
8
+
9
+ 2. You may modify your copy of the software in any way, provided that
10
+ you do at least ONE of the following:
11
+
12
+ a) place your modifications in the Public Domain or otherwise make them
13
+ Freely Available, such as by posting said modifications to Usenet or an
14
+ equivalent medium, or by allowing the author to include your
15
+ modifications in the software.
16
+
17
+ b) use the modified software only within your corporation or
18
+ organization.
19
+
20
+ c) rename any non-standard executables so the names do not conflict with
21
+ standard executables, which must also be provided.
22
+
23
+ d) make other distribution arrangements with the author.
24
+
25
+ 3. You may distribute the software in object code or executable
26
+ form, provided that you do at least ONE of the following:
27
+
28
+ a) distribute the executables and library files of the software,
29
+ together with instructions (in the manual page or equivalent) on where
30
+ to get the original distribution.
31
+
32
+ b) accompany the distribution with the machine-readable source of the
33
+ software.
34
+
35
+ c) give non-standard executables non-standard names, with
36
+ instructions on where to get the original software distribution.
37
+
38
+ d) make other distribution arrangements with the author.
39
+
40
+ 4. You may modify and include the part of the software into any other
41
+ software (possibly commercial). But some files in the distribution
42
+ are not written by the author, so that they are not under this terms.
43
+
44
+ 5. The scripts and library files supplied as input to or produced as
45
+ output from the software do not automatically fall under the
46
+ copyright of the software, but belong to whomever generated them,
47
+ and may be sold commercially, and may be aggregated with this
48
+ software.
49
+
50
+ 6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
51
+ IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
52
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
53
+ PURPOSE.
54
+
55
+
data/README ADDED
@@ -0,0 +1,27 @@
1
+ = About
2
+
3
+ AutoZest is an autotest extension
4
+
5
+ = Author
6
+
7
+ Wayne E. Seguin (wayneeseguin at gmail dot com)
8
+
9
+ = Features
10
+
11
+ * automated growl installation
12
+ $ autozest install growl
13
+
14
+ * generation of .autotest with growl & autozest config
15
+ $ autozest setup autotest
16
+
17
+ * generation of .autozest.yml config file
18
+ $ autozest setup
19
+
20
+ * autozest.sqlite3 database file for pulling random messages based on severity, update via:
21
+ $ autozest update
22
+
23
+ Notes:
24
+
25
+ * config file can specify extra image fetching options
26
+ * dependency: ZenTest
27
+
data/Rakefile ADDED
@@ -0,0 +1,204 @@
1
+ require "rake"
2
+ require "rake/clean"
3
+ require "rake/gempackagetask"
4
+ require "rake/rdoctask"
5
+ require "fileutils" ; include FileUtils
6
+ require "yaml"
7
+ require "lib/autozest"
8
+
9
+ ##############################################################################
10
+ # Constants
11
+ ##############################################################################
12
+ GemName = "AutoZest"
13
+ Version = "0.0.1"
14
+ Title = "Refreshing Taunts"
15
+ Summary = "AutoZest < ZenTest::AutoTest extension for growl & custom messages"
16
+ Authors = "Wayne E. Seguin, Lance Carlson"
17
+ Emails = "wayneeseugin@gmail.com, lancecarlson@gmail.com"
18
+ Homepage = "http://autozest.rubyforge.org"
19
+
20
+ ##############################################################################
21
+ # Gem Management
22
+ ##############################################################################
23
+ GEM_NAME = "AutoZest"
24
+ GEM_VERSION = AutoZest::Version
25
+ RDocOptions = [
26
+ "--quiet", "--title", "#{GEM_NAME}-#{GEM_VERSION} Reference", "--main", "README", "--inline-source"
27
+ ]
28
+
29
+ @config_file = "~/.rubyforge/user-config.yml"
30
+ @config = nil
31
+
32
+ def rubyforge_username
33
+ unless @config
34
+ begin
35
+ @config = YAML.load(File.read(File.expand_path(@config_file)))
36
+ rescue
37
+ puts <<-EOS
38
+ ERROR: No rubyforge config file found: #{@config_file}"
39
+ Run 'rubyforge setup' to prepare your env for access to Rubyforge
40
+ - See http://newgem.rubyforge.org/rubyforge.html for more details
41
+ EOS
42
+ exit
43
+ end
44
+ end
45
+ @rubyforge_username ||= @config["username"]
46
+ end
47
+
48
+ desc "Packages up #{GemName}."
49
+ task :package# => [:clean]
50
+
51
+ desc "Releases packages for #{GemName}."
52
+ task :release => [:package]
53
+
54
+ spec =
55
+ Gem::Specification.new do | specification |
56
+ specification.name = GemName
57
+ specification.version = Version
58
+ specification.platform = Gem::Platform::RUBY
59
+ specification.has_rdoc = true
60
+ specification.extra_rdoc_files = ["README", "CHANGELOG", "COPYING"]
61
+ specification.rdoc_options += RDocOptions
62
+ specification.summary = Summary
63
+ specification.description = Summary
64
+ specification.author = Authors
65
+ specification.email = Emails
66
+ specification.homepage = Homepage
67
+
68
+
69
+ specification.extra_rdoc_files = ["README", "CHANGELOG", "COPYING"]
70
+ specification.summary = "a threadsafe non-blocking asynchronous configurable logger for Ruby."
71
+ specification.description = specification.summary
72
+ specification.author = "Wayne E. Seguin"
73
+ specification.email = "wayneeseguin at gmail dot com"
74
+ specification.homepage = "alogr.rubyforge.org"
75
+
76
+ specification.files = %w(COPYING README Rakefile) +
77
+ Dir.glob("{bin,doc,test,lib,extras}/**/*")
78
+
79
+ specification.require_path = "lib"
80
+
81
+ specification.bindir = "bin"
82
+ end
83
+
84
+ Rake::GemPackageTask.new(spec) do | package |
85
+ package.need_tar = true
86
+ package.gem_spec = spec
87
+ end
88
+
89
+ task "lib" do
90
+ directory "lib"
91
+ end
92
+
93
+ task :install do
94
+ sh %{rake package}
95
+ sh %{sudo gem install pkg/#{GEM_NAME}-#{GEM_VERSION}.gem}
96
+ end
97
+
98
+ task :uninstall do
99
+ sh %{sudo gem uninstall #{GEM_NAME}.gem}
100
+ end
101
+
102
+
103
+ #
104
+ # Website tasks using webgen
105
+ #
106
+
107
+ desc "Generate and upload website files"
108
+ task :website => [:generate_website, :upload_website, :generate_rdoc, :upload_rdoc]
109
+
110
+ task :generate_website do
111
+ # ruby atom.rb > output/feed.atom
112
+ sh %{pushd website; webgen; popd }
113
+ end
114
+
115
+ task :generate_rdoc do
116
+ sh %{rake rdoc}
117
+ end
118
+
119
+ desc "Upload website files to rubyforge"
120
+ task :upload_website do
121
+ sh %{rsync -avz website/output/ #{rubyforge_username}@rubyforge.org:/var/www/gforge-projects/#{GEM_NAME}/}
122
+ end
123
+
124
+ desc "Upload rdoc files to rubyforge"
125
+ task :upload_rdoc do
126
+ sh %{rsync -avz doc/rdoc/ #{rubyforge_username}@rubyforge.org:/var/www/gforge-projects/#{GEM_NAME}/rdoc}
127
+ end
128
+
129
+ desc "Release the website and new gem version"
130
+ task :deploy => [:check_version, :website, :release] do
131
+ puts "Remember to create SVN tag:"
132
+ puts "svn copy svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/trunk " +
133
+ "svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/tags/REL-#{GEM_VERSION} "
134
+ puts "Suggested comment:"
135
+ puts "Tagging release #{CHANGES}"
136
+ end
137
+
138
+ desc "Runs tasks website_generate and install_gem as a local deployment of the gem"
139
+ task :local_deploy => [:website_generate, :install_gem]
140
+
141
+ task :check_version do
142
+ unless ENV["VERSION"]
143
+ puts "Must pass a VERSION=x.y.z release version"
144
+ exit
145
+ end
146
+ unless ENV["VERSION"] == GEM_VERSION
147
+ puts "Please update your version.rb to match the release version, currently #{GEM_VERSION}"
148
+ exit
149
+ end
150
+ end
151
+
152
+ ##############################################################################
153
+ # rSpec
154
+ ##############################################################################
155
+
156
+ require "spec/rake/spectask"
157
+
158
+ desc "Run specs with coverage"
159
+ Spec::Rake::SpecTask.new("spec") do |spec_task|
160
+ spec_task.spec_opts = File.read("spec/spec.opts").split("\n")
161
+ spec_task.spec_files = FileList["spec/*_spec.rb"].sort
162
+ spec_task.rcov = true
163
+ end
164
+
165
+ desc "Run specs without coverage"
166
+ Spec::Rake::SpecTask.new("spec_no_cov") do |spec_task|
167
+ spec_task.spec_opts = File.read("spec/spec.opts").split("\n")
168
+ spec_task.spec_files = FileList["spec/*_spec.rb"].sort
169
+ end
170
+
171
+ desc "Run all specs with coverage"
172
+ Spec::Rake::SpecTask.new("specs") do |spec_task|
173
+ spec_task.spec_opts = File.read("spec/spec.opts").split("\n")
174
+ spec_task.spec_files = FileList["spec/**/*_spec.rb"].sort
175
+ spec_task.rcov = true
176
+ end
177
+
178
+ desc "Run all specs without coverage"
179
+ Spec::Rake::SpecTask.new("specs_no_cov") do |spec_task|
180
+ spec_task.spec_opts = File.read("spec/spec.opts").split("\n")
181
+ spec_task.spec_files = FileList["spec/**/*_spec.rb"].sort
182
+ end
183
+
184
+ desc "Run all specs and output html"
185
+ Spec::Rake::SpecTask.new("specs_html") do |spec_task|
186
+ spec_task.spec_opts = ["--format", "html"]
187
+ spec_task.spec_files = Dir["spec/**/*_spec.rb"].sort
188
+ end
189
+
190
+ ##############################################################################
191
+ # Statistics
192
+ ##############################################################################
193
+
194
+ STATS_DIRECTORIES = [
195
+ %w(Code lib/),
196
+ %w(Spec spec/)
197
+ ].collect { |name, dir| [ name, "./#{dir}" ] }.select { |name, dir| File.directory?(dir) }
198
+
199
+ desc "Report code statistics (KLOCs, etc) from the application"
200
+ task :stats do
201
+ require "extra/stats"
202
+ verbose = true
203
+ CodeStatistics.new(*STATS_DIRECTORIES).to_s
204
+ end
data/bin/autozest ADDED
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/ruby
2
+
3
+ # TODO: parse command line options and call appropriate modulerequire "rubigen"
4
+ require "autozest"
5
+
6
+ if %w(-v --version).include? ARGV.first
7
+ puts "#{File.basename($0)} #{AutoZest::VERSION::STRING}"
8
+ exit(0)
9
+ end
10
+
11
+ require "rubigen/scripts/generate"
12
+ RubiGen::Base.use_application_sources!
13
+ RubiGen::Scripts::Generate.new.run(ARGV, :generator => "autozest")
data/bin/install ADDED
@@ -0,0 +1,6 @@
1
+ #!/bin/bash
2
+ mkdir -p $HOME/.autozest/images
3
+ cp $HOME/.autotest $HOME/.autotest.autozest.backup
4
+ cp examples/dot_autotest $HOME/.autotest
5
+ cp examples/config.yml $HOME/.autozest/config.yml
6
+ cp images/*.png $HOME/.autozest/images/
data/bin/spec ADDED
@@ -0,0 +1,19 @@
1
+ #!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
2
+ #
3
+ # This file was generated by RubyGems.
4
+ #
5
+ # The application 'rspec' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'rubygems'
10
+
11
+ version = ">= 0"
12
+
13
+ if ARGV.first =~ /^_(.*)_$/ and Gem::Version.correct? $1 then
14
+ version = $1
15
+ ARGV.shift
16
+ end
17
+
18
+ gem 'rspec', version
19
+ load 'spec'
@@ -0,0 +1,29 @@
1
+ # AutoZest::Config
2
+ module AutoZest
3
+ class Config
4
+
5
+ # Setup config and read in yml configuration file.
6
+ class << self
7
+ @@config_file = "#{`echo $HOME`.strip}/.autozest/config.yml"
8
+ @@config ||= Erubis.load_yaml_file(@@config_file)
9
+
10
+ # Allow for calling keys as methods on Config object
11
+ #def method_missing(method,*arguments)
12
+ # if config.has_key?(method.to_sym)
13
+ # config[method]
14
+ # else
15
+ # super(method,*arguments)
16
+ # end
17
+ #end
18
+
19
+ end
20
+
21
+ # direct config lookup
22
+ # AutoZest::Config[:some_key]
23
+ def self.[](key)
24
+ @@config[key]
25
+ end
26
+
27
+ end
28
+
29
+ end
@@ -0,0 +1,4 @@
1
+ module AutoZest
2
+ class Generator
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module AutoZest
2
+ class Installer
3
+ end
4
+ end
@@ -0,0 +1,84 @@
1
+ module AutoZest
2
+ class Notifier
3
+ class << self
4
+
5
+ attr_accessor :examples, :failures, :pending
6
+
7
+ # Sends the command to the console (Only supports Growl at the moment)
8
+ def notify!(results)
9
+ parse(results)
10
+ # TODO: this should all come from config
11
+ if AutoZest::Config[:notifier] == "gnome"
12
+ # TODO: deal with it :-p
13
+ else
14
+ # default is growl
15
+ cmd = AutoZest::Config[:notifier_uri]
16
+ cmd << " -a #{AutoZest::Config[:application]}" # name of the app?
17
+ cmd << " -n #{AutoZest::Config[:application]}" # the name of the application that sends the notification, default: growlnotify
18
+ cmd << " --image #{image}" if image
19
+ cmd << " -m '#{message}'"
20
+ cmd << " --title #{title}" unless title.empty?
21
+ end
22
+ puts "<i> #{message}"
23
+ system(cmd)
24
+ end
25
+
26
+ private
27
+
28
+ # returns a message string based on the number of failures
29
+ def message
30
+ # for now we'll test with this
31
+ # TODO: hookup to database
32
+ # "SELECT message FROM messages ORDER BY failures DESC WHERE severity <= #{failures}").first
33
+ if failures <= 0
34
+ "w00t!!! All #{@examples} examples passed!!!" # You want me to copy it over or do you got it? I remember there being something funky with SEE
35
+ elsif failures < 10
36
+ "Cleanup aisle #{failures}... there were #{failures} failing specs)."
37
+ elsif failures < 25
38
+ "Reconstruction time... there were #{failures} failing spec."
39
+ elsif failures < 50
40
+ "Things are getting pretty bad... #{failures} failing specs!!!"
41
+ elsif failures > 50
42
+ "Dude, you really messed up... #{failures} failing specs!!!"
43
+ elsif failures > 100
44
+ "is anyone looking? Quick, revert! #{failures} failing specs!!!"
45
+ elsif failures > 200
46
+ "is the computer even on? (#{failures} failing specs!!! "
47
+ else
48
+ "There was an error running the specs"
49
+ end
50
+
51
+ end
52
+
53
+ # returns a image URI based on the number of errors
54
+ def image
55
+ # For now:
56
+ if failures <= 0
57
+ # "~/.autozest/images/pass.png"
58
+ AutoZest::Config[:images][:pass_uri]
59
+ elsif failures > 0
60
+ AutoZest::Config[:images][:fail_uri]
61
+ # "~/.autozest/images/fail.png"
62
+ end
63
+ end
64
+
65
+ # returns a string representing the title.
66
+ def title
67
+ # TODO: implement this, gNotify requires a title?
68
+ # To be compatible with gNotify the following switch is accepted:
69
+ # -t,--title Does nothing. Any text following will be treated as the
70
+ # title because that's the default argument behaviour
71
+ ""
72
+ end
73
+
74
+ def parse(results)
75
+ # TODO: Verifiy that test / test::unit both spitout errors in the
76
+ # same order as rspec. If not we have to adjust below slightly.
77
+ @examples, @failures, @pending = results.scan(/(\d+)/).map{ |d| d.first.to_i }
78
+ end
79
+
80
+ end
81
+
82
+ end
83
+
84
+ end
@@ -0,0 +1,4 @@
1
+ module AutoZest
2
+ class Updater
3
+ end
4
+ end
data/lib/autozest.rb ADDED
@@ -0,0 +1,15 @@
1
+ require "yaml"
2
+ require "erubis"
3
+ #require "sequel"
4
+ # http://code.google.com/p/ruby-sequel/wiki/CheatSheetrequire "#{File.dirname(__FILE__)}/autozest/installer"
5
+
6
+ require "#{File.dirname(__FILE__)}/erubis_ext"
7
+ require "#{File.dirname(__FILE__)}/autozest/config"
8
+ require "#{File.dirname(__FILE__)}/autozest/notifier"
9
+ require "#{File.dirname(__FILE__)}/autozest/updater"
10
+ require "#{File.dirname(__FILE__)}/autozest/generator"
11
+ require "#{File.dirname(__FILE__)}/autozest/installer"
12
+
13
+ module AutoZest
14
+ Version = "0.0.1"
15
+ end
data/lib/erubis_ext.rb ADDED
@@ -0,0 +1,9 @@
1
+ module Erubis
2
+ class MEruby < Erubis::Eruby
3
+ include PercentLineEnhancer
4
+ include StringBufferEnhancer
5
+ end
6
+ def self.load_yaml_file(file, binding = binding)
7
+ YAML::load(Erubis::MEruby.new(IO.read(File.expand_path(file))).result(binding))
8
+ end
9
+ end
metadata ADDED
@@ -0,0 +1,74 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: AutoZest
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Wayne E. Seguin
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2007-12-11 00:00:00 -05:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: a threadsafe non-blocking asynchronous configurable logger for Ruby.
17
+ email: wayneeseguin at gmail dot com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - README
24
+ - CHANGELOG
25
+ - COPYING
26
+ files:
27
+ - COPYING
28
+ - README
29
+ - Rakefile
30
+ - bin/autozest
31
+ - bin/install
32
+ - bin/spec
33
+ - lib/autozest
34
+ - lib/autozest/config.rb
35
+ - lib/autozest/generator.rb
36
+ - lib/autozest/installer.rb
37
+ - lib/autozest/notifier.rb
38
+ - lib/autozest/updater.rb
39
+ - lib/autozest.rb
40
+ - lib/erubis_ext.rb
41
+ - CHANGELOG
42
+ has_rdoc: true
43
+ homepage: alogr.rubyforge.org
44
+ post_install_message:
45
+ rdoc_options:
46
+ - --quiet
47
+ - --title
48
+ - AutoZest-0.0.1 Reference
49
+ - --main
50
+ - README
51
+ - --inline-source
52
+ require_paths:
53
+ - lib
54
+ required_ruby_version: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: "0"
59
+ version:
60
+ required_rubygems_version: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: "0"
65
+ version:
66
+ requirements: []
67
+
68
+ rubyforge_project:
69
+ rubygems_version: 0.9.5
70
+ signing_key:
71
+ specification_version: 2
72
+ summary: a threadsafe non-blocking asynchronous configurable logger for Ruby.
73
+ test_files: []
74
+