Permalink
Browse files

Initial commit; basic functionality works with zero configurability (…

…next version coming this weekend will have sweet, sweet DSL goodness)
  • Loading branch information...
0 parents commit 1117219da483ea4d0e6b4f84efb7b8a3a92fda2c @jm committed Jul 30, 2010
Showing with 305 additions and 0 deletions.
  1. +5 −0 .document
  2. +21 −0 .gitignore
  3. +20 −0 LICENSE
  4. +25 −0 README.rdoc
  5. +54 −0 Rakefile
  6. +1 −0 VERSION
  7. +4 −0 bin/primadoro
  8. +105 −0 lib/primadoro.rb
  9. +54 −0 primadoro.gemspec
  10. BIN resources/bell.mp3
  11. BIN resources/windup.wav
  12. +9 −0 test/helper.rb
  13. +7 −0 test/test_primadoro.rb
@@ -0,0 +1,5 @@
+README.rdoc
+lib/**/*.rb
+bin/*
+features/**/*.feature
+LICENSE
@@ -0,0 +1,21 @@
+## MAC OS
+.DS_Store
+
+## TEXTMATE
+*.tmproj
+tmtags
+
+## EMACS
+*~
+\#*
+.\#*
+
+## VIM
+*.swp
+
+## PROJECT::GENERAL
+coverage
+rdoc
+pkg
+
+## PROJECT::SPECIFIC
@@ -0,0 +1,20 @@
+Copyright (c) 2009 Jeremy McAnally
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,25 @@
+= primadoro
+
+A neato gem for helping with Pomodoros
+
+== Using
+
+To use Primadoro, simply run:
+
+ primadoro
+
+There are no configuration options yet. They are coming (and will be awesome!).
+
+== Note on Patches/Pull Requests
+
+* Fork the project.
+* Make your feature addition or bug fix.
+* Add tests for it. This is important so I don't break it in a
+ future version unintentionally.
+* Commit, do not mess with rakefile, version, or history.
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
+* Send me a pull request. Bonus points for topic branches.
+
+== Copyright
+
+Copyright (c) 2010 Jeremy McAnally. See LICENSE for details.
@@ -0,0 +1,54 @@
+require 'rubygems'
+require 'rake'
+
+begin
+ require 'jeweler'
+ Jeweler::Tasks.new do |gem|
+ gem.name = "primadoro"
+ gem.summary = %Q{A neato gem for helping with Pomodoros}
+ gem.description = %Q{A gem for executing custom actions during Pomodoros}
+ gem.email = "jeremymcanally@gmail.com"
+ gem.homepage = "http://github.com/jm/primadoro"
+ gem.authors = ["Jeremy McAnally"]
+ gem.bindir = "bin"
+ gem.files += Dir['resources/*']
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
+ end
+ Jeweler::GemcutterTasks.new
+rescue LoadError
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
+end
+
+require 'rake/testtask'
+Rake::TestTask.new(:test) do |test|
+ test.libs << 'lib' << 'test'
+ test.pattern = 'test/**/test_*.rb'
+ test.verbose = true
+end
+
+begin
+ require 'rcov/rcovtask'
+ Rcov::RcovTask.new do |test|
+ test.libs << 'test'
+ test.pattern = 'test/**/test_*.rb'
+ test.verbose = true
+ end
+rescue LoadError
+ task :rcov do
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
+ end
+end
+
+task :test => :check_dependencies
+
+task :default => :test
+
+require 'rake/rdoctask'
+Rake::RDocTask.new do |rdoc|
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
+
+ rdoc.rdoc_dir = 'rdoc'
+ rdoc.title = "primadoro #{version}"
+ rdoc.rdoc_files.include('README*')
+ rdoc.rdoc_files.include('lib/**/*.rb')
+end
@@ -0,0 +1 @@
+0.0.0
@@ -0,0 +1,4 @@
+#!/usr/bin/env ruby
+
+require File.join(File.dirname(__FILE__), "..", "lib", "primadoro")
+Primadoro.run
@@ -0,0 +1,105 @@
+module Primadoro
+ class <<self
+ def run
+ # TODO: Make each of these configurable
+ @views = [
+ Views::Tunes.new,
+ Views::Growl.new,
+ Views::Sound.new
+ ]
+
+ @actions = {:break_time => 5, :pomodoro => 25}
+
+ while(true)
+ # TODO: Add action hooks later
+ action(:pomodoro)
+ action(:break_time)
+ end
+ end
+
+ def action(action_taken)
+ puts "#{action_taken} at #{Time.now.strftime('%D %T')}"
+
+ @views.each {|v| v.send(action_taken)}
+ sleep(@actions[action_taken] * 60)
+ end
+ end
+
+ module Views
+ class Base
+ # TODO: Add intermittent update displays for timers etc.
+ def display?(runner); false; end
+
+ def display!
+ raise "Implement the display! method on #{self.class.name} if you're going to make me display, fool!"
+ end
+
+ def pomodoro; end
+
+ def break_time; end
+ end
+
+ class Growl < Base
+ begin
+ require 'ruby-growl'
+
+ def initialize
+ @growler = ::Growl.new "localhost", "Primadoro", ["pomodoro", "break time"]
+ end
+
+ def pomodoro
+ @growler.notify "pomodoro", "Pomodoro time!", "Get your work on..." rescue puts "! Growl not configured properly (make sure you allow network connections)"
+ end
+
+ def break_time
+ @growler.notify "break time", "Break time!", "Get your break on..." rescue puts "! Growl not configured properly (make sure you allow network connections)"
+ end
+ rescue Exception
+ require 'rubygems'
+ retry
+
+ puts "! Install ruby-growl for growl support (no Windows etc. support yet)"
+ end
+ end
+
+ class Sound < Base
+ def play(file)
+ if RUBY_PLATFORM =~ /darwin/
+ `afplay #{file}`
+ elsif RUBY_PLATFORM =~ /mswin32/
+ `sndrec32 /play /close "#{file}"`
+ else
+ `play #{file}`
+ end
+ end
+
+ def pomodoro
+ play(File.join(File.dirname(__FILE__), "..", "resources", "windup.wav"))
+ end
+
+ def break_time
+ play(File.join(File.dirname(__FILE__), "..", "resources", "bell.mp3"))
+ end
+ end
+
+ class Tunes < Base
+ begin
+ require 'rbosa'
+
+ def initialize
+ @app = OSA.app('iTunes')
+ end
+
+ def pomodoro
+ @app.play rescue puts '! iTunes not running'
+ end
+
+ def break_time
+ @app.pause rescue puts '! iTunes not running'
+ end
+ rescue Exception
+ puts "! To use the iTunes integration, you need rubyosa installed! (no Windows etc. support yet)"
+ end
+ end
+ end
+end
@@ -0,0 +1,54 @@
+# Generated by jeweler
+# DO NOT EDIT THIS FILE DIRECTLY
+# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
+# -*- encoding: utf-8 -*-
+
+Gem::Specification.new do |s|
+ s.name = %q{primadoro}
+ s.version = "0.0.0"
+
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
+ s.authors = ["Jeremy McAnally"]
+ s.date = %q{2010-07-30}
+ s.default_executable = %q{primadoro}
+ s.description = %q{A gem for executing custom actions during Pomodoros}
+ s.email = %q{jeremymcanally@gmail.com}
+ s.executables = ["primadoro"]
+ s.extra_rdoc_files = [
+ "LICENSE",
+ "README.rdoc"
+ ]
+ s.files = [
+ ".document",
+ ".gitignore",
+ "LICENSE",
+ "README.rdoc",
+ "Rakefile",
+ "VERSION",
+ "lib/primadoro.rb",
+ "resources/bell.mp3",
+ "resources/windup.wav",
+ "test/helper.rb",
+ "test/test_primadoro.rb"
+ ]
+ s.homepage = %q{http://github.com/jm/primadoro}
+ s.rdoc_options = ["--charset=UTF-8"]
+ s.require_paths = ["lib"]
+ s.rubygems_version = %q{1.3.6}
+ s.summary = %q{A neato gem for helping with Pomodoros}
+ s.test_files = [
+ "test/helper.rb",
+ "test/test_primadoro.rb"
+ ]
+
+ if s.respond_to? :specification_version then
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
+ s.specification_version = 3
+
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
+ else
+ end
+ else
+ end
+end
+
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,9 @@
+require 'rubygems'
+require 'test/unit'
+
+$LOAD_PATH.unshift(File.dirname(__FILE__))
+$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
+require 'primadoro'
+
+class Test::Unit::TestCase
+end
@@ -0,0 +1,7 @@
+require 'helper'
+
+class TestPrimadoro < Test::Unit::TestCase
+ def test_something_for_real
+ flunk "PFFT GET REAL (tests coming real soon now since it's about to get real up in here)"
+ end
+end

0 comments on commit 1117219

Please sign in to comment.