rubytodo 0.0.1
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.
- data/LICENSE +7 -0
 - data/README.md +32 -0
 - data/Rakefile +20 -0
 - data/bin/rubytodo +8 -0
 - data/lib/object.rb +13 -0
 - data/lib/rubytodo/version.rb +3 -0
 - data/lib/rubytodo.rb +34 -0
 - metadata +119 -0
 
    
        data/LICENSE
    ADDED
    
    | 
         @@ -0,0 +1,7 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            Copyright (C) 2012 Katsuya Noguchi
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
         
     | 
    
        data/README.md
    ADDED
    
    | 
         @@ -0,0 +1,32 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            ## RubyTodo
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            How do you manage todos in your code base? Usually people use comments like `# TODO` to specify todos in the code base and then use `grep '# TODO'` to grab them.
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            With rubytodo gem you can specify your todo anywhere in your code with `todo "todo description"` and then you can list all todos with a command `rubytodo`.
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            ## Installation
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 10 
     | 
    
         
            +
            gem install 'rubytodo'
         
     | 
| 
      
 11 
     | 
    
         
            +
            ```
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
            ## Quick Start
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
            Add todo in your ruby file:
         
     | 
| 
      
 16 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 17 
     | 
    
         
            +
            require 'rubytodo'
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
            class MyClass
         
     | 
| 
      
 20 
     | 
    
         
            +
              def my_method
         
     | 
| 
      
 21 
     | 
    
         
            +
                todo "implement my_method"
         
     | 
| 
      
 22 
     | 
    
         
            +
              end
         
     | 
| 
      
 23 
     | 
    
         
            +
            end
         
     | 
| 
      
 24 
     | 
    
         
            +
            ```
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
            Then list todos in all ruby files under a given root folder:
         
     | 
| 
      
 27 
     | 
    
         
            +
            ```
         
     | 
| 
      
 28 
     | 
    
         
            +
            $ rubytodo lib
         
     | 
| 
      
 29 
     | 
    
         
            +
            Scanning todos in lib ...
         
     | 
| 
      
 30 
     | 
    
         
            +
            lib/my_class.rb
         
     | 
| 
      
 31 
     | 
    
         
            +
            * implement my_method
         
     | 
| 
      
 32 
     | 
    
         
            +
            ```
         
     | 
    
        data/Rakefile
    ADDED
    
    | 
         @@ -0,0 +1,20 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'rdoc/task'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'rubygems'
         
     | 
| 
      
 3 
     | 
    
         
            +
            require 'rubygems/package_task'
         
     | 
| 
      
 4 
     | 
    
         
            +
            require 'rspec/core/rake_task'
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            desc 'Default: run specs.'
         
     | 
| 
      
 7 
     | 
    
         
            +
            task :default => :rspec
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            desc 'Run the specs'
         
     | 
| 
      
 10 
     | 
    
         
            +
            RSpec::Core::RakeTask.new(:rspec) do |t|
         
     | 
| 
      
 11 
     | 
    
         
            +
              t.rspec_opts = ['--color']
         
     | 
| 
      
 12 
     | 
    
         
            +
              t.pattern = './spec/**/*_spec.rb'
         
     | 
| 
      
 13 
     | 
    
         
            +
            end
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
            spec = Gem::Specification.load(File.join(File.dirname(__FILE__), "/rubytodo.gemspec"))
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
            desc "Package gem."
         
     | 
| 
      
 18 
     | 
    
         
            +
            Gem::PackageTask.new(spec) do |pkg|
         
     | 
| 
      
 19 
     | 
    
         
            +
              pkg.gem_spec = spec
         
     | 
| 
      
 20 
     | 
    
         
            +
            end
         
     | 
    
        data/bin/rubytodo
    ADDED
    
    
    
        data/lib/object.rb
    ADDED
    
    | 
         @@ -0,0 +1,13 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            class Object
         
     | 
| 
      
 2 
     | 
    
         
            +
              def todo msg
         
     | 
| 
      
 3 
     | 
    
         
            +
                unless msg and msg.is_a?(String)
         
     | 
| 
      
 4 
     | 
    
         
            +
                  raise "todo method requires you to pass a todo description as a first argument"
         
     | 
| 
      
 5 
     | 
    
         
            +
                end
         
     | 
| 
      
 6 
     | 
    
         
            +
              end
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
              def self.todo msg
         
     | 
| 
      
 9 
     | 
    
         
            +
                unless msg and msg.is_a?(String)
         
     | 
| 
      
 10 
     | 
    
         
            +
                  raise "todo method requires you to pass a todo description as a first argument"
         
     | 
| 
      
 11 
     | 
    
         
            +
                end
         
     | 
| 
      
 12 
     | 
    
         
            +
              end
         
     | 
| 
      
 13 
     | 
    
         
            +
            end
         
     | 
    
        data/lib/rubytodo.rb
    ADDED
    
    | 
         @@ -0,0 +1,34 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'object'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'ruby_parser'
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            class RubyTodo
         
     | 
| 
      
 5 
     | 
    
         
            +
              def self.list options
         
     | 
| 
      
 6 
     | 
    
         
            +
                root = options[:root]
         
     | 
| 
      
 7 
     | 
    
         
            +
                puts "Scanning todos in #{root} ..."
         
     | 
| 
      
 8 
     | 
    
         
            +
                files = Dir.glob File.join(root, "**", "*")
         
     | 
| 
      
 9 
     | 
    
         
            +
                files.reject { |f| f !~ /\.rb\Z/ }.each do |f|
         
     | 
| 
      
 10 
     | 
    
         
            +
                  todos = scan_todos f
         
     | 
| 
      
 11 
     | 
    
         
            +
                  puts f unless todos.nil? || todos.empty?
         
     | 
| 
      
 12 
     | 
    
         
            +
                  todos.each { |todo| puts "* #{todo}" }
         
     | 
| 
      
 13 
     | 
    
         
            +
                end
         
     | 
| 
      
 14 
     | 
    
         
            +
              end
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
              def self.scan_todos file_path
         
     | 
| 
      
 17 
     | 
    
         
            +
                ptree = RubyParser.new.parse File.open(file_path, 'r').read
         
     | 
| 
      
 18 
     | 
    
         
            +
                extract_todos ptree
         
     | 
| 
      
 19 
     | 
    
         
            +
              end
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
              protected
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
              def self.extract_todos node
         
     | 
| 
      
 24 
     | 
    
         
            +
                return nil unless node.is_a? Sexp
         
     | 
| 
      
 25 
     | 
    
         
            +
                todos = node.find_nodes(:call).map { |n| extract_todo_msg_from_args(n[3]) if n[2] == :todo }
         
     | 
| 
      
 26 
     | 
    
         
            +
                (todos | node.collect { |n| extract_todos n }).flatten.compact
         
     | 
| 
      
 27 
     | 
    
         
            +
              end
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
              def self.extract_todo_msg_from_args node
         
     | 
| 
      
 30 
     | 
    
         
            +
                return nil unless node.node_type && node.node_type == :arglist
         
     | 
| 
      
 31 
     | 
    
         
            +
                return nil unless node[1] && node[1].node_type == :str
         
     | 
| 
      
 32 
     | 
    
         
            +
                node[1].value
         
     | 
| 
      
 33 
     | 
    
         
            +
              end
         
     | 
| 
      
 34 
     | 
    
         
            +
            end
         
     | 
    
        metadata
    ADDED
    
    | 
         @@ -0,0 +1,119 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            --- !ruby/object:Gem::Specification
         
     | 
| 
      
 2 
     | 
    
         
            +
            name: rubytodo
         
     | 
| 
      
 3 
     | 
    
         
            +
            version: !ruby/object:Gem::Version
         
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.0.1
         
     | 
| 
      
 5 
     | 
    
         
            +
              prerelease: 
         
     | 
| 
      
 6 
     | 
    
         
            +
            platform: ruby
         
     | 
| 
      
 7 
     | 
    
         
            +
            authors:
         
     | 
| 
      
 8 
     | 
    
         
            +
            - Katsuya Noguchi
         
     | 
| 
      
 9 
     | 
    
         
            +
            autorequire: 
         
     | 
| 
      
 10 
     | 
    
         
            +
            bindir: bin
         
     | 
| 
      
 11 
     | 
    
         
            +
            cert_chain: []
         
     | 
| 
      
 12 
     | 
    
         
            +
            date: 2012-10-28 00:00:00.000000000 Z
         
     | 
| 
      
 13 
     | 
    
         
            +
            dependencies:
         
     | 
| 
      
 14 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 15 
     | 
    
         
            +
              name: ruby_parser
         
     | 
| 
      
 16 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 17 
     | 
    
         
            +
                none: false
         
     | 
| 
      
 18 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 19 
     | 
    
         
            +
                - - ~>
         
     | 
| 
      
 20 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 21 
     | 
    
         
            +
                    version: 2.3.0
         
     | 
| 
      
 22 
     | 
    
         
            +
              type: :runtime
         
     | 
| 
      
 23 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 24 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 25 
     | 
    
         
            +
                none: false
         
     | 
| 
      
 26 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 27 
     | 
    
         
            +
                - - ~>
         
     | 
| 
      
 28 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 29 
     | 
    
         
            +
                    version: 2.3.0
         
     | 
| 
      
 30 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 31 
     | 
    
         
            +
              name: rake
         
     | 
| 
      
 32 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 33 
     | 
    
         
            +
                none: false
         
     | 
| 
      
 34 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 35 
     | 
    
         
            +
                - - ! '>='
         
     | 
| 
      
 36 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 37 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 38 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 39 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 40 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 41 
     | 
    
         
            +
                none: false
         
     | 
| 
      
 42 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 43 
     | 
    
         
            +
                - - ! '>='
         
     | 
| 
      
 44 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 45 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 46 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 47 
     | 
    
         
            +
              name: rspec
         
     | 
| 
      
 48 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 49 
     | 
    
         
            +
                none: false
         
     | 
| 
      
 50 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 51 
     | 
    
         
            +
                - - ! '>='
         
     | 
| 
      
 52 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 53 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 54 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 55 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 56 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 57 
     | 
    
         
            +
                none: false
         
     | 
| 
      
 58 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 59 
     | 
    
         
            +
                - - ! '>='
         
     | 
| 
      
 60 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 61 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 62 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 63 
     | 
    
         
            +
              name: rdoc
         
     | 
| 
      
 64 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 65 
     | 
    
         
            +
                none: false
         
     | 
| 
      
 66 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 67 
     | 
    
         
            +
                - - ! '>='
         
     | 
| 
      
 68 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 69 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 70 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 71 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 72 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 73 
     | 
    
         
            +
                none: false
         
     | 
| 
      
 74 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 75 
     | 
    
         
            +
                - - ! '>='
         
     | 
| 
      
 76 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 77 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 78 
     | 
    
         
            +
            description: RubyTodo allows you to have in-code todos and scan them to view the todos
         
     | 
| 
      
 79 
     | 
    
         
            +
              as a list
         
     | 
| 
      
 80 
     | 
    
         
            +
            email:
         
     | 
| 
      
 81 
     | 
    
         
            +
            - katsuya.noguchi@gmail.com
         
     | 
| 
      
 82 
     | 
    
         
            +
            executables:
         
     | 
| 
      
 83 
     | 
    
         
            +
            - rubytodo
         
     | 
| 
      
 84 
     | 
    
         
            +
            extensions: []
         
     | 
| 
      
 85 
     | 
    
         
            +
            extra_rdoc_files: []
         
     | 
| 
      
 86 
     | 
    
         
            +
            files:
         
     | 
| 
      
 87 
     | 
    
         
            +
            - LICENSE
         
     | 
| 
      
 88 
     | 
    
         
            +
            - README.md
         
     | 
| 
      
 89 
     | 
    
         
            +
            - Rakefile
         
     | 
| 
      
 90 
     | 
    
         
            +
            - bin/rubytodo
         
     | 
| 
      
 91 
     | 
    
         
            +
            - lib/object.rb
         
     | 
| 
      
 92 
     | 
    
         
            +
            - lib/rubytodo/version.rb
         
     | 
| 
      
 93 
     | 
    
         
            +
            - lib/rubytodo.rb
         
     | 
| 
      
 94 
     | 
    
         
            +
            homepage: https://github.com/kn/rubytodo
         
     | 
| 
      
 95 
     | 
    
         
            +
            licenses: []
         
     | 
| 
      
 96 
     | 
    
         
            +
            post_install_message: 
         
     | 
| 
      
 97 
     | 
    
         
            +
            rdoc_options: []
         
     | 
| 
      
 98 
     | 
    
         
            +
            require_paths:
         
     | 
| 
      
 99 
     | 
    
         
            +
            - lib
         
     | 
| 
      
 100 
     | 
    
         
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 101 
     | 
    
         
            +
              none: false
         
     | 
| 
      
 102 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 103 
     | 
    
         
            +
              - - ! '>='
         
     | 
| 
      
 104 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 105 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
      
 106 
     | 
    
         
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 107 
     | 
    
         
            +
              none: false
         
     | 
| 
      
 108 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 109 
     | 
    
         
            +
              - - ! '>='
         
     | 
| 
      
 110 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 111 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
      
 112 
     | 
    
         
            +
            requirements: []
         
     | 
| 
      
 113 
     | 
    
         
            +
            rubyforge_project: 
         
     | 
| 
      
 114 
     | 
    
         
            +
            rubygems_version: 1.8.23
         
     | 
| 
      
 115 
     | 
    
         
            +
            signing_key: 
         
     | 
| 
      
 116 
     | 
    
         
            +
            specification_version: 3
         
     | 
| 
      
 117 
     | 
    
         
            +
            summary: RubyTodo allows you to have in-code todos and scan them to view the todos
         
     | 
| 
      
 118 
     | 
    
         
            +
              as a list
         
     | 
| 
      
 119 
     | 
    
         
            +
            test_files: []
         
     |