yadoro 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5c203c79ce8e119df347df4c86e189858f91a029
4
+ data.tar.gz: b023ec63a1c4cad947d87a1152dc6a875719b6d5
5
+ SHA512:
6
+ metadata.gz: b9550c3fe694e6ea0d4b2661bbdc297d6e7daf832b91217f756e1ef66fddfe50c4840b0e2eab2c4b4c59ee7718f0bae587cf7f79c92d8eb8af3bf6ce291ac426
7
+ data.tar.gz: 69b28b049250df97b0de22722f05f331a2a5596913074f787100520c70fdd5a664582b024e6c83673916c27f30cab9c582be9f36627629e26d00ace31f092ff8
data/.byebug_history ADDED
@@ -0,0 +1,17 @@
1
+ c
2
+ n
3
+ s
4
+ n
5
+ i
6
+ c
7
+ n
8
+ minutes
9
+ c
10
+ n
11
+ notifier.methods - Object.methods
12
+ notifier
13
+ c
14
+ e.type
15
+ e.text
16
+ e.message
17
+ e
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ yadoro*.gem
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in yadoro.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Nathan Matteson
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # Yadoro
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/yadoro`. 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 'yadoro'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install yadoro
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. 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/[USERNAME]/yadoro.
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/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "yadoro"
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
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
data/exe/yadoro ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby -wU
2
+
3
+ require 'yadoro'
4
+
5
+ Yadoro::YadoroCLI.start(ARGV)
data/lib/yadoro/cli.rb ADDED
@@ -0,0 +1,52 @@
1
+ require 'thor'
2
+ require 'terminal-notifier'
3
+ require 'ruby-progressbar'
4
+ require 'yaml'
5
+ require_relative 'notifier.rb'
6
+ require_relative 'pomo.rb'
7
+ require_relative 'configuration.rb'
8
+ require_relative 'pomo_runner.rb'
9
+
10
+ module Yadoro
11
+ class YadoroCLI < Thor
12
+ desc "Runs a timer", "Runs a timer with the given message"
13
+ long_desc "Runs a "
14
+ def start(*msg)
15
+ config = Yadoro::Configuration.new(task: msg.join(" "))
16
+ runner = PomoRunner.new(config)
17
+
18
+ 4.times do
19
+ runner.run
20
+ end
21
+ rescue Exception => e
22
+ puts e.message
23
+ end
24
+ desc "Runs a timer once", "Runs a timer once with the given message"
25
+ def one(msg="")
26
+ config = Yadoro::Configuration.new(task: msg)
27
+ runner = PomoRunner.new(config)
28
+
29
+ runner.run
30
+ rescue Exception => e
31
+ puts e.message
32
+ end
33
+
34
+ desc "test save", "test save"
35
+ long_desc "saves whatever thangs you want into ~/.yadoro"
36
+ def save
37
+ f = File.open(File.expand_path('~/.yadoro'), 'w')
38
+ configs = {
39
+ "configs" => [
40
+ {"config_1" => {"work_minutes" => 25, "break_minutes" => 5}},
41
+ {"config_2" => {"work_minutes" => 40, "break_minutes" => 20}}
42
+ ]
43
+ }
44
+ f.puts(configs.to_yaml)
45
+ f.close
46
+ end
47
+
48
+ default_task :one
49
+
50
+ private
51
+ end
52
+ end
@@ -0,0 +1,41 @@
1
+ module Yadoro
2
+ class Configuration
3
+ def initialize(options = {})
4
+ @options = {work_minutes: 25, break_minutes: 5, task: ""}.merge(options)
5
+ validate!
6
+ end
7
+
8
+ def validate!
9
+ if work_seconds > 60 * 60 * 24
10
+ puts "Warning: a very long duration has been set for work_minutes."
11
+ end
12
+ if break_seconds > 60 * 60 * 24
13
+ puts "Warning: a very long duration has been set for break_seconds."
14
+ end
15
+ end
16
+
17
+ def work_minutes
18
+ @options[:work_minutes]
19
+ end
20
+
21
+ def work_seconds
22
+ work_minutes * 60
23
+ end
24
+
25
+ def break_minutes
26
+ @options[:break_minutes]
27
+ end
28
+
29
+ def break_seconds
30
+ break_minutes * 60
31
+ end
32
+
33
+ def task
34
+ @options[:task]
35
+ end
36
+
37
+ def to_yaml
38
+ @options.to_yaml
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,32 @@
1
+ module Yadoro
2
+ class NotificationBuilder
3
+ def initialize
4
+ @commands = {}
5
+ end
6
+
7
+ def title(title)
8
+ @commands[:title] = "-title \"#{title}\"" unless title.nil?
9
+ self
10
+ end
11
+
12
+ def subtitle(subtitle)
13
+ @commands[:subtitle] = "-subtitle \"#{subtitle}\"" unless subtitle.nil?
14
+ self
15
+ end
16
+
17
+ def has_sound(has_sound)
18
+ @commands[:has_sound] = has_sound ? "-sound default" : ""
19
+ self
20
+ end
21
+
22
+ def message(message)
23
+ @commands[:message] = "-message \"#{message}\"" unless message.nil?
24
+ self
25
+ end
26
+
27
+ def notify
28
+ cmd = "terminal-notifier #{@commands.values.join(" ")}"
29
+ `#{cmd}`
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,34 @@
1
+ require_relative 'notification_builder.rb'
2
+
3
+ module Yadoro
4
+ class Notifier
5
+ def initialize(config)
6
+ @config = config
7
+ end
8
+
9
+ def start_notification
10
+ NotificationBuilder.new
11
+ .title("Pomodoro start")
12
+ .subtitle("#{@config.work_minutes} minutes remaining")
13
+ .has_sound(true)
14
+ .message(@config.task)
15
+ .notify
16
+ end
17
+
18
+ def break_notification
19
+ NotificationBuilder.new
20
+ .title("Break start")
21
+ .subtitle("#{@config.break_minutes} remaining")
22
+ .has_sound(true)
23
+ .message(@config.task)
24
+ .notify
25
+ end
26
+
27
+ def end_notification
28
+ NotificationBuilder.new
29
+ .title("Pomodoro complete!")
30
+ .has_sound(true)
31
+ .notify
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,35 @@
1
+ require 'ruby-progressbar'
2
+ module Yadoro
3
+ class Pomo
4
+ def initialize(config)
5
+ @config = config
6
+ end
7
+
8
+ def do_work
9
+ do_timer(@config.work_seconds, "%a 🍅 %B ✓")
10
+ end
11
+
12
+ def do_break
13
+ do_timer(@config.break_seconds, "%a 🍅 %B ✓")
14
+ end
15
+
16
+ def do_timer(seconds_duration, form)
17
+ clock = Thread.new do
18
+ prog = ProgressBar.create(
19
+ total: seconds_duration,
20
+ length: 50,
21
+ format: form
22
+ )
23
+ seconds_duration.times {prog.increment; sleep 1}
24
+ end
25
+
26
+ sleep seconds_duration
27
+ clock.kill
28
+ end
29
+
30
+ def timestamp
31
+ Time.now.strftime("%H:%M")
32
+ end
33
+ end
34
+
35
+ end
@@ -0,0 +1,27 @@
1
+ require_relative 'configuration.rb'
2
+ require_relative 'notifier.rb'
3
+ require_relative 'pomo.rb'
4
+
5
+ module Yadoro
6
+ class PomoRunner
7
+ attr_accessor :config
8
+
9
+ def initialize(config)
10
+ raise "Invalid config passed to PomoRunner" unless config.is_a?(Configuration)
11
+ @config = config
12
+ end
13
+
14
+ def run
15
+ notifier = Yadoro::Notifier.new(@config)
16
+ pomo = Yadoro::Pomo.new(@config)
17
+
18
+ notifier.start_notification
19
+ pomo.do_work
20
+
21
+ notifier.break_notification
22
+ pomo.do_break
23
+
24
+ notifier.end_notification
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,3 @@
1
+ module Yadoro
2
+ VERSION = "0.3.0"
3
+ end
data/lib/yadoro.rb ADDED
@@ -0,0 +1,5 @@
1
+ require "yadoro/version"
2
+ require_relative "yadoro/cli"
3
+ module Yadoro
4
+ # Your code goes here...
5
+ end
data/yadoro.gemspec ADDED
@@ -0,0 +1,36 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'yadoro/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "yadoro"
8
+ spec.version = Yadoro::VERSION
9
+ spec.authors = ["Nathan Matteson"]
10
+ spec.email = ["nwmatteson@gmail.com"]
11
+
12
+ spec.summary = %q{Yet another pomodoro.}
13
+ spec.description = %q{Yet another pomodoro CLI, complete with desktop notifications.}
14
+ spec.homepage = "http://github.com/nmatte"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+ if spec.respond_to?(:metadata)
20
+ spec.metadata['allowed_push_host'] = "https://rubygems.org"
21
+ else
22
+ raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
23
+ end
24
+
25
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
+ spec.bindir = "exe"
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ["lib"]
29
+
30
+ spec.add_development_dependency "bundler", "~> 1.12"
31
+ spec.add_development_dependency "rake", "~> 10.0"
32
+ spec.add_development_dependency 'byebug', '~> 9.0', '>= 9.0.5'
33
+ spec.add_dependency "thor", "~> 0.19"
34
+ spec.add_dependency "terminal-notifier", "1.6"
35
+ spec.add_dependency "ruby-progressbar", "~> 1.8", ">= 1.8.1"
36
+ end
metadata ADDED
@@ -0,0 +1,160 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: yadoro
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.0
5
+ platform: ruby
6
+ authors:
7
+ - Nathan Matteson
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-06-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.12'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.12'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: byebug
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '9.0'
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: 9.0.5
51
+ type: :development
52
+ prerelease: false
53
+ version_requirements: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - "~>"
56
+ - !ruby/object:Gem::Version
57
+ version: '9.0'
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: 9.0.5
61
+ - !ruby/object:Gem::Dependency
62
+ name: thor
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '0.19'
68
+ type: :runtime
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '0.19'
75
+ - !ruby/object:Gem::Dependency
76
+ name: terminal-notifier
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - '='
80
+ - !ruby/object:Gem::Version
81
+ version: '1.6'
82
+ type: :runtime
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - '='
87
+ - !ruby/object:Gem::Version
88
+ version: '1.6'
89
+ - !ruby/object:Gem::Dependency
90
+ name: ruby-progressbar
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - "~>"
94
+ - !ruby/object:Gem::Version
95
+ version: '1.8'
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ version: 1.8.1
99
+ type: :runtime
100
+ prerelease: false
101
+ version_requirements: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - "~>"
104
+ - !ruby/object:Gem::Version
105
+ version: '1.8'
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ version: 1.8.1
109
+ description: Yet another pomodoro CLI, complete with desktop notifications.
110
+ email:
111
+ - nwmatteson@gmail.com
112
+ executables:
113
+ - yadoro
114
+ extensions: []
115
+ extra_rdoc_files: []
116
+ files:
117
+ - ".byebug_history"
118
+ - ".gitignore"
119
+ - Gemfile
120
+ - LICENSE.txt
121
+ - README.md
122
+ - Rakefile
123
+ - bin/console
124
+ - bin/setup
125
+ - exe/yadoro
126
+ - lib/yadoro.rb
127
+ - lib/yadoro/cli.rb
128
+ - lib/yadoro/configuration.rb
129
+ - lib/yadoro/notification_builder.rb
130
+ - lib/yadoro/notifier.rb
131
+ - lib/yadoro/pomo.rb
132
+ - lib/yadoro/pomo_runner.rb
133
+ - lib/yadoro/version.rb
134
+ - yadoro.gemspec
135
+ homepage: http://github.com/nmatte
136
+ licenses:
137
+ - MIT
138
+ metadata:
139
+ allowed_push_host: https://rubygems.org
140
+ post_install_message:
141
+ rdoc_options: []
142
+ require_paths:
143
+ - lib
144
+ required_ruby_version: !ruby/object:Gem::Requirement
145
+ requirements:
146
+ - - ">="
147
+ - !ruby/object:Gem::Version
148
+ version: '0'
149
+ required_rubygems_version: !ruby/object:Gem::Requirement
150
+ requirements:
151
+ - - ">="
152
+ - !ruby/object:Gem::Version
153
+ version: '0'
154
+ requirements: []
155
+ rubyforge_project:
156
+ rubygems_version: 2.2.2
157
+ signing_key:
158
+ specification_version: 4
159
+ summary: Yet another pomodoro.
160
+ test_files: []