neruda 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0f5fb5997c152378f937f4b226182001790d4c35
4
- data.tar.gz: 5fd12f03ac8acdab7a6f26e03226a0dba2a39ee6
3
+ metadata.gz: 1fec1e086d008db01ac799fc96019a2b04f284f5
4
+ data.tar.gz: bdd74e72f8116cf2c1156f085eb41c2b23744b1a
5
5
  SHA512:
6
- metadata.gz: dc0c38d5bfce0fd5c82e39fe0aedc5596a15e4e38a0d2b0fc400959708fc23b22f4feb5fa96691a0059e034791529f4ff927e21dde2559e1a82ca65daf2b2fd5
7
- data.tar.gz: 81112c53025ca25ebcd6a64927455556948c486d0a05d624d1d8c502a54174dc7f5d70d8e0badf7fa3ffaf64eab67c3f385de3cd85d858fe1b8b46fc9dec467e
6
+ metadata.gz: 9b08b4e4040c7ca5ec07f556b0b71dafaf141f6c25a2027188569a60661e5c0dc6354ed8efc1a22adc16ba43322f9c633d092656eb697efb60198226fc7e6452
7
+ data.tar.gz: 2b8457ae617246c0c96ac522d9cc3d0036daee5ae14089d74656bdb7e5b57a37b4d77fcb0aa646628b53b33b00d1dc846a47dba904945669b706151145228964
data/README.org CHANGED
@@ -3,11 +3,14 @@
3
3
  *Neruda* is a little [[http://sinatrarb.com][Sinatra]] app, which aims to offer a quick access for
4
4
  writers to web publication. It is named in memory of Pablo Neruda.
5
5
 
6
+ Source code is available on my [[https://git.deparis.io/neruda][cgit instance]], while issues should be
7
+ followed on my [[https://projects.deparis.io/projects/neruda][redmine instance]].
8
+
6
9
  * Install
7
10
 
8
11
  These installation instructions use [[https://rvm.io][rvm]] as ruby provider. If you want to
9
12
  use rbenv or your system ruby, please refer to their specific
10
- documentation to know how to install ruby 2.4 and [[https://bundler.io/][bundler]].
13
+ documentation to know how to install ruby 2.4.
11
14
 
12
15
  First we need to upgrade rvm (always do that from time to time):
13
16
 
@@ -20,9 +23,7 @@ Then the installation itself:
20
23
 
21
24
  #+begin_src shell
22
25
  $ mkdir mysite
23
- $ rvm use ruby-2.4.1
24
- $ rvm gemset create neruda
25
- $ rvm gemset use neruda
26
+ $ rvm use ruby-2.4.1@neruda --create
26
27
  $ gem install neruda
27
28
  #+end_src
28
29
 
@@ -30,6 +31,7 @@ Finally, you need to configure it to your needs.
30
31
 
31
32
  #+begin_src shell
32
33
  $ pablo init
34
+ $ bundle install
33
35
  #+end_src
34
36
 
35
37
  * Running it
@@ -49,7 +51,56 @@ $ APP_ENV=production pablo start
49
51
  To stop it, just enter =ctrl+C= if you are in development mode or enter
50
52
  =pablo stop= in production mode.
51
53
 
52
- You can now start your first chapter: =pablo new=
54
+ * Pablo command
55
+
56
+ In order to manage you Neruda installation, this gem provides a little
57
+ helper called =pablo=. You already used it to =init=, =start= and =stop=
58
+ your local installation. It can do a little more.
59
+
60
+ ** New
61
+
62
+ =pablo new [article title]= will open your favorite text editor to let
63
+ you write a new chapter to your book.
64
+
65
+ If you don't provide a title to the command, =pablo= will ask you for
66
+ one before launching your editor.
67
+
68
+ If you don't have configured the =EDITOR= or =VISUAL= environnement
69
+ variable, =pablo= will default to Gnu Emacs.
70
+
71
+ ** Compile
72
+
73
+ =pablo compile= will first convert your orphaned org files (the ones
74
+ without a corresponding epub file), then producing the global epub book,
75
+ made with all your chapters.
76
+
77
+ ** Capify
78
+
79
+ =pablo capify= will add the correct references to Neruda rake tasks in
80
+ your =Capfile=, what will allow you to call them as part of your
81
+ deployment workflow.
82
+
83
+ You can add the =chapters:sync= task:
84
+
85
+ #+begin_src ruby
86
+ after 'deploy:finishing', 'chapters:sync'
87
+ #+end_src
88
+
89
+ This task depends on all the following. Or you can just select a bunch
90
+ of them:
91
+
92
+ #+begin_src ruby
93
+ after 'deploy:finishing', 'chapters:build_epubs'
94
+ after 'deploy:finishing', 'chapters:upload_epubs'
95
+ after 'deploy:finishing', 'chapters:upload_book'
96
+ after 'deploy:finishing', 'chapters:purge:remote'
97
+ #+end_src
98
+
99
+ Don't forget to restart the remote sinatra server:
100
+
101
+ #+begin_src ruby
102
+ after 'deploy:finished', 'sinatra:restart:remote'
103
+ #+end_src
53
104
 
54
105
  * Known issues
55
106
 
data/bin/pablo CHANGED
@@ -1,33 +1,36 @@
1
1
  #!/usr/bin/env ruby
2
+ # coding: utf-8
3
+ # frozen_string_literal: true
2
4
 
3
5
  require 'yaml'
6
+ require 'rainbow'
4
7
  require 'fileutils'
5
8
 
6
9
  def help
7
10
  unless File.exist? 'config/config.yml'
8
- STDERR.puts 'Please init your website: pablo init'
11
+ STDERR.puts 'Please init your website: ' +
12
+ Rainbow('pablo init').yellow
9
13
  exit 1
10
14
  end
11
15
 
12
- options = ['start', 'stop', 'new']
16
+ options = ['start', 'stop', 'new', 'compile']
13
17
  options << 'capify' if File.exist? 'Capfile'
14
18
 
15
- STDERR.puts "pablo [ #{options.join(' | ')} ]"
16
- exit 1
19
+ STDERR.puts 'Usage: ' + Rainbow("pablo [ #{options.join(' | ')} ]").yellow
17
20
  end
18
21
 
19
22
  def capify
20
23
  unless File.exist? 'Capfile'
21
- STDERR.puts 'Capfile does not exist. Aborting'
24
+ STDERR.puts Rainbow('ERROR: Capfile does not exist.').red
22
25
  exit 1
23
26
  end
24
27
 
25
28
  capfile = File.new('Capfile', 'a')
26
- capfile.write <<EOF
27
- neruda_spec = Gem::Specification.find_by_name 'neruda'
28
- Dir.glob("\#{neruda_spec.gem_dir}/lib/tasks/*.rake").each { |r| import r }
29
- Dir.glob("\#{neruda_spec.gem_dir}/lib/tasks/capistrano/*.rake").each { |r| import r }
30
- EOF
29
+ capfile.write <<~EOF
30
+ neruda_spec = Gem::Specification.find_by_name 'neruda'
31
+ Dir.glob("\#{neruda_spec.gem_dir}/lib/tasks/*.rake").each { |r| import r }
32
+ Dir.glob("\#{neruda_spec.gem_dir}/lib/tasks/capistrano/*.rake").each { |r| import r }
33
+ EOF
31
34
  end
32
35
 
33
36
  def _init_path
@@ -78,20 +81,60 @@ def _init_rackup
78
81
  end
79
82
 
80
83
  return if File.exist? 'config.ru'
81
- rackup_conf = <<EOF
82
- # frozen_string_literal: true
84
+ rackup_conf = <<~EOF
85
+ # frozen_string_literal: true
83
86
 
84
- require 'neruda'
85
- run Neruda::App
86
- EOF
87
+ require 'neruda'
88
+ run Neruda::App
89
+ EOF
87
90
  IO.write('config.ru', rackup_conf)
88
91
  end
89
92
 
93
+ def _init_bundler
94
+ # print 'Do you want to use [o]rg files, [m]arkdown files or [b]oth' \
95
+ # ' (default is org): '
96
+ # markup = STDIN.gets.strip.downcase
97
+ # if markup == 'm'
98
+ # markup_gem = 'gem \'kramdown\''
99
+ # elsif markup == 'b'
100
+ # markup_gem = "gem 'kramdown'\ngem 'org-ruby'"
101
+ # else
102
+ # markup_gem = 'gem \'org-ruby\''
103
+ # end
104
+ markup_gem = 'gem \'org-ruby\''
105
+
106
+ gemfile = <<~EOF
107
+ # frozen_string_literal: true
108
+
109
+ source 'https://rubygems.org'
110
+
111
+ gem 'neruda'
112
+ #{markup_gem}
113
+
114
+ group :development do
115
+ gem 'capistrano'
116
+ gem 'capistrano-bundler'
117
+ gem 'capistrano-rvm'
118
+ gem 'rubocop'
119
+ end
120
+ EOF
121
+ IO.write('Gemfile', gemfile)
122
+ end
123
+
90
124
  def init
125
+ puts Rainbow('Creating main folders…').green
91
126
  _init_path
127
+ puts Rainbow('Populating config file…').green
92
128
  _init_config
129
+ puts Rainbow('Copying template files…').green
93
130
  _init_assets
131
+ puts Rainbow('Installing rake and bundler files…').green
94
132
  _init_rackup
133
+ _init_bundler
134
+ puts Rainbow('Neruda has been successfully installed.').green
135
+ puts ''
136
+ puts 'To complete this installation, you must now run: ' +
137
+ Rainbow('bundle install').yellow
95
138
  end
96
139
 
97
140
  def create_new(title)
@@ -103,18 +146,17 @@ def create_new(title)
103
146
 
104
147
  filename = "private/orgs/#{filename}.org"
105
148
 
106
- if Dir.exist? 'private/orgs'
107
- config = YAML.load_file('config/config.yml')
108
- IO.write filename, <<EOF
109
- #+title: #{title}
110
- #+date: <#{Date.today.strftime('%Y-%m-%d %a.')}>
111
- #+author: #{config['author']}
149
+ FileUtils.mkdir_p 'private/orgs' unless Dir.exist? 'private/orgs'
150
+ config = YAML.load_file('config/config.yml')
151
+ IO.write filename, <<~EOF
152
+ #+title: #{title}
153
+ #+date: <#{Date.today.strftime('%Y-%m-%d %a.')}>
154
+ #+author: #{config['author']}
112
155
 
113
156
 
114
- EOF
115
- end
157
+ EOF
116
158
 
117
- editor = ENV['EDITOR'] || 'emacs'
159
+ editor = ENV['EDITOR'] || ENV['VISUAL'] || 'emacs'
118
160
  exec editor, filename
119
161
  end
120
162
 
@@ -125,16 +167,18 @@ elsif ARGV[0] == 'capify'
125
167
  capify
126
168
 
127
169
  elsif ['start', 'run'].include?(ARGV[0])
128
- puts 'You can also start neruda with the following command:'
129
- puts 'rake sinatra:start'
130
-
131
- exec 'rake', 'sinatra:start'
170
+ puts Rainbow('bundle exec rake sinatra:start').green
171
+ system 'bundle', 'exec', 'rake', 'sinatra:start'
132
172
 
133
173
  elsif ARGV[0] == 'stop'
134
- puts 'You can also stop neruda with the following command:'
135
- puts 'rake sinatra:stop'
136
-
137
- exec 'rake', 'sinatra:stop'
174
+ puts Rainbow('bundle exec rake sinatra:stop').green
175
+ system 'bundle', 'exec', 'rake', 'sinatra:stop'
176
+
177
+ elsif ARGV[0] == 'compile'
178
+ puts Rainbow('bundle exec rake chapters:build_epubs').green
179
+ system 'bundle', 'exec', 'rake', 'chapters:build_epubs'
180
+ puts Rainbow('bundle exec rake chapters:make_book').green
181
+ system 'bundle', 'exec', 'rake', 'chapters:make_book'
138
182
 
139
183
  elsif ARGV[0] == 'new'
140
184
  if ARGV[1].nil?
@@ -1,7 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'yaml'
2
4
 
3
5
  namespace :chapters do
4
-
5
6
  desc 'Upload epub files listed in tmp/epub_to_upload.yml'
6
7
  task :upload_epubs do
7
8
  next unless File.exist?('tmp/epub_to_upload.yml')
@@ -32,7 +33,12 @@ namespace :chapters do
32
33
  final_org = neruda_config['book_filename'] || 'all'
33
34
  on roles(:app) do
34
35
  within release_path do
35
- epub_files = capture :ls, '-1', 'private/epubs/*.epub'
36
+ begin
37
+ epub_files = capture :ls, '-1', 'private/epubs/*.epub'
38
+ rescue SSHKit::Command::Failed
39
+ warn 'No epub files found. Aborting.'
40
+ next
41
+ end
36
42
  epub_files.each_line do |filename|
37
43
  filename.delete!("\n")
38
44
  file_radix = File.basename(filename, '.epub')
@@ -46,4 +52,9 @@ namespace :chapters do
46
52
  end
47
53
  end
48
54
  end
55
+
56
+ desc 'Execute in one call the following: :build_epubs,' \
57
+ ':upload_epubs, :upload_book, :purge:remote'
58
+ task sync: ['chapters:build_epubs', 'chapters:upload_epubs',
59
+ 'chapters:upload_book', 'chapters:purge:remote']
49
60
  end
@@ -45,7 +45,7 @@ namespace :chapters do
45
45
  next if file_radix == 'index'
46
46
  epub_file = "private/epubs/#{file_radix}.epub"
47
47
  epub_to_upload << epub_file
48
- execute :pandoc, '-S', "-o #{epub_file}", filename
48
+ system 'pandoc', '-S', "-o #{epub_file}", filename
49
49
  end
50
50
  next if epub_to_upload.empty?
51
51
  IO.write('tmp/epub_to_upload.yml', epub_to_upload.to_yaml)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  namespace :sinatra do
2
4
  desc 'Stop the underlaying sinatra application'
3
5
  task :stop do
@@ -15,7 +17,7 @@ namespace :sinatra do
15
17
  loc_env = ENV['APP_ENV'] || 'development'
16
18
  cmd = ['rackup', "-E #{loc_env}", '-P', 'tmp/pids/neruda.pid']
17
19
  cmd << '-D' if loc_env == 'production'
18
- exec cmd.join(' ')
20
+ system cmd.join(' ')
19
21
  end
20
22
 
21
23
  desc 'Restart local sinatra server'
metadata CHANGED
@@ -1,15 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: neruda
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
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-06-12 00:00:00.000000000 Z
11
+ date: 2017-06-14 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rainbow
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.2'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.2'
13
41
  - !ruby/object:Gem::Dependency
14
42
  name: org-ruby
15
43
  requirement: !ruby/object:Gem::Requirement
@@ -66,7 +94,9 @@ dependencies:
66
94
  - - "~>"
67
95
  - !ruby/object:Gem::Version
68
96
  version: '2.0'
69
- description: Write your org files, we take care of the rest.
97
+ description: |
98
+ A simplistic way to publish a book online.
99
+ Write your org files, we take care of the rest.
70
100
  email: etienne@depar.is
71
101
  executables:
72
102
  - pablo
@@ -90,7 +120,7 @@ files:
90
120
  - lib/tasks/capistrano/sinatra.rake
91
121
  - lib/tasks/chapters.rake
92
122
  - lib/tasks/sinatra.rake
93
- homepage: https://git.deparis.io/neruda/
123
+ homepage: https://git.deparis.io/neruda/about/
94
124
  licenses:
95
125
  - WTFPL
96
126
  metadata: {}
@@ -102,7 +132,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
102
132
  requirements:
103
133
  - - ">="
104
134
  - !ruby/object:Gem::Version
105
- version: '0'
135
+ version: '2.4'
106
136
  required_rubygems_version: !ruby/object:Gem::Requirement
107
137
  requirements:
108
138
  - - ">="