re-org 0.0.3 → 0.0.4
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/bin/re-org +1 -1
- data/lib/re-org/command.rb +5 -2
- data/lib/re-org/org_file.rb +2 -2
- data/lib/re-org/templates/jekyll-post.org +2 -2
- data/lib/re-org/version.rb +1 -1
- data/spec/command_spec.rb +44 -0
- data/spec/org_file_spec.rb +1 -1
- metadata +18 -7
    
        data/bin/re-org
    CHANGED
    
    | @@ -8,7 +8,7 @@ doc = <<OPTIONS | |
| 8 8 | 
             
            re-org: A tool to help re-organize your texts written in Org mode
         | 
| 9 9 |  | 
| 10 10 | 
             
            Usage:
         | 
| 11 | 
            -
              re-org new <template>   [--notebook=<notebook>] [--title=<title>] | 
| 11 | 
            +
              re-org new <template>   [--notebook=<notebook>] [--title=<title>] [--category=<category>] [--date=<date>] [--layout=<layout>] [--path=<path>]
         | 
| 12 12 | 
             
              re-org status           [--notebook=<notebook>] [--count-keywords]
         | 
| 13 13 | 
             
              re-org templates        [--name=<name>]
         | 
| 14 14 |  | 
    
        data/lib/re-org/command.rb
    CHANGED
    
    | @@ -86,7 +86,10 @@ module ReOrg | |
| 86 86 | 
             
                end
         | 
| 87 87 |  | 
| 88 88 | 
             
                def new_file
         | 
| 89 | 
            -
                  @org = OrgFile.new({ : | 
| 89 | 
            +
                  @org = OrgFile.new({ :category => @options["--category"],
         | 
| 90 | 
            +
                                       :date => @options["--date"],
         | 
| 91 | 
            +
                                       :title => @options["--title"],
         | 
| 92 | 
            +
                                       :layout => @options["--layout"],
         | 
| 90 93 | 
             
                                       :template => @options["<template>"],
         | 
| 91 94 | 
             
                                       :notebook => @options["<notebook>"] || @options["--notebook"],
         | 
| 92 95 | 
             
                                       :path     => @options["--path"]
         | 
| @@ -96,7 +99,7 @@ module ReOrg | |
| 96 99 | 
             
                  c = 1
         | 
| 97 100 | 
             
                  while File.exists?(@org[:file])
         | 
| 98 101 | 
             
                    c += 1
         | 
| 99 | 
            -
                    @org[:filename] = Time.at(@org[:time]).strftime("%Y-%m-%d-%s-#{c}")
         | 
| 102 | 
            +
                    @org[:filename] = @org[:date] ? "#{@org[:date]}-#{c}" : Time.at(@org[:time]).strftime("%Y-%m-%d-%s-#{c}")
         | 
| 100 103 | 
             
                    @org[:file]     = File.expand_path(File.join(@org[:todo_dir], "#{@org[:filename]}.org"))
         | 
| 101 104 | 
             
                  end
         | 
| 102 105 | 
             
                  template =  @org[:template] || 'writing'
         | 
    
        data/lib/re-org/org_file.rb
    CHANGED
    
    | @@ -11,7 +11,7 @@ module ReOrg | |
| 11 11 |  | 
| 12 12 | 
             
                  @options[:title]         ||= 'Untitled'
         | 
| 13 13 | 
             
                  @options[:time]            = Time.now
         | 
| 14 | 
            -
                  @options[:date] | 
| 14 | 
            +
                  @options[:date]          ||= Time.at(@options[:time]).strftime("%Y-%m-%d")
         | 
| 15 15 | 
             
                  @options[:org_format_date] = org_format_date(@options[:time])
         | 
| 16 16 | 
             
                  @options[:todo_dir]      ||= @options[:path] || OrgFile.todo_dir
         | 
| 17 17 | 
             
                  @options[:done_dir]      ||= OrgFile.done_dir
         | 
| @@ -35,7 +35,7 @@ module ReOrg | |
| 35 35 |  | 
| 36 36 | 
             
                def resolve_filename
         | 
| 37 37 | 
             
                  slug = slugify(@options[:title] || @options[:notebook])
         | 
| 38 | 
            -
                  Time.at(@options[:time]).strftime("%Y-%m-%d-#{slug}")
         | 
| 38 | 
            +
                  @options[:date] ? "#{@options[:date]}-#{slug}" : Time.at(@options[:time]).strftime("%Y-%m-%d-#{slug}")
         | 
| 39 39 | 
             
                end
         | 
| 40 40 |  | 
| 41 41 | 
             
                def slugify(name)
         | 
    
        data/lib/re-org/version.rb
    CHANGED
    
    
    
        data/spec/command_spec.rb
    CHANGED
    
    | @@ -46,6 +46,50 @@ describe ReOrg::Command do | |
| 46 46 | 
             
                end
         | 
| 47 47 | 
             
              end
         | 
| 48 48 |  | 
| 49 | 
            +
              context "when using `re-org new jekyll-post`" do
         | 
| 50 | 
            +
                before(:each) do
         | 
| 51 | 
            +
                  @cmd = {
         | 
| 52 | 
            +
                    "new"        => true,
         | 
| 53 | 
            +
                    "<template>" => 'jekyll-post',
         | 
| 54 | 
            +
                    "--title"    => "test-#{$test_number}",
         | 
| 55 | 
            +
                  }
         | 
| 56 | 
            +
                end
         | 
| 57 | 
            +
             | 
| 58 | 
            +
                it 'should create a new jekyll-post with the --title option' do
         | 
| 59 | 
            +
                  o = ReOrg::Command.new(@cmd)
         | 
| 60 | 
            +
                  o.execute!
         | 
| 61 | 
            +
                  orgs = Dir["#{@dir}/todo/*"]
         | 
| 62 | 
            +
                  orgs.count.should == 1
         | 
| 63 | 
            +
                end
         | 
| 64 | 
            +
             | 
| 65 | 
            +
                it 'should create a new jekyll-post with an arbitrary date given the --date option' do
         | 
| 66 | 
            +
                  @cmd['--date']    = '2014-03-29'
         | 
| 67 | 
            +
                  o = ReOrg::Command.new(@cmd)
         | 
| 68 | 
            +
                  o.execute!
         | 
| 69 | 
            +
                  orgs = Dir["#{@dir}/todo/*"]
         | 
| 70 | 
            +
                  orgs.count.should == 1
         | 
| 71 | 
            +
                  orgs.first.should =~ /2014-03-29/
         | 
| 72 | 
            +
                end
         | 
| 73 | 
            +
             | 
| 74 | 
            +
                it 'should create a new jekyll-post with a layout set by --layout option' do
         | 
| 75 | 
            +
                  @cmd['--layout']    = 'main'
         | 
| 76 | 
            +
                  o = ReOrg::Command.new(@cmd)
         | 
| 77 | 
            +
                  o.execute!
         | 
| 78 | 
            +
                  orgs = Dir["#{@dir}/todo/*"]
         | 
| 79 | 
            +
                  orgs.count.should == 1
         | 
| 80 | 
            +
                  File.open(orgs.first).read().should =~ /\#\+layout\:        main/
         | 
| 81 | 
            +
                end
         | 
| 82 | 
            +
             | 
| 83 | 
            +
                it 'should create a new jekyll-post with a category set by --category option' do
         | 
| 84 | 
            +
                  @cmd['--category']    = 'food'
         | 
| 85 | 
            +
                  o = ReOrg::Command.new(@cmd)
         | 
| 86 | 
            +
                  o.execute!
         | 
| 87 | 
            +
                  orgs = Dir["#{@dir}/todo/*"]
         | 
| 88 | 
            +
                  orgs.count.should == 1
         | 
| 89 | 
            +
                  File.open(orgs.first).read().should =~ /\#\+category\:      food/
         | 
| 90 | 
            +
                end
         | 
| 91 | 
            +
              end
         | 
| 92 | 
            +
             | 
| 49 93 | 
             
              context "when using `re-org templates`" do 
         | 
| 50 94 | 
             
                before(:each) do
         | 
| 51 95 | 
             
                  @cmd = {
         | 
    
        data/spec/org_file_spec.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: re-org
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.0. | 
| 4 | 
            +
              version: 0.0.4
         | 
| 5 5 | 
             
              prerelease: 
         | 
| 6 6 | 
             
            platform: ruby
         | 
| 7 7 | 
             
            authors:
         | 
| @@ -9,11 +9,11 @@ authors: | |
| 9 9 | 
             
            autorequire: 
         | 
| 10 10 | 
             
            bindir: bin
         | 
| 11 11 | 
             
            cert_chain: []
         | 
| 12 | 
            -
            date:  | 
| 12 | 
            +
            date: 2014-03-31 00:00:00.000000000 Z
         | 
| 13 13 | 
             
            dependencies:
         | 
| 14 14 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 15 15 | 
             
              name: docopt
         | 
| 16 | 
            -
              requirement:  | 
| 16 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 17 17 | 
             
                none: false
         | 
| 18 18 | 
             
                requirements:
         | 
| 19 19 | 
             
                - - ! '>='
         | 
| @@ -21,10 +21,15 @@ dependencies: | |
| 21 21 | 
             
                    version: '0'
         | 
| 22 22 | 
             
              type: :runtime
         | 
| 23 23 | 
             
              prerelease: false
         | 
| 24 | 
            -
              version_requirements:  | 
| 24 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 25 | 
            +
                none: false
         | 
| 26 | 
            +
                requirements:
         | 
| 27 | 
            +
                - - ! '>='
         | 
| 28 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 29 | 
            +
                    version: '0'
         | 
| 25 30 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 26 31 | 
             
              name: org-ruby
         | 
| 27 | 
            -
              requirement:  | 
| 32 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 28 33 | 
             
                none: false
         | 
| 29 34 | 
             
                requirements:
         | 
| 30 35 | 
             
                - - ! '>='
         | 
| @@ -32,7 +37,12 @@ dependencies: | |
| 32 37 | 
             
                    version: '0'
         | 
| 33 38 | 
             
              type: :runtime
         | 
| 34 39 | 
             
              prerelease: false
         | 
| 35 | 
            -
              version_requirements:  | 
| 40 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 41 | 
            +
                none: false
         | 
| 42 | 
            +
                requirements:
         | 
| 43 | 
            +
                - - ! '>='
         | 
| 44 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 45 | 
            +
                    version: '0'
         | 
| 36 46 | 
             
            description: An Org mode file organizer
         | 
| 37 47 | 
             
            email:
         | 
| 38 48 | 
             
            - waldemar.quevedo@gmail.com
         | 
| @@ -81,7 +91,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 81 91 | 
             
                  version: '0'
         | 
| 82 92 | 
             
            requirements: []
         | 
| 83 93 | 
             
            rubyforge_project: 
         | 
| 84 | 
            -
            rubygems_version: 1.8. | 
| 94 | 
            +
            rubygems_version: 1.8.21
         | 
| 85 95 | 
             
            signing_key: 
         | 
| 86 96 | 
             
            specification_version: 3
         | 
| 87 97 | 
             
            summary: Instead of having tons of sparsed Org mode files everywhere, this project
         | 
| @@ -91,3 +101,4 @@ test_files: | |
| 91 101 | 
             
            - spec/command_spec.rb
         | 
| 92 102 | 
             
            - spec/org_file_spec.rb
         | 
| 93 103 | 
             
            - spec/spec_helper.rb
         | 
| 104 | 
            +
            has_rdoc: 
         |