buffalo-run 0.0.10.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/bin/buffalo +32 -0
- data/buffalo.gemspec +27 -0
- data/lib/buffalo.rb +49 -0
- data/lib/buffalo/api.rb +40 -0
- data/lib/buffalo/browser.rb +25 -0
- data/lib/buffalo/config.rb +63 -0
- data/lib/buffalo/control.rb +45 -0
- data/lib/buffalo/git.rb +14 -0
- data/lib/buffalo/installer.rb +78 -0
- data/lib/buffalo/sync.rb +119 -0
- data/lib/buffalo/version.rb +3 -0
- data/lib/buffalo/watcher.rb +71 -0
- metadata +117 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3ab7ebb3afc4cfd0c68bb6e6b5179ce479a6ef79
|
4
|
+
data.tar.gz: e879f93acb8d43942ed7f3f74709d4714b6d1f79
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 64f8eaeb009d8f5ff7b71e6461fe08da235684f88d1ecc993e35009327e23c45f87fe6d71fb888c491446ae26d036bb7ea3ffb807f89a3d0dc9f7bae351511de
|
7
|
+
data.tar.gz: fd92d7c39fc170605e999e362e4f6f283de34d533b23171d725b83c3aca7fc0416460152f56aaefb5b7237e65428624cd0b08eacb785c7865cd2c64cd7749f4b
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Elia Schito
|
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,29 @@
|
|
1
|
+
# Buffalo
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'buffalo'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install buffalo
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/buffalo
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'buffalo'
|
4
|
+
|
5
|
+
if ARGV.any?
|
6
|
+
if ARGV.size == 1
|
7
|
+
case ARGV.first
|
8
|
+
when '--install'; Buffalo.install
|
9
|
+
when '--uninstall'; Buffalo.uninstall
|
10
|
+
else
|
11
|
+
$stderr.puts "Unknown argument: #{ARGV.first}"
|
12
|
+
exit -1
|
13
|
+
end
|
14
|
+
else
|
15
|
+
$stderr.puts "Unknown arguments: #{ARGV.inspect}"
|
16
|
+
exit -1
|
17
|
+
end
|
18
|
+
exit 0
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
trap('INT') do
|
23
|
+
puts
|
24
|
+
exit
|
25
|
+
end
|
26
|
+
|
27
|
+
begin
|
28
|
+
Buffalo.start
|
29
|
+
sleep
|
30
|
+
ensure
|
31
|
+
Buffalo.stop
|
32
|
+
end
|
data/buffalo.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'buffalo/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = 'buffalo-run'
|
8
|
+
gem.version = Buffalo::VERSION
|
9
|
+
gem.authors = ['Elia Schito']
|
10
|
+
gem.email = ['elia@schito.me']
|
11
|
+
gem.description = %q{Oh boy!, It's Buffalo!}
|
12
|
+
gem.summary = %q{Oh boy!, It's Buffalo!}
|
13
|
+
gem.homepage = ''
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
|
20
|
+
gem.add_runtime_dependency 'rest-client'
|
21
|
+
gem.add_runtime_dependency 'json'
|
22
|
+
|
23
|
+
# Watcher
|
24
|
+
# gem.add_runtime_dependency 'listen', '~> 0.7.3'
|
25
|
+
gem.add_runtime_dependency 'rb-fsevent', '~> 0.9.3'
|
26
|
+
gem.add_runtime_dependency 'launchdr', '~> 3'
|
27
|
+
end
|
data/lib/buffalo.rb
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'logger'
|
2
|
+
|
3
|
+
require 'buffalo/version'
|
4
|
+
require 'buffalo/config'
|
5
|
+
require 'buffalo/control'
|
6
|
+
require 'buffalo/installer'
|
7
|
+
|
8
|
+
module Kernel
|
9
|
+
def logger
|
10
|
+
$logger ||= Logger.new($stdout)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
|
15
|
+
module Buffalo
|
16
|
+
extend self
|
17
|
+
|
18
|
+
def start
|
19
|
+
logger.info "[#{self}] Starting (v#{VERSION})..."
|
20
|
+
control.start
|
21
|
+
end
|
22
|
+
|
23
|
+
def stop
|
24
|
+
control.stop
|
25
|
+
end
|
26
|
+
|
27
|
+
def install
|
28
|
+
installer.start
|
29
|
+
end
|
30
|
+
|
31
|
+
def uninstall
|
32
|
+
installer.stop
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def installer
|
39
|
+
@installer ||= Installer.new(config)
|
40
|
+
end
|
41
|
+
|
42
|
+
def config
|
43
|
+
@config ||= Config.new
|
44
|
+
end
|
45
|
+
|
46
|
+
def control
|
47
|
+
@control ||= Control.new(config)
|
48
|
+
end
|
49
|
+
end
|
data/lib/buffalo/api.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
module Buffalo
|
4
|
+
class Api
|
5
|
+
def initialize token, base_uri
|
6
|
+
@token, @base_uri = token, base_uri
|
7
|
+
end
|
8
|
+
|
9
|
+
def get_config
|
10
|
+
response = resource[:config].get :params => {:token => token}
|
11
|
+
{
|
12
|
+
:watch_paths => JSON.parse(response)
|
13
|
+
}
|
14
|
+
end
|
15
|
+
|
16
|
+
def sync_file file
|
17
|
+
logger.info "[#{self.class}] Uploading to: #{base_uri}, file: #{file.inspect}"
|
18
|
+
resource[:sync].post :timestamps => file, :token => token
|
19
|
+
rescue RestClient::RequestFailed => error
|
20
|
+
logger.error "[#{self.class}] GOT AN ERROR FROM THE SERVER!!! <<<#{error}>>>"
|
21
|
+
raise
|
22
|
+
rescue SocketError
|
23
|
+
logger.error "[#{self.class}] GOT AN ERROR FROM THE SOCKET!!! <<<#{error}>>>"
|
24
|
+
raise
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def up?
|
31
|
+
Net::HTTP.new(base_uri).head('/').kind_of? Net::HTTPOK
|
32
|
+
end
|
33
|
+
|
34
|
+
attr_reader :token, :base_uri
|
35
|
+
|
36
|
+
def resource
|
37
|
+
@resource ||= RestClient::Resource.new(base_uri)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Buffalo
|
2
|
+
class Browser
|
3
|
+
def initialize
|
4
|
+
require 'rubygems'
|
5
|
+
require 'appscript'
|
6
|
+
extend Appscript
|
7
|
+
end
|
8
|
+
|
9
|
+
def current_app
|
10
|
+
@se ||= app('System Events')
|
11
|
+
@se.processes.get.find{|p| p.frontmost.get }.name.get
|
12
|
+
end
|
13
|
+
|
14
|
+
def current_url
|
15
|
+
case current_app
|
16
|
+
when 'Safari'
|
17
|
+
s = app('Safari')
|
18
|
+
s.documents.first.URL.get
|
19
|
+
when 'Google Chrome'
|
20
|
+
c = app('Google Chrome')
|
21
|
+
c.windows.first.active_tab.URL.get
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
module Buffalo
|
4
|
+
class Config
|
5
|
+
def initialize name = 'buffalo'
|
6
|
+
@name = name
|
7
|
+
@name << '-local' if local?
|
8
|
+
FileUtils.mkdir_p base_dir
|
9
|
+
end
|
10
|
+
|
11
|
+
def base_dir
|
12
|
+
@base_dir ||= File.expand_path("~/.#{name}")
|
13
|
+
end
|
14
|
+
|
15
|
+
def update config
|
16
|
+
File.open(watch_paths_file, 'w'){ |f| f << config[:watch_paths].join("\n") }
|
17
|
+
end
|
18
|
+
|
19
|
+
def token
|
20
|
+
@token ||= File.read(token_file).strip
|
21
|
+
end
|
22
|
+
|
23
|
+
def base_uri
|
24
|
+
local? ?
|
25
|
+
'http://buffalo.dev/api' :
|
26
|
+
'https://buffalo-run.herokuapp.com/api'
|
27
|
+
end
|
28
|
+
|
29
|
+
def watch_paths
|
30
|
+
File.read(watch_paths_file).strip.split("\n").map(&:strip)
|
31
|
+
end
|
32
|
+
|
33
|
+
def live_history
|
34
|
+
"#{base_dir}/local-history"
|
35
|
+
end
|
36
|
+
|
37
|
+
def dir path
|
38
|
+
path = File.join(base_dir, path)
|
39
|
+
unless File.directory? path
|
40
|
+
logger.debug "[#{self.class}] Creating dir: #{path}"
|
41
|
+
FileUtils.mkdir_p(path)
|
42
|
+
end
|
43
|
+
path
|
44
|
+
end
|
45
|
+
|
46
|
+
attr_reader :name
|
47
|
+
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
def watch_paths_file
|
52
|
+
File.join(base_dir, 'watch_paths')
|
53
|
+
end
|
54
|
+
|
55
|
+
def token_file
|
56
|
+
@token_path ||= File.expand_path("~/.#{name}.token")
|
57
|
+
end
|
58
|
+
|
59
|
+
def local?
|
60
|
+
ENV['LOCAL_BUFFALO']
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'buffalo/api'
|
2
|
+
require 'buffalo/sync'
|
3
|
+
require 'buffalo/watcher'
|
4
|
+
|
5
|
+
module Buffalo
|
6
|
+
class Control
|
7
|
+
def initialize config
|
8
|
+
@config = config
|
9
|
+
end
|
10
|
+
|
11
|
+
def start
|
12
|
+
update_config
|
13
|
+
watcher.start
|
14
|
+
sync.start
|
15
|
+
end
|
16
|
+
|
17
|
+
def stop
|
18
|
+
logger.debug "[#{self.class}] Exiting..."
|
19
|
+
sync.stop
|
20
|
+
watcher.stop
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
attr_reader :config
|
27
|
+
|
28
|
+
def watcher
|
29
|
+
@watcher ||= Watcher.new(config, *config.watch_paths)
|
30
|
+
end
|
31
|
+
|
32
|
+
def sync
|
33
|
+
@sync ||= Sync.new(api, config)
|
34
|
+
end
|
35
|
+
|
36
|
+
def api
|
37
|
+
@api ||= Api.new(config.token, config.base_uri)
|
38
|
+
end
|
39
|
+
|
40
|
+
def update_config
|
41
|
+
logger.debug "[#{self.class}] Updating configuration..."
|
42
|
+
config.update(api.get_config)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
data/lib/buffalo/git.rb
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
module Buffalo
|
2
|
+
class Installer
|
3
|
+
def initialize config
|
4
|
+
@config = config
|
5
|
+
create
|
6
|
+
end
|
7
|
+
|
8
|
+
def start
|
9
|
+
load
|
10
|
+
end
|
11
|
+
|
12
|
+
def stop
|
13
|
+
unload
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def create
|
20
|
+
require 'launchdr'
|
21
|
+
|
22
|
+
# From: launchdr/task.rb
|
23
|
+
path = LaunchDr::Launchd::Paths[opts[:type] || :user_agent]
|
24
|
+
raise "Type error! Must be one of #{LaunchDr::Launchd::Paths.keys.join(", ")}" unless path
|
25
|
+
plist.dump File.expand_path(path)
|
26
|
+
end
|
27
|
+
|
28
|
+
def load
|
29
|
+
plist.unload!
|
30
|
+
plist.load!
|
31
|
+
puts "** `#{[opts[:bin], opts[:arguments]].flatten.join(' ')}` will now be run on startup!"
|
32
|
+
end
|
33
|
+
|
34
|
+
def unload
|
35
|
+
plist.unload!
|
36
|
+
end
|
37
|
+
|
38
|
+
def plist
|
39
|
+
@plist ||= begin
|
40
|
+
require 'launchdr'
|
41
|
+
|
42
|
+
plist = LaunchDr::Launchd.new name
|
43
|
+
plist[:ProgramArguments] = [opts[:bin], opts[:arguments]].flatten
|
44
|
+
plist[:KeepAlive] = true
|
45
|
+
plist[:RunAtLoad] = true
|
46
|
+
plist[:StandardErrorPath] = File.expand_path("~/Library/Logs/#{name}.log")
|
47
|
+
plist[:StandardOutPath] = File.expand_path("~/Library/Logs/#{name}.log")
|
48
|
+
plist
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def opts
|
53
|
+
@opts ||= {:bin => ruby_bin, :arguments => ['-S', buffalo_bin]}
|
54
|
+
end
|
55
|
+
|
56
|
+
def buffalo_bin
|
57
|
+
File.expand_path('../../../bin/buffalo', __FILE__)
|
58
|
+
end
|
59
|
+
|
60
|
+
def name
|
61
|
+
"com.eliae-societas.#{config.name}.client"
|
62
|
+
end
|
63
|
+
|
64
|
+
attr_reader :config
|
65
|
+
|
66
|
+
def ruby_bin
|
67
|
+
# From: http://stackoverflow.com/a/11477062/601782
|
68
|
+
@ruby_bin ||= File.join(ruby_config::CONFIG['bindir'],
|
69
|
+
ruby_config::CONFIG['ruby_install_name']
|
70
|
+
).sub(/.*\s.*/m, '"\&"')
|
71
|
+
end
|
72
|
+
|
73
|
+
def ruby_config
|
74
|
+
@ruby_config ||= defined?(RbConfig) ? RbConfig : Config
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
data/lib/buffalo/sync.rb
ADDED
@@ -0,0 +1,119 @@
|
|
1
|
+
require 'rest-client'
|
2
|
+
require 'fileutils'
|
3
|
+
|
4
|
+
module Buffalo
|
5
|
+
class Sync
|
6
|
+
def initialize api, config
|
7
|
+
@api = api
|
8
|
+
@config = config
|
9
|
+
end
|
10
|
+
|
11
|
+
def start
|
12
|
+
logger.debug "[#{self.class}] Starting..."
|
13
|
+
start_thread_loop do |options|
|
14
|
+
sync
|
15
|
+
sleep pause_time
|
16
|
+
end
|
17
|
+
logger.debug "[#{self.class}] Started."
|
18
|
+
end
|
19
|
+
|
20
|
+
def stop
|
21
|
+
logger.debug "[#{self.class}] Stopping..."
|
22
|
+
stop_thread
|
23
|
+
logger.debug "[#{self.class}] Stopped."
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
attr_reader :api, :thread, :config
|
32
|
+
|
33
|
+
|
34
|
+
# Thread
|
35
|
+
|
36
|
+
def pause_time
|
37
|
+
60 * 5 # minutes
|
38
|
+
end
|
39
|
+
|
40
|
+
def stop_thread
|
41
|
+
return unless thread
|
42
|
+
thread[:stop] = true
|
43
|
+
thread.exit if thread.status == 'sleep'
|
44
|
+
thread.join
|
45
|
+
end
|
46
|
+
|
47
|
+
def start_thread_loop(&block)
|
48
|
+
@thread = nil if @thread and @thread[:stop]
|
49
|
+
@thread ||= Thread.new do
|
50
|
+
loop do
|
51
|
+
break if Thread.current[:stop]
|
52
|
+
block.call
|
53
|
+
end
|
54
|
+
end.tap { |t| t.abort_on_exception = true }
|
55
|
+
end
|
56
|
+
|
57
|
+
|
58
|
+
# Actions
|
59
|
+
|
60
|
+
def upload file
|
61
|
+
logger.debug "[#{self.class}] Uploading #{file}"
|
62
|
+
api.sync_file File.open(file, 'rb')
|
63
|
+
end
|
64
|
+
|
65
|
+
def sync
|
66
|
+
files = syncable_files
|
67
|
+
logger.debug "[#{self.class}] Starting sync (#{files.size} files)..."
|
68
|
+
files.each do |file|
|
69
|
+
begin
|
70
|
+
upload file
|
71
|
+
logger.debug "[#{self.class}] Uploaded #{File.size file} bytes."
|
72
|
+
move file, uploaded_dir
|
73
|
+
rescue
|
74
|
+
logger.error "[#{self.class}] An error occurred during sync of file: #{file}..."
|
75
|
+
end
|
76
|
+
end
|
77
|
+
logger.debug "[#{self.class}] Finished sync..."
|
78
|
+
end
|
79
|
+
|
80
|
+
|
81
|
+
# Files
|
82
|
+
|
83
|
+
def syncable_files
|
84
|
+
if File.exist? live_history
|
85
|
+
now = Time.now.to_i
|
86
|
+
backup_and_truncate live_history, "#{uploadable_dir}/#{now}"
|
87
|
+
end
|
88
|
+
Dir[uploadable_dir + '/*']
|
89
|
+
end
|
90
|
+
|
91
|
+
def backup_and_truncate source_file, target_file
|
92
|
+
FileUtils.cp source_file, target_file
|
93
|
+
File.open(source_file, 'w').close
|
94
|
+
end
|
95
|
+
|
96
|
+
def move source_file, target_dir
|
97
|
+
FileUtils.mv source_file, target_dir
|
98
|
+
end
|
99
|
+
|
100
|
+
def live_history
|
101
|
+
config.live_history
|
102
|
+
end
|
103
|
+
|
104
|
+
|
105
|
+
# Folders
|
106
|
+
|
107
|
+
def base_dir
|
108
|
+
config.base_dir
|
109
|
+
end
|
110
|
+
|
111
|
+
def uploadable_dir
|
112
|
+
@uploadable_dir ||= config.dir('uploadable')
|
113
|
+
end
|
114
|
+
|
115
|
+
def uploaded_dir
|
116
|
+
@uploaded_dir ||= config.dir('uploaded-history')
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
module Buffalo
|
2
|
+
class Watcher
|
3
|
+
def initialize config, *watch_paths
|
4
|
+
@config = config
|
5
|
+
@watch_paths = watch_paths.map { |p| File.expand_path(p) }
|
6
|
+
end
|
7
|
+
|
8
|
+
attr_reader :watch_paths, :thread, :config
|
9
|
+
|
10
|
+
def stop
|
11
|
+
logger.debug "[#{self.class}] Stopping..."
|
12
|
+
thread.exit if thread
|
13
|
+
logger.debug "[#{self.class}] Stopped."
|
14
|
+
end
|
15
|
+
|
16
|
+
def history_file
|
17
|
+
config.live_history
|
18
|
+
end
|
19
|
+
|
20
|
+
def listener
|
21
|
+
require 'rb-fsevent'
|
22
|
+
@listener ||= FSEvent.new
|
23
|
+
end
|
24
|
+
|
25
|
+
def start
|
26
|
+
listener.watch(watch_paths, :latency => 5) { |paths| save_paths(paths) }
|
27
|
+
|
28
|
+
logger.debug "[#{self.class}] Starting watch of: #{watch_paths.inspect}"
|
29
|
+
logger.debug "[#{self.class}] Saving timestamps to: #{history_file.inspect}"
|
30
|
+
|
31
|
+
@thread ||= Thread.new do
|
32
|
+
Thread.current.abort_on_exception = true
|
33
|
+
listener.run
|
34
|
+
end
|
35
|
+
logger.debug "[#{self.class}] Started."
|
36
|
+
end
|
37
|
+
|
38
|
+
# def listener
|
39
|
+
# require 'listen'
|
40
|
+
# @listener ||= Listen.to(*watch_paths, :latency => 120)
|
41
|
+
# end
|
42
|
+
#
|
43
|
+
# def start
|
44
|
+
# listener.change do |mod, add, rem|
|
45
|
+
# paths = [mod, add, rem].flatten.uniq
|
46
|
+
# save_paths(paths)
|
47
|
+
# end
|
48
|
+
# logger.debug "[#{self.class}] Starting watch of: #{watch_paths.inspect}"
|
49
|
+
# logger.debug "[#{self.class}] Saving timestamps to: #{history_file.inspect}"
|
50
|
+
#
|
51
|
+
# @thread ||= Thread.new do
|
52
|
+
# Thread.current.abort_on_exception = true
|
53
|
+
# listener.start #(false) # unblocking
|
54
|
+
# end
|
55
|
+
# logger.debug "[#{self.class}] Started."
|
56
|
+
# end
|
57
|
+
|
58
|
+
def save_paths paths
|
59
|
+
File.open(history_file, 'a') do |file|
|
60
|
+
time = Time.now.to_i
|
61
|
+
paths.each do |path|
|
62
|
+
string = "#{time}: #{path}\n"
|
63
|
+
file << string
|
64
|
+
logger.debug "[#{self.class}] << #{string.strip}"
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
|
metadata
ADDED
@@ -0,0 +1,117 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: buffalo-run
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.10.pre
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Elia Schito
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-03-28 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rest-client
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: json
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rb-fsevent
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.9.3
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.9.3
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: launchdr
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3'
|
69
|
+
description: Oh boy!, It's Buffalo!
|
70
|
+
email:
|
71
|
+
- elia@schito.me
|
72
|
+
executables:
|
73
|
+
- buffalo
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- .gitignore
|
78
|
+
- Gemfile
|
79
|
+
- LICENSE.txt
|
80
|
+
- README.md
|
81
|
+
- Rakefile
|
82
|
+
- bin/buffalo
|
83
|
+
- buffalo.gemspec
|
84
|
+
- lib/buffalo.rb
|
85
|
+
- lib/buffalo/api.rb
|
86
|
+
- lib/buffalo/browser.rb
|
87
|
+
- lib/buffalo/config.rb
|
88
|
+
- lib/buffalo/control.rb
|
89
|
+
- lib/buffalo/git.rb
|
90
|
+
- lib/buffalo/installer.rb
|
91
|
+
- lib/buffalo/sync.rb
|
92
|
+
- lib/buffalo/version.rb
|
93
|
+
- lib/buffalo/watcher.rb
|
94
|
+
homepage: ''
|
95
|
+
licenses: []
|
96
|
+
metadata: {}
|
97
|
+
post_install_message:
|
98
|
+
rdoc_options: []
|
99
|
+
require_paths:
|
100
|
+
- lib
|
101
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - '>='
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
106
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '>'
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 1.3.1
|
111
|
+
requirements: []
|
112
|
+
rubyforge_project:
|
113
|
+
rubygems_version: 2.0.3
|
114
|
+
signing_key:
|
115
|
+
specification_version: 4
|
116
|
+
summary: Oh boy!, It's Buffalo!
|
117
|
+
test_files: []
|