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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ddbcda46d079575fdde51e42f6a67e3fad287244
4
- data.tar.gz: 0dfc9d51ca2f43739c8cd5a042f88223b91a7d31
3
+ metadata.gz: ccb54c0bd6edab1981311801e3abedc70f2b446f
4
+ data.tar.gz: 1ea771c5578999270aad1565ed63ed6f7601140e
5
5
  SHA512:
6
- metadata.gz: 0c760ad6cfcb13e2d9e7087db0411ef0022dfd3a49a55abe7f3354cd42f24bf7bf5c4a3fcca6845cf9c4e809691cc0b61f7216839162ca194c0e307adec22fb1
7
- data.tar.gz: 1c809e15ee49d341bd4d002b0e839e06c6b59a503a7949cfa6ceac05ba4dfaf74f237047173b66d00d56e5f0de23529599faf710ecb454a4b58f684136699ee7
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,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,6 @@
1
+ module Demonizer
2
+ def demonize(process)
3
+ process.daemon(true, true)
4
+ yield
5
+ end
6
+ end
@@ -0,0 +1,11 @@
1
+ module Notifier
2
+ module Adapters
3
+ module Say
4
+ class << self
5
+ def run(message)
6
+ `say "#{message}"`
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,19 @@
1
+ module Notifier
2
+ class Base
3
+ class << self
4
+ def init
5
+ self.tap { @adapter = adapter }
6
+ end
7
+
8
+ def run(message)
9
+ @adapter.run(message)
10
+ end
11
+
12
+ private
13
+
14
+ def adapter
15
+ Adapters::Say
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,7 @@
1
+ class Notifier
2
+ class << self
3
+ def run(message)
4
+ `say "#{message}"`
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ require 'sucker_punch'
2
+
3
+ module Performer
4
+ class Base
5
+ include SuckerPunch::Job
6
+ end
7
+ end
@@ -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
@@ -0,0 +1,3 @@
1
+ module Reminder
2
+ VERSION = "0.1.4"
3
+ end
@@ -0,0 +1,11 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe Reminder do
4
+ it "has a version number" do
5
+ expect(Reminder::VERSION).not_to be nil
6
+ end
7
+
8
+ it "does something useful" do
9
+ expect(false).to eq(true)
10
+ end
11
+ end
@@ -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.3
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