tomatos 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rubocop.yml +13 -0
- data/Gemfile +12 -0
- data/LICENSE.txt +21 -0
- data/README.md +39 -0
- data/Rakefile +16 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/exe/tomatos +32 -0
- data/lib/tomatos/version.rb +5 -0
- data/lib/tomatos.rb +71 -0
- data/sig/tomatos.rbs +4 -0
- data/tomatos.gemspec +37 -0
- metadata +59 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 169f7f8359fecd3538137b143d68793523327a4eb18a5dd1db26cfe95b3ac2f3
|
4
|
+
data.tar.gz: e8af5dc12aca6d64dd56b74617599d50ed6ba423ee07108ad7df35926859b2df
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 81934dacfe59b6d5faccc350c2dbcb2bfdeb5dd94ae4b57d39ba7adb5b217b3be6f790738bfc8099afcfeaa8089849d78524189cff7b9b27451162c66380f6ae
|
7
|
+
data.tar.gz: 69e3e21c061292c6d39176f16a2d1b3344f44c5de0ea1a3501b5bdf820bad16afdac1b254844c3fe105da49537da26b9f7cfcc2de47b12e35dd7896be1325cb9
|
data/.rubocop.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2022 张阳
|
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,39 @@
|
|
1
|
+
# Tomatos
|
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/tomatos`. 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 'tomatos'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle install
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install tomatos
|
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 test` 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 the created tag, 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]/tomatos.
|
36
|
+
|
37
|
+
## License
|
38
|
+
|
39
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "bundler/gem_tasks"
|
4
|
+
require "rake/testtask"
|
5
|
+
|
6
|
+
Rake::TestTask.new(:test) do |t|
|
7
|
+
t.libs << "test"
|
8
|
+
t.libs << "lib"
|
9
|
+
t.test_files = FileList["test/**/test_*.rb"]
|
10
|
+
end
|
11
|
+
|
12
|
+
require "rubocop/rake_task"
|
13
|
+
|
14
|
+
RuboCop::RakeTask.new
|
15
|
+
|
16
|
+
task default: %i[test rubocop]
|
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "bundler/setup"
|
5
|
+
require "tomatos"
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require "irb"
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/exe/tomatos
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
|
2
|
+
#!/usr/bin/env ruby
|
3
|
+
# frozen_string_literal: true
|
4
|
+
|
5
|
+
require_relative '../lib/tomatos'
|
6
|
+
require 'optparse'
|
7
|
+
|
8
|
+
stop_follow = lambda { puts 'See you later :D' }
|
9
|
+
trap("INT") {
|
10
|
+
stop_follow.call
|
11
|
+
exit!
|
12
|
+
}
|
13
|
+
|
14
|
+
at_exit {
|
15
|
+
stop_follow.call
|
16
|
+
}
|
17
|
+
|
18
|
+
|
19
|
+
options = {}
|
20
|
+
OptionParser.new do |parser|
|
21
|
+
parser.banner = "Usage: tomato.rb [options]"
|
22
|
+
|
23
|
+
parser.on("-tTIME", "--time=TIME", "Time delta: `15m` means 15mins, `30s` means 30secs, default use mins ") do |v|
|
24
|
+
options[:time] = v
|
25
|
+
end
|
26
|
+
parser.on("-mMESSAGE", "--message=MESSAGE", "Message for this time task") do |v|
|
27
|
+
options[:message] = v
|
28
|
+
end
|
29
|
+
end.parse!
|
30
|
+
|
31
|
+
|
32
|
+
Tomatos::App.new(options).run
|
data/lib/tomatos.rb
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "tomatos/version"
|
4
|
+
|
5
|
+
module Tomatos
|
6
|
+
class Error < StandardError; end
|
7
|
+
# Your code goes here...
|
8
|
+
end
|
9
|
+
|
10
|
+
module Tomatos
|
11
|
+
class App
|
12
|
+
def initialize(options)
|
13
|
+
@title = 'Tomatos'
|
14
|
+
@time_delta = options[:time] || '15m'
|
15
|
+
@time_value = 0
|
16
|
+
@unit = 'm'
|
17
|
+
@message = options[:message] || nil
|
18
|
+
end
|
19
|
+
|
20
|
+
def notice(content, title = nil, subtitle = nil)
|
21
|
+
system("osascript -e 'display notification \"#{content}\" with title \"#{title}\" subtitle \"#{subtitle}\"'")
|
22
|
+
end
|
23
|
+
|
24
|
+
def parser_delta_time
|
25
|
+
# use secs
|
26
|
+
time_delta_secs = 0
|
27
|
+
|
28
|
+
case @time_delta
|
29
|
+
when /(\d+)m$/
|
30
|
+
time_delta_secs = $1.to_i * 60
|
31
|
+
@time_value = $1
|
32
|
+
@unit = 'm'
|
33
|
+
when /(\d+)s$/
|
34
|
+
time_delta_secs = $1.to_i
|
35
|
+
@time_value = $1
|
36
|
+
@unit = 's'
|
37
|
+
|
38
|
+
when /(\d+)$/
|
39
|
+
time_delta_secs = $1.to_i
|
40
|
+
@time_value = $1
|
41
|
+
@unit = 'm'
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def count_down_text(count_down)
|
46
|
+
mins = count_down / 60 % 60
|
47
|
+
secs = count_down % 60
|
48
|
+
|
49
|
+
return "#{mins < 10 ? '0' + mins.to_s : mins.to_s} min #{secs < 10 ? '0'+secs.to_s : secs.to_s} sec"
|
50
|
+
end
|
51
|
+
|
52
|
+
def run
|
53
|
+
self.parser_delta_time
|
54
|
+
unit_text = @unit == 'm' ? 'min' : 'sec'
|
55
|
+
total_secs = @unit == 'm' ? @time_value.to_i * 60 : @time_value.to_i
|
56
|
+
|
57
|
+
self.notice("Start: #{@time_value} #{unit_text}", @title, @message)
|
58
|
+
count_down = total_secs.dup
|
59
|
+
total_secs.times do
|
60
|
+
sleep(1)
|
61
|
+
system('clear')
|
62
|
+
count_down -= 1
|
63
|
+
puts "Tomato:"
|
64
|
+
puts "@time: #{self.count_down_text(count_down)}"
|
65
|
+
puts "@message: #{@message}"
|
66
|
+
end
|
67
|
+
sleep(total_secs)
|
68
|
+
self.notice("#{@time_value} #{unit_text} Finished", @title, @message)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
data/sig/tomatos.rbs
ADDED
data/tomatos.gemspec
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/tomatos/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "tomatos"
|
7
|
+
spec.version = Tomatos::VERSION
|
8
|
+
spec.authors = ["Mark24"]
|
9
|
+
spec.email = ["mark.zhangyoung@qq.com"]
|
10
|
+
|
11
|
+
spec.summary = "Tomato click for mac terminal"
|
12
|
+
spec.description = "Tomato click for mac terminal"
|
13
|
+
spec.homepage = "https://github.com/Mark24Code/tomatos"
|
14
|
+
spec.license = "MIT"
|
15
|
+
spec.required_ruby_version = ">= 2.6.0"
|
16
|
+
|
17
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
18
|
+
spec.metadata["source_code_uri"] = "https://github.com/Mark24Code/tomatos"
|
19
|
+
spec.metadata["changelog_uri"] = "https://github.com/Mark24Code/tomatos"
|
20
|
+
|
21
|
+
# Specify which files should be added to the gem when it is released.
|
22
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
23
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
24
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
25
|
+
(f == __FILE__) || f.match(%r{\A(?:(?:test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
|
26
|
+
end
|
27
|
+
end
|
28
|
+
spec.bindir = "exe"
|
29
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
30
|
+
spec.require_paths = ["lib"]
|
31
|
+
|
32
|
+
# Uncomment to register a new dependency of your gem
|
33
|
+
# spec.add_dependency "example-gem", "~> 1.0"
|
34
|
+
|
35
|
+
# For more information and examples about making a new gem, check out our
|
36
|
+
# guide at: https://bundler.io/guides/creating_gem.html
|
37
|
+
end
|
metadata
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: tomatos
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Mark24
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-03-07 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Tomato click for mac terminal
|
14
|
+
email:
|
15
|
+
- mark.zhangyoung@qq.com
|
16
|
+
executables:
|
17
|
+
- tomatos
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- ".rubocop.yml"
|
22
|
+
- Gemfile
|
23
|
+
- LICENSE.txt
|
24
|
+
- README.md
|
25
|
+
- Rakefile
|
26
|
+
- bin/console
|
27
|
+
- bin/setup
|
28
|
+
- exe/tomatos
|
29
|
+
- lib/tomatos.rb
|
30
|
+
- lib/tomatos/version.rb
|
31
|
+
- sig/tomatos.rbs
|
32
|
+
- tomatos.gemspec
|
33
|
+
homepage: https://github.com/Mark24Code/tomatos
|
34
|
+
licenses:
|
35
|
+
- MIT
|
36
|
+
metadata:
|
37
|
+
homepage_uri: https://github.com/Mark24Code/tomatos
|
38
|
+
source_code_uri: https://github.com/Mark24Code/tomatos
|
39
|
+
changelog_uri: https://github.com/Mark24Code/tomatos
|
40
|
+
post_install_message:
|
41
|
+
rdoc_options: []
|
42
|
+
require_paths:
|
43
|
+
- lib
|
44
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: 2.6.0
|
49
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
requirements: []
|
55
|
+
rubygems_version: 3.3.3
|
56
|
+
signing_key:
|
57
|
+
specification_version: 4
|
58
|
+
summary: Tomato click for mac terminal
|
59
|
+
test_files: []
|