routinized 0.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 ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in routinized.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Zack Hubert
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,62 @@
1
+ # Routinized
2
+
3
+ Get a Routine!
4
+
5
+ Routinized is just a convenient way to add some structure to your day. It
6
+ turns a routine and a set of commands into a crontab. Easy.
7
+
8
+ ## Why?
9
+
10
+ Well, I wanted to start work listening to "Working Man" by Rush, and then be
11
+ reminded to do some pushups, stretch every so often to prevent screen lock,
12
+ and have it be flexible enough that I could extend it with additional verbs.
13
+
14
+ Cron was a natural fit as I wanted to use as much operating system level
15
+ things as I could, rather than run a scheduler and additional data storage.
16
+
17
+ ## Installation
18
+
19
+ Install it:
20
+
21
+ $ gem install routinized
22
+ $ rbenv rehash # if necessary
23
+
24
+ ## Usage
25
+
26
+ Once installed, it's time to make your dotfiles...everything lives in
27
+ .routinized.
28
+
29
+ $ routinized bootstrap
30
+
31
+ This makes all sorts of files for you:
32
+
33
+ ~/.routinized/master.rb # your master routine
34
+ ~/.routinized/config.json # location of binaries commands might need
35
+ ~/.routinized/commands/* # commands you reference in your routine
36
+
37
+ After you've made all sorts of changes, you can generate and install the
38
+ crontab via:
39
+
40
+ $ routinized install
41
+
42
+ Over time, more commands will be available (contribute some!), upgrading
43
+ is as easy as:
44
+
45
+ $ routinized upgrade
46
+
47
+ (depending on the command, you might need to customize config.json)
48
+
49
+ ## Acknowledgements
50
+
51
+ This is really just a thin shim on top of the
52
+ [whenever gem](https://github.com/javan/whenever), thanks!
53
+
54
+ Also was inspired by the idea of a simplified Hubot/Huginn for personal use.
55
+
56
+ ## Contributing
57
+
58
+ 1. Fork it
59
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
60
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
61
+ 4. Push to the branch (`git push origin my-new-feature`)
62
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/routinized ADDED
@@ -0,0 +1,42 @@
1
+ #!/usr/bin/env ruby
2
+ require 'routinized'
3
+ require 'optparse'
4
+
5
+ options = {}
6
+
7
+ opt_parser = OptionParser.new do |opt|
8
+ opt.banner = "Usage: routinized COMMAND"
9
+ opt.separator ""
10
+ opt.separator "Commands"
11
+ opt.separator " bootstrap - seeds your .routinized/* dotfiles"
12
+ opt.separator " install - current routine is installed in cron"
13
+ opt.separator " upgrade - grabs new commands for .routinized/commands/*"
14
+ opt.separator ""
15
+
16
+ opt.on("-h","--help","help") do
17
+ puts opt_parser
18
+ end
19
+ end
20
+
21
+ opt_parser.parse!
22
+
23
+ $stdout.sync = true
24
+
25
+ case ARGV[0]
26
+ when "bootstrap"
27
+ puts "Populating ~/.routinized..."
28
+ Routinized.bootstrap
29
+ puts "Done! Customize your master routine before installing."
30
+ when "install"
31
+ puts "Activating whenever to install your routine into cron."
32
+ `/usr/bin/env whenever -f ~/.routinized/master.rb -w`
33
+ puts "Installed. You may need to start cron if not running already:"
34
+ puts " sudo launchctl unload /System/Library/LaunchDaemons/com.vix.cron.plist"
35
+ puts " sudo launchctl load /System/Library/LaunchDaemons/com.vix.cron.plist"
36
+ when "upgrade"
37
+ puts "Upgrading available commands..."
38
+ Routinized.upgrade.each{|x| puts " #{x}"}
39
+ puts "Done! Be sure to run 'gem install routinized' to get the latest."
40
+ else
41
+ puts opt_parser
42
+ end
@@ -0,0 +1,17 @@
1
+ def itunes_play(artist,album,song)
2
+ bin = Routinized.config['itunes_play']['bin']
3
+ full_path = find_exact_song(artist,album,song)
4
+ return "#{bin} \"#{full_path}\" &"
5
+ end
6
+
7
+ # skip the nuisance of escaping manually
8
+ def find_exact_song(artist,album,song)
9
+ itunes_location = Routinized.config['itunes_play']['directory']
10
+ Dir.chdir(itunes_location)
11
+ matched_artist = Dir.glob("*#{artist}*").first
12
+ Dir.chdir(matched_artist)
13
+ matched_album = Dir.glob("*#{album}*").first
14
+ Dir.chdir(matched_album)
15
+ matched_song = Dir.glob("*#{song}*").first
16
+ return "#{itunes_location}/#{matched_artist}/#{matched_album}/#{matched_song}"
17
+ end
@@ -0,0 +1,4 @@
1
+ def osx_notify(title,message)
2
+ terminal_notifier = Routinized.config['osx_notify']['bin']
3
+ "#{terminal_notifier} -message \"#{message}\" -title \"#{title}\""
4
+ end
@@ -0,0 +1,4 @@
1
+ def say(message)
2
+ bin = Routinized.config['say']['bin']
3
+ return "#{bin} '#{message}'"
4
+ end
@@ -0,0 +1,3 @@
1
+ def sleep(seconds)
2
+ "#{Routinized.config['sleep']['bin']} #{seconds} && "
3
+ end
@@ -0,0 +1,3 @@
1
+ module Routinized
2
+ VERSION = "0.0.1"
3
+ end
data/lib/routinized.rb ADDED
@@ -0,0 +1,24 @@
1
+ require "routinized/version"
2
+ require 'fileutils'
3
+ require 'json'
4
+ module Routinized
5
+ ROOT = File.join(Dir.home,'.routinized')
6
+
7
+ def self.config
8
+ JSON.load(File.open(File.join(ROOT, 'config.json')))
9
+ end
10
+
11
+ def self.upgrade
12
+ Dir.chdir(ROOT)
13
+ Dir.mkdir("commands") unless File.exists?("commands")
14
+ FileUtils.cp_r Dir.glob(File.dirname(__FILE__) + '/commands/*.rb'), File.join(ROOT,'commands')
15
+ return Dir.entries(File.join(ROOT,'commands')).select{|f| f =~ /rb/}.map{|x| x.split(".rb").first}
16
+ end
17
+
18
+ def self.bootstrap
19
+ Dir.mkdir(ROOT,0755) unless File.exists?(ROOT)
20
+ Routinized.upgrade
21
+ FileUtils.cp File.join(File.dirname(__FILE__) + '/templates/master.rb.template'), File.join(ROOT,'master.rb')
22
+ FileUtils.cp File.join(File.dirname(__FILE__) + '/templates/config.json.template'), File.join(ROOT,'config.json')
23
+ end
24
+ end
@@ -0,0 +1,15 @@
1
+ {
2
+ "osx_notify": {
3
+ "bin": "/Users/zhubert/.rbenv/shims/terminal-notifier"
4
+ },
5
+ "say": {
6
+ "bin": "/usr/bin/say"
7
+ },
8
+ "sleep": {
9
+ "bin": "/bin/sleep"
10
+ },
11
+ "itunes_play": {
12
+ "bin": "/usr/bin/afplay",
13
+ "directory": "/Users/zhubert/Music/iTunes/iTunes Media/Music"
14
+ }
15
+ }
@@ -0,0 +1,46 @@
1
+ require 'routinized'
2
+ Dir[File.dirname(__FILE__) + '/commands/*.rb'].each {|file| require file }
3
+ set :output, "#{Dir.home}/.cron_whenever.log"
4
+
5
+ # Morning Routine
6
+ #
7
+ # Go to WORK!
8
+ every :weekday, :at => '8:00am' do
9
+ command say 'Go to Work'
10
+ command itunes_play('Rush',"World",'Working Man')
11
+ end
12
+
13
+ every :weekday, :at => '8:45am' do
14
+ command say 'Read Hacker News'
15
+ command osx_notify('HN',"Grab a coffee and read Hacker News")
16
+ end
17
+
18
+ # Stretch Break every 30 minutes during the work week
19
+ every '*/30 9-16 * * 1-5' do
20
+ command sleep(5) + say('Time to stretch')
21
+ command osx_notify('Stretch',"Take a short break and stretch")
22
+ end
23
+
24
+ # Pushups!
25
+ every :weekday, :at => '10:00am' do
26
+ command sleep(10) + say('Time for pushups')
27
+ command osx_notify('Pushups','Do pushups')
28
+ end
29
+
30
+ # Lunch!
31
+ every :weekday, :at => '12:00pm' do
32
+ command say 'Time for Lunch'
33
+ command osx_notify('Lunch','Time to eat some food')
34
+ end
35
+
36
+ # Stop Working
37
+ every :weekday, :at => '5:15pm' do
38
+ command say 'Good work Zack, go home'
39
+ command itunes_play('Rush','Rio','Spirit')
40
+ command osx_notify('Go Home','Time to stop working dear chap.')
41
+ end
42
+
43
+ # Clean out log file, good citizenship!
44
+ every :day do
45
+ command "/bin/cat /dev/null >! /Users/zhubert/.cron_whenever.log"
46
+ end
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'routinized/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "routinized"
8
+ spec.version = Routinized::VERSION
9
+ spec.authors = ["Zack Hubert"]
10
+ spec.email = ["zhubert@gmail.com"]
11
+ spec.description = %q{Add some structure to your work day}
12
+ spec.summary = spec.description
13
+ spec.homepage = "http://github.com/zhubert/routinized"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_dependency 'whenever', '0.8.2'
24
+ spec.add_dependency 'terminal-notifier', '1.4.2'
25
+ spec.add_dependency 'json', '1.7.7'
26
+ end
metadata ADDED
@@ -0,0 +1,142 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: routinized
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Zack Hubert
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-04-11 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.3'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.3'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: whenever
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - '='
52
+ - !ruby/object:Gem::Version
53
+ version: 0.8.2
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - '='
60
+ - !ruby/object:Gem::Version
61
+ version: 0.8.2
62
+ - !ruby/object:Gem::Dependency
63
+ name: terminal-notifier
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - '='
68
+ - !ruby/object:Gem::Version
69
+ version: 1.4.2
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - '='
76
+ - !ruby/object:Gem::Version
77
+ version: 1.4.2
78
+ - !ruby/object:Gem::Dependency
79
+ name: json
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - '='
84
+ - !ruby/object:Gem::Version
85
+ version: 1.7.7
86
+ type: :runtime
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - '='
92
+ - !ruby/object:Gem::Version
93
+ version: 1.7.7
94
+ description: Add some structure to your work day
95
+ email:
96
+ - zhubert@gmail.com
97
+ executables:
98
+ - routinized
99
+ extensions: []
100
+ extra_rdoc_files: []
101
+ files:
102
+ - .gitignore
103
+ - Gemfile
104
+ - LICENSE.txt
105
+ - README.md
106
+ - Rakefile
107
+ - bin/routinized
108
+ - lib/commands/itunes_play.rb
109
+ - lib/commands/osx_notify.rb
110
+ - lib/commands/say.rb
111
+ - lib/commands/sleep.rb
112
+ - lib/routinized.rb
113
+ - lib/routinized/version.rb
114
+ - lib/templates/config.json.template
115
+ - lib/templates/master.rb.template
116
+ - routinized.gemspec
117
+ homepage: http://github.com/zhubert/routinized
118
+ licenses:
119
+ - MIT
120
+ post_install_message:
121
+ rdoc_options: []
122
+ require_paths:
123
+ - lib
124
+ required_ruby_version: !ruby/object:Gem::Requirement
125
+ none: false
126
+ requirements:
127
+ - - ! '>='
128
+ - !ruby/object:Gem::Version
129
+ version: '0'
130
+ required_rubygems_version: !ruby/object:Gem::Requirement
131
+ none: false
132
+ requirements:
133
+ - - ! '>='
134
+ - !ruby/object:Gem::Version
135
+ version: '0'
136
+ requirements: []
137
+ rubyforge_project:
138
+ rubygems_version: 1.8.23
139
+ signing_key:
140
+ specification_version: 3
141
+ summary: Add some structure to your work day
142
+ test_files: []