surely 0.1.2 → 0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZGNiNjlkY2UzZmE3NDNlNGI0YzNjMDU2YTY4ZDVhMTY1MDc1ZWE1Yw==
4
+ ZjEwNmU3MmQ5NjBkNDFiMWYxZjg1NGNjZjYwZDE2MTUxZDY3OWVmMA==
5
5
  data.tar.gz: !binary |-
6
- NzdkM2MzNmZlZDAwMjhjZWY5MWRhNDc1Yzc5NjA4MWRiNWU4ZDRlMg==
6
+ NGZlZWZkM2JhMzlkMjU3N2NmNjNmZDYyNDRkODk0MjRjNmI4YWE3Yg==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- NTI1ODI3NGRiZTAzZjNkZWI4OGRjODk1YjZhZDZjNWY3NDFlNzI4N2MzOTg0
10
- MTk1NmY0OTk3MzQwYjZmNGE1NWM2NzAyOTQwNzY0N2M0NGEzYjhiN2RlMzdi
11
- NGVkMDgwOWYwNTdlNGE2Zjk3YjFkY2Y1OWI3OGE0YzU5MzE3NjE=
9
+ ZTQyYTM0M2U2M2NiMWMyZGZiNjRiMzlmZjYyNTIwMmRlNzRmY2EzNmQ4YWZm
10
+ NjlhYjI2ZmZiYjQxMmZlNTUwMmE2YWMyY2I4MDMyYTIzZjlhZjBmNTQ0ODQz
11
+ MTIxZjFiNTdkMWZkMjBiYzViNTQxMWQzMGMyNDYyYTYwYjMwNjE=
12
12
  data.tar.gz: !binary |-
13
- ZWE2ZTk0NjJiN2ZmOWQ4NTg2OTg0OTJkNzlkMDUyYWJjZjc1YmY2ZTQ4YTJh
14
- MGMyMDc5ZjNiMGY5YTkzNTIwM2MxY2NmNmExYzA3ZjdhNTg1MTY0ZmYzMTA2
15
- NTY0OTVjYzc2MTVjYzQxNGQxMTQwOWEwNGEyYjJmYjMyYjQ5OTE=
13
+ NjRkNzAxZDQxOGM2NmZjZjk4YTc5NzBhOGRkYmFkYWYzMmE1ZTYzMjE1NmZj
14
+ ZmIxNGU1YjQ3MWIxMzA2ZGNlMjZjZDdhYzU3NTBiMGRjZjFhNDU2MWFkYzFl
15
+ OWEyNThjYTlkNGVmNTliZGJiNzg2YmYwODNiOWUyZGY0MmVlZWY=
data/.gitignore CHANGED
@@ -1,3 +1,5 @@
1
1
  /Gemfile.lock
2
2
  /pkg
3
3
  /tmp
4
+ *.log
5
+ *.pid
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Surely
2
2
 
3
- Surely watches your screenshots directory and upload new files to your [imgur](http://imgur.com/) account.
3
+ Surely is a daemon that watches your screenshots directory and upload new files to your [imgur](http://imgur.com/) account.
4
4
 
5
5
  ## Usage
6
6
 
@@ -13,6 +13,6 @@ $ gem install surely
13
13
  export IMGUR_CLIENT_ID=…
14
14
  export IMGUR_CLIENT_SECRET=…
15
15
 
16
- # Start the watcher (OS X screenshots directory by default)
17
- $ surely
16
+ # Start the daemon (OS X screenshots directory by default)
17
+ $ surely start -d
18
18
  ```
data/bin/surely CHANGED
@@ -4,4 +4,8 @@ $:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
4
4
 
5
5
  require 'surely'
6
6
 
7
- Surely::Daemon.new(ARGV, ENV)
7
+ module Surely
8
+ def self.new(*args)
9
+ Daemon.new(ENV)
10
+ end
11
+ end
data/lib/surely/daemon.rb CHANGED
@@ -1,20 +1,22 @@
1
1
  module Surely
2
2
  class Daemon
3
- def initialize(argv, env)
4
- directory = env['SURELY_DIRECTORY'] || `defaults read com.apple.screencapture location`.chomp
5
- @uploader = Uploader.new(env, directory)
3
+ def initialize(env)
4
+ @env = env
5
+ end
6
+
7
+ def start
8
+ directory = @env['SURELY_DIRECTORY'] || `defaults read com.apple.screencapture location`.chomp
9
+ @uploader = Uploader.new(@env, directory)
6
10
  @uploader.authorize!
7
11
 
8
- begin
9
- puts "Listening to changes on #{directory}..."
12
+ Raad::Logger.info "Listening to changes on #{directory}..."
13
+
14
+ listener = Listen.to(directory)
15
+ listener.filter(/\.(png|jpg|jpeg|gif)$/)
16
+ listener.change(&@uploader.callback)
17
+ listener.start
10
18
 
11
- listener = Listen.to(directory)
12
- listener.filter(/\.(png|jpg|jpeg|gif)$/)
13
- listener.change(&@uploader.callback)
14
- listener.start!
15
- ensure
16
- exit
17
- end
19
+ sleep(1) while !Raad.stopped?
18
20
  end
19
21
  end
20
22
  end
@@ -67,11 +67,11 @@ module Surely
67
67
  def callback
68
68
  @callback ||= lambda do |modified, added, removed|
69
69
  if added.any?
70
- print 'Uploading... '
70
+ Raad::Logger.info 'Uploading... '
71
71
  refresh_token!
72
72
 
73
73
  if uploaded_file = upload_file(File.join(@directory, added.first))
74
- puts "done! #{uploaded_file['link']}"
74
+ Raad::Logger.info "Done! Uploaded #{uploaded_file['link']}"
75
75
  system "say -v 'Fred' 'Uploaded'"
76
76
  system "echo #{uploaded_file['link']} | pbcopy"
77
77
  end
@@ -1,3 +1,3 @@
1
1
  module Surely
2
- VERSION = '0.1.2'
2
+ VERSION = '0.2'
3
3
  end
data/lib/surely.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require 'raad'
1
2
  require 'faraday'
2
3
  require 'listen'
3
4
  require 'multi_json'
data/surely.gemspec CHANGED
@@ -17,10 +17,11 @@ Gem::Specification.new do |s|
17
17
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
18
  s.require_paths = ["lib"]
19
19
 
20
- s.add_runtime_dependency "faraday"
21
- s.add_runtime_dependency "listen"
22
- s.add_runtime_dependency "multi_json"
23
- s.add_runtime_dependency "yajl-ruby"
20
+ s.add_runtime_dependency "faraday", '~> 0.8'
21
+ s.add_runtime_dependency "listen", '~> 1.0'
22
+ s.add_runtime_dependency "multi_json", '~> 1.7'
23
+ s.add_runtime_dependency "yajl-ruby", '~> 1.1'
24
+ s.add_runtime_dependency "raad", '~> 0.5'
24
25
 
25
- s.add_development_dependency "rake"
26
+ s.add_development_dependency "rake", '~> 10.0'
26
27
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: surely
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: '0.2'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rémi Prévost
@@ -14,72 +14,86 @@ dependencies:
14
14
  name: faraday
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ! '>='
17
+ - - ~>
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: '0.8'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ! '>='
24
+ - - ~>
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: '0.8'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: listen
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ! '>='
31
+ - - ~>
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: '1.0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ! '>='
38
+ - - ~>
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: '1.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: multi_json
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ! '>='
45
+ - - ~>
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: '1.7'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ! '>='
52
+ - - ~>
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: '1.7'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: yajl-ruby
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ! '>='
59
+ - - ~>
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: '1.1'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ! '>='
66
+ - - ~>
67
67
  - !ruby/object:Gem::Version
68
- version: '0'
68
+ version: '1.1'
69
+ - !ruby/object:Gem::Dependency
70
+ name: raad
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: '0.5'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: '0.5'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: rake
71
85
  requirement: !ruby/object:Gem::Requirement
72
86
  requirements:
73
- - - ! '>='
87
+ - - ~>
74
88
  - !ruby/object:Gem::Version
75
- version: '0'
89
+ version: '10.0'
76
90
  type: :development
77
91
  prerelease: false
78
92
  version_requirements: !ruby/object:Gem::Requirement
79
93
  requirements:
80
- - - ! '>='
94
+ - - ~>
81
95
  - !ruby/object:Gem::Version
82
- version: '0'
96
+ version: '10.0'
83
97
  description: Surely watches your screenshots directory and upload new files to your
84
98
  imgur account.
85
99
  email: