remme 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +41 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/reminder/demonizer.rb +6 -0
- data/lib/reminder/notifier/adapters/say.rb +11 -0
- data/lib/reminder/notifier/base.rb +19 -0
- data/lib/reminder/notifier.rb +7 -0
- data/lib/reminder/performer/base.rb +7 -0
- data/lib/reminder/player/adapters/spotify.rb +33 -0
- data/lib/reminder/player/base.rb +30 -0
- data/lib/reminder/scheduler.rb +51 -0
- data/lib/reminder/version.rb +3 -0
- data/spec/reminder_spec.rb +11 -0
- data/spec/spec_helper.rb +11 -0
- metadata +15 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ccb54c0bd6edab1981311801e3abedc70f2b446f
|
4
|
+
data.tar.gz: 1ea771c5578999270aad1565ed63ed6f7601140e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d20c73c185587aa8fcea427d828a2b69e79eedac718e65f623a684a3f21c86b8f099f2194a589b2688e596b8bddcc95e7a3fd78ef96aae27b13f18c8a723d2c9
|
7
|
+
data.tar.gz: fb97f3ac8e069a05fd4789d8d548413b781323e021efeb55aa766291c0c72894ce9544561b11cf97e84c1c170ee91f223b131561435bbd52c947e056e9937918
|
data/README.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# Reminder
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/reminder`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'reminder'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install reminder
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/Luis Vasconcellos/reminder. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
36
|
+
|
37
|
+
|
38
|
+
## License
|
39
|
+
|
40
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
41
|
+
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "reminder"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
module Player
|
2
|
+
module Adapters
|
3
|
+
module Spotify
|
4
|
+
class << self
|
5
|
+
def play
|
6
|
+
`osascript -e 'tell application "Spotify" to play'`
|
7
|
+
end
|
8
|
+
|
9
|
+
def pause
|
10
|
+
`osascript -e 'tell application "Spotify" to pause'`
|
11
|
+
end
|
12
|
+
|
13
|
+
def being_played?
|
14
|
+
script = %q{
|
15
|
+
echo $(osascript <<EOF
|
16
|
+
set state to missing value
|
17
|
+
|
18
|
+
if application "Spotify" is running then
|
19
|
+
tell application "Spotify"
|
20
|
+
set state to (player state as text)
|
21
|
+
end tell
|
22
|
+
end if
|
23
|
+
|
24
|
+
return state is equal to "playing"
|
25
|
+
EOF)
|
26
|
+
}
|
27
|
+
|
28
|
+
`#{script}`.strip == 'true'
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'byebug'
|
2
|
+
|
3
|
+
module Player
|
4
|
+
class Base
|
5
|
+
class << self
|
6
|
+
def init
|
7
|
+
self.tap do
|
8
|
+
@adapter = adapter
|
9
|
+
@was_playing = adapter.being_played?
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def pause
|
14
|
+
return if !@was_playing
|
15
|
+
@adapter.pause
|
16
|
+
end
|
17
|
+
|
18
|
+
def play
|
19
|
+
return if !@was_playing
|
20
|
+
@adapter.play
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def adapter
|
26
|
+
Adapters::Spotify
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'reminder/performer/base'
|
2
|
+
|
3
|
+
class Scheduler < Performer::Base
|
4
|
+
class << self
|
5
|
+
attr_accessor :completed
|
6
|
+
alias :completed? :completed
|
7
|
+
|
8
|
+
@@class_instance_fields = %i(
|
9
|
+
after_hook before_hook
|
10
|
+
message notifier
|
11
|
+
)
|
12
|
+
|
13
|
+
def run(options)
|
14
|
+
build_class_instance_fields(options)
|
15
|
+
perform_in(options.delete(:timeout))
|
16
|
+
end
|
17
|
+
|
18
|
+
@@class_instance_fields.each do |field|
|
19
|
+
define_method(field) { instance_variable_get("@#{field}") }
|
20
|
+
end
|
21
|
+
|
22
|
+
def build_class_instance_fields(options)
|
23
|
+
@@class_instance_fields.each do |field_name|
|
24
|
+
instance_variable_set("@#{field_name}", options.delete(field_name))
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def perform
|
30
|
+
complete_after { notify }
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def notify
|
36
|
+
with_callbacks do
|
37
|
+
self.class.notifier.run(self.class.message)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def complete_after
|
42
|
+
yield
|
43
|
+
self.class.completed = true
|
44
|
+
end
|
45
|
+
|
46
|
+
def with_callbacks
|
47
|
+
self.class.before_hook.call
|
48
|
+
yield
|
49
|
+
self.class.after_hook.call
|
50
|
+
end
|
51
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
require "bundler/setup"
|
2
|
+
require "reminder"
|
3
|
+
|
4
|
+
RSpec.configure do |config|
|
5
|
+
# Enable flags like --only-failures and --next-failure
|
6
|
+
config.example_status_persistence_file_path = ".rspec_status"
|
7
|
+
|
8
|
+
config.expect_with :rspec do |c|
|
9
|
+
c.syntax = :expect
|
10
|
+
end
|
11
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: remme
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luis Vasconcellos
|
@@ -88,8 +88,22 @@ executables:
|
|
88
88
|
extensions: []
|
89
89
|
extra_rdoc_files: []
|
90
90
|
files:
|
91
|
+
- README.md
|
92
|
+
- bin/console
|
91
93
|
- bin/remme
|
94
|
+
- bin/setup
|
92
95
|
- lib/reminder.rb
|
96
|
+
- lib/reminder/demonizer.rb
|
97
|
+
- lib/reminder/notifier.rb
|
98
|
+
- lib/reminder/notifier/adapters/say.rb
|
99
|
+
- lib/reminder/notifier/base.rb
|
100
|
+
- lib/reminder/performer/base.rb
|
101
|
+
- lib/reminder/player/adapters/spotify.rb
|
102
|
+
- lib/reminder/player/base.rb
|
103
|
+
- lib/reminder/scheduler.rb
|
104
|
+
- lib/reminder/version.rb
|
105
|
+
- spec/reminder_spec.rb
|
106
|
+
- spec/spec_helper.rb
|
93
107
|
homepage: http://luisvasconcellos.com
|
94
108
|
licenses:
|
95
109
|
- MIT
|