retter 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +1 -1
- data/ChangeLog.md +10 -0
- data/README.md +1 -3
- data/bin/retter +8 -4
- data/lib/retter/binder.rb +50 -0
- data/lib/retter/command.rb +42 -39
- data/lib/retter/config.rb +24 -23
- data/lib/retter/entries.rb +14 -18
- data/lib/retter/entry.rb +52 -29
- data/lib/retter/generator/base.rb +6 -7
- data/lib/retter/generator/skel/Gemfile +1 -2
- data/lib/retter/generator/skel/Retterfile +2 -2
- data/lib/retter/generator/skel/layouts/article.html.haml +3 -2
- data/lib/retter/generator/skel/layouts/entry.html.haml +3 -2
- data/lib/retter/generator/skel/layouts/index.html.haml +4 -2
- data/lib/retter/generator.rb +0 -1
- data/lib/retter/{renderers.rb → markdown.rb} +22 -1
- data/lib/retter/page/article.rb +54 -0
- data/lib/retter/page/base.rb +97 -0
- data/lib/retter/page/entries.rb +17 -0
- data/lib/retter/page/entry.rb +46 -0
- data/lib/retter/page/feed.rb +63 -0
- data/lib/retter/page/index.rb +17 -0
- data/lib/retter/page/profile.rb +17 -0
- data/lib/retter/page/view_helper.rb +9 -1
- data/lib/retter/page.rb +22 -74
- data/lib/retter/preprint.rb +19 -10
- data/lib/retter/version.rb +1 -1
- data/lib/retter.rb +41 -29
- data/retter.gemspec +44 -53
- data/spec/command/callback_spec.rb +16 -6
- data/spec/command/clean_spec.rb +20 -0
- data/spec/command/commit_spec.rb +11 -12
- data/spec/command/edit_spec.rb +28 -38
- data/spec/command/list_spec.rb +4 -4
- data/spec/command/open_spec.rb +2 -2
- data/spec/command/preview_spec.rb +7 -12
- data/spec/command/rebind_spec.rb +143 -66
- data/spec/spec_helper.rb +10 -3
- data/spec/support/example_group_helper.rb +55 -15
- data/spec/support/matchers.rb +0 -1
- metadata +195 -78
- data/lib/retter/generator/updator.rb +0 -7
- data/lib/retter/pages/article.rb +0 -41
- data/lib/retter/pages/entries.rb +0 -15
- data/lib/retter/pages/entry.rb +0 -35
- data/lib/retter/pages/feed.rb +0 -51
- data/lib/retter/pages/index.rb +0 -15
- data/lib/retter/pages/profile.rb +0 -15
- data/lib/retter/pages.rb +0 -77
- data/spec/command/invoke_after_spec.rb +0 -29
- data/spec/fixtures/sample.md +0 -295
data/retter.gemspec
CHANGED
@@ -1,55 +1,46 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
$:.push File.expand_path(
|
3
|
-
require
|
4
|
-
|
5
|
-
Gem::Specification.new do |
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
s.add_runtime_dependency 'rack', ['>= 1.4.1']
|
47
|
-
s.add_runtime_dependency 'i18n', ['>= 0.6.0']
|
48
|
-
|
49
|
-
s.add_development_dependency 'rake', ['>= 0.9.2']
|
50
|
-
s.add_development_dependency 'ir_b', ['>= 1.4.0']
|
51
|
-
s.add_development_dependency 'tapp', ['>= 1.1.0']
|
52
|
-
s.add_development_dependency 'rspec', ['>= 2.6.0']
|
53
|
-
s.add_development_dependency 'fuubar', ['>= 0.0.6']
|
54
|
-
s.add_development_dependency 'simplecov', ['>= 0.5.3']
|
2
|
+
$:.push File.expand_path('../lib', __FILE__)
|
3
|
+
require 'retter/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |gem|
|
6
|
+
gem.name = 'retter'
|
7
|
+
gem.version = Retter::VERSION
|
8
|
+
gem.authors = ['hibariya', 'uzura29']
|
9
|
+
gem.email = ['celluloid.key@gmail.com']
|
10
|
+
gem.homepage = 'https://github.com/hibariya/retter'
|
11
|
+
gem.summary = %q{Flyweight diary workflow}
|
12
|
+
gem.description = %q{Flyweight diary workflow. ruby-1.9.2 or later is required.}
|
13
|
+
|
14
|
+
gem.files = `git ls-files`.split("\n")
|
15
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
16
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
17
|
+
gem.require_paths = ['lib']
|
18
|
+
|
19
|
+
gem.required_ruby_version = '>= 1.9.1'
|
20
|
+
|
21
|
+
gem.add_runtime_dependency 'thor', ['>= 0.15.2']
|
22
|
+
gem.add_runtime_dependency 'builder', ['>= 3.0.0']
|
23
|
+
gem.add_runtime_dependency 'redcarpet', ['>= 2.1.1']
|
24
|
+
gem.add_runtime_dependency 'coderay', ['>= 1.0.7']
|
25
|
+
gem.add_runtime_dependency 'pygments.rb', ['>= 0.2.13']
|
26
|
+
gem.add_runtime_dependency 'nokogiri', ['>= 1.5.3']
|
27
|
+
gem.add_runtime_dependency 'launchy', ['>= 2.1.0']
|
28
|
+
gem.add_runtime_dependency 'haml', ['>= 3.1.6']
|
29
|
+
gem.add_runtime_dependency 'tilt', ['>= 1.3.3']
|
30
|
+
gem.add_runtime_dependency 'bundler', ['>= 1.1.4']
|
31
|
+
gem.add_runtime_dependency 'grit', ['>= 2.5.0']
|
32
|
+
gem.add_runtime_dependency 'chronic', ['>= 0.6.7']
|
33
|
+
gem.add_runtime_dependency 'activesupport', ['>= 3.2.5']
|
34
|
+
|
35
|
+
# XXX for ActiveSupport dependencies
|
36
|
+
gem.add_runtime_dependency 'rack', ['>= 1.4.1']
|
37
|
+
gem.add_runtime_dependency 'i18n', ['>= 0.6.0']
|
38
|
+
|
39
|
+
gem.add_development_dependency 'rake', ['>= 0.9.2']
|
40
|
+
gem.add_development_dependency 'ir_b', ['>= 1.5.0']
|
41
|
+
gem.add_development_dependency 'tapp', ['>= 1.3.1']
|
42
|
+
gem.add_development_dependency 'rspec', ['>= 2.10.0']
|
43
|
+
gem.add_development_dependency 'fuubar', ['>= 1.0.0']
|
44
|
+
gem.add_development_dependency 'simplecov', ['>= 0.6.4']
|
45
|
+
gem.add_development_dependency 'delorean', ['>= 2.0.0']
|
55
46
|
end
|
@@ -3,15 +3,25 @@
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
5
|
describe 'Retter::Command#callback', clean: :all do
|
6
|
-
|
7
|
-
|
6
|
+
context 'invoke with proc' do
|
7
|
+
specify 'callback should called' do
|
8
|
+
command.should_receive(:commit)
|
8
9
|
|
9
|
-
|
10
|
+
invoke_command :callback, after: :edit do |config|
|
11
|
+
config.after :edit do
|
12
|
+
commit
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
10
16
|
end
|
11
17
|
|
12
|
-
|
13
|
-
|
18
|
+
context 'invoke with symbol' do
|
19
|
+
specify 'callback should called' do
|
20
|
+
command.should_receive(:commit)
|
14
21
|
|
15
|
-
|
22
|
+
invoke_command :callback, after: :edit do |config|
|
23
|
+
config.after :edit, :commit
|
24
|
+
end
|
25
|
+
end
|
16
26
|
end
|
17
27
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe 'Retter::Command#clean', clean: :all do
|
6
|
+
let(:cache_path) { %(#{Retter::Site.config.cache.cache_path}/*) }
|
7
|
+
|
8
|
+
before do
|
9
|
+
write_to_wip_file 'hi'
|
10
|
+
|
11
|
+
invoke_command :rebind
|
12
|
+
flunk if Dir.glob(cache_path).empty?
|
13
|
+
|
14
|
+
invoke_command :clean
|
15
|
+
end
|
16
|
+
|
17
|
+
subject { Dir.glob(cache_path) }
|
18
|
+
|
19
|
+
it { should be_empty }
|
20
|
+
end
|
data/spec/command/commit_spec.rb
CHANGED
@@ -4,22 +4,25 @@ require 'spec_helper'
|
|
4
4
|
require 'grit'
|
5
5
|
|
6
6
|
describe 'Retter::Command#commit', clean: :all do
|
7
|
-
let(:
|
7
|
+
let(:retter_home) { Retter::Site.config.retter_home }
|
8
|
+
let(:repo) { Grit::Repo.new(retter_home) }
|
8
9
|
let(:article) { '今日の記事' }
|
9
10
|
|
10
11
|
before do
|
11
12
|
command.stub!(:say) { true }
|
12
|
-
wip_file.open('w') {|f| f.puts article }
|
13
|
-
command.rebind
|
14
13
|
|
15
|
-
|
14
|
+
write_to_wip_file article
|
15
|
+
|
16
|
+
invoke_command :rebind
|
17
|
+
|
18
|
+
Grit::Repo.init retter_home.to_path
|
16
19
|
end
|
17
20
|
|
18
21
|
context 'with no options' do
|
19
22
|
before do
|
20
|
-
command.should_receive(:
|
23
|
+
command.should_receive(:after_callback).with(:commit)
|
21
24
|
|
22
|
-
|
25
|
+
invoke_command :commit
|
23
26
|
end
|
24
27
|
|
25
28
|
subject { repo.commits.first }
|
@@ -28,14 +31,10 @@ describe 'Retter::Command#commit', clean: :all do
|
|
28
31
|
end
|
29
32
|
|
30
33
|
context 'with silent option' do
|
31
|
-
before do
|
32
|
-
command.stub!(:options) { {silent: true} }
|
33
|
-
end
|
34
|
-
|
35
34
|
specify 'callback should not called' do
|
36
|
-
command.should_not_receive(:
|
35
|
+
command.should_not_receive(:after_callback).with(:commit)
|
37
36
|
|
38
|
-
|
37
|
+
invoke_command :commit, silent: :true
|
39
38
|
end
|
40
39
|
end
|
41
40
|
end
|
data/spec/command/edit_spec.rb
CHANGED
@@ -5,23 +5,25 @@ require 'spec_helper'
|
|
5
5
|
describe 'Retter::Command#edit', clean: :all do
|
6
6
|
context 'no options' do
|
7
7
|
before do
|
8
|
-
command.should_receive(:
|
9
|
-
|
8
|
+
command.should_receive(:after_callback).with(:edit)
|
9
|
+
|
10
|
+
invoke_command :edit
|
10
11
|
end
|
11
12
|
|
12
13
|
it { wip_file.should written }
|
13
14
|
end
|
14
15
|
|
15
16
|
context 'after edit and rebind (no options)' do
|
16
|
-
let(:
|
17
|
-
let(:today_entry) {
|
17
|
+
let(:date_str) { '2011/01/01' }
|
18
|
+
let(:today_entry) { find_entry_by_string(date_str) }
|
18
19
|
|
19
20
|
before do
|
20
|
-
|
21
|
-
|
22
|
-
|
21
|
+
time_travel_to date_str
|
22
|
+
|
23
|
+
today_entry.path.open('w') { |f| f.puts 'written' }
|
23
24
|
|
24
|
-
|
25
|
+
invoke_command :rebind
|
26
|
+
invoke_command :edit
|
25
27
|
end
|
26
28
|
|
27
29
|
specify 'wip file should not be written' do
|
@@ -30,17 +32,14 @@ describe 'Retter::Command#edit', clean: :all do
|
|
30
32
|
end
|
31
33
|
|
32
34
|
context 'with date (YYYYMMDD) option' do
|
33
|
-
let(:date_str) { '20110101' }
|
34
|
-
let(:date) { Date.parse(date_str) }
|
35
|
-
|
36
35
|
before do
|
37
|
-
|
36
|
+
invoke_command :edit, '20110101'
|
38
37
|
end
|
39
38
|
|
40
39
|
it { wip_file.should_not written }
|
41
40
|
|
42
41
|
describe 'date file' do
|
43
|
-
subject {
|
42
|
+
subject { markdown_file('20110101' ) }
|
44
43
|
|
45
44
|
it { should written }
|
46
45
|
end
|
@@ -48,15 +47,13 @@ describe 'Retter::Command#edit', clean: :all do
|
|
48
47
|
|
49
48
|
context 'with date (1.day.ago) option' do
|
50
49
|
before do
|
51
|
-
|
50
|
+
time_travel_to '2011/04/02'
|
52
51
|
|
53
|
-
|
52
|
+
invoke_command :edit, '1.day.ago'
|
54
53
|
end
|
55
54
|
|
56
55
|
describe 'target date file' do
|
57
|
-
|
58
|
-
|
59
|
-
subject { Retter.entries.retter_file(one_day_ago) }
|
56
|
+
subject { markdown_file('2011/04/01') }
|
60
57
|
|
61
58
|
it { should written }
|
62
59
|
end
|
@@ -64,33 +61,29 @@ describe 'Retter::Command#edit', clean: :all do
|
|
64
61
|
|
65
62
|
context 'with date (yesterday) option' do
|
66
63
|
before do
|
67
|
-
|
64
|
+
time_travel_to '2011/04/02'
|
68
65
|
|
69
|
-
|
66
|
+
invoke_command :edit, 'yesterday'
|
70
67
|
end
|
71
68
|
|
72
69
|
describe 'target date file' do
|
73
|
-
|
74
|
-
|
75
|
-
subject { Retter.entries.retter_file(yesterday) }
|
70
|
+
subject { markdown_file('2011/04/01') }
|
76
71
|
|
77
72
|
it { should written }
|
78
73
|
end
|
79
74
|
end
|
80
75
|
|
81
76
|
context 'with filename (20110401.md) option' do
|
82
|
-
let(:a_day) { Date.parse('20110401') }
|
83
|
-
|
84
77
|
before do
|
85
|
-
FileUtils.touch
|
78
|
+
FileUtils.touch markdown_file('20110401')
|
86
79
|
|
87
|
-
Retter.reset! # XXX
|
80
|
+
Retter::Site.reset! # XXX
|
88
81
|
|
89
|
-
|
82
|
+
invoke_command :edit, '20110401.md'
|
90
83
|
end
|
91
84
|
|
92
85
|
describe 'target date file' do
|
93
|
-
subject {
|
86
|
+
subject { markdown_file('20110401') }
|
94
87
|
|
95
88
|
it { should written }
|
96
89
|
end
|
@@ -98,30 +91,27 @@ describe 'Retter::Command#edit', clean: :all do
|
|
98
91
|
|
99
92
|
context 'with no exist filename option' do
|
100
93
|
it {
|
101
|
-
-> {
|
94
|
+
-> { invoke_command :edit, '19850126.md' }.should raise_error(Retter::EntryLoadError)
|
102
95
|
}
|
103
96
|
end
|
104
97
|
|
105
98
|
context 'with filename (today.md) option' do
|
106
99
|
before do
|
107
|
-
FileUtils.touch
|
100
|
+
FileUtils.touch wip_file.to_path
|
108
101
|
|
109
|
-
|
102
|
+
invoke_command :edit, 'today.md'
|
110
103
|
end
|
111
104
|
|
112
105
|
describe 'target file' do
|
113
|
-
|
114
|
-
|
115
|
-
it { should written }
|
106
|
+
it { wip_file.should written }
|
116
107
|
end
|
117
108
|
end
|
118
109
|
|
119
110
|
context 'with silent option' do
|
120
111
|
before do
|
121
|
-
command.
|
112
|
+
command.should_not_receive(:after_callback)
|
122
113
|
|
123
|
-
|
124
|
-
command.edit
|
114
|
+
invoke_command :edit, silent: true
|
125
115
|
end
|
126
116
|
|
127
117
|
it { wip_file.should written }
|
data/spec/command/list_spec.rb
CHANGED
@@ -5,7 +5,7 @@ require 'spec_helper'
|
|
5
5
|
describe 'Retter::Command#list', clean: :all do
|
6
6
|
context 'happy case' do
|
7
7
|
before do
|
8
|
-
|
8
|
+
markdown_file('20110101').open('w') do |f|
|
9
9
|
f.puts <<-EOM
|
10
10
|
# 朝11時
|
11
11
|
|
@@ -17,7 +17,7 @@ describe 'Retter::Command#list', clean: :all do
|
|
17
17
|
EOM
|
18
18
|
end
|
19
19
|
|
20
|
-
|
20
|
+
markdown_file('20110222').open('w') do |f|
|
21
21
|
f.puts <<-EOM
|
22
22
|
# 朝11時30分
|
23
23
|
|
@@ -29,10 +29,10 @@ describe 'Retter::Command#list', clean: :all do
|
|
29
29
|
EOM
|
30
30
|
end
|
31
31
|
|
32
|
-
Retter.reset! # XXX
|
32
|
+
Retter::Site.reset! # XXX
|
33
33
|
end
|
34
34
|
|
35
|
-
subject { capture(:stdout) {
|
35
|
+
subject { capture(:stdout) { invoke_command :list }.split(/\n+/) }
|
36
36
|
|
37
37
|
its([0]) { should match /\[e0\]\s+2011\-02\-22/ }
|
38
38
|
its([1]) { should match /朝11時30分, 夜1時30分/ }
|
data/spec/command/open_spec.rb
CHANGED
@@ -5,8 +5,8 @@ require 'launchy'
|
|
5
5
|
|
6
6
|
describe 'Retter::Command#open', clean: :all do
|
7
7
|
specify 'should be open application' do
|
8
|
-
Launchy.should_receive(:open).with(
|
8
|
+
Launchy.should_receive(:open).with(generated_file('index.html').to_path)
|
9
9
|
|
10
|
-
|
10
|
+
invoke_command :open
|
11
11
|
end
|
12
12
|
end
|
@@ -4,9 +4,7 @@ require 'spec_helper'
|
|
4
4
|
require 'launchy'
|
5
5
|
|
6
6
|
describe 'Retter::Command#preview', clean: :all do
|
7
|
-
|
8
|
-
Retter.config.retter_home.join('.preview.html').read
|
9
|
-
end
|
7
|
+
let(:preview_html) { generated_file('.preview.html').read }
|
10
8
|
|
11
9
|
before do
|
12
10
|
Launchy.should_receive(:open).with(anything)
|
@@ -14,9 +12,9 @@ describe 'Retter::Command#preview', clean: :all do
|
|
14
12
|
|
15
13
|
context 'no options' do
|
16
14
|
before do
|
17
|
-
|
15
|
+
write_to_wip_file 'w00t!'
|
18
16
|
|
19
|
-
|
17
|
+
invoke_command :preview
|
20
18
|
end
|
21
19
|
|
22
20
|
subject { texts_of(preview_html, 'article p') }
|
@@ -25,21 +23,18 @@ describe 'Retter::Command#preview', clean: :all do
|
|
25
23
|
end
|
26
24
|
|
27
25
|
context 'with date option' do
|
28
|
-
let(:
|
29
|
-
let(:date_file) { Retter.entries.retter_file(Date.parse(date_str)) }
|
26
|
+
let(:date_file) { markdown_file('20110101') }
|
30
27
|
|
31
28
|
before do
|
32
|
-
|
29
|
+
write_to_wip_file 'w00t!'
|
33
30
|
date_file.open('w') {|f| f.puts 'preview me' }
|
34
31
|
|
35
|
-
|
36
|
-
|
37
|
-
command.preview
|
32
|
+
invoke_command :preview, date: '20110101'
|
38
33
|
end
|
39
34
|
|
40
35
|
subject { texts_of(preview_html, 'article p') }
|
41
36
|
|
42
37
|
it { should_not include 'w00t!' }
|
43
|
-
it { should
|
38
|
+
it { should include 'preview me' }
|
44
39
|
end
|
45
40
|
end
|