todo_txt_viewer 0.1.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
+ SHA256:
3
+ metadata.gz: 8526fcfbd1454bcc870775a23bd2a4d329d9c383b21b5c1e1de4ff7a94875c29
4
+ data.tar.gz: e031967fa019ecb04d05ea539c3f6b3b2e00dbc00094da03aed348460a967bcb
5
+ SHA512:
6
+ metadata.gz: 7ab92a1faa619acc813346642e323779b8796545104e95b7a0fb2c8501d00ae41b6bb238000a201f0232af5b14a042f39814612efaa79ddcfebb18e604906f63
7
+ data.tar.gz: 1437dc5e3daeb46cedf7b2c9e80550513f2012244e76556332634428b6ec80234b5f95f6b124509324d1245ab3025a11552a099b6f624de65179002576160d95
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /vendor/bundle
3
+ /vendor/gems
4
+ /.yardoc
5
+ /_yardoc/
6
+ /coverage/
7
+ /doc/
8
+ /pkg/
9
+ /spec/reports/
10
+ /tmp/
data/.gitlab-ci.yml ADDED
@@ -0,0 +1,7 @@
1
+ image: ruby:2.5.1
2
+
3
+ before_script:
4
+ - bundle install
5
+
6
+ rubocop:
7
+ script: bundle exec rubocop
data/.rubocop.yml ADDED
@@ -0,0 +1,2 @@
1
+ inherit_gem:
2
+ ThunderKey-rubocop: rubocop.yml
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at nicolas@keltec.ch. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
6
+ git_source(:gitlab) {|repo_name| "https://gitlab.com/#{repo_name}" }
7
+
8
+ # Specify your gem's dependencies in todo_txt_viewer.gemspec
9
+ gemspec
10
+
11
+ # gem 'fullscreen_tui', path: 'vendor/gems/fullscreen_tui'
12
+ # gem 'fullscreen_tui', gitlab: 'ThunderKey/fullscreen_tui'
13
+ gem 'ThunderKey-rubocop'
data/Gemfile.lock ADDED
@@ -0,0 +1,51 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ todo_txt_viewer (0.1.0)
5
+ fullscreen_tui (~> 0.1)
6
+ todo-txt (~> 0.12)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ ThunderKey-rubocop (0.0.9)
12
+ rubocop (~> 0.59)
13
+ rubocop-rspec (~> 1.30)
14
+ ast (2.4.0)
15
+ colorize (0.8.1)
16
+ fullscreen_tui (0.1.0)
17
+ colorize (~> 0.8)
18
+ ruby-terminfo (~> 0.1)
19
+ jaro_winkler (1.5.1)
20
+ parallel (1.12.1)
21
+ parser (2.5.3.0)
22
+ ast (~> 2.4.0)
23
+ powerpack (0.1.2)
24
+ rainbow (3.0.0)
25
+ rake (10.5.0)
26
+ rubocop (0.61.1)
27
+ jaro_winkler (~> 1.5.1)
28
+ parallel (~> 1.10)
29
+ parser (>= 2.5, != 2.5.1.1)
30
+ powerpack (~> 0.1)
31
+ rainbow (>= 2.2.2, < 4.0)
32
+ ruby-progressbar (~> 1.7)
33
+ unicode-display_width (~> 1.4.0)
34
+ rubocop-rspec (1.30.1)
35
+ rubocop (>= 0.60.0)
36
+ ruby-progressbar (1.10.0)
37
+ ruby-terminfo (0.1.1)
38
+ todo-txt (0.12)
39
+ unicode-display_width (1.4.1)
40
+
41
+ PLATFORMS
42
+ ruby
43
+
44
+ DEPENDENCIES
45
+ ThunderKey-rubocop
46
+ bundler (~> 1.16)
47
+ rake (~> 10.0)
48
+ todo_txt_viewer!
49
+
50
+ BUNDLED WITH
51
+ 1.16.1
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Nicolas Ganz
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,43 @@
1
+ # TodoTxtViewer
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/todo/txt/viewer`. 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 'todo_txt_viewer'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install todo_txt_viewer
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://gitlab.com/ThunderKey/todo_txt_viewer. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
36
+
37
+ ## License
38
+
39
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
40
+
41
+ ## Code of Conduct
42
+
43
+ Everyone interacting in the TodoTxtViewer project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://gitlab.com/ThunderKey/todo_txt_viewer/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ task default: :spec
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 'todo_txt_viewer'
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
@@ -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
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'todo_txt_viewer'
5
+
6
+ TodoTxtViewer.ui.run
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'todo_txt_viewer/version'
4
+ require_relative 'todo_txt_viewer/ui'
5
+
6
+ module TodoTxtViewer
7
+ def self.ui
8
+ folder = Pathname.new File.join(Dir.home, '.todo-txt')
9
+ Ui.new folder.join('todo.txt'), folder.join('done.txt')
10
+ end
11
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TodoTxtViewer
4
+ class HeaderLine
5
+ def initialize header
6
+ @header = header.to_s
7
+ end
8
+
9
+ def to_s
10
+ @header
11
+ end
12
+
13
+ def task_action(action) end
14
+ end
15
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TodoTxtViewer
4
+ class HelpUi < FullscreenTui
5
+ CONTENT = {
6
+ 'd' => 'do/mark as done',
7
+ 'u' => 'undo/mark as todo',
8
+ 'a' => 'archive this task',
9
+ '+' => 'increase the priority',
10
+ '-' => 'decrease the priority',
11
+ '1-9' => 'set priority to A-I',
12
+ '0' => 'remove the priority',
13
+ 'i' => 'insert a new task',
14
+ 'r' => 'reload the file',
15
+ 'h/?' => 'show this help',
16
+ 'q' => 'quit',
17
+ }.freeze
18
+
19
+ def initialize
20
+ super headers: ['Help']
21
+ key_width = CONTENT.keys.map(&:size).max
22
+ @lines = CONTENT.map {|k, v| "#{k.ljust key_width} = #{v}" }
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TodoTxtViewer
4
+ class TaskLine
5
+ ALLOWED_ACTIONS = %i(do! undo! priority_inc! priority_dec!).freeze
6
+
7
+ attr_reader :task
8
+
9
+ def initialize task
10
+ @task = task
11
+ end
12
+
13
+ def to_s
14
+ task.to_s
15
+ end
16
+
17
+ def task_action action
18
+ raise "illegal action #{action}" unless ALLOWED_ACTIONS.include? action
19
+
20
+ task.send action
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,92 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'todo-txt'
4
+ require 'fullscreen_tui'
5
+ require_relative 'task_line'
6
+ require_relative 'header_line'
7
+ require_relative 'help_ui'
8
+
9
+ module TodoTxtViewer
10
+ class Ui < FullscreenTui
11
+ def initialize main_file, archive_file
12
+ super headers: []
13
+
14
+ @main_file = main_file.to_s
15
+ @archive_file = archive_file.to_s
16
+ load_file
17
+ end
18
+
19
+ def key_press key # rubocop:disable Metrics/CyclomaticComplexity
20
+ case key
21
+ when 'd' then task_action :do!
22
+ when 'u' then task_action :undo!
23
+ when 'a' then archive_task
24
+ when '+' then task_action :priority_inc!
25
+ when '-' then task_action :priority_dec!
26
+ when ('0'..'9') then select_priority key
27
+ when 'i' then create_task
28
+ when 'r' then load_file
29
+ when 'h', '?' then help
30
+ else super
31
+ end
32
+ end
33
+
34
+ private
35
+
36
+ def task_action action
37
+ selected_line.task_action action
38
+ @list.save!
39
+ load_lines
40
+ end
41
+
42
+ def archive_task
43
+ archive = Todo::List.new @archive_file
44
+ task = selected_line.task
45
+ @list.delete_if {|other| other.object_id == task.object_id }
46
+ archive << task
47
+ archive.save!
48
+ @list.save!
49
+ load_lines
50
+ @footer.message = "Archived the Task #{task}"
51
+ end
52
+
53
+ def select_priority key
54
+ task = selected_line.task
55
+ key = key.to_i
56
+ priority = key.zero? ? nil : ('A'.ord + key - 1).chr
57
+ task.instance_variable_set :@priority, priority
58
+ @list.save!
59
+ load_lines
60
+ end
61
+
62
+ def create_task
63
+ line = read_full_line 'Please enter a task:'
64
+ task = Todo::Task.new line
65
+ task.instance_variable_set(:@created_on, Date.today) unless task.created_on
66
+ @list << task
67
+ @list.save!
68
+ load_lines
69
+ @footer.message = 'Task inserted'
70
+ end
71
+
72
+ def help
73
+ HelpUi.new.run
74
+ end
75
+
76
+ def load_file
77
+ @list = Todo::List.new @main_file
78
+ load_lines
79
+ @footer.message = "Loaded: #{@main_file}"
80
+ end
81
+
82
+ def load_lines
83
+ @lines = []
84
+
85
+ @lines << HeaderLine.new('# todo')
86
+ @list.by_not_done.sort.reverse_each {|t| @lines << TaskLine.new(t) }
87
+
88
+ @lines << HeaderLine.new('# done')
89
+ @list.by_done.sort.reverse_each {|t| @lines << TaskLine.new(t) }
90
+ end
91
+ end
92
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TodoTxtViewer
4
+ VERSION = '0.1.0'
5
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'todo_txt_viewer/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'todo_txt_viewer'
9
+ spec.version = TodoTxtViewer::VERSION
10
+ spec.authors = ['Nicolas Ganz']
11
+ spec.email = ['nicolas@keltec.ch']
12
+
13
+ spec.summary = 'An interactive viewer for todo.txt'
14
+ spec.homepage = 'https://gitlab.com/ThunderKey/todo_txt_viewer'
15
+ spec.license = 'MIT'
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ spec.bindir = 'exe'
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ['lib']
23
+
24
+ spec.add_dependency 'fullscreen_tui', '~> 0.1'
25
+ spec.add_dependency 'todo-txt', '~> 0.12'
26
+
27
+ spec.add_development_dependency 'bundler', '~> 1.16'
28
+ spec.add_development_dependency 'rake', '~> 10.0'
29
+ end
metadata ADDED
@@ -0,0 +1,120 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: todo_txt_viewer
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Nicolas Ganz
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-12-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: fullscreen_tui
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.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.1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: todo-txt
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.12'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.12'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.16'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.16'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ description:
70
+ email:
71
+ - nicolas@keltec.ch
72
+ executables:
73
+ - todo_txt_viewer
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".gitignore"
78
+ - ".gitlab-ci.yml"
79
+ - ".rubocop.yml"
80
+ - CODE_OF_CONDUCT.md
81
+ - Gemfile
82
+ - Gemfile.lock
83
+ - LICENSE.txt
84
+ - README.md
85
+ - Rakefile
86
+ - bin/console
87
+ - bin/setup
88
+ - exe/todo_txt_viewer
89
+ - lib/todo_txt_viewer.rb
90
+ - lib/todo_txt_viewer/header_line.rb
91
+ - lib/todo_txt_viewer/help_ui.rb
92
+ - lib/todo_txt_viewer/task_line.rb
93
+ - lib/todo_txt_viewer/ui.rb
94
+ - lib/todo_txt_viewer/version.rb
95
+ - todo_txt_viewer.gemspec
96
+ homepage: https://gitlab.com/ThunderKey/todo_txt_viewer
97
+ licenses:
98
+ - MIT
99
+ metadata: {}
100
+ post_install_message:
101
+ rdoc_options: []
102
+ require_paths:
103
+ - lib
104
+ required_ruby_version: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ required_rubygems_version: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - ">="
112
+ - !ruby/object:Gem::Version
113
+ version: '0'
114
+ requirements: []
115
+ rubyforge_project:
116
+ rubygems_version: 2.7.6
117
+ signing_key:
118
+ specification_version: 4
119
+ summary: An interactive viewer for todo.txt
120
+ test_files: []