na 1.2.84 → 1.2.86
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 +4 -4
 - data/.cursor/commands/priority35m36m335m32m.md +0 -0
 - data/.rubocop_todo.yml +30 -35
 - data/CHANGELOG.md +18 -0
 - data/Gemfile +2 -0
 - data/Gemfile.lock +9 -1
 - data/README.md +2 -2
 - data/bin/commands/update.rb +120 -37
 - data/lib/na/action.rb +74 -14
 - data/lib/na/array.rb +9 -0
 - data/lib/na/benchmark.rb +8 -0
 - data/lib/na/colors.rb +11 -4
 - data/lib/na/editor.rb +89 -1
 - data/lib/na/hash.rb +9 -0
 - data/lib/na/help_monkey_patch.rb +10 -1
 - data/lib/na/next_action.rb +93 -19
 - data/lib/na/project.rb +8 -0
 - data/lib/na/string.rb +51 -12
 - data/lib/na/theme.rb +58 -41
 - data/lib/na/todo.rb +8 -0
 - data/lib/na/version.rb +5 -1
 - data/lib/na.rb +11 -1
 - data/src/_README.md +1 -1
 - metadata +2 -1
 
    
        data/lib/na/theme.rb
    CHANGED
    
    | 
         @@ -1,10 +1,16 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # frozen_string_literal: true
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            module NA
         
     | 
| 
      
 4 
     | 
    
         
            +
              # Provides theme and color template helpers for todo CLI output.
         
     | 
| 
      
 5 
     | 
    
         
            +
              #
         
     | 
| 
      
 6 
     | 
    
         
            +
              # @example Get theme help text
         
     | 
| 
      
 7 
     | 
    
         
            +
              #   NA::Theme.template_help
         
     | 
| 
       4 
8 
     | 
    
         
             
              module Theme
         
     | 
| 
       5 
9 
     | 
    
         
             
                class << self
         
     | 
| 
       6 
10 
     | 
    
         
             
                  # Returns a help string describing available color placeholders for themes.
         
     | 
| 
       7 
11 
     | 
    
         
             
                  # @return [String] Help text for theme placeholders
         
     | 
| 
      
 12 
     | 
    
         
            +
                  # @example
         
     | 
| 
      
 13 
     | 
    
         
            +
                  #   NA::Theme.template_help
         
     | 
| 
       8 
14 
     | 
    
         
             
                  def template_help
         
     | 
| 
       9 
15 
     | 
    
         
             
                    <<~EOHELP
         
     | 
| 
       10 
16 
     | 
    
         
             
                      Use {X} placeholders to apply colors. Available colors are:
         
     | 
| 
         @@ -28,52 +34,63 @@ module NA 
     | 
|
| 
       28 
34 
     | 
    
         
             
                  # Writes the help text and theme YAML to the theme file.
         
     | 
| 
       29 
35 
     | 
    
         
             
                  # @param template [Hash] Additional theme settings to merge
         
     | 
| 
       30 
36 
     | 
    
         
             
                  # @return [Hash] The merged theme configuration
         
     | 
| 
      
 37 
     | 
    
         
            +
                  # @example
         
     | 
| 
      
 38 
     | 
    
         
            +
                  #   NA::Theme.load_theme(template: { action: '{r}' })
         
     | 
| 
       31 
39 
     | 
    
         
             
                  def load_theme(template: {})
         
     | 
| 
       32 
     | 
    
         
            -
                    NA::Benchmark 
     | 
| 
       33 
     | 
    
         
            -
                       
     | 
| 
       34 
     | 
    
         
            -
             
     | 
| 
       35 
     | 
    
         
            -
             
     | 
| 
       36 
     | 
    
         
            -
             
     | 
| 
       37 
     | 
    
         
            -
             
     | 
| 
       38 
     | 
    
         
            -
             
     | 
| 
       39 
     | 
    
         
            -
             
     | 
| 
       40 
     | 
    
         
            -
                        tags: '{m}',
         
     | 
| 
       41 
     | 
    
         
            -
                        value_parens: '{m}',
         
     | 
| 
       42 
     | 
    
         
            -
                        values: '{c}',
         
     | 
| 
       43 
     | 
    
         
            -
                        search_highlight: '{y}',
         
     | 
| 
       44 
     | 
    
         
            -
                        note: '{dw}',
         
     | 
| 
       45 
     | 
    
         
            -
                        dirname: '{xdw}',
         
     | 
| 
       46 
     | 
    
         
            -
                        filename: '{xb}{#eccc87}',
         
     | 
| 
       47 
     | 
    
         
            -
                        prompt: '{m}',
         
     | 
| 
       48 
     | 
    
         
            -
                        success: '{bg}',
         
     | 
| 
       49 
     | 
    
         
            -
                        error: '{b}{#b61d2a}',
         
     | 
| 
       50 
     | 
    
         
            -
                        warning: '{by}',
         
     | 
| 
       51 
     | 
    
         
            -
                        debug: '{dw}',
         
     | 
| 
       52 
     | 
    
         
            -
                        templates: {
         
     | 
| 
       53 
     | 
    
         
            -
                          output: '%filename%parents| %action',
         
     | 
| 
       54 
     | 
    
         
            -
                          default: '%parent%action',
         
     | 
| 
       55 
     | 
    
         
            -
                          single_file: '%parent%action',
         
     | 
| 
       56 
     | 
    
         
            -
                          multi_file: '%filename%parent%action',
         
     | 
| 
       57 
     | 
    
         
            -
                          no_file: '%parent%action'
         
     | 
| 
       58 
     | 
    
         
            -
                        }
         
     | 
| 
       59 
     | 
    
         
            -
                      }
         
     | 
| 
      
 40 
     | 
    
         
            +
                    if defined?(NA::Benchmark) && NA::Benchmark
         
     | 
| 
      
 41 
     | 
    
         
            +
                      NA::Benchmark.measure('Theme.load_theme') do
         
     | 
| 
      
 42 
     | 
    
         
            +
                        load_theme_internal(template: template)
         
     | 
| 
      
 43 
     | 
    
         
            +
                      end
         
     | 
| 
      
 44 
     | 
    
         
            +
                    else
         
     | 
| 
      
 45 
     | 
    
         
            +
                      load_theme_internal(template: template)
         
     | 
| 
      
 46 
     | 
    
         
            +
                    end
         
     | 
| 
      
 47 
     | 
    
         
            +
                  end
         
     | 
| 
       60 
48 
     | 
    
         | 
| 
       61 
     | 
    
         
            -
             
     | 
| 
       62 
     | 
    
         
            -
             
     | 
| 
       63 
     | 
    
         
            -
             
     | 
| 
       64 
     | 
    
         
            -
             
     | 
| 
       65 
     | 
    
         
            -
             
     | 
| 
       66 
     | 
    
         
            -
             
     | 
| 
       67 
     | 
    
         
            -
             
     | 
| 
       68 
     | 
    
         
            -
                       
     | 
| 
      
 49 
     | 
    
         
            +
                  def load_theme_internal(template: {})
         
     | 
| 
      
 50 
     | 
    
         
            +
                    # Default colorization, can be overridden with full or partial template variable
         
     | 
| 
      
 51 
     | 
    
         
            +
                    default_template = {
         
     | 
| 
      
 52 
     | 
    
         
            +
                      parent: '{c}',
         
     | 
| 
      
 53 
     | 
    
         
            +
                      bracket: '{dc}',
         
     | 
| 
      
 54 
     | 
    
         
            +
                      parent_divider: '{xw}/',
         
     | 
| 
      
 55 
     | 
    
         
            +
                      action: '{bg}',
         
     | 
| 
      
 56 
     | 
    
         
            +
                      project: '{xbk}',
         
     | 
| 
      
 57 
     | 
    
         
            +
                      tags: '{m}',
         
     | 
| 
      
 58 
     | 
    
         
            +
                      value_parens: '{m}',
         
     | 
| 
      
 59 
     | 
    
         
            +
                      values: '{c}',
         
     | 
| 
      
 60 
     | 
    
         
            +
                      search_highlight: '{y}',
         
     | 
| 
      
 61 
     | 
    
         
            +
                      note: '{dw}',
         
     | 
| 
      
 62 
     | 
    
         
            +
                      dirname: '{xdw}',
         
     | 
| 
      
 63 
     | 
    
         
            +
                      filename: '{xb}{#eccc87}',
         
     | 
| 
      
 64 
     | 
    
         
            +
                      line: '{dw}',
         
     | 
| 
      
 65 
     | 
    
         
            +
                      prompt: '{m}',
         
     | 
| 
      
 66 
     | 
    
         
            +
                      success: '{bg}',
         
     | 
| 
      
 67 
     | 
    
         
            +
                      error: '{b}{#b61d2a}',
         
     | 
| 
      
 68 
     | 
    
         
            +
                      warning: '{by}',
         
     | 
| 
      
 69 
     | 
    
         
            +
                      debug: '{dw}',
         
     | 
| 
      
 70 
     | 
    
         
            +
                      templates: {
         
     | 
| 
      
 71 
     | 
    
         
            +
                        output: '%filename%line%parents| %action',
         
     | 
| 
      
 72 
     | 
    
         
            +
                        default: '%parents %line %action',
         
     | 
| 
      
 73 
     | 
    
         
            +
                        single_file: '%parents %line %action',
         
     | 
| 
      
 74 
     | 
    
         
            +
                        multi_file: '%filename%line%parents %action',
         
     | 
| 
      
 75 
     | 
    
         
            +
                        no_file: '%parents %line %action'
         
     | 
| 
      
 76 
     | 
    
         
            +
                      }
         
     | 
| 
      
 77 
     | 
    
         
            +
                    }
         
     | 
| 
       69 
78 
     | 
    
         | 
| 
       70 
     | 
    
         
            -
             
     | 
| 
       71 
     | 
    
         
            -
             
     | 
| 
       72 
     | 
    
         
            -
             
     | 
| 
       73 
     | 
    
         
            -
             
     | 
| 
      
 79 
     | 
    
         
            +
                    # Load custom theme
         
     | 
| 
      
 80 
     | 
    
         
            +
                    theme_file = NA.database_path(file: 'theme.yaml')
         
     | 
| 
      
 81 
     | 
    
         
            +
                    theme = if File.exist?(theme_file)
         
     | 
| 
      
 82 
     | 
    
         
            +
                              YAML.load(File.read(theme_file)) || {}
         
     | 
| 
      
 83 
     | 
    
         
            +
                            else
         
     | 
| 
      
 84 
     | 
    
         
            +
                              {}
         
     | 
| 
      
 85 
     | 
    
         
            +
                            end
         
     | 
| 
      
 86 
     | 
    
         
            +
                    theme = default_template.deep_merge(theme)
         
     | 
| 
       74 
87 
     | 
    
         | 
| 
       75 
     | 
    
         
            -
             
     | 
| 
      
 88 
     | 
    
         
            +
                    File.open(theme_file, 'w') do |f|
         
     | 
| 
      
 89 
     | 
    
         
            +
                      f.puts template_help.comment
         
     | 
| 
      
 90 
     | 
    
         
            +
                      f.puts YAML.dump(theme)
         
     | 
| 
       76 
91 
     | 
    
         
             
                    end
         
     | 
| 
      
 92 
     | 
    
         
            +
             
     | 
| 
      
 93 
     | 
    
         
            +
                    theme.merge(template)
         
     | 
| 
       77 
94 
     | 
    
         
             
                  end
         
     | 
| 
       78 
95 
     | 
    
         
             
                end
         
     | 
| 
       79 
96 
     | 
    
         
             
              end
         
     | 
    
        data/lib/na/todo.rb
    CHANGED
    
    | 
         @@ -1,6 +1,10 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # frozen_string_literal: true
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            module NA
         
     | 
| 
      
 4 
     | 
    
         
            +
              # Represents a parsed todo file, including actions, projects, and file management.
         
     | 
| 
      
 5 
     | 
    
         
            +
              #
         
     | 
| 
      
 6 
     | 
    
         
            +
              # @example Parse a todo file
         
     | 
| 
      
 7 
     | 
    
         
            +
              #   todo = NA::Todo.new(file_path: 'todo.txt')
         
     | 
| 
       4 
8 
     | 
    
         
             
              class Todo
         
     | 
| 
       5 
9 
     | 
    
         
             
                attr_accessor :actions, :projects, :files
         
     | 
| 
       6 
10 
     | 
    
         | 
| 
         @@ -8,6 +12,8 @@ module NA 
     | 
|
| 
       8 
12 
     | 
    
         
             
                #
         
     | 
| 
       9 
13 
     | 
    
         
             
                # @param options [Hash] Options for parsing todo files
         
     | 
| 
       10 
14 
     | 
    
         
             
                # @return [void]
         
     | 
| 
      
 15 
     | 
    
         
            +
                # @example
         
     | 
| 
      
 16 
     | 
    
         
            +
                #   todo = NA::Todo.new(file_path: 'todo.txt')
         
     | 
| 
       11 
17 
     | 
    
         
             
                def initialize(options = {})
         
     | 
| 
       12 
18 
     | 
    
         
             
                  @files, @actions, @projects = parse(options)
         
     | 
| 
       13 
19 
     | 
    
         
             
                end
         
     | 
| 
         @@ -26,6 +32,8 @@ module NA 
     | 
|
| 
       26 
32 
     | 
    
         
             
                # @option options [Boolean] :require_na Require @na tag
         
     | 
| 
       27 
33 
     | 
    
         
             
                # @option options [String] :file_path file path to parse
         
     | 
| 
       28 
34 
     | 
    
         
             
                # @return [Array] files, actions, projects
         
     | 
| 
      
 35 
     | 
    
         
            +
                # @example
         
     | 
| 
      
 36 
     | 
    
         
            +
                #   files, actions, projects = todo.parse(file_path: 'todo.txt')
         
     | 
| 
       29 
37 
     | 
    
         
             
                def parse(options)
         
     | 
| 
       30 
38 
     | 
    
         
             
                  NA::Benchmark.measure('Todo.parse') do
         
     | 
| 
       31 
39 
     | 
    
         
             
                    defaults = {
         
     | 
    
        data/lib/na/version.rb
    CHANGED
    
    
    
        data/lib/na.rb
    CHANGED
    
    | 
         @@ -1,6 +1,16 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # frozen_string_literal: true
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
            require 'na/benchmark'
         
     | 
| 
      
 3 
     | 
    
         
            +
            require 'na/benchmark' if ENV['NA_BENCHMARK']
         
     | 
| 
      
 4 
     | 
    
         
            +
            # Define a dummy Benchmark if not available for tests
         
     | 
| 
      
 5 
     | 
    
         
            +
            unless defined?(NA::Benchmark)
         
     | 
| 
      
 6 
     | 
    
         
            +
              module NA
         
     | 
| 
      
 7 
     | 
    
         
            +
                module Benchmark
         
     | 
| 
      
 8 
     | 
    
         
            +
                  def self.measure(_label)
         
     | 
| 
      
 9 
     | 
    
         
            +
                    yield
         
     | 
| 
      
 10 
     | 
    
         
            +
                  end
         
     | 
| 
      
 11 
     | 
    
         
            +
                end
         
     | 
| 
      
 12 
     | 
    
         
            +
              end
         
     | 
| 
      
 13 
     | 
    
         
            +
            end
         
     | 
| 
       4 
14 
     | 
    
         
             
            require 'na/version'
         
     | 
| 
       5 
15 
     | 
    
         
             
            require 'na/pager'
         
     | 
| 
       6 
16 
     | 
    
         
             
            require 'time'
         
     | 
    
        data/src/_README.md
    CHANGED
    
    | 
         @@ -9,7 +9,7 @@ 
     | 
|
| 
       9 
9 
     | 
    
         
             
            _If you're one of the rare people like me who find this useful, feel free to
         
     | 
| 
       10 
10 
     | 
    
         
             
            [buy me some coffee][donate]._
         
     | 
| 
       11 
11 
     | 
    
         | 
| 
       12 
     | 
    
         
            -
            The current version of `na` is <!--VER-->1.2. 
     | 
| 
      
 12 
     | 
    
         
            +
            The current version of `na` is <!--VER-->1.2.85<!--END VER-->.
         
     | 
| 
       13 
13 
     | 
    
         | 
| 
       14 
14 
     | 
    
         
             
            `na` ("next action") is a command line tool designed to make it easy to see what your next actions are for any project, right from the command line. It works with TaskPaper-formatted files (but any plain text format will do), looking for `@na` tags (or whatever you specify) in todo files in your current folder.
         
     | 
| 
       15 
15 
     | 
    
         | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: na
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 1.2. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 1.2.86
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Brett Terpstra
         
     | 
| 
         @@ -245,6 +245,7 @@ extra_rdoc_files: 
     | 
|
| 
       245 
245 
     | 
    
         
             
            - README.md
         
     | 
| 
       246 
246 
     | 
    
         
             
            - na.rdoc
         
     | 
| 
       247 
247 
     | 
    
         
             
            files:
         
     | 
| 
      
 248 
     | 
    
         
            +
            - ".cursor/commands/priority35m36m335m32m.md"
         
     | 
| 
       248 
249 
     | 
    
         
             
            - ".rubocop.yml"
         
     | 
| 
       249 
250 
     | 
    
         
             
            - ".rubocop_todo.yml"
         
     | 
| 
       250 
251 
     | 
    
         
             
            - ".travis.yml"
         
     |