Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Move config management to time_tap.rb

  • Loading branch information...
commit 6dd8579443fa9a89fd91505186d8c4e41f5e8c47 1 parent 4030a67
@elia authored
Showing with 59 additions and 15 deletions.
  1. +4 −15 bin/timetap
  2. +23 −0 lib/time_tap.rb
  3. +32 −0 lib/time_tap/config.yml.example
View
19 bin/timetap
@@ -4,10 +4,7 @@
require 'time_tap'
-require 'yaml'
-user_config = File.expand_path('~/.timetap.config')
-TimeTap.config.merge! YAML.load_file(user_config) if File.exist?(user_config)
-
+TimeTap.load_user_config!
require 'optparse'
OptionParser.new do |opts|
@@ -30,19 +27,11 @@ OptionParser.new do |opts|
end
opts.on("-i", "--install", "Sets TimeTap to be launched automatically at login, and boots it.") do
- puts 'Installing launcher...'
TimeTap.install_launcher!
-
- unless File.exist? user_config
- require 'fileutils'
- puts 'Copying example config file to ~/.tap_config...'
- FileUtils.cp config_file, user_config
- end
-
- puts 'Reloading system launcher...'
+ TimeTap.install_config!
TimeTap.reload_launcher!
-
- exit # TimeTap::reload_launcher! uses `exec` so this is never actually ran
+ # TimeTap::reload_launcher! uses `exec` so it never gets here
+ exit
end
end.parse!
View
23 lib/time_tap.rb
@@ -111,6 +111,8 @@ def start options = {}
# Add a plist for OSX's launchd and have *TimeTap* launched automatically at login.
def install_launcher!
+ puts 'Installing launcher...'
+
load_plist_info!
ruby = config[:ruby] || "/usr/bin/ruby"
include_dir = '-I'+File.expand_path('../../lib', __FILE__)
@@ -159,11 +161,32 @@ def install_launcher!
end
def reload_launcher!
+ puts 'Reloading system launcher...'
+
load_plist_info!
command = "launchctl unload #{plist_path}; launchctl load #{plist_path}"
exec command
end
+ def load_user_config!
+ require 'yaml'
+ TimeTap.config.merge! YAML.load_file(user_config) if File.exist?(user_config)
+ end
+
+ def user_config
+ @user_config ||= File.expand_path('~/.timetap.config')
+ end
+
+ def install_config!
+ puts 'Checking config...'
+ unless File.exist? user_config
+ require 'fileutils'
+ example_config = File.expand_path('../time_tap/config.yml.example', __FILE__)
+ FileUtils.copy example_config, user_config
+ puts "Added default config to #{user_config}"
+ end
+ end
+
View
32 lib/time_tap/config.yml.example
@@ -0,0 +1,32 @@
+# This is where the "db" will be saved
+root: "~"
+
+# See the README about nested projects
+nested_project_layers: 1
+
+# The port on localhost for the web interface
+port: 1111
+
+# Set your editor:
+#
+# editor: text_mate
+# editor: sublime_text2
+editor: text_mate2
+
+# Use a custom Ruby
+#
+# RVM Example:
+# ruby: /Users/elia/.rvm/bin/ruby-1.9.3-p286
+
+# Replace the folders timetap will look into:
+# Example:
+#
+# code_folders:
+# - "/Volumes/Oliver/Code"
+# - "~/Code/Mikamai"
+# - "~/Code"
+# - "~"
+#
+
+
+
Please sign in to comment.
Something went wrong with that request. Please try again.