retter 0.2.0 → 0.2.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/ChangeLog.md +53 -0
- data/README.md +39 -7
- data/bin/retter +1 -1
- data/lib/retter/command.rb +106 -97
- data/lib/retter/config.rb +54 -76
- data/lib/retter/configurable.rb +26 -0
- data/lib/retter/entries.rb +28 -26
- data/lib/retter/entry.rb +76 -74
- data/lib/retter/generator/skel/Retterfile +26 -17
- data/lib/retter/page/view_helper.rb +5 -5
- data/lib/retter/page.rb +8 -6
- data/lib/retter/pages/article.rb +37 -35
- data/lib/retter/pages/entries.rb +15 -0
- data/lib/retter/pages/entry.rb +25 -22
- data/lib/retter/pages/feed.rb +35 -33
- data/lib/retter/pages/index.rb +9 -7
- data/lib/retter/pages/profile.rb +9 -7
- data/lib/retter/pages.rb +50 -13
- data/lib/retter/preprint.rb +5 -5
- data/lib/retter/renderers.rb +0 -1
- data/lib/retter/repository.rb +5 -4
- data/lib/retter/version.rb +1 -1
- data/lib/retter.rb +20 -24
- data/retter.gemspec +3 -1
- data/spec/bin/fake_editor +3 -0
- data/spec/command/callback_spec.rb +1 -1
- data/spec/command/commit_spec.rb +2 -2
- data/spec/command/edit_spec.rb +9 -7
- data/spec/command/invoke_after_spec.rb +2 -2
- data/spec/command/list_spec.rb +4 -2
- data/spec/command/open_spec.rb +1 -1
- data/spec/command/preview_spec.rb +2 -2
- data/spec/command/rebind_spec.rb +50 -10
- data/spec/spec_helper.rb +11 -6
- data/spec/support/example_group_helper.rb +1 -9
- metadata +68 -43
- data/CHANGELOG.md +0 -21
- data/lib/retter/pages/archive.rb +0 -13
data/lib/retter/pages/profile.rb
CHANGED
@@ -1,13 +1,15 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
module Retter
|
4
|
+
class Pages::Profile
|
5
|
+
include Page
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
|
7
|
+
def pathname
|
8
|
+
config.retter_home.join('profile.html')
|
9
|
+
end
|
9
10
|
|
10
|
-
|
11
|
-
|
11
|
+
def part_layout_pathname
|
12
|
+
Pages.find_layout_path('profile')
|
13
|
+
end
|
12
14
|
end
|
13
15
|
end
|
data/lib/retter/pages.rb
CHANGED
@@ -1,30 +1,49 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
3
|
module Retter
|
4
|
-
class Pages
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
4
|
+
class Pages # XXX 名前が気に食わない
|
5
|
+
autoload :Index, 'retter/pages/index'
|
6
|
+
autoload :Profile, 'retter/pages/profile'
|
7
|
+
autoload :Entries, 'retter/pages/entries'
|
8
|
+
autoload :Feed, 'retter/pages/feed'
|
9
|
+
autoload :Entry, 'retter/pages/entry'
|
10
|
+
autoload :Article, 'retter/pages/article'
|
11
11
|
|
12
|
-
include
|
12
|
+
include Stationery
|
13
|
+
extend Configurable
|
13
14
|
|
14
|
-
|
15
|
+
configurable :layouts_dir, :entries_dir, :allow_binding
|
16
|
+
|
17
|
+
class << self
|
18
|
+
def find_layout_path(name)
|
19
|
+
detected = Dir.glob(layouts_dir.join("#{name}.*.*")).first
|
20
|
+
|
21
|
+
Pathname.new(detected)
|
22
|
+
end
|
23
|
+
|
24
|
+
def layout_file
|
25
|
+
@layout_file ||= find_layout_path('retter')
|
26
|
+
end
|
27
|
+
|
28
|
+
def entry_file(date)
|
29
|
+
entries_dir.join date.strftime('%Y%m%d.html')
|
30
|
+
end
|
31
|
+
|
32
|
+
def entry_dir(date)
|
33
|
+
entries_dir.join date.strftime('%Y%m%d')
|
34
|
+
end
|
35
|
+
end
|
15
36
|
|
16
37
|
def initialize
|
17
|
-
|
18
|
-
@index, @profile, @archive, @feed = *singleton_pages
|
38
|
+
load_singleton_pages
|
19
39
|
end
|
20
40
|
|
21
41
|
def bind!
|
22
42
|
print_entries
|
23
43
|
|
24
|
-
singleton_pages.each(&:print)
|
44
|
+
@singleton_pages.each(&:print)
|
25
45
|
end
|
26
46
|
|
27
|
-
|
28
47
|
def print_entries
|
29
48
|
entries.each do |entry|
|
30
49
|
entry_page = Entry.new(entry)
|
@@ -36,5 +55,23 @@ module Retter
|
|
36
55
|
end
|
37
56
|
end
|
38
57
|
end
|
58
|
+
|
59
|
+
private
|
60
|
+
|
61
|
+
def load_singleton_pages
|
62
|
+
@singleton_pages = available_singleton_page_names.map {|name|
|
63
|
+
Pages.const_get(name.capitalize).new
|
64
|
+
}
|
65
|
+
end
|
66
|
+
|
67
|
+
def available_singleton_page_names
|
68
|
+
availables = [:index]
|
69
|
+
|
70
|
+
unless allow_binding == :none
|
71
|
+
availables += allow_binding || [:profile, :entries, :feed]
|
72
|
+
end
|
73
|
+
|
74
|
+
availables.map(&:downcase).uniq
|
75
|
+
end
|
39
76
|
end
|
40
77
|
end
|
data/lib/retter/preprint.rb
CHANGED
@@ -2,21 +2,21 @@
|
|
2
2
|
|
3
3
|
module Retter
|
4
4
|
class Preprint
|
5
|
-
include
|
5
|
+
include Page
|
6
6
|
|
7
7
|
def pathname
|
8
8
|
config.retter_home.join '.preview.html'
|
9
9
|
end
|
10
10
|
|
11
11
|
def part_layout_pathname
|
12
|
-
|
12
|
+
Pages.find_layout_path('entry')
|
13
13
|
end
|
14
14
|
|
15
15
|
def print(entry)
|
16
|
-
part =
|
17
|
-
part_layout_pathname.
|
16
|
+
part = Tilt.new(
|
17
|
+
part_layout_pathname.to_path,
|
18
18
|
ugly: true,
|
19
|
-
filename: part_layout_pathname.
|
19
|
+
filename: part_layout_pathname.to_path
|
20
20
|
).render(view_scope, entry: entry)
|
21
21
|
|
22
22
|
print_with_layout part
|
data/lib/retter/renderers.rb
CHANGED
data/lib/retter/repository.rb
CHANGED
@@ -4,11 +4,12 @@ require 'grit'
|
|
4
4
|
|
5
5
|
module Retter
|
6
6
|
class Repository
|
7
|
-
|
7
|
+
def self.open(working_dir, &block)
|
8
|
+
new(working_dir).open(&block)
|
9
|
+
end
|
8
10
|
|
9
|
-
def initialize
|
10
|
-
|
11
|
-
@repo = Grit::Repo.new(working_dir)
|
11
|
+
def initialize(working_dir)
|
12
|
+
@repo = Grit::Repo.new(working_dir.to_s)
|
12
13
|
end
|
13
14
|
|
14
15
|
def open
|
data/lib/retter/version.rb
CHANGED
data/lib/retter.rb
CHANGED
@@ -7,7 +7,7 @@ module Retter
|
|
7
7
|
class RetterError < RuntimeError; end
|
8
8
|
|
9
9
|
module Stationery
|
10
|
-
[:config, :entries
|
10
|
+
[:config, :entries].each do |meth|
|
11
11
|
define_method meth do
|
12
12
|
Retter.send meth
|
13
13
|
end
|
@@ -15,38 +15,34 @@ module Retter
|
|
15
15
|
end
|
16
16
|
|
17
17
|
class << self
|
18
|
-
|
19
|
-
@config = Config.new(env)
|
20
|
-
end
|
18
|
+
attr_reader :config
|
21
19
|
|
22
|
-
def
|
23
|
-
@config
|
20
|
+
def load(env)
|
21
|
+
@config = Config.new(env)
|
24
22
|
end
|
25
23
|
|
26
|
-
def
|
24
|
+
def reset!
|
27
25
|
@entries = nil
|
28
26
|
end
|
29
27
|
|
30
|
-
|
31
|
-
|
32
|
-
define_method sym do
|
33
|
-
eval "@#{sym} ||= #{sym.capitalize}.new"
|
34
|
-
end
|
28
|
+
def entries
|
29
|
+
@entries ||= Entries.new
|
35
30
|
end
|
36
31
|
end
|
37
32
|
|
38
|
-
autoload :Generator,
|
39
|
-
|
40
|
-
autoload :VERSION,
|
41
|
-
autoload :
|
42
|
-
autoload :
|
43
|
-
autoload :
|
44
|
-
autoload :
|
45
|
-
autoload :
|
46
|
-
autoload :
|
47
|
-
autoload :
|
48
|
-
autoload :
|
49
|
-
autoload :
|
33
|
+
autoload :Generator, 'retter/generator'
|
34
|
+
|
35
|
+
autoload :VERSION, 'retter/version'
|
36
|
+
autoload :Configurable, 'retter/configurable'
|
37
|
+
autoload :Config, 'retter/config'
|
38
|
+
autoload :Renderers, 'retter/renderers'
|
39
|
+
autoload :Entry, 'retter/entry'
|
40
|
+
autoload :Entries, 'retter/entries'
|
41
|
+
autoload :Page, 'retter/page'
|
42
|
+
autoload :Pages, 'retter/pages'
|
43
|
+
autoload :Preprint, 'retter/preprint'
|
44
|
+
autoload :Repository, 'retter/repository'
|
45
|
+
autoload :Command, 'retter/command'
|
50
46
|
end
|
51
47
|
|
52
48
|
require 'date'
|
data/retter.gemspec
CHANGED
@@ -17,7 +17,7 @@ Gem::Specification.new do |s|
|
|
17
17
|
|
18
18
|
Pygments syntax highlight is now available.
|
19
19
|
To use, add a following line to Retterfile.
|
20
|
-
|
20
|
+
|
21
21
|
```ruby
|
22
22
|
renderer Retter::Renderers::PygmentsRenderer
|
23
23
|
```
|
@@ -36,8 +36,10 @@ Gem::Specification.new do |s|
|
|
36
36
|
s.add_runtime_dependency 'nokogiri', ['>= 1.5.0']
|
37
37
|
s.add_runtime_dependency 'launchy', ['>= 2.0.5']
|
38
38
|
s.add_runtime_dependency 'haml', ['>= 3.1.3']
|
39
|
+
s.add_runtime_dependency 'tilt', ['>= 1.1.3']
|
39
40
|
s.add_runtime_dependency 'bundler', ['>= 1.0']
|
40
41
|
s.add_runtime_dependency 'grit', ['>= 2.4.1']
|
42
|
+
s.add_runtime_dependency 'chronic', ['>= 0.6.7']
|
41
43
|
s.add_runtime_dependency 'activesupport', ['>= 3.1.0']
|
42
44
|
|
43
45
|
# XXX for ActiveSupport dependency
|
data/spec/command/commit_spec.rb
CHANGED
@@ -4,7 +4,7 @@ require 'spec_helper'
|
|
4
4
|
require 'grit'
|
5
5
|
|
6
6
|
describe 'Retter::Command#commit', clean: :all do
|
7
|
-
let(:repo) { Grit::Repo.new(
|
7
|
+
let(:repo) { Grit::Repo.new(Retter.config.retter_home) }
|
8
8
|
let(:article) { '今日の記事' }
|
9
9
|
|
10
10
|
before do
|
@@ -12,7 +12,7 @@ describe 'Retter::Command#commit', clean: :all do
|
|
12
12
|
wip_file.open('w') {|f| f.puts article }
|
13
13
|
command.rebind
|
14
14
|
|
15
|
-
Grit::Repo.init
|
15
|
+
Grit::Repo.init Retter.config.retter_home.to_path
|
16
16
|
end
|
17
17
|
|
18
18
|
context 'with no options' do
|
data/spec/command/edit_spec.rb
CHANGED
@@ -40,7 +40,7 @@ describe 'Retter::Command#edit', clean: :all do
|
|
40
40
|
it { wip_file.should_not written }
|
41
41
|
|
42
42
|
describe 'date file' do
|
43
|
-
subject {
|
43
|
+
subject { Retter.entries.retter_file(date) }
|
44
44
|
|
45
45
|
it { should written }
|
46
46
|
end
|
@@ -56,7 +56,7 @@ describe 'Retter::Command#edit', clean: :all do
|
|
56
56
|
describe 'target date file' do
|
57
57
|
let(:one_day_ago) { Date.parse('2011/04/01') }
|
58
58
|
|
59
|
-
subject {
|
59
|
+
subject { Retter.entries.retter_file(one_day_ago) }
|
60
60
|
|
61
61
|
it { should written }
|
62
62
|
end
|
@@ -72,7 +72,7 @@ describe 'Retter::Command#edit', clean: :all do
|
|
72
72
|
describe 'target date file' do
|
73
73
|
let(:yesterday) { Date.parse('2011/04/01') }
|
74
74
|
|
75
|
-
subject {
|
75
|
+
subject { Retter.entries.retter_file(yesterday) }
|
76
76
|
|
77
77
|
it { should written }
|
78
78
|
end
|
@@ -82,13 +82,15 @@ describe 'Retter::Command#edit', clean: :all do
|
|
82
82
|
let(:a_day) { Date.parse('20110401') }
|
83
83
|
|
84
84
|
before do
|
85
|
-
FileUtils.touch
|
85
|
+
FileUtils.touch Retter.entries.retter_file(a_day)
|
86
|
+
|
87
|
+
Retter.reset! # XXX
|
86
88
|
|
87
89
|
command.edit '20110401.md'
|
88
90
|
end
|
89
91
|
|
90
92
|
describe 'target date file' do
|
91
|
-
subject {
|
93
|
+
subject { Retter.entries.retter_file(a_day) }
|
92
94
|
|
93
95
|
it { should written }
|
94
96
|
end
|
@@ -102,13 +104,13 @@ describe 'Retter::Command#edit', clean: :all do
|
|
102
104
|
|
103
105
|
context 'with filename (today.md) option' do
|
104
106
|
before do
|
105
|
-
FileUtils.touch
|
107
|
+
FileUtils.touch Retter.config.wip_file.to_path
|
106
108
|
|
107
109
|
command.edit 'today.md'
|
108
110
|
end
|
109
111
|
|
110
112
|
describe 'target file' do
|
111
|
-
subject {
|
113
|
+
subject { Retter.config.wip_file }
|
112
114
|
|
113
115
|
it { should written }
|
114
116
|
end
|
@@ -5,7 +5,7 @@ require 'spec_helper'
|
|
5
5
|
describe 'Retter::Command#invoke_after', clean: :all do
|
6
6
|
context 'invoke with proc' do
|
7
7
|
before do
|
8
|
-
|
8
|
+
Retter.config.after(:edit) { commit }
|
9
9
|
end
|
10
10
|
|
11
11
|
specify 'callback should called' do
|
@@ -17,7 +17,7 @@ describe 'Retter::Command#invoke_after', clean: :all do
|
|
17
17
|
|
18
18
|
context 'invoke with symbol' do
|
19
19
|
before do
|
20
|
-
|
20
|
+
Retter.config.after(:edit, :commit)
|
21
21
|
end
|
22
22
|
|
23
23
|
specify 'callback should called' do
|
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
|
+
Retter.entries.retter_file(Date.parse('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
|
+
Retter.entries.retter_file(Date.parse('20110222')).open('w') do |f|
|
21
21
|
f.puts <<-EOM
|
22
22
|
# 朝11時30分
|
23
23
|
|
@@ -28,6 +28,8 @@ describe 'Retter::Command#list', clean: :all do
|
|
28
28
|
おやすみなさい
|
29
29
|
EOM
|
30
30
|
end
|
31
|
+
|
32
|
+
Retter.reset! # XXX
|
31
33
|
end
|
32
34
|
|
33
35
|
subject { capture(:stdout) { command.list }.split(/\n+/) }
|
data/spec/command/open_spec.rb
CHANGED
@@ -5,7 +5,7 @@ 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(Retter.config.retter_home.join('index.html').to_path)
|
9
9
|
|
10
10
|
command.open
|
11
11
|
end
|
@@ -5,7 +5,7 @@ require 'launchy'
|
|
5
5
|
|
6
6
|
describe 'Retter::Command#preview', clean: :all do
|
7
7
|
def preview_html
|
8
|
-
|
8
|
+
Retter.config.retter_home.join('.preview.html').read
|
9
9
|
end
|
10
10
|
|
11
11
|
before do
|
@@ -26,7 +26,7 @@ describe 'Retter::Command#preview', clean: :all do
|
|
26
26
|
|
27
27
|
context 'with date option' do
|
28
28
|
let(:date_str) { '20110101' }
|
29
|
-
let(:date_file) {
|
29
|
+
let(:date_file) { Retter.entries.retter_file(Date.parse(date_str)) }
|
30
30
|
|
31
31
|
before do
|
32
32
|
wip_file.open('w') {|f| f.puts 'w00t!' }
|
data/spec/command/rebind_spec.rb
CHANGED
@@ -6,8 +6,8 @@ describe 'Retter::Command#rebind', clean: :all do
|
|
6
6
|
context 'first post' do
|
7
7
|
let(:date_str) { '20110101' }
|
8
8
|
let(:date) { Date.parse(date_str) }
|
9
|
-
let(:date_file) {
|
10
|
-
let(:date_html) {
|
9
|
+
let(:date_file) { Retter.entries.retter_file(date) }
|
10
|
+
let(:date_html) { Retter::Pages.entry_file(date) }
|
11
11
|
let(:article) { <<-EOM }
|
12
12
|
# 朝11時
|
13
13
|
|
@@ -35,7 +35,7 @@ describe 'Retter::Command#rebind', clean: :all do
|
|
35
35
|
end
|
36
36
|
|
37
37
|
describe 'index.html' do
|
38
|
-
let(:index_html) {
|
38
|
+
let(:index_html) { Retter.config.retter_home.join('index.html').read }
|
39
39
|
|
40
40
|
it { texts_of(index_html, 'article p').should include('おはようございます') }
|
41
41
|
it { texts_of(index_html, 'article h1.date').should == %w(2011-01-01) }
|
@@ -43,14 +43,14 @@ describe 'Retter::Command#rebind', clean: :all do
|
|
43
43
|
end
|
44
44
|
|
45
45
|
describe 'entries.html' do
|
46
|
-
let(:entries_html) {
|
46
|
+
let(:entries_html) { Retter.config.retter_home.join('entries.html').read }
|
47
47
|
|
48
48
|
it { texts_of(entries_html, 'a.entry').first.should == '2011-01-01' }
|
49
49
|
it { texts_of(entries_html, 'a.title').should == %w(朝11時 夜1時) }
|
50
50
|
end
|
51
51
|
|
52
52
|
describe 'entry.html' do
|
53
|
-
let(:entry_html) {
|
53
|
+
let(:entry_html) { Retter::Pages.entry_file(date).read }
|
54
54
|
|
55
55
|
it { texts_of(entry_html, 'article p').should == %w(おはようございます おやすみなさい) }
|
56
56
|
it { texts_of(entry_html, 'article h1.date').should == %w(2011-01-01) }
|
@@ -58,7 +58,7 @@ describe 'Retter::Command#rebind', clean: :all do
|
|
58
58
|
end
|
59
59
|
|
60
60
|
describe 'entry part(first)' do
|
61
|
-
let(:part_html) {
|
61
|
+
let(:part_html) { Retter::Pages.entry_dir(date).join('a0.html').read }
|
62
62
|
|
63
63
|
describe 'body' do
|
64
64
|
subject { texts_of(part_html, 'article p') }
|
@@ -82,7 +82,7 @@ describe 'Retter::Command#rebind', clean: :all do
|
|
82
82
|
end
|
83
83
|
|
84
84
|
describe 'entry part(last)' do
|
85
|
-
let(:part_html) {
|
85
|
+
let(:part_html) { Retter::Pages.entry_dir(date).join('a1.html').read }
|
86
86
|
|
87
87
|
describe 'body' do
|
88
88
|
subject { texts_of(part_html, 'article p') }
|
@@ -107,7 +107,7 @@ describe 'Retter::Command#rebind', clean: :all do
|
|
107
107
|
end
|
108
108
|
|
109
109
|
context 'includes code block' do
|
110
|
-
let(:index_html) {
|
110
|
+
let(:index_html) { Retter.config.retter_home.join('index.html').read }
|
111
111
|
let(:article) { <<-EOM }
|
112
112
|
# コードを書きました
|
113
113
|
|
@@ -122,7 +122,7 @@ sleep 1000
|
|
122
122
|
|
123
123
|
context 'use Pygments' do
|
124
124
|
before do
|
125
|
-
|
125
|
+
Retter.config.renderer Retter::Renderers::PygmentsRenderer
|
126
126
|
command.rebind
|
127
127
|
end
|
128
128
|
|
@@ -133,7 +133,7 @@ sleep 1000
|
|
133
133
|
|
134
134
|
context 'use CodeRay' do
|
135
135
|
before do
|
136
|
-
|
136
|
+
Retter.config.renderer Retter::Renderers::CodeRayRenderer
|
137
137
|
command.rebind
|
138
138
|
end
|
139
139
|
|
@@ -156,4 +156,44 @@ sleep 1000
|
|
156
156
|
command.rebind
|
157
157
|
end
|
158
158
|
end
|
159
|
+
|
160
|
+
context 'skipping some singleton pages binding' do
|
161
|
+
let(:retter_home) { Retter.config.retter_home }
|
162
|
+
let(:index_html) { retter_home.join('index.html') }
|
163
|
+
let(:profile_html) { retter_home.join('profile.html') }
|
164
|
+
let(:entries_html) { retter_home.join('entries.html') }
|
165
|
+
let(:feed_file) { retter_home.join('feed.rss') }
|
166
|
+
|
167
|
+
before do
|
168
|
+
index_html.unlink
|
169
|
+
|
170
|
+
command.edit
|
171
|
+
end
|
172
|
+
|
173
|
+
context 'skipping all' do
|
174
|
+
before do
|
175
|
+
Retter::Pages.allow_binding :none
|
176
|
+
|
177
|
+
command.rebind
|
178
|
+
end
|
179
|
+
|
180
|
+
it { profile_html.should_not be_exist }
|
181
|
+
it { entries_html.should_not be_exist }
|
182
|
+
it { feed_file.should_not be_exist }
|
183
|
+
it { index_html.should be_exist }
|
184
|
+
end
|
185
|
+
|
186
|
+
context 'skipping only :feed' do
|
187
|
+
before do
|
188
|
+
Retter::Pages.allow_binding [:profile, :entries]
|
189
|
+
|
190
|
+
command.rebind
|
191
|
+
end
|
192
|
+
|
193
|
+
it { profile_html.should be_exist }
|
194
|
+
it { entries_html.should be_exist }
|
195
|
+
it { feed_file.should_not be_exist }
|
196
|
+
it { index_html.should be_exist }
|
197
|
+
end
|
198
|
+
end
|
159
199
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
3
|
require 'tapp'
|
4
|
-
require 'simplecov'
|
5
4
|
|
6
|
-
|
5
|
+
if ENV['COVERAGE']
|
6
|
+
require 'simplecov'
|
7
|
+
SimpleCov.start
|
8
|
+
end
|
7
9
|
|
8
10
|
RETTER_ROOT = Pathname.new(File.dirname(__FILE__) + '/../').realpath
|
9
11
|
require RETTER_ROOT.join('lib', 'retter')
|
@@ -14,8 +16,9 @@ RSpec.configure do |config|
|
|
14
16
|
config.filter_run focus: true
|
15
17
|
config.run_all_when_everything_filtered = true
|
16
18
|
|
17
|
-
retter_home = RETTER_ROOT.join('tmp
|
18
|
-
skel = RETTER_ROOT.join('lib
|
19
|
+
retter_home = RETTER_ROOT.join('tmp/test')
|
20
|
+
skel = RETTER_ROOT.join('lib/retter/generator/skel')
|
21
|
+
fake_editor = RETTER_ROOT.join('spec/bin/fake_editor')
|
19
22
|
|
20
23
|
config.before :each, clean: :all do
|
21
24
|
FileUtils.cp_r skel, retter_home.dirname.join('test')
|
@@ -23,11 +26,13 @@ RSpec.configure do |config|
|
|
23
26
|
|
24
27
|
config.after :each, clean: :all do
|
25
28
|
FileUtils.rm_rf retter_home
|
26
|
-
Retter.
|
29
|
+
Retter.reset!
|
27
30
|
end
|
28
31
|
|
29
32
|
config.before do
|
30
|
-
|
33
|
+
env = {'EDITOR' => fake_editor.to_path, 'RETTER_HOME' => RETTER_ROOT.join('tmp', 'test').to_s}
|
34
|
+
|
35
|
+
Retter.load env
|
31
36
|
end
|
32
37
|
|
33
38
|
config.include ExampleGroupHelper
|
@@ -9,16 +9,8 @@ module ExampleGroupHelper
|
|
9
9
|
@command ||= Retter::Command.new
|
10
10
|
end
|
11
11
|
|
12
|
-
def retter_config
|
13
|
-
return @config if @config
|
14
|
-
|
15
|
-
env = {'EDITOR' => 'echo written >', 'RETTER_HOME' => RETTER_ROOT.join('tmp', 'test').to_s}
|
16
|
-
|
17
|
-
@config = Retter::Config.new(env)
|
18
|
-
end
|
19
|
-
|
20
12
|
def wip_file
|
21
|
-
|
13
|
+
Retter.entries.wip_file
|
22
14
|
end
|
23
15
|
end
|
24
16
|
|