work_guide 1.0.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: 2ee2817fc90609c9619d184b7ee830e3c9a9668c
4
+ data.tar.gz: a1f10dff3fbd65372c01dbf4275476d96e03e8b8
5
+ SHA512:
6
+ metadata.gz: bdf813960760883db86e147800e8b090fda3959e83eab16c66bb7e113966a06046c499e093ad1117d33bcc12da45c3d233a1bdcf336411e5a52fb7a523ea548e
7
+ data.tar.gz: c330080fbeba4b118f3c569d4208e92873cede04bc89f0ae059b26dc9aa789bf3a2921e082b0f9848e957b1d3299532f68285a95119ea063ede0c54752c92898
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.2
4
+ before_install: gem install bundler -v 1.10.5
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in work_guide.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 adorechic
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,42 @@
1
+ # WorkGuide
2
+
3
+ WorkGuide is a CLI tool to listup your routine tasks.
4
+
5
+ ```
6
+ +-----+-----+--------+------------------+-------------------------+
7
+ |index|cycle|priorify|description |done_at |
8
+ +-----+-----+--------+------------------+-------------------------+
9
+ |0 |daily|high |Study langueages |2015-11-07 00:04:44 +0900|
10
+ |1 |daily|medium |Review team repos |2015-11-07 00:13:56 +0900|
11
+ |2 |daily|low |Running at gym |2015-11-07 18:58:15 +0900|
12
+ +-----+-----+--------+------------------+-------------------------+
13
+ ```
14
+
15
+ ## Installation
16
+
17
+ $ gem install work_guide
18
+
19
+ ## Usage
20
+
21
+ ```
22
+ Commands:
23
+ wguide add [guide description] # Add a new guide
24
+ wguide delete [index] # Delete a guide
25
+ wguide done [index] # Mark as done
26
+ wguide help [COMMAND] # Describe available commands or one specific command
27
+ wguide list # List guides
28
+ wguide update [index] # Edit a guide
29
+ ```
30
+
31
+ ## Development
32
+
33
+ `rake test` to test all.
34
+
35
+ ## Contributing
36
+
37
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/work_guide. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
38
+
39
+
40
+ ## License
41
+
42
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList['test/**/*_test.rb']
8
+ end
9
+
10
+ task :default => :test
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "work_guide"
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,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
data/exe/wguide ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'work_guide'
4
+ WorkGuide::CLI.start(ARGV)
@@ -0,0 +1,67 @@
1
+ require 'thor'
2
+ require 'kosi'
3
+
4
+ module WorkGuide
5
+ class CLI < Thor
6
+ desc "add [guide description]", "Add a new guide"
7
+ option :cycle, default: 'daily', banner: '[hourly|daily|weekly|monthly]', aliases: :c
8
+ def add(description)
9
+ guide = Guide.create(
10
+ description: description,
11
+ cycle: options[:cycle]
12
+ )
13
+ puts "Created [#{Guide.all.size - 1}]#{guide}"
14
+ end
15
+
16
+ desc "update [index]", "Edit a guide"
17
+ option :priority, default: 'medium', banner: '[high|medium|low]'
18
+ def update(index)
19
+ guide = Guide.all[index.to_i]
20
+ guide.priority = options[:priority] if options[:priority]
21
+ Guide.save
22
+ puts "Update [#{index}]#{guide}"
23
+ end
24
+
25
+ desc "list", "List guides"
26
+ option :all, type: :boolean, default: false, aliases: :a
27
+ def list
28
+ table = Kosi::Table.new(
29
+ header: %w(index cycle priorify description done_at)
30
+ )
31
+
32
+ rows = Guide.all.map.with_index { |guide, index|
33
+ [index, guide]
34
+ }.select { |index, guide|
35
+ options[:all] || guide.should_do?
36
+ }.sort_by { |index, guide|
37
+ guide.priority_rate
38
+ }.map { |index, guide|
39
+ [index, guide.cycle, guide.priority, guide.description, guide.done_at]
40
+ }
41
+
42
+ puts table.render(rows)
43
+ end
44
+
45
+ desc "delete [index]", "Delete a guide"
46
+ def delete(index)
47
+ guide = Guide.all.delete_at(index.to_i)
48
+ Guide.save
49
+ puts "Deleted [#{index}]#{guide}"
50
+ end
51
+
52
+ desc "done [index]", "Mark as done"
53
+ option :at, banner: "done_at"
54
+ def done(index)
55
+ guide = Guide.all[index.to_i]
56
+ guide.done_at =
57
+ if options[:at]
58
+ Time.parse(options[:at])
59
+ else
60
+ Time.now
61
+ end
62
+
63
+ Guide.save
64
+ puts "Done [#{index}]#{guide}"
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,86 @@
1
+ require 'active_support'
2
+ require 'active_support/core_ext'
3
+
4
+ module WorkGuide
5
+ class Guide
6
+ attr_accessor :description, :cycle, :done_at, :priority
7
+
8
+ class << self
9
+ def create(args)
10
+ guide = new(args)
11
+ all << guide
12
+ save
13
+ guide
14
+ end
15
+
16
+ def all
17
+ @all ||= Storage.new(:guide).load.map { |h| new(h.symbolize_keys) }
18
+ end
19
+
20
+ def save
21
+ Storage.new(:guide).store(to_json)
22
+ end
23
+
24
+ private
25
+
26
+ def to_json
27
+ all.map(&:to_h).to_json
28
+ end
29
+ end
30
+
31
+ def initialize(
32
+ description: ,
33
+ cycle: 'daily',
34
+ done_at: nil,
35
+ priority: 'medium'
36
+ )
37
+ @description = description
38
+ @cycle = cycle
39
+ if done_at
40
+ @done_at = Time.parse(done_at)
41
+ end
42
+ @priority = priority
43
+ end
44
+
45
+ def should_do?
46
+ if done_at
47
+ case cycle
48
+ when 'hourly'
49
+ 1.hour.since(done_at).beginning_of_hour.past?
50
+ when 'daily'
51
+ 1.day.since(done_at).beginning_of_day.past?
52
+ when 'weekly'
53
+ 1.week.since(done_at).beginning_of_day.past?
54
+ when 'monthly'
55
+ 1.month.since(done_at).beginning_of_month.past?
56
+ else
57
+ raise ArgumentError, "Unknown cycle: #{cycle}"
58
+ end
59
+ else
60
+ true
61
+ end
62
+ end
63
+
64
+ def priority_rate
65
+ case priority
66
+ when 'high' ; 1
67
+ when 'medium'; 2
68
+ when 'low' ; 3
69
+ else ; 9
70
+ end
71
+ end
72
+
73
+ def to_h
74
+ {
75
+ description: description,
76
+ cycle: cycle,
77
+ done_at: done_at,
78
+ priority: priority,
79
+ }
80
+ end
81
+
82
+ def to_s
83
+ "[#{cycle}/#{priority}] #{description} (#{done_at || '--'})"
84
+ end
85
+ end
86
+ end
@@ -0,0 +1,33 @@
1
+ require 'json'
2
+ require 'pathname'
3
+
4
+ module WorkGuide
5
+ class Storage
6
+
7
+ def initialize(name)
8
+ @path = work_guide_dir.join(name.to_s)
9
+ end
10
+
11
+ def load
12
+ if @path.exist?
13
+ JSON.parse(@path.read)
14
+ else
15
+ []
16
+ end
17
+ end
18
+
19
+ def store(json)
20
+ @path.open('w') do |f|
21
+ f.puts json
22
+ end
23
+ end
24
+
25
+ private
26
+
27
+ def work_guide_dir
28
+ Pathname.new(Dir.home).join('.work_guide').tap do |dir|
29
+ dir.mkpath
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,3 @@
1
+ module WorkGuide
2
+ VERSION = "1.0.0"
3
+ end
data/lib/work_guide.rb ADDED
@@ -0,0 +1,7 @@
1
+ require "work_guide/version"
2
+ require "work_guide/cli"
3
+ require "work_guide/guide"
4
+ require "work_guide/storage"
5
+
6
+ module WorkGuide
7
+ end
@@ -0,0 +1,33 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'work_guide/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "work_guide"
8
+ spec.version = WorkGuide::VERSION
9
+ spec.authors = ["adorechic"]
10
+ spec.email = ["adorechic@gmail.com"]
11
+
12
+ spec.summary = %q{CLI tool to listup routine tasks}
13
+ spec.description = %q{WorkGuide is a CLI tool to manage your routine tasks}
14
+ spec.homepage = "https://github.com/adorechic/work_guide"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_dependency "thor"
23
+ spec.add_dependency "activesupport"
24
+ spec.add_dependency "kosi"
25
+
26
+ spec.add_development_dependency "bundler", "~> 1.10"
27
+ spec.add_development_dependency "rake", "~> 10.0"
28
+ spec.add_development_dependency "minitest"
29
+ spec.add_development_dependency "minitest-reporters"
30
+ spec.add_development_dependency "fakefs"
31
+ spec.add_development_dependency "pry"
32
+ spec.add_development_dependency "timecop"
33
+ end
metadata ADDED
@@ -0,0 +1,201 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: work_guide
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - adorechic
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-11-08 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'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: activesupport
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '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'
41
+ - !ruby/object:Gem::Dependency
42
+ name: kosi
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.10'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.10'
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.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.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: minitest
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: minitest-reporters
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: fakefs
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: pry
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: timecop
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ description: WorkGuide is a CLI tool to manage your routine tasks
154
+ email:
155
+ - adorechic@gmail.com
156
+ executables:
157
+ - wguide
158
+ extensions: []
159
+ extra_rdoc_files: []
160
+ files:
161
+ - ".gitignore"
162
+ - ".travis.yml"
163
+ - CODE_OF_CONDUCT.md
164
+ - Gemfile
165
+ - LICENSE.txt
166
+ - README.md
167
+ - Rakefile
168
+ - bin/console
169
+ - bin/setup
170
+ - exe/wguide
171
+ - lib/work_guide.rb
172
+ - lib/work_guide/cli.rb
173
+ - lib/work_guide/guide.rb
174
+ - lib/work_guide/storage.rb
175
+ - lib/work_guide/version.rb
176
+ - work_guide.gemspec
177
+ homepage: https://github.com/adorechic/work_guide
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.8
198
+ signing_key:
199
+ specification_version: 4
200
+ summary: CLI tool to listup routine tasks
201
+ test_files: []