terminal_cal 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +8 -0
- data/.travis.yml +7 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +34 -0
- data/LICENSE.txt +21 -0
- data/README.md +10 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/bin/terminal_cal +29 -0
- data/exe/terminal_cal +5 -0
- data/lib/terminal_cal/app.rb +71 -0
- data/lib/terminal_cal/config.rb +32 -0
- data/lib/terminal_cal/event.rb +12 -0
- data/lib/terminal_cal/version.rb +3 -0
- data/lib/terminal_cal.rb +12 -0
- data/terminal_cal.gemspec +47 -0
- data/vendor/cache/coderay-1.1.2.gem +0 -0
- data/vendor/cache/colorize-0.8.1.gem +0 -0
- data/vendor/cache/ics_parser-0.0.3.gem +0 -0
- data/vendor/cache/method_source-0.9.2.gem +0 -0
- data/vendor/cache/minitest-5.11.3.gem +0 -0
- data/vendor/cache/pry-0.12.2.gem +0 -0
- data/vendor/cache/rake-10.5.0.gem +0 -0
- data/vendor/cache/table_print-1.5.6.gem +0 -0
- metadata +171 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8cd5fb9cde3b246549f7a44e1a068559164eeddb
|
4
|
+
data.tar.gz: 4b97366cce752dd4ac5d1b28ec9a621f47df2465
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 06241aa95470a2f2bff3f31d8fc46a837d78a64be3f27d074318df6b4b9ad6516b43d98bc2880103f51ad0695bf98f99e15a51b5a6fa68eaae413d675263b73d
|
7
|
+
data.tar.gz: 0a9b669701c2ca9bc4b185eebc2eebbecc055d4853f84e273a6e6883fc0907e205ac1c184a21127f9439adf1252b304f8ad0870bbb9f09301c4f264032f9cf66
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
terminal_cal (0.1.0)
|
5
|
+
colorize (~> 0.8.1)
|
6
|
+
ics_parser (~> 0.0.3)
|
7
|
+
table_print (~> 1.5)
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
coderay (1.1.2)
|
13
|
+
colorize (0.8.1)
|
14
|
+
ics_parser (0.0.3)
|
15
|
+
method_source (0.9.2)
|
16
|
+
minitest (5.11.3)
|
17
|
+
pry (0.12.2)
|
18
|
+
coderay (~> 1.1.0)
|
19
|
+
method_source (~> 0.9.0)
|
20
|
+
rake (10.5.0)
|
21
|
+
table_print (1.5.6)
|
22
|
+
|
23
|
+
PLATFORMS
|
24
|
+
ruby
|
25
|
+
|
26
|
+
DEPENDENCIES
|
27
|
+
bundler (~> 2.0)
|
28
|
+
minitest (~> 5.0)
|
29
|
+
pry (~> 0.12.2)
|
30
|
+
rake (~> 10.0)
|
31
|
+
terminal_cal!
|
32
|
+
|
33
|
+
BUNDLED WITH
|
34
|
+
2.0.1
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 Chris Roerig
|
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,10 @@
|
|
1
|
+
# TerminalCal
|
2
|
+
|
3
|
+
|
4
|
+
## Contributing
|
5
|
+
|
6
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/chris-roerig/terminal_cal.
|
7
|
+
|
8
|
+
## License
|
9
|
+
|
10
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "terminal_cal"
|
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
data/bin/terminal_cal
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'terminal_cal' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("terminal_cal", "terminal_cal")
|
data/exe/terminal_cal
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
module TerminalCal
|
2
|
+
class App
|
3
|
+
DATE_FMT = '%m/%d'.freeze
|
4
|
+
TIME_FMT = '%I:%M %p'.freeze
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
@config = Config.load
|
8
|
+
@today = Time.now.strftime(DATE_FMT)
|
9
|
+
@events = []
|
10
|
+
@parser = IcsParser
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.run
|
14
|
+
new.run
|
15
|
+
end
|
16
|
+
|
17
|
+
def run
|
18
|
+
config_check
|
19
|
+
load_events
|
20
|
+
print_events
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def config_check
|
26
|
+
@ics = @config[:ics]
|
27
|
+
|
28
|
+
if @ics.to_s.empty?
|
29
|
+
puts "no ics path defined in #{Config::CONFIG_PATH}"
|
30
|
+
exit
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def load_events
|
35
|
+
now = Time.now
|
36
|
+
events = @parser.from_string(read_cal_file).events
|
37
|
+
|
38
|
+
events.sort_by { |e| e.starts_at.to_i }.each do |event|
|
39
|
+
next unless event.starts_at.strftime(DATE_FMT) == @today
|
40
|
+
|
41
|
+
if (event.starts_at..event.ends_at).include?(now)
|
42
|
+
active = "==="
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
@events << Event.new(date: event.starts_at.strftime(DATE_FMT),
|
47
|
+
start_time: event.starts_at.strftime(TIME_FMT),
|
48
|
+
end_time: "#{event.ends_at.strftime(TIME_FMT)} #{active}",
|
49
|
+
summary: event.summary)
|
50
|
+
# end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def print_events
|
55
|
+
unless @events.empty?
|
56
|
+
tp @events
|
57
|
+
else
|
58
|
+
puts "No events scheduled yet."
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def read_cal_file
|
63
|
+
cal = Tempfile.new
|
64
|
+
cal.write(open(@ics) { |f| f.read } )
|
65
|
+
cal.rewind
|
66
|
+
cal.read
|
67
|
+
ensure
|
68
|
+
cal.close
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module TerminalCal
|
2
|
+
class Config
|
3
|
+
CONFIG_DIR = File.join(Dir.home, '.terminal_cal')
|
4
|
+
CONFIG_FILE = 'config.yaml'.freeze
|
5
|
+
CONFIG_PATH = File.join(CONFIG_DIR, CONFIG_FILE)
|
6
|
+
|
7
|
+
def self.load
|
8
|
+
unless File.exist?(CONFIG_PATH)
|
9
|
+
FileUtils.mkdir_p(CONFIG_DIR)
|
10
|
+
FileUtils.touch(CONFIG_PATH)
|
11
|
+
end
|
12
|
+
|
13
|
+
config = self.read
|
14
|
+
|
15
|
+
if config[:ics].to_s.empty?
|
16
|
+
self.write(:ics, '')
|
17
|
+
end
|
18
|
+
|
19
|
+
config
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.write(key, value)
|
23
|
+
config = self.read
|
24
|
+
config[key] = value
|
25
|
+
File.write(CONFIG_PATH, config.to_yaml)
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.read
|
29
|
+
YAML.load_file(CONFIG_PATH) || {}
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module TerminalCal
|
2
|
+
class Event
|
3
|
+
attr_reader :date, :start_time, :end_time, :summary
|
4
|
+
|
5
|
+
def initialize(options)
|
6
|
+
@date = options[:date]
|
7
|
+
@start_time = options[:start_time]
|
8
|
+
@end_time = options[:end_time]
|
9
|
+
@summary = options[:summary]
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
data/lib/terminal_cal.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'ics_parser'
|
2
|
+
require 'open-uri'
|
3
|
+
require 'table_print'
|
4
|
+
require 'fileutils'
|
5
|
+
require 'yaml'
|
6
|
+
require 'tempfile'
|
7
|
+
require 'colorize'
|
8
|
+
|
9
|
+
require 'terminal_cal/version'
|
10
|
+
require 'terminal_cal/config'
|
11
|
+
require 'terminal_cal/event'
|
12
|
+
require 'terminal_cal/app'
|
@@ -0,0 +1,47 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "terminal_cal/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "terminal_cal"
|
8
|
+
spec.version = TerminalCal::VERSION
|
9
|
+
spec.authors = ["Chris Roerig"]
|
10
|
+
spec.email = ["idwyjm@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Prints ics calendar events in the terminal}
|
13
|
+
spec.homepage = "https://github.com/chris-roerig/terminal_cal"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
17
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
18
|
+
if spec.respond_to?(:metadata)
|
19
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org/"
|
20
|
+
|
21
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
22
|
+
spec.metadata["source_code_uri"] = "https://github.com/chris-roerig/terminal_cal"
|
23
|
+
# spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
|
24
|
+
else
|
25
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
26
|
+
"public gem pushes."
|
27
|
+
end
|
28
|
+
|
29
|
+
# Specify which files should be added to the gem when it is released.
|
30
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
31
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
32
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
33
|
+
end
|
34
|
+
|
35
|
+
spec.bindir = "exe"
|
36
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
37
|
+
spec.require_paths = ["lib"]
|
38
|
+
|
39
|
+
spec.add_dependency "ics_parser", "~> 0.0.3"
|
40
|
+
spec.add_dependency "table_print", "~> 1.5"
|
41
|
+
spec.add_dependency "colorize", "~> 0.8.1"
|
42
|
+
|
43
|
+
spec.add_development_dependency "pry", "~> 0.12.2"
|
44
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
45
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
46
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
47
|
+
end
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
metadata
ADDED
@@ -0,0 +1,171 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: terminal_cal
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Chris Roerig
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-07-26 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: ics_parser
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.0.3
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.0.3
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: table_print
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.5'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.5'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: colorize
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.8.1
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.8.1
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.12.2
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.12.2
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: bundler
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '2.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '2.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rake
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '10.0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '10.0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: minitest
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '5.0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '5.0'
|
111
|
+
description:
|
112
|
+
email:
|
113
|
+
- idwyjm@gmail.com
|
114
|
+
executables:
|
115
|
+
- terminal_cal
|
116
|
+
extensions: []
|
117
|
+
extra_rdoc_files: []
|
118
|
+
files:
|
119
|
+
- ".gitignore"
|
120
|
+
- ".travis.yml"
|
121
|
+
- Gemfile
|
122
|
+
- Gemfile.lock
|
123
|
+
- LICENSE.txt
|
124
|
+
- README.md
|
125
|
+
- Rakefile
|
126
|
+
- bin/console
|
127
|
+
- bin/setup
|
128
|
+
- bin/terminal_cal
|
129
|
+
- exe/terminal_cal
|
130
|
+
- lib/terminal_cal.rb
|
131
|
+
- lib/terminal_cal/app.rb
|
132
|
+
- lib/terminal_cal/config.rb
|
133
|
+
- lib/terminal_cal/event.rb
|
134
|
+
- lib/terminal_cal/version.rb
|
135
|
+
- terminal_cal.gemspec
|
136
|
+
- vendor/cache/coderay-1.1.2.gem
|
137
|
+
- vendor/cache/colorize-0.8.1.gem
|
138
|
+
- vendor/cache/ics_parser-0.0.3.gem
|
139
|
+
- vendor/cache/method_source-0.9.2.gem
|
140
|
+
- vendor/cache/minitest-5.11.3.gem
|
141
|
+
- vendor/cache/pry-0.12.2.gem
|
142
|
+
- vendor/cache/rake-10.5.0.gem
|
143
|
+
- vendor/cache/table_print-1.5.6.gem
|
144
|
+
homepage: https://github.com/chris-roerig/terminal_cal
|
145
|
+
licenses:
|
146
|
+
- MIT
|
147
|
+
metadata:
|
148
|
+
allowed_push_host: https://rubygems.org/
|
149
|
+
homepage_uri: https://github.com/chris-roerig/terminal_cal
|
150
|
+
source_code_uri: https://github.com/chris-roerig/terminal_cal
|
151
|
+
post_install_message:
|
152
|
+
rdoc_options: []
|
153
|
+
require_paths:
|
154
|
+
- lib
|
155
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
161
|
+
requirements:
|
162
|
+
- - ">="
|
163
|
+
- !ruby/object:Gem::Version
|
164
|
+
version: '0'
|
165
|
+
requirements: []
|
166
|
+
rubyforge_project:
|
167
|
+
rubygems_version: 2.6.12
|
168
|
+
signing_key:
|
169
|
+
specification_version: 4
|
170
|
+
summary: Prints ics calendar events in the terminal
|
171
|
+
test_files: []
|