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 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>] [--path=<path>]
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
 
@@ -86,7 +86,10 @@ module ReOrg
86
86
  end
87
87
 
88
88
  def new_file
89
- @org = OrgFile.new({ :title => @options["--title"],
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'
@@ -11,7 +11,7 @@ module ReOrg
11
11
 
12
12
  @options[:title] ||= 'Untitled'
13
13
  @options[:time] = Time.now
14
- @options[:date] = Time.at(@options[:time]).strftime("%Y-%m-%d")
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)
@@ -1,5 +1,5 @@
1
1
  #+title: <%= @org[:title].capitalize.gsub("-", " ") %>
2
2
  #+date: <%= @org[:date] %>
3
- #+layout: post
4
- #+category: posts
3
+ #+layout: <%= @org[:layout] ? @org[:layout] : 'post' %>
4
+ #+category: <%= @org[:category] ? @org[:category] : 'posts' %>
5
5
 
@@ -1,3 +1,3 @@
1
1
  module ReOrg
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -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 = {
@@ -7,7 +7,7 @@ describe ReOrg::OrgFile do
7
7
  end
8
8
 
9
9
  it 'should create date in org format' do
10
- date = Time.at(1377411362)
10
+ date = Time.at(1377411362).utc
11
11
  @org.org_format_date(date).should == '[2013-08-25 Sun]'
12
12
  end
13
13
  end
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.3
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: 2013-12-19 00:00:00.000000000 Z
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: &70351242424800 !ruby/object:Gem::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: *70351242424800
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: &70351242424380 !ruby/object:Gem::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: *70351242424380
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.10
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: