chronosphere 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 +18 -0
- data/.travis.yml +8 -0
- data/CHANGELOG.md +3 -0
- data/CONTRIBUTING.md +28 -0
- data/Gemfile +4 -0
- data/LICENSE +20 -0
- data/README.md +4 -0
- data/Rakefile +6 -0
- data/bin/chronosphere +7 -0
- data/chronosphere.gemspec +31 -0
- data/lib/chronosphere.rb +5 -0
- data/lib/chronosphere/cli.rb +62 -0
- data/lib/chronosphere/middleware.rb +43 -0
- data/lib/chronosphere/middleware/base.rb +28 -0
- data/lib/chronosphere/middleware/calendar.rb +22 -0
- data/lib/chronosphere/middleware/christmas.rb +22 -0
- data/lib/chronosphere/middleware/since.rb +30 -0
- data/lib/chronosphere/middleware/until.rb +29 -0
- data/lib/chronosphere/middleware/weekday.rb +21 -0
- data/lib/chronosphere/version.rb +3 -0
- data/spec/cli/calendar_spec.rb +21 -0
- data/spec/cli/christmas_spec.rb +41 -0
- data/spec/cli/help_cli_spec.rb +17 -0
- data/spec/cli/since_spec.rb +26 -0
- data/spec/cli/until_spec.rb +26 -0
- data/spec/cli/version_cli_spec.rb +16 -0
- data/spec/cli/weekday_spec.rb +21 -0
- data/spec/middleware/base_spec.rb +15 -0
- data/spec/shared/environment.rb +28 -0
- data/spec/spec_helper.rb +13 -0
- metadata +211 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 933042f987ddb5333d23643e37b26085f47aae66
|
4
|
+
data.tar.gz: 4636d2d57afa2d68de7fbf43d13ded066a21ead7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 91a7b0751d972da0c4dfcd121fa7de67754f62582a99243cfd3ca58cb1ff911232712096d41378547c9935415499e93c98a312186b7df7128ef2714091420789
|
7
|
+
data.tar.gz: aa441dd58475c16391c5833c0b0422b9c57ee255966377f25e21bb8196626697b44f6402014b796e82ed0395602a1ce44c22e0891bf941af479ea7ca01b084c5
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# Contributing
|
2
|
+
|
3
|
+
1. Fork it
|
4
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
5
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
6
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
7
|
+
5. Create new Pull Request
|
8
|
+
|
9
|
+
## Development Environment
|
10
|
+
|
11
|
+
To add a feature, fix a bug, or to run a development build of Chronosphere
|
12
|
+
on your machine, clone down the repo and run:
|
13
|
+
|
14
|
+
$ bundle
|
15
|
+
|
16
|
+
You can then execute chronosphere:
|
17
|
+
|
18
|
+
$ bundle exec chronosphere [command]
|
19
|
+
|
20
|
+
As well as run the tests:
|
21
|
+
|
22
|
+
$ bundle exec rspec
|
23
|
+
|
24
|
+
To install the gem on your system from source:
|
25
|
+
|
26
|
+
$ bundle exec rake install
|
27
|
+
|
28
|
+
If you need help with your environment, feel free to open an issue.
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2013 Peter Souter
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
7
|
+
the Software without restriction, including without limitation the rights to
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
10
|
+
subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
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, FITNESS
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
data/Rakefile
ADDED
data/bin/chronosphere
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'chronosphere/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "chronosphere"
|
8
|
+
gem.version = Chronosphere::VERSION
|
9
|
+
gem.authors = ["Peter Souter"]
|
10
|
+
gem.email = ["p.morsou@gmail.com"]
|
11
|
+
gem.description = %q{A command line tool for various calendar and date tasks}
|
12
|
+
gem.summary = %q{Chronosphere is a CLI for dates and calendar tasks.}
|
13
|
+
gem.homepage = "https://github.com/petems/chronosphere"
|
14
|
+
gem.license = 'MIT'
|
15
|
+
|
16
|
+
gem.files = `git ls-files`.split($/)
|
17
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
18
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
19
|
+
gem.require_paths = ["lib"]
|
20
|
+
|
21
|
+
gem.add_dependency "thor", "~> 0.18.1"
|
22
|
+
gem.add_dependency "middleware" , "~> 0.1.0"
|
23
|
+
gem.add_dependency "shellout", "~> 0.5"
|
24
|
+
gem.add_dependency "chronic", "~> 0.10.2"
|
25
|
+
|
26
|
+
gem.add_development_dependency "rake", "~> 10.1.0"
|
27
|
+
gem.add_development_dependency "rspec-core", "~> 2.13.0"
|
28
|
+
gem.add_development_dependency "rspec-expectations", "~> 2.13.0"
|
29
|
+
gem.add_development_dependency "rspec-mocks", "~> 2.13.0"
|
30
|
+
gem.add_development_dependency "timecop", "0.6.1"
|
31
|
+
end
|
data/lib/chronosphere.rb
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'thor'
|
2
|
+
|
3
|
+
module Chronosphere
|
4
|
+
autoload :Middleware, "chronosphere/middleware"
|
5
|
+
|
6
|
+
class CLI < Thor
|
7
|
+
include Thor::Actions
|
8
|
+
ENV['THOR_COLUMNS'] = '120'
|
9
|
+
|
10
|
+
!check_unknown_options
|
11
|
+
|
12
|
+
map "--version" => :version,
|
13
|
+
"-v" => :version
|
14
|
+
|
15
|
+
desc "help [COMMAND]", "Describe commands or a specific command"
|
16
|
+
def help(meth=nil)
|
17
|
+
super
|
18
|
+
if !meth
|
19
|
+
say "To learn more or to contribute, please see github.com/petems/chronosphere"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
desc "calendar", "Show a ascii calendar for a given date"
|
24
|
+
long_desc "This will print out an ascii calendar for a given date"
|
25
|
+
def calendar(date)
|
26
|
+
Middleware.sequence_calendar.call({"date" => date})
|
27
|
+
end
|
28
|
+
desc "cal", "An alias for calendar"
|
29
|
+
long_desc "`chronosphere help calendar` for full details"
|
30
|
+
alias :cal :calendar
|
31
|
+
|
32
|
+
desc "christmas", "Get days until christmas"
|
33
|
+
def christmas
|
34
|
+
Middleware.sequence_christmas.call()
|
35
|
+
end
|
36
|
+
|
37
|
+
desc "since", "Show the days since a certain date and todays date"
|
38
|
+
long_desc "This will print the days since a certain date"
|
39
|
+
def since(date)
|
40
|
+
Middleware.sequence_since.call({"date" => date})
|
41
|
+
end
|
42
|
+
|
43
|
+
desc "until", "Show the days until a certain date and todays date"
|
44
|
+
long_desc "This will print the days a certain date is away"
|
45
|
+
def until(date)
|
46
|
+
Middleware.sequence_until.call({"date" => date})
|
47
|
+
end
|
48
|
+
|
49
|
+
desc "weekday", "Show the weekday of a given date"
|
50
|
+
long_desc "This will print the weekday (Monday, Tuesday etc) of a given date"
|
51
|
+
def weekday(date)
|
52
|
+
Middleware.sequence_weekday.call({"date" => date})
|
53
|
+
end
|
54
|
+
|
55
|
+
desc "version", "Show version"
|
56
|
+
def version
|
57
|
+
say "Chronosphere #{Chronosphere::VERSION}"
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require "middleware"
|
2
|
+
|
3
|
+
module Chronosphere
|
4
|
+
module Middleware
|
5
|
+
autoload :Base, "chronosphere/middleware/base"
|
6
|
+
autoload :Calendar, "chronosphere/middleware/calendar"
|
7
|
+
autoload :Christmas, "chronosphere/middleware/christmas"
|
8
|
+
autoload :Since, "chronosphere/middleware/since"
|
9
|
+
autoload :Until, "chronosphere/middleware/until"
|
10
|
+
autoload :Weekday, "chronosphere/middleware/weekday"
|
11
|
+
|
12
|
+
def self.sequence_calendar
|
13
|
+
::Middleware::Builder.new do
|
14
|
+
use Calendar
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.sequence_since
|
19
|
+
::Middleware::Builder.new do
|
20
|
+
use Since
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.sequence_until
|
25
|
+
::Middleware::Builder.new do
|
26
|
+
use Until
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.sequence_weekday
|
31
|
+
::Middleware::Builder.new do
|
32
|
+
use Weekday
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.sequence_christmas
|
37
|
+
::Middleware::Builder.new do
|
38
|
+
use Christmas
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Chronosphere
|
2
|
+
module Middleware
|
3
|
+
# A base middleware class to initalize.
|
4
|
+
class Base
|
5
|
+
# Some colors for making things pretty.
|
6
|
+
CLEAR = "\e[0m"
|
7
|
+
RED = "\e[31m"
|
8
|
+
GREEN = "\e[32m"
|
9
|
+
YELLOW = "\e[33m"
|
10
|
+
|
11
|
+
# We want access to all of the fun thor cli helper methods,
|
12
|
+
# like say, yes?, ask, etc.
|
13
|
+
include Thor::Shell
|
14
|
+
|
15
|
+
def initialize(app)
|
16
|
+
@app = app
|
17
|
+
# This resets the color to "clear" on the user's terminal.
|
18
|
+
say "", :clear, false
|
19
|
+
end
|
20
|
+
|
21
|
+
def call(env)
|
22
|
+
@app.call(env)
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'chronic'
|
2
|
+
require 'shellout'
|
3
|
+
include Shellout
|
4
|
+
|
5
|
+
module Chronosphere
|
6
|
+
module Middleware
|
7
|
+
class Calendar < Base
|
8
|
+
def call(env)
|
9
|
+
|
10
|
+
cli_date = env["date"]
|
11
|
+
|
12
|
+
parsed_date = Chronic.parse(cli_date)
|
13
|
+
|
14
|
+
say Calendar(Date.parse(parsed_date.to_s)).print
|
15
|
+
|
16
|
+
@app.call(env)
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
module Chronosphere
|
3
|
+
module Middleware
|
4
|
+
class Christmas < Base
|
5
|
+
def call(env)
|
6
|
+
|
7
|
+
today = DateTime.now
|
8
|
+
christmas = DateTime.new(DateTime.now.year, 12, 25)
|
9
|
+
christmas = DateTime.new(DateTime.now.year+1, 12, 25) if today > christmas
|
10
|
+
days_left = (christmas - today).to_i
|
11
|
+
if days_left == 0
|
12
|
+
say "\xF0\x9F\x8E\x84 Today is Christmas! \xF0\x9F\x8E\x84 Ho,ho,ho! \xF0\x9F\x8E\x85 "
|
13
|
+
else
|
14
|
+
say "Only #{days_left} day#{"s" unless days_left==1} until Christmas!"
|
15
|
+
end
|
16
|
+
|
17
|
+
@app.call(env)
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'chronic'
|
2
|
+
|
3
|
+
module Chronosphere
|
4
|
+
module Middleware
|
5
|
+
class Since < Base
|
6
|
+
def call(env)
|
7
|
+
|
8
|
+
cli_date = env["date"]
|
9
|
+
|
10
|
+
parsed_date = Chronic.parse(cli_date)
|
11
|
+
|
12
|
+
parsed_date = Date.parse(parsed_date.to_s)
|
13
|
+
|
14
|
+
if (parsed_date > Date.today)
|
15
|
+
say "You've asked for days since a date in the future!", :red
|
16
|
+
say "Use `chronosphere until '#{cli_date}' instead`", :green
|
17
|
+
exit 1
|
18
|
+
end
|
19
|
+
|
20
|
+
days_since = (Date.today - parsed_date).to_i
|
21
|
+
|
22
|
+
say "It's been #{days_since} days since #{cli_date}"
|
23
|
+
|
24
|
+
@app.call(env)
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'chronic'
|
2
|
+
|
3
|
+
module Chronosphere
|
4
|
+
module Middleware
|
5
|
+
class Until < Base
|
6
|
+
def call(env)
|
7
|
+
|
8
|
+
cli_date = env["date"]
|
9
|
+
|
10
|
+
parsed_date = Chronic.parse(cli_date)
|
11
|
+
|
12
|
+
parsed_date = Date.parse(parsed_date.to_s)
|
13
|
+
|
14
|
+
if (parsed_date < Date.today)
|
15
|
+
say "You've asked for days until a date in the past!", :red
|
16
|
+
say "Use `chronosphere since '#{cli_date}' instead`", :green
|
17
|
+
exit 1
|
18
|
+
end
|
19
|
+
|
20
|
+
days_until = (Date.parse(parsed_date.to_s) - Date.today).to_i
|
21
|
+
|
22
|
+
say "It'll be #{days_until} days until #{cli_date}"
|
23
|
+
|
24
|
+
@app.call(env)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'chronic'
|
2
|
+
|
3
|
+
module Chronosphere
|
4
|
+
module Middleware
|
5
|
+
class Weekday < Base
|
6
|
+
def call(env)
|
7
|
+
|
8
|
+
cli_date = env["date"]
|
9
|
+
|
10
|
+
parsed_date = Chronic.parse(cli_date)
|
11
|
+
|
12
|
+
parsed_date = Date.parse(parsed_date.to_s)
|
13
|
+
|
14
|
+
say "The weekday of #{cli_date} is #{parsed_date.strftime('%A')}"
|
15
|
+
|
16
|
+
@app.call(env)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'timecop'
|
3
|
+
|
4
|
+
describe Chronosphere::CLI do
|
5
|
+
include_context "spec"
|
6
|
+
|
7
|
+
before do
|
8
|
+
Timecop.freeze(Time.local(2012))
|
9
|
+
end
|
10
|
+
|
11
|
+
after do
|
12
|
+
Timecop.return
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "calendar" do
|
16
|
+
it "shows a shows a calendar for a given string" do
|
17
|
+
@cli.calendar('next month')
|
18
|
+
expect($stdout.string).to eq " February 2012 \nMo Tu We Th Fr Sa Su \n 1 2 3 4 5 \n 6 7 8 9 10 11 12 \n13 14 15 16 17 18 19 \n20 21 22 23 24 25 26 \n27 28 29 \n\n"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'timecop'
|
4
|
+
|
5
|
+
describe Chronosphere::CLI do
|
6
|
+
include_context "spec"
|
7
|
+
|
8
|
+
after do
|
9
|
+
Timecop.return
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "christmas" do
|
13
|
+
it "gives number of days until christmas before" do
|
14
|
+
new_time = Time.local(2012, 12, 15)
|
15
|
+
Timecop.freeze(new_time)
|
16
|
+
@cli.christmas
|
17
|
+
expect($stdout.string).to include "Only 10 days until Christmas!\n"
|
18
|
+
end
|
19
|
+
|
20
|
+
it "gives number of days until christmas before in singular days" do
|
21
|
+
new_time = Time.local(2012, 12, 24)
|
22
|
+
Timecop.freeze(new_time)
|
23
|
+
@cli.christmas
|
24
|
+
expect($stdout.string).to include "Only 1 day until Christmas!\n"
|
25
|
+
end
|
26
|
+
|
27
|
+
it "returns happy message on the day" do
|
28
|
+
new_time = Time.local(2012, 12, 25)
|
29
|
+
Timecop.freeze(new_time)
|
30
|
+
@cli.christmas
|
31
|
+
expect($stdout.string).to include "\xF0\x9F\x8E\x84 Today is Christmas! \xF0\x9F\x8E\x84 Ho,ho,ho! \xF0\x9F\x8E\x85"
|
32
|
+
end
|
33
|
+
|
34
|
+
it "gives number of days until christmas after" do
|
35
|
+
new_time = Time.local(2012, 1, 1)
|
36
|
+
Timecop.freeze(new_time)
|
37
|
+
@cli.christmas
|
38
|
+
expect($stdout.string).to include "Only 359 days until Christmas!\n"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Chronosphere::CLI do
|
4
|
+
include_context "spec"
|
5
|
+
|
6
|
+
describe "help" do
|
7
|
+
it "shows a help message" do
|
8
|
+
@cli.help
|
9
|
+
expect($stdout.string).to match("Commands:")
|
10
|
+
end
|
11
|
+
|
12
|
+
it "shows a help message for specific commands" do
|
13
|
+
@cli.help "version"
|
14
|
+
expect($stdout.string).to match("Usage:")
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'timecop'
|
3
|
+
|
4
|
+
describe Chronosphere::CLI do
|
5
|
+
include_context "spec"
|
6
|
+
|
7
|
+
before do
|
8
|
+
Timecop.freeze(Time.local(2012))
|
9
|
+
end
|
10
|
+
|
11
|
+
after do
|
12
|
+
Timecop.return
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "since" do
|
16
|
+
it "returns error string if you give a date in the future" do
|
17
|
+
expect{@cli.since('next year')}.to raise_error(SystemExit)
|
18
|
+
expect($stdout.string).to eq "You've asked for days since a date in the future!\nUse `chronosphere until 'next year' instead`\n"
|
19
|
+
end
|
20
|
+
|
21
|
+
it "returns the amount of days until a date" do
|
22
|
+
@cli.since('a year ago')
|
23
|
+
expect($stdout.string).to eq "It's been 365 days since a year ago\n"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'timecop'
|
3
|
+
|
4
|
+
describe Chronosphere::CLI do
|
5
|
+
include_context "spec"
|
6
|
+
|
7
|
+
before do
|
8
|
+
Timecop.freeze(Time.local(2012))
|
9
|
+
end
|
10
|
+
|
11
|
+
after do
|
12
|
+
Timecop.return
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "until" do
|
16
|
+
it "returns error string if you give a date in the past" do
|
17
|
+
expect{@cli.since('next year')}.to raise_error(SystemExit)
|
18
|
+
expect($stdout.string).to eq "You've asked for days since a date in the future!\nUse `chronosphere until 'next year' instead`\n"
|
19
|
+
end
|
20
|
+
|
21
|
+
it "returns the amount of days until a date" do
|
22
|
+
@cli.until('a year from now')
|
23
|
+
expect($stdout.string).to eq "It'll be 366 days until a year from now\n"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Chronosphere::CLI do
|
4
|
+
include_context "spec"
|
5
|
+
|
6
|
+
describe "version" do
|
7
|
+
it "shows the correct version" do
|
8
|
+
|
9
|
+
@cli.options = @cli.options.merge(:version => true)
|
10
|
+
@cli.version
|
11
|
+
|
12
|
+
expect($stdout.string.chomp).to eq("Chronosphere #{Chronosphere::VERSION.to_s}")
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'timecop'
|
3
|
+
|
4
|
+
describe Chronosphere::CLI do
|
5
|
+
include_context "spec"
|
6
|
+
|
7
|
+
before do
|
8
|
+
Timecop.freeze(Time.local(2012))
|
9
|
+
end
|
10
|
+
|
11
|
+
after do
|
12
|
+
Timecop.return
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "weekday" do
|
16
|
+
it "returns the day of the week from a date" do
|
17
|
+
@cli.weekday('december 25th')
|
18
|
+
expect($stdout.string).to eq "The weekday of december 25th is Tuesday\n"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Chronosphere::Middleware::Base do
|
4
|
+
include_context "spec"
|
5
|
+
|
6
|
+
let(:klass) { described_class }
|
7
|
+
|
8
|
+
describe ".initialize" do
|
9
|
+
it "prints a clear line" do
|
10
|
+
$stdout.should_receive(:print).with("")
|
11
|
+
klass.new({})
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
shared_context "spec" do
|
4
|
+
let(:app) { lambda { |env| } }
|
5
|
+
let(:env) { {} }
|
6
|
+
|
7
|
+
before(:each) do
|
8
|
+
$stdout.sync = true
|
9
|
+
$stderr.sync = true
|
10
|
+
|
11
|
+
@cli = Chronosphere::CLI.new
|
12
|
+
|
13
|
+
# Keep track of the old stderr / out
|
14
|
+
@orig_stderr = $stderr
|
15
|
+
@orig_stdout = $stdout
|
16
|
+
|
17
|
+
# Make them strings so we can manipulate and compare.
|
18
|
+
$stderr = StringIO.new
|
19
|
+
$stdout = StringIO.new
|
20
|
+
end
|
21
|
+
|
22
|
+
after(:each) do
|
23
|
+
# Reassign the stderr / out so rspec can have it back.
|
24
|
+
$stderr = @orig_stderr
|
25
|
+
$stdout = @orig_stdout
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,211 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: chronosphere
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Peter Souter
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-12-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: thor
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.18.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.18.1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: middleware
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.1.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.1.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: shellout
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0.5'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.5'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: chronic
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.10.2
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.10.2
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ~>
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 10.1.0
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ~>
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 10.1.0
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec-core
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ~>
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 2.13.0
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ~>
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 2.13.0
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rspec-expectations
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ~>
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 2.13.0
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ~>
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 2.13.0
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rspec-mocks
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ~>
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 2.13.0
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ~>
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 2.13.0
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: timecop
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - '='
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: 0.6.1
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - '='
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: 0.6.1
|
139
|
+
description: A command line tool for various calendar and date tasks
|
140
|
+
email:
|
141
|
+
- p.morsou@gmail.com
|
142
|
+
executables:
|
143
|
+
- chronosphere
|
144
|
+
extensions: []
|
145
|
+
extra_rdoc_files: []
|
146
|
+
files:
|
147
|
+
- .gitignore
|
148
|
+
- .travis.yml
|
149
|
+
- CHANGELOG.md
|
150
|
+
- CONTRIBUTING.md
|
151
|
+
- Gemfile
|
152
|
+
- LICENSE
|
153
|
+
- README.md
|
154
|
+
- Rakefile
|
155
|
+
- bin/chronosphere
|
156
|
+
- chronosphere.gemspec
|
157
|
+
- lib/chronosphere.rb
|
158
|
+
- lib/chronosphere/cli.rb
|
159
|
+
- lib/chronosphere/middleware.rb
|
160
|
+
- lib/chronosphere/middleware/base.rb
|
161
|
+
- lib/chronosphere/middleware/calendar.rb
|
162
|
+
- lib/chronosphere/middleware/christmas.rb
|
163
|
+
- lib/chronosphere/middleware/since.rb
|
164
|
+
- lib/chronosphere/middleware/until.rb
|
165
|
+
- lib/chronosphere/middleware/weekday.rb
|
166
|
+
- lib/chronosphere/version.rb
|
167
|
+
- spec/cli/calendar_spec.rb
|
168
|
+
- spec/cli/christmas_spec.rb
|
169
|
+
- spec/cli/help_cli_spec.rb
|
170
|
+
- spec/cli/since_spec.rb
|
171
|
+
- spec/cli/until_spec.rb
|
172
|
+
- spec/cli/version_cli_spec.rb
|
173
|
+
- spec/cli/weekday_spec.rb
|
174
|
+
- spec/middleware/base_spec.rb
|
175
|
+
- spec/shared/environment.rb
|
176
|
+
- spec/spec_helper.rb
|
177
|
+
homepage: https://github.com/petems/chronosphere
|
178
|
+
licenses:
|
179
|
+
- MIT
|
180
|
+
metadata: {}
|
181
|
+
post_install_message:
|
182
|
+
rdoc_options: []
|
183
|
+
require_paths:
|
184
|
+
- lib
|
185
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
186
|
+
requirements:
|
187
|
+
- - '>='
|
188
|
+
- !ruby/object:Gem::Version
|
189
|
+
version: '0'
|
190
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - '>='
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: '0'
|
195
|
+
requirements: []
|
196
|
+
rubyforge_project:
|
197
|
+
rubygems_version: 2.4.4
|
198
|
+
signing_key:
|
199
|
+
specification_version: 4
|
200
|
+
summary: Chronosphere is a CLI for dates and calendar tasks.
|
201
|
+
test_files:
|
202
|
+
- spec/cli/calendar_spec.rb
|
203
|
+
- spec/cli/christmas_spec.rb
|
204
|
+
- spec/cli/help_cli_spec.rb
|
205
|
+
- spec/cli/since_spec.rb
|
206
|
+
- spec/cli/until_spec.rb
|
207
|
+
- spec/cli/version_cli_spec.rb
|
208
|
+
- spec/cli/weekday_spec.rb
|
209
|
+
- spec/middleware/base_spec.rb
|
210
|
+
- spec/shared/environment.rb
|
211
|
+
- spec/spec_helper.rb
|