neruda 0.0.8 → 0.0.9
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.
- checksums.yaml +4 -4
- data/bin/pablo +59 -48
- data/lib/tasks/book.rake +1 -1
- data/lib/tasks/chapters.rake +15 -10
- data/lib/tasks/sinatra.rake +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e3101ba04a16de9562d4834ebde5c9034103d14d
|
4
|
+
data.tar.gz: f50ebe738e0771b75ed532319e84cfe1027bea25
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c3ca902065a455800fdd16b9b9ee0d81921b7971d4a25b9aa8e5bf0327ab05f97ddd39b7d710ab7937cee1b11a1b61e33b51ee04a140d31ad0418584de15c95d
|
7
|
+
data.tar.gz: 011f3df145a513b3b780fbf543db6eb5a76cd6c89acb8342428799bd32b3bfef21a38efc5019de9b686f4517bc642649fadbbd99864eb015b14e4bb957549a10
|
data/bin/pablo
CHANGED
@@ -20,8 +20,9 @@ module BundlerHelper
|
|
20
20
|
def rake_or_bundle_run(cmd, use_system = false)
|
21
21
|
cmd.insert(1, '-s') unless @options[:verbose]
|
22
22
|
cmd = ['bundle', 'exec'] + cmd if bundler_is_present?
|
23
|
-
|
24
|
-
|
23
|
+
joined_cmd = cmd.join(' ')
|
24
|
+
puts Rainbow(joined_cmd).blue if @options[:verbose]
|
25
|
+
return system(joined_cmd) if use_system
|
25
26
|
exec(*cmd)
|
26
27
|
end
|
27
28
|
|
@@ -32,11 +33,11 @@ module BundlerHelper
|
|
32
33
|
end
|
33
34
|
|
34
35
|
capfile = File.new('Capfile', 'a')
|
35
|
-
capfile.write <<~
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
36
|
+
capfile.write <<~CAPFILE
|
37
|
+
neruda_spec = Gem::Specification.find_by_name 'neruda'
|
38
|
+
Dir.glob("\#{neruda_spec.gem_dir}/lib/tasks/*.rake").each { |r| import r }
|
39
|
+
Dir.glob("\#{neruda_spec.gem_dir}/lib/tasks/capistrano/*.rake").each { |r| import r }
|
40
|
+
CAPFILE
|
40
41
|
end
|
41
42
|
end
|
42
43
|
|
@@ -93,13 +94,12 @@ module PabloInit
|
|
93
94
|
end
|
94
95
|
|
95
96
|
return if File.exist? 'config.ru'
|
96
|
-
|
97
|
-
|
97
|
+
IO.write 'config.ru', <<~CONFIG
|
98
|
+
# frozen_string_literal: true
|
98
99
|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
IO.write('config.ru', rackup_conf)
|
100
|
+
require 'neruda'
|
101
|
+
run Neruda::App
|
102
|
+
CONFIG
|
103
103
|
end
|
104
104
|
|
105
105
|
def init_bundler
|
@@ -119,22 +119,21 @@ module PabloInit
|
|
119
119
|
# end
|
120
120
|
markup_gem = 'gem \'org-ruby\''
|
121
121
|
|
122
|
-
|
123
|
-
|
122
|
+
IO.write 'Gemfile', <<~GEMFILE
|
123
|
+
# frozen_string_literal: true
|
124
124
|
|
125
|
-
|
125
|
+
source 'https://rubygems.org'
|
126
126
|
|
127
|
-
|
128
|
-
|
127
|
+
gem 'neruda'
|
128
|
+
#{markup_gem}
|
129
129
|
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
IO.write('Gemfile', gemfile)
|
130
|
+
group :development do
|
131
|
+
gem 'capistrano'
|
132
|
+
gem 'capistrano-bundler'
|
133
|
+
gem 'capistrano-rvm'
|
134
|
+
gem 'rubocop'
|
135
|
+
end
|
136
|
+
GEMFILE
|
138
137
|
puts ''
|
139
138
|
puts 'To complete this installation, you must now run: ' +
|
140
139
|
Rainbow('bundle install').yellow
|
@@ -161,42 +160,41 @@ class Pablo
|
|
161
160
|
@options = {
|
162
161
|
verbose: false
|
163
162
|
}
|
164
|
-
@available_commands = ['capify', 'list', 'start', '
|
163
|
+
@available_commands = ['capify', 'list', 'start', 'edit',
|
165
164
|
'setup', 'stop', 'compile']
|
166
165
|
|
167
166
|
parse_options
|
167
|
+
# Be sure required directories are always there
|
168
|
+
init_path unless @arg == 'setup'
|
168
169
|
route_command
|
169
170
|
end
|
170
171
|
|
171
172
|
def route_command
|
172
|
-
|
173
|
-
when 'capify', 'list', 'start', 'new_chapter', 'setup'
|
174
|
-
send @arg
|
175
|
-
|
176
|
-
when 'stop'
|
173
|
+
if @arg == 'stop'
|
177
174
|
rake_or_bundle_run ['rake', 'sinatra:stop']
|
178
|
-
|
179
|
-
when 'compile'
|
180
|
-
rake_or_bundle_run ['rake', 'chapters:build_epubs'], true
|
181
|
-
rake_or_bundle_run ['rake', 'book:make']
|
175
|
+
return
|
182
176
|
end
|
177
|
+
|
178
|
+
ARGV.shift
|
179
|
+
send @arg
|
183
180
|
end
|
184
181
|
|
185
182
|
private
|
186
183
|
|
187
184
|
def parse_options
|
188
185
|
optparse = OptionParser.new do |opts|
|
189
|
-
opts.banner = <<~
|
186
|
+
opts.banner = <<~HELP
|
190
187
|
Usage:
|
191
188
|
pablo -h
|
192
189
|
pablo [ -v ] command
|
193
190
|
|
194
|
-
|
191
|
+
HELP
|
195
192
|
opts.on('-v', '--verbose', 'Output more information') do
|
196
193
|
@options[:verbose] = true
|
197
194
|
end
|
198
195
|
opts.on('-h', '--help', 'Display this screen') do
|
199
196
|
STDERR.puts opts
|
197
|
+
STDERR.puts
|
200
198
|
pablo_help
|
201
199
|
end
|
202
200
|
end
|
@@ -205,11 +203,17 @@ class Pablo
|
|
205
203
|
|
206
204
|
@arg = ARGV[0]
|
207
205
|
if @arg == 'new'
|
208
|
-
@arg = '
|
206
|
+
@arg = 'edit'
|
209
207
|
elsif @arg == 'run'
|
210
208
|
@arg = 'start'
|
209
|
+
elsif @arg == 'init'
|
210
|
+
@arg = 'setup'
|
211
211
|
end
|
212
212
|
|
213
|
+
if !File.exist?('config/config.yml') && @arg != 'setup'
|
214
|
+
STDERR.puts Rainbow('ERROR: please run pablo setup before all').red
|
215
|
+
exit 1
|
216
|
+
end
|
213
217
|
return if @available_commands.include?(@arg)
|
214
218
|
STDERR.puts Rainbow('ERROR: no or unknown command given.').red
|
215
219
|
STDERR.puts Rainbow('Run pablo -h for options and available ' \
|
@@ -221,10 +225,10 @@ class Pablo
|
|
221
225
|
include PabloInit
|
222
226
|
|
223
227
|
def pablo_help
|
224
|
-
STDERR.puts <<~
|
225
|
-
|
228
|
+
STDERR.puts <<~HELP
|
226
229
|
Book Commands:
|
227
|
-
new
|
230
|
+
new [title] Begin to write a new chapter
|
231
|
+
edit [title] Continue the writing of a chapter
|
228
232
|
compile Generate the epubs files
|
229
233
|
list [elements] List various book elements
|
230
234
|
(chapters, characters, notes, sceneries)
|
@@ -234,11 +238,18 @@ class Pablo
|
|
234
238
|
(you just need to do it once).
|
235
239
|
start Start a test web server
|
236
240
|
stop Stop the web server
|
237
|
-
|
241
|
+
HELP
|
238
242
|
exit
|
239
243
|
end
|
240
244
|
|
245
|
+
def compile
|
246
|
+
rake_or_bundle_run ['rake', 'chapters:build_epubs'], true
|
247
|
+
rake_or_bundle_run ['rake', 'book:make'], true
|
248
|
+
end
|
249
|
+
|
241
250
|
def start
|
251
|
+
compile
|
252
|
+
|
242
253
|
loc_env = ENV['APP_ENV'] || 'development'
|
243
254
|
if loc_env != 'production'
|
244
255
|
puts Rainbow("Neruda is run in #{loc_env} environment").green
|
@@ -249,18 +260,18 @@ class Pablo
|
|
249
260
|
rake_or_bundle_run ['rake', 'sinatra:start']
|
250
261
|
end
|
251
262
|
|
252
|
-
def
|
253
|
-
if ARGV[
|
263
|
+
def edit
|
264
|
+
if ARGV[0].nil?
|
254
265
|
print 'Title: '
|
255
266
|
title = STDIN.gets.strip
|
256
267
|
else
|
257
|
-
title = ARGV
|
268
|
+
title = ARGV.join(' ')
|
258
269
|
end
|
259
|
-
rake_or_bundle_run ['rake', "chapters:
|
270
|
+
rake_or_bundle_run ['rake', "chapters:create_or_edit[#{title}]"]
|
260
271
|
end
|
261
272
|
|
262
273
|
def list
|
263
|
-
list_type = ARGV[
|
274
|
+
list_type = ARGV[0] || 'chapters'
|
264
275
|
rake_or_bundle_run ['rake', "book:list[#{list_type}]"]
|
265
276
|
end
|
266
277
|
end
|
data/lib/tasks/book.rake
CHANGED
data/lib/tasks/chapters.rake
CHANGED
@@ -16,7 +16,7 @@ namespace :chapters do
|
|
16
16
|
end
|
17
17
|
next if org_to_convert.empty?
|
18
18
|
Dir.mkdir 'tmp' unless Dir.exist? 'tmp'
|
19
|
-
IO.write
|
19
|
+
IO.write 'tmp/org_to_convert.yml', org_to_convert.to_yaml
|
20
20
|
end
|
21
21
|
|
22
22
|
desc 'Identify orphan (without epubs) org files'
|
@@ -31,7 +31,7 @@ namespace :chapters do
|
|
31
31
|
org_to_convert << filename unless File.exist? epub_file
|
32
32
|
end
|
33
33
|
next if org_to_convert.empty?
|
34
|
-
IO.write
|
34
|
+
IO.write 'tmp/org_to_convert.yml', org_to_convert.to_yaml
|
35
35
|
end
|
36
36
|
|
37
37
|
desc 'Convert org files from tmp/org_to_convert.yml to epubs'
|
@@ -45,10 +45,11 @@ namespace :chapters do
|
|
45
45
|
file_radix = File.basename(filename, '.org')
|
46
46
|
epub_file = "private/epubs/#{file_radix}.epub"
|
47
47
|
epub_to_upload << epub_file
|
48
|
+
puts "Converting #{filename} to #{epub_file}"
|
48
49
|
sh 'pandoc', '-S', "--output=#{epub_file}", filename
|
49
50
|
end
|
50
51
|
next if epub_to_upload.empty?
|
51
|
-
IO.write
|
52
|
+
IO.write 'tmp/epub_to_upload.yml', epub_to_upload.to_yaml
|
52
53
|
end
|
53
54
|
|
54
55
|
desc 'Build missing epubs'
|
@@ -93,11 +94,11 @@ namespace :chapters do
|
|
93
94
|
title = f.in_buffer_settings['TITLE']
|
94
95
|
chapters << { slug: file_radix, title: title } unless title.nil?
|
95
96
|
end
|
96
|
-
IO.write
|
97
|
+
IO.write 'config/chapters.yml', chapters.to_yaml
|
97
98
|
end
|
98
99
|
|
99
100
|
desc 'Open an editor to create a new chapter'
|
100
|
-
task :
|
101
|
+
task :create_or_edit, :title do |_, args|
|
101
102
|
if args[:title] == ''
|
102
103
|
filename = 'new'
|
103
104
|
else
|
@@ -108,20 +109,24 @@ namespace :chapters do
|
|
108
109
|
|
109
110
|
unless File.exist? filename
|
110
111
|
config = YAML.load_file('config/config.yml')
|
111
|
-
|
112
|
+
filecontent = <<~ORG
|
112
113
|
#+title: #{args[:title]}
|
113
114
|
#+date: <#{Date.today.strftime('%Y-%m-%d %a.')}>
|
114
115
|
#+author: #{config['author']}
|
115
116
|
|
116
|
-
|
117
|
-
|
117
|
+
ORG
|
118
|
+
IO.write filename, filecontent
|
118
119
|
end
|
119
120
|
|
120
121
|
editor = ENV['EDITOR'] || ENV['VISUAL'] || 'emacs'
|
122
|
+
|
123
|
+
puts Rainbow(args[:title]).blue
|
124
|
+
puts "Opening #{filename} with #{editor}"
|
125
|
+
|
121
126
|
if editor.match?(/^emacs/)
|
122
|
-
sh editor, '+5', filename
|
127
|
+
sh [editor, '+5', filename].join(' ')
|
123
128
|
else
|
124
|
-
sh editor, filename
|
129
|
+
sh [editor, filename].join(' ')
|
125
130
|
end
|
126
131
|
end
|
127
132
|
end
|
data/lib/tasks/sinatra.rake
CHANGED
@@ -6,7 +6,7 @@ namespace :sinatra do
|
|
6
6
|
desc 'Stop the underlaying sinatra application'
|
7
7
|
task :stop do
|
8
8
|
unless File.exist? 'tmp/pids/neruda.pid'
|
9
|
-
STDERR.puts 'No pid file found'
|
9
|
+
STDERR.puts Rainbow('No pid file found').red
|
10
10
|
exit 1
|
11
11
|
end
|
12
12
|
pid = IO.read('tmp/pids/neruda.pid').strip.to_i
|
@@ -27,7 +27,7 @@ namespace :sinatra do
|
|
27
27
|
sh(*cmd)
|
28
28
|
end
|
29
29
|
rescue Interrupt
|
30
|
-
puts Rainbow('
|
30
|
+
puts Rainbow('Kthxbye').blue
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: neruda
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Étienne Deparis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-09-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rainbow
|