guard-pushover 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ M2ZjZGMyODUzOWEwZDllMDc3MjE4NjNlMWY5ZThjNDJmZjQ5MjBlNg==
5
+ data.tar.gz: !binary |-
6
+ ZDAzYzViNTI1YmJmMDA4MmZlZTczMmU4NmRmZDU5MmFiMjNlYTE1Ng==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ YTA5ODYzZTk5Y2ZkZWIzOWU5MzBjN2M5ZGYzOTY0MjA4Mzg3N2YyYTY1YmVm
10
+ MWFlNGUwNTBiOTE3Njk3M2FmNzc1NGZkYTQ0NGIxYjYxNTZlODEwMzZkNDUy
11
+ M2ZkNzgyYjFiMDg2ZjQzMGI5NmQ3NWRhMDVhMWVhZWQ4MmEwODQ=
12
+ data.tar.gz: !binary |-
13
+ MjFlMGZlMTI4ZjY2NGU3NmQ2ZDhhOWM1NDM4NzAyZTNmMmZlNGYwZDY3OGFj
14
+ M2FmYWZjNWM3ZTFiYjJlZDMxNzc3OGFmNmFjNjkyOTZkYzU1MTQ4Y2MyYmVj
15
+ MmVlNDY4YmU3ZjdhNjI0Y2RmMDVjMzE1M2RkZWM0MTQ1YTZkNDg=
data/Gemfile CHANGED
@@ -1,5 +1,5 @@
1
- source 'https://rubygems.org'
1
+ source 'http://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in guard-pushover.gemspec
4
4
  gemspec
5
- gem 'rb-inotify', '~> 0.9', :require => false
5
+ gem 'rb-inotify', '~> 0.9', :require => false
data/README.md CHANGED
@@ -8,25 +8,41 @@ Send [Pushover](https://pushover.net/) notifications with Guard!
8
8
 
9
9
  ## Installation
10
10
 
11
- Install it yourself as:
11
+ $ gem install guard-pushover
12
+
13
+ or
12
14
 
13
- $ git clone git@github.com:joenas/preek.git
15
+ # Add to Gemfile
16
+ gem 'guard/pushover
14
17
 
15
- $ cd preek
18
+ or install it yourself
16
19
 
20
+ $ git clone git@github.com:joenas/guard-pushover.git
21
+ $ cd guard-pushover
17
22
  $ rake install
18
23
 
19
- Gem will be available soon.
20
24
 
21
25
  ## Usage
22
26
 
23
- To generate template: `guard init pushover`
27
+ To generate template:
28
+
29
+ $ guard init pushover
24
30
 
25
31
  ### Example
32
+ ```ruby
33
+ guard :pushover, :api_key => '', :user_key => '' do
34
+ watch(/lib\/(.*).rb/)
35
+ end
36
+ ```
37
+
38
+ ### Available options
39
+
40
+ ``` ruby
41
+ :title => 'Title' # Custom title, default is 'Guard'
42
+ :priority => 1 # Priority, default is 0
43
+ ```
26
44
 
27
- guard :pushover, :api_key => '', :user_key => '' do
28
- watch(/lib\/(.*).rb/)
29
- end
45
+ Read more on [Pushover API](https://pushover.net/api).
30
46
 
31
47
  Guard::Pushover will send a message like "[filename] was changed/removed/added".
32
48
  Support will be added for custom messages.
@@ -16,19 +16,19 @@ module Guard
16
16
  options = DEFAULTS.merge(options)
17
17
  @user_key = options.delete(:user_key)
18
18
  @api_key = options.delete(:api_key)
19
- super
19
+ super watchers, options
20
20
  end
21
21
 
22
22
  def run_on_changes(paths)
23
- send_notification "#{paths.first} was changed."
23
+ send_notification "%s was changed.", paths.first
24
24
  end
25
25
 
26
26
  def run_on_removals(paths)
27
- send_notification "#{paths.first} was removed."
27
+ send_notification "%s was removed.", paths.first
28
28
  end
29
29
 
30
30
  def run_on_additions(paths)
31
- send_notification "#{paths.first} was added."
31
+ send_notification "%s was added.", paths.first
32
32
  end
33
33
 
34
34
  private
@@ -37,8 +37,9 @@ module Guard
37
37
  @client = options.delete(:client) || Rushover::Client.new(@api_key)
38
38
  end
39
39
 
40
- def send_notification(msg)
41
- return unless api_keys_valid?
40
+ def send_notification(msg, file)
41
+ return unless api_keys_present?
42
+ msg = (options.delete(:message) || msg) % file
42
43
  @resp = client.notify(@user_key, msg, options)
43
44
  if @resp.ok?
44
45
  UI.info "Pushover: message sent"
@@ -47,7 +48,7 @@ module Guard
47
48
  end
48
49
  end
49
50
 
50
- def api_keys_valid?
51
+ def api_keys_present?
51
52
  return UI.error "No API key given." unless @api_key
52
53
  return UI.error "No User key given." unless @user_key
53
54
  true
@@ -1,5 +1,5 @@
1
1
  module Guard
2
2
  module PushoverVersion
3
- VERSION = "0.1.0"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
@@ -83,6 +83,18 @@ describe Guard::Pushover do
83
83
  run_on_changes
84
84
  end
85
85
  end
86
+
87
+ context "with option :message => 'lets sprint the %s'" do
88
+ let(:expected_options){ { :title => 'Guard', :priority => 0 } }
89
+ it "sends a notification to client with correct parameters" do
90
+ options[:message] = 'lets sprint the %s'
91
+ message = "lets sprint the #{paths.first}"
92
+ client.should_receive(:notify).with(user_key, message, expected_options)
93
+ Guard::UI.should_receive(:info).with(/Pushover: message sent/)
94
+ run_on_changes
95
+ end
96
+ end
97
+
86
98
  end
87
99
 
88
100
  context "and invalid credentials" do
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: guard-pushover
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
5
- prerelease:
4
+ version: 0.2.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Jon Neverland
@@ -14,7 +13,6 @@ dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rushover
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ! '>='
20
18
  - !ruby/object:Gem::Version
@@ -22,7 +20,6 @@ dependencies:
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ! '>='
28
25
  - !ruby/object:Gem::Version
@@ -30,7 +27,6 @@ dependencies:
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: guard
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
31
  - - ! '>='
36
32
  - !ruby/object:Gem::Version
@@ -38,7 +34,6 @@ dependencies:
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
38
  - - ! '>='
44
39
  - !ruby/object:Gem::Version
@@ -46,7 +41,6 @@ dependencies:
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: guard
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
45
  - - ! '>='
52
46
  - !ruby/object:Gem::Version
@@ -54,7 +48,6 @@ dependencies:
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
52
  - - ! '>='
60
53
  - !ruby/object:Gem::Version
@@ -62,7 +55,6 @@ dependencies:
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: guard-rspec
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
59
  - - ! '>='
68
60
  - !ruby/object:Gem::Version
@@ -70,7 +62,6 @@ dependencies:
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
66
  - - ! '>='
76
67
  - !ruby/object:Gem::Version
@@ -78,7 +69,6 @@ dependencies:
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: rspec
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
73
  - - ! '>='
84
74
  - !ruby/object:Gem::Version
@@ -86,7 +76,6 @@ dependencies:
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
80
  - - ! '>='
92
81
  - !ruby/object:Gem::Version
@@ -94,7 +83,6 @@ dependencies:
94
83
  - !ruby/object:Gem::Dependency
95
84
  name: coveralls
96
85
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
86
  requirements:
99
87
  - - ! '>='
100
88
  - !ruby/object:Gem::Version
@@ -102,7 +90,6 @@ dependencies:
102
90
  type: :development
103
91
  prerelease: false
104
92
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
93
  requirements:
107
94
  - - ! '>='
108
95
  - !ruby/object:Gem::Version
@@ -131,29 +118,27 @@ files:
131
118
  homepage: https://github.com/joenas/guard-pushover/
132
119
  licenses:
133
120
  - MIT
121
+ metadata: {}
134
122
  post_install_message:
135
123
  rdoc_options: []
136
124
  require_paths:
137
125
  - lib
138
126
  required_ruby_version: !ruby/object:Gem::Requirement
139
- none: false
140
127
  requirements:
141
128
  - - ! '>='
142
129
  - !ruby/object:Gem::Version
143
130
  version: '0'
144
131
  required_rubygems_version: !ruby/object:Gem::Requirement
145
- none: false
146
132
  requirements:
147
133
  - - ! '>='
148
134
  - !ruby/object:Gem::Version
149
135
  version: '0'
150
136
  requirements: []
151
137
  rubyforge_project:
152
- rubygems_version: 1.8.24
138
+ rubygems_version: 2.0.0
153
139
  signing_key:
154
- specification_version: 3
140
+ specification_version: 4
155
141
  summary: ''
156
142
  test_files:
157
143
  - spec/guard/pushover_spec.rb
158
144
  - spec/spec_helper.rb
159
- has_rdoc: