retter 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +2 -1
- data/lib/generator/skel/Retterfile +15 -0
- data/lib/retter/command.rb +21 -2
- data/lib/retter/config.rb +9 -0
- data/lib/retter/version.rb +1 -1
- data/retter.gemspec +13 -13
- data/spec/command/callback_spec.rb +29 -0
- metadata +45 -43
data/.travis.yml
CHANGED
@@ -1,6 +1,21 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
1
2
|
# coding: utf-8
|
2
3
|
|
3
4
|
url 'http://retter.example.com/'
|
4
5
|
title '<%= name %>'
|
5
6
|
description '<%= name %>'
|
6
7
|
author '<%= ENV["USER"] %>'
|
8
|
+
|
9
|
+
## Callbacks for retter sub-command: edit, rebind, commit
|
10
|
+
##
|
11
|
+
## Syntax:
|
12
|
+
## after [command], [invoke command or proc]
|
13
|
+
#
|
14
|
+
## Using symbol example:
|
15
|
+
# after :rebind, :commit
|
16
|
+
#
|
17
|
+
## Using proc example:
|
18
|
+
# after :commit do
|
19
|
+
# system "cd #{config.retter_home}"
|
20
|
+
# system 'git push origin master'
|
21
|
+
# end
|
data/lib/retter/command.rb
CHANGED
@@ -5,6 +5,8 @@ class Retter::Command < Thor
|
|
5
5
|
method_options date: :string
|
6
6
|
def edit
|
7
7
|
system config.editor, detected_retter_file.to_s
|
8
|
+
|
9
|
+
invoke_after :edit
|
8
10
|
end
|
9
11
|
|
10
12
|
default_task :edit
|
@@ -29,6 +31,8 @@ class Retter::Command < Thor
|
|
29
31
|
|
30
32
|
binder.commit_wip_file
|
31
33
|
binder.rebind!
|
34
|
+
|
35
|
+
invoke_after :rebind
|
32
36
|
end
|
33
37
|
|
34
38
|
desc 'bind', 'Re-bind the draft article, re-generate all html pages.'
|
@@ -42,11 +46,12 @@ class Retter::Command < Thor
|
|
42
46
|
|
43
47
|
say git.add(working_dir), :green
|
44
48
|
say git.commit_all('Retter commit'), :green
|
49
|
+
|
50
|
+
invoke_after :commit
|
45
51
|
end
|
46
52
|
|
47
53
|
desc 'new', 'Create a new site'
|
48
|
-
def new
|
49
|
-
end
|
54
|
+
def new; end
|
50
55
|
|
51
56
|
desc 'usage', 'Show usage.'
|
52
57
|
def usage
|
@@ -76,6 +81,20 @@ class Retter::Command < Thor
|
|
76
81
|
exit 1
|
77
82
|
end
|
78
83
|
|
84
|
+
def invoke_after(name)
|
85
|
+
callback = config.after(name)
|
86
|
+
return unless callback
|
87
|
+
|
88
|
+
case callback
|
89
|
+
when Proc
|
90
|
+
instance_eval &callback
|
91
|
+
when Symbol
|
92
|
+
invoke callback
|
93
|
+
else
|
94
|
+
raise ArgumentError
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
79
98
|
def self.usage
|
80
99
|
<<-EOM
|
81
100
|
Usage:
|
data/lib/retter/config.rb
CHANGED
@@ -34,6 +34,7 @@ class Retter::Config
|
|
34
34
|
|
35
35
|
def initialize(env)
|
36
36
|
@env, @options = env, {}
|
37
|
+
@after_callbacks = {}
|
37
38
|
|
38
39
|
detect_retter_home
|
39
40
|
raise Retter::EnvError unless env.values_at('EDITOR', 'RETTER_HOME').all?
|
@@ -79,4 +80,12 @@ class Retter::Config
|
|
79
80
|
def self.delegatables
|
80
81
|
ATTRIBUTES + [:retter_file, :entry_file]
|
81
82
|
end
|
83
|
+
|
84
|
+
def after(name, sym = nil, &block)
|
85
|
+
if callback = sym || block
|
86
|
+
@after_callbacks[name] = callback
|
87
|
+
else
|
88
|
+
@after_callbacks[name]
|
89
|
+
end
|
90
|
+
end
|
82
91
|
end
|
data/lib/retter/version.rb
CHANGED
data/retter.gemspec
CHANGED
@@ -18,19 +18,19 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
19
|
s.require_paths = ["lib"]
|
20
20
|
|
21
|
-
s.add_runtime_dependency 'thor'
|
22
|
-
s.add_runtime_dependency 'builder'
|
21
|
+
s.add_runtime_dependency 'thor', ['>= 0.14.6']
|
22
|
+
s.add_runtime_dependency 'builder', ['>= 3.0.0']
|
23
23
|
s.add_runtime_dependency 'redcarpet', ['>= 2.0.0b3']
|
24
|
-
s.add_runtime_dependency 'coderay'
|
25
|
-
s.add_runtime_dependency 'nokogiri'
|
26
|
-
s.add_runtime_dependency 'launchy'
|
27
|
-
s.add_runtime_dependency 'haml'
|
28
|
-
s.add_runtime_dependency 'bundler'
|
29
|
-
s.add_runtime_dependency 'grit'
|
24
|
+
s.add_runtime_dependency 'coderay', ['>= 0.9.8']
|
25
|
+
s.add_runtime_dependency 'nokogiri', ['>= 1.5.0']
|
26
|
+
s.add_runtime_dependency 'launchy', ['>= 2.0.5']
|
27
|
+
s.add_runtime_dependency 'haml', ['>= 3.1.3']
|
28
|
+
s.add_runtime_dependency 'bundler', ['>= 1.0']
|
29
|
+
s.add_runtime_dependency 'grit', ['>= 2.4.1']
|
30
30
|
|
31
|
-
s.add_development_dependency 'rake'
|
32
|
-
s.add_development_dependency 'ir_b'
|
33
|
-
s.add_development_dependency 'tapp'
|
34
|
-
s.add_development_dependency 'rspec'
|
35
|
-
s.add_development_dependency 'simplecov'
|
31
|
+
s.add_development_dependency 'rake', ['>= 0.9.2']
|
32
|
+
s.add_development_dependency 'ir_b', ['>= 1.4.0']
|
33
|
+
s.add_development_dependency 'tapp', ['>= 1.1.0']
|
34
|
+
s.add_development_dependency 'rspec', ['>= 2.6.0']
|
35
|
+
s.add_development_dependency 'simplecov', ['>= 0.5.3']
|
36
36
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
4
|
+
|
5
|
+
describe 'Retter::Command#invoke_after', clean: :all do
|
6
|
+
let(:command) { Retter::Command.new }
|
7
|
+
|
8
|
+
context 'invoke with proc' do
|
9
|
+
before do
|
10
|
+
command.stub!(:config) { retter_config }
|
11
|
+
|
12
|
+
retter_config.after(:edit) { commit }
|
13
|
+
command.should_receive(:commit).and_return(true)
|
14
|
+
end
|
15
|
+
|
16
|
+
it { command.edit.should }
|
17
|
+
end
|
18
|
+
|
19
|
+
context 'invoke with symbol' do
|
20
|
+
before do
|
21
|
+
command.stub!(:config) { retter_config }
|
22
|
+
|
23
|
+
retter_config.after(:edit, :commit)
|
24
|
+
command.should_receive(:invoke).with(:commit).and_return(true)
|
25
|
+
end
|
26
|
+
|
27
|
+
it { command.edit.should }
|
28
|
+
end
|
29
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: retter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,33 +9,33 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-09-
|
12
|
+
date: 2011-09-16 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: thor
|
16
|
-
requirement: &
|
16
|
+
requirement: &70165694450760 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
21
|
+
version: 0.14.6
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70165694450760
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: builder
|
27
|
-
requirement: &
|
27
|
+
requirement: &70165694450200 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version:
|
32
|
+
version: 3.0.0
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70165694450200
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: redcarpet
|
38
|
-
requirement: &
|
38
|
+
requirement: &70165694449720 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,128 +43,128 @@ dependencies:
|
|
43
43
|
version: 2.0.0b3
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70165694449720
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: coderay
|
49
|
-
requirement: &
|
49
|
+
requirement: &70165694449240 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 0.9.8
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70165694449240
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: nokogiri
|
60
|
-
requirement: &
|
60
|
+
requirement: &70165694448760 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
64
64
|
- !ruby/object:Gem::Version
|
65
|
-
version:
|
65
|
+
version: 1.5.0
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70165694448760
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: launchy
|
71
|
-
requirement: &
|
71
|
+
requirement: &70165694448280 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
75
75
|
- !ruby/object:Gem::Version
|
76
|
-
version:
|
76
|
+
version: 2.0.5
|
77
77
|
type: :runtime
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70165694448280
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: haml
|
82
|
-
requirement: &
|
82
|
+
requirement: &70165694447800 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ! '>='
|
86
86
|
- !ruby/object:Gem::Version
|
87
|
-
version:
|
87
|
+
version: 3.1.3
|
88
88
|
type: :runtime
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *70165694447800
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: bundler
|
93
|
-
requirement: &
|
93
|
+
requirement: &70165694447320 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
96
|
- - ! '>='
|
97
97
|
- !ruby/object:Gem::Version
|
98
|
-
version: '0'
|
98
|
+
version: '1.0'
|
99
99
|
type: :runtime
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *70165694447320
|
102
102
|
- !ruby/object:Gem::Dependency
|
103
103
|
name: grit
|
104
|
-
requirement: &
|
104
|
+
requirement: &70165694431940 !ruby/object:Gem::Requirement
|
105
105
|
none: false
|
106
106
|
requirements:
|
107
107
|
- - ! '>='
|
108
108
|
- !ruby/object:Gem::Version
|
109
|
-
version:
|
109
|
+
version: 2.4.1
|
110
110
|
type: :runtime
|
111
111
|
prerelease: false
|
112
|
-
version_requirements: *
|
112
|
+
version_requirements: *70165694431940
|
113
113
|
- !ruby/object:Gem::Dependency
|
114
114
|
name: rake
|
115
|
-
requirement: &
|
115
|
+
requirement: &70165694431440 !ruby/object:Gem::Requirement
|
116
116
|
none: false
|
117
117
|
requirements:
|
118
118
|
- - ! '>='
|
119
119
|
- !ruby/object:Gem::Version
|
120
|
-
version:
|
120
|
+
version: 0.9.2
|
121
121
|
type: :development
|
122
122
|
prerelease: false
|
123
|
-
version_requirements: *
|
123
|
+
version_requirements: *70165694431440
|
124
124
|
- !ruby/object:Gem::Dependency
|
125
125
|
name: ir_b
|
126
|
-
requirement: &
|
126
|
+
requirement: &70165694430920 !ruby/object:Gem::Requirement
|
127
127
|
none: false
|
128
128
|
requirements:
|
129
129
|
- - ! '>='
|
130
130
|
- !ruby/object:Gem::Version
|
131
|
-
version:
|
131
|
+
version: 1.4.0
|
132
132
|
type: :development
|
133
133
|
prerelease: false
|
134
|
-
version_requirements: *
|
134
|
+
version_requirements: *70165694430920
|
135
135
|
- !ruby/object:Gem::Dependency
|
136
136
|
name: tapp
|
137
|
-
requirement: &
|
137
|
+
requirement: &70165694430420 !ruby/object:Gem::Requirement
|
138
138
|
none: false
|
139
139
|
requirements:
|
140
140
|
- - ! '>='
|
141
141
|
- !ruby/object:Gem::Version
|
142
|
-
version:
|
142
|
+
version: 1.1.0
|
143
143
|
type: :development
|
144
144
|
prerelease: false
|
145
|
-
version_requirements: *
|
145
|
+
version_requirements: *70165694430420
|
146
146
|
- !ruby/object:Gem::Dependency
|
147
147
|
name: rspec
|
148
|
-
requirement: &
|
148
|
+
requirement: &70165694429900 !ruby/object:Gem::Requirement
|
149
149
|
none: false
|
150
150
|
requirements:
|
151
151
|
- - ! '>='
|
152
152
|
- !ruby/object:Gem::Version
|
153
|
-
version:
|
153
|
+
version: 2.6.0
|
154
154
|
type: :development
|
155
155
|
prerelease: false
|
156
|
-
version_requirements: *
|
156
|
+
version_requirements: *70165694429900
|
157
157
|
- !ruby/object:Gem::Dependency
|
158
158
|
name: simplecov
|
159
|
-
requirement: &
|
159
|
+
requirement: &70165694429420 !ruby/object:Gem::Requirement
|
160
160
|
none: false
|
161
161
|
requirements:
|
162
162
|
- - ! '>='
|
163
163
|
- !ruby/object:Gem::Version
|
164
|
-
version:
|
164
|
+
version: 0.5.3
|
165
165
|
type: :development
|
166
166
|
prerelease: false
|
167
|
-
version_requirements: *
|
167
|
+
version_requirements: *70165694429420
|
168
168
|
description: Lightweight diary workflow. ruby-1.9.2 or later is required.
|
169
169
|
email:
|
170
170
|
- celluloid.key@gmail.com
|
@@ -206,6 +206,7 @@ files:
|
|
206
206
|
- lib/retter/stationery/view.rb
|
207
207
|
- lib/retter/version.rb
|
208
208
|
- retter.gemspec
|
209
|
+
- spec/command/callback_spec.rb
|
209
210
|
- spec/command/commit_spec.rb
|
210
211
|
- spec/command/edit_spec.rb
|
211
212
|
- spec/command/open_spec.rb
|
@@ -241,6 +242,7 @@ signing_key:
|
|
241
242
|
specification_version: 3
|
242
243
|
summary: Lightweight diary workflow
|
243
244
|
test_files:
|
245
|
+
- spec/command/callback_spec.rb
|
244
246
|
- spec/command/commit_spec.rb
|
245
247
|
- spec/command/edit_spec.rb
|
246
248
|
- spec/command/open_spec.rb
|