neruda 0.0.2 → 0.0.3

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: 1fec1e086d008db01ac799fc96019a2b04f284f5
4
- data.tar.gz: bdd74e72f8116cf2c1156f085eb41c2b23744b1a
3
+ metadata.gz: 763f0127b37c30ad1d8bf6217259349364b5b0c3
4
+ data.tar.gz: e1e24d906ba72ff2432b27d2bafb960dd068b281
5
5
  SHA512:
6
- metadata.gz: 9b08b4e4040c7ca5ec07f556b0b71dafaf141f6c25a2027188569a60661e5c0dc6354ed8efc1a22adc16ba43322f9c633d092656eb697efb60198226fc7e6452
7
- data.tar.gz: 2b8457ae617246c0c96ac522d9cc3d0036daee5ae14089d74656bdb7e5b57a37b4d77fcb0aa646628b53b33b00d1dc846a47dba904945669b706151145228964
6
+ metadata.gz: f5067b657dc79aa4cec67e5be77d6cf475e3ee29a83da58a0583f502ae2fc55b44072577b6b17e90df46effc2e59fe214b02927bf2827f093525e6451d2e9c95
7
+ data.tar.gz: b1c4ffd1196f3c65267fca521bdb92a983888ec8b64d310262b7a4e437debd748334b9af16307609415cbc41062ad571d9cdd805c9b7671fcdf455e59bba43e1
data/README.md ADDED
@@ -0,0 +1,96 @@
1
+ **Neruda** is a little [Sinatra](http://sinatrarb.com) app, which aims to offer a quick access for writers to web publication. It is named in memory of Pablo Neruda.
2
+
3
+ Source code is available on my [cgit instance](https://git.deparis.io/neruda), while issues should be followed on my [redmine instance](https://projects.deparis.io/projects/neruda).
4
+
5
+ Install
6
+ =======
7
+
8
+ These installation instructions use [rvm](https://rvm.io) as ruby provider. If you want to use rbenv or your system ruby, please refer to their specific documentation to know how to install ruby 2.4.
9
+
10
+ First we need to upgrade rvm (always do that from time to time):
11
+
12
+ ``` bash
13
+ $ rvm get latest
14
+ $ rvm install ruby-2.4.1
15
+ ```
16
+
17
+ Then the installation itself:
18
+
19
+ ``` bash
20
+ $ mkdir mysite
21
+ $ rvm use ruby-2.4.1@neruda --create
22
+ $ gem install neruda
23
+ ```
24
+
25
+ Finally, you need to configure it to your needs.
26
+
27
+ ``` bash
28
+ $ pablo init
29
+ ```
30
+
31
+ Running it
32
+ ==========
33
+
34
+ For testing it, you should just run:
35
+
36
+ ``` bash
37
+ $ pablo start
38
+ ```
39
+
40
+ For production use, just pass the right environnement variable:
41
+
42
+ ``` bash
43
+ $ APP_ENV=production pablo start
44
+ ```
45
+
46
+ To stop it, just enter `ctrl+C` if you are in development mode or enter `pablo stop` in production mode.
47
+
48
+ Pablo command
49
+ =============
50
+
51
+ In order to manage you Neruda installation, this gem provides a little helper called `pablo`. You already used it to `init`, `start` and `stop` your local installation. It can do a little more.
52
+
53
+ New
54
+ ---
55
+
56
+ `pablo new [article title]` will open your favorite text editor to let you write a new chapter to your book.
57
+
58
+ If you don't provide a title to the command, `pablo` will ask you for one before launching your editor.
59
+
60
+ If you don't have configured the `EDITOR` or `VISUAL` environnement variable, `pablo` will default to Gnu Emacs.
61
+
62
+ Compile
63
+ -------
64
+
65
+ `pablo compile` will first convert your orphaned org files (the ones without a corresponding epub file), then producing the global epub book, made with all your chapters.
66
+
67
+ Capify
68
+ ------
69
+
70
+ `pablo capify` will add the correct references to Neruda rake tasks in your `Capfile`, what will allow you to call them as part of your deployment workflow.
71
+
72
+ You can add the `chapters:sync` task:
73
+
74
+ ``` ruby
75
+ after 'deploy:finishing', 'chapters:sync'
76
+ ```
77
+
78
+ This task depends on all the following. Or you can just select a bunch of them:
79
+
80
+ ``` ruby
81
+ after 'deploy:finishing', 'chapters:build_epubs'
82
+ after 'deploy:finishing', 'chapters:upload_epubs'
83
+ after 'deploy:finishing', 'chapters:upload_book'
84
+ after 'deploy:finishing', 'chapters:purge:remote'
85
+ ```
86
+
87
+ Don't forget to restart the remote sinatra server:
88
+
89
+ ``` ruby
90
+ after 'deploy:finished', 'sinatra:restart:remote'
91
+ ```
92
+
93
+ Known issues
94
+ ============
95
+
96
+ See [issues on redmine](https://projects.deparis.io/projects/neruda/issues).
data/bin/pablo CHANGED
@@ -19,6 +19,13 @@ def help
19
19
  STDERR.puts 'Usage: ' + Rainbow("pablo [ #{options.join(' | ')} ]").yellow
20
20
  end
21
21
 
22
+ def bundler_is_present?
23
+ ENV['PATH'].split(':').each do |folder|
24
+ return true if File.exist? File.join(folder, 'bundle')
25
+ end
26
+ false
27
+ end
28
+
22
29
  def capify
23
30
  unless File.exist? 'Capfile'
24
31
  STDERR.puts Rainbow('ERROR: Capfile does not exist.').red
@@ -91,6 +98,10 @@ def _init_rackup
91
98
  end
92
99
 
93
100
  def _init_bundler
101
+ return if File.exist? 'Gemfile'
102
+ puts ''
103
+ puts 'Bundler has been detected in your path.'
104
+ # puts ''
94
105
  # print 'Do you want to use [o]rg files, [m]arkdown files or [b]oth' \
95
106
  # ' (default is org): '
96
107
  # markup = STDIN.gets.strip.downcase
@@ -119,22 +130,23 @@ def _init_bundler
119
130
  end
120
131
  EOF
121
132
  IO.write('Gemfile', gemfile)
133
+ puts ''
134
+ puts 'To complete this installation, you must now run: ' +
135
+ Rainbow('bundle install').yellow
122
136
  end
123
137
 
124
138
  def init
125
- puts Rainbow('Creating main folders…').green
139
+ puts Rainbow('Creating main folders…').blue
126
140
  _init_path
127
- puts Rainbow('Populating config file…').green
141
+ puts Rainbow('Populating config file…').blue
128
142
  _init_config
129
- puts Rainbow('Copying template files…').green
143
+ puts Rainbow('Copying template files…').blue
130
144
  _init_assets
131
- puts Rainbow('Installing rake and bundler files…').green
145
+ puts Rainbow('Installing rake files…').blue
132
146
  _init_rackup
133
- _init_bundler
134
- puts Rainbow('Neruda has been successfully installed.').green
135
147
  puts ''
136
- puts 'To complete this installation, you must now run: ' +
137
- Rainbow('bundle install').yellow
148
+ puts Rainbow('Neruda has been successfully installed.').green
149
+ _init_bundler if bundler_is_present?
138
150
  end
139
151
 
140
152
  def create_new(title)
@@ -167,18 +179,42 @@ elsif ARGV[0] == 'capify'
167
179
  capify
168
180
 
169
181
  elsif ['start', 'run'].include?(ARGV[0])
170
- puts Rainbow('bundle exec rake sinatra:start').green
171
- system 'bundle', 'exec', 'rake', 'sinatra:start'
182
+ loc_env = ENV['APP_ENV'] || 'development'
183
+ if loc_env != 'production'
184
+ puts Rainbow("Neruda is run in #{loc_env} environment").green
185
+ else
186
+ puts Rainbow('>> Neruda is run in production environment <<').yellow
187
+ end
188
+ puts ''
189
+ if bundler_is_present?
190
+ puts Rainbow('bundle exec rake sinatra:start').blue
191
+ exec 'bundle', 'exec', 'rake', 'sinatra:start'
192
+ else
193
+ puts Rainbow('rake sinatra:start').blue
194
+ exec 'rake', 'sinatra:start'
195
+ end
172
196
 
173
197
  elsif ARGV[0] == 'stop'
174
- puts Rainbow('bundle exec rake sinatra:stop').green
175
- system 'bundle', 'exec', 'rake', 'sinatra:stop'
198
+ if bundler_is_present?
199
+ puts Rainbow('bundle exec rake sinatra:stop').blue
200
+ exec 'bundle', 'exec', 'rake', 'sinatra:stop'
201
+ else
202
+ puts Rainbow('rake sinatra:stop').blue
203
+ exec 'rake', 'sinatra:stop'
204
+ end
176
205
 
177
206
  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'
207
+ if bundler_is_present?
208
+ puts Rainbow('bundle exec rake chapters:build_epubs').blue
209
+ exec 'bundle', 'exec', 'rake', 'chapters:build_epubs'
210
+ puts Rainbow('bundle exec rake chapters:make_book').blue
211
+ exec 'bundle', 'exec', 'rake', 'chapters:make_book'
212
+ else
213
+ puts Rainbow('rake chapters:build_epubs').blue
214
+ exec 'rake', 'chapters:build_epubs'
215
+ puts Rainbow('rake chapters:make_book').blue
216
+ exec 'rake', 'chapters:make_book'
217
+ end
182
218
 
183
219
  elsif ARGV[0] == 'new'
184
220
  if ARGV[1].nil?
@@ -187,7 +223,6 @@ elsif ARGV[0] == 'new'
187
223
  else
188
224
  title = ARGV[1]
189
225
  end
190
-
191
226
  create_new title
192
227
 
193
228
  else
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  namespace :sinatra do
2
4
  namespace :restart do
3
5
  desc 'Restart the remote neruda application'
@@ -7,7 +9,7 @@ namespace :sinatra do
7
9
  if test("[ -e '#{release_path}/tmp/pids/sinatra.pid' ]")
8
10
  execute :pkill, '-F', 'tmp/pids/sinatra.pid'
9
11
  end
10
- execute :bundle, :exec, :rackup, '-E', fetch(:app_env),
12
+ execute :rackup, '-E', fetch(:app_env),
11
13
  '-P', 'tmp/pids/sinatra.pid', '-D'
12
14
  end
13
15
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'yaml'
2
4
 
3
5
  namespace :chapters do
@@ -45,7 +47,7 @@ namespace :chapters do
45
47
  next if file_radix == 'index'
46
48
  epub_file = "private/epubs/#{file_radix}.epub"
47
49
  epub_to_upload << epub_file
48
- system 'pandoc', '-S', "-o #{epub_file}", filename
50
+ sh 'pandoc', '-S', "-o #{epub_file}", filename
49
51
  end
50
52
  next if epub_to_upload.empty?
51
53
  IO.write('tmp/epub_to_upload.yml', epub_to_upload.to_yaml)
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'rainbow'
4
+
3
5
  namespace :sinatra do
4
6
  desc 'Stop the underlaying sinatra application'
5
7
  task :stop do
@@ -10,6 +12,7 @@ namespace :sinatra do
10
12
  pid = IO.read('tmp/pids/neruda.pid').strip.to_i
11
13
  Process.kill('TERM', pid)
12
14
  File.unlink 'tmp/pids/neruda.pid'
15
+ puts Rainbow('Done').green
13
16
  end
14
17
 
15
18
  desc 'Start the underlaying sinatra application'
@@ -17,7 +20,11 @@ namespace :sinatra do
17
20
  loc_env = ENV['APP_ENV'] || 'development'
18
21
  cmd = ['rackup', "-E #{loc_env}", '-P', 'tmp/pids/neruda.pid']
19
22
  cmd << '-D' if loc_env == 'production'
20
- system cmd.join(' ')
23
+ begin
24
+ sh cmd.join(' ')
25
+ rescue Interrupt
26
+ puts Rainbow(' Kthxbye').blue
27
+ end
21
28
  end
22
29
 
23
30
  desc 'Restart local sinatra server'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: neruda
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Étienne Deparis
@@ -10,20 +10,6 @@ bindir: bin
10
10
  cert_chain: []
11
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
13
  - !ruby/object:Gem::Dependency
28
14
  name: rainbow
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -101,11 +87,12 @@ email: etienne@depar.is
101
87
  executables:
102
88
  - pablo
103
89
  extensions: []
104
- extra_rdoc_files: []
90
+ extra_rdoc_files:
91
+ - README.md
92
+ - LICENSE
105
93
  files:
106
94
  - LICENSE
107
- - README.org
108
- - TODO.org
95
+ - README.md
109
96
  - bin/pablo
110
97
  - docs/Rakefile.example
111
98
  - docs/config.yml.example
data/README.org DELETED
@@ -1,107 +0,0 @@
1
- #+title: Neruda
2
-
3
- *Neruda* is a little [[http://sinatrarb.com][Sinatra]] app, which aims to offer a quick access for
4
- writers to web publication. It is named in memory of Pablo Neruda.
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
-
9
- * Install
10
-
11
- These installation instructions use [[https://rvm.io][rvm]] as ruby provider. If you want to
12
- use rbenv or your system ruby, please refer to their specific
13
- documentation to know how to install ruby 2.4.
14
-
15
- First we need to upgrade rvm (always do that from time to time):
16
-
17
- #+begin_src shell
18
- $ rvm get latest
19
- $ rvm install ruby-2.4.1
20
- #+end_src
21
-
22
- Then the installation itself:
23
-
24
- #+begin_src shell
25
- $ mkdir mysite
26
- $ rvm use ruby-2.4.1@neruda --create
27
- $ gem install neruda
28
- #+end_src
29
-
30
- Finally, you need to configure it to your needs.
31
-
32
- #+begin_src shell
33
- $ pablo init
34
- $ bundle install
35
- #+end_src
36
-
37
- * Running it
38
-
39
- For testing it, you should just run:
40
-
41
- #+begin_src shell
42
- $ pablo start
43
- #+end_src
44
-
45
- For production use, just pass the right environnement variable:
46
-
47
- #+begin_src shell
48
- $ APP_ENV=production pablo start
49
- #+end_src
50
-
51
- To stop it, just enter =ctrl+C= if you are in development mode or enter
52
- =pablo stop= in production mode.
53
-
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
104
-
105
- * Known issues
106
-
107
- See [[TODO.org][TODO.org]]
data/TODO.org DELETED
@@ -1,12 +0,0 @@
1
- #+title: TODO
2
-
3
- * TODO Documentation
4
-
5
- Write a better documentation
6
-
7
- * TODO Capistrano tasks
8
-
9
- ** TODO Add capistrano commands to =pablo=
10
- ** TODO Complete documentation on capistrano
11
-
12
- * TODO Deploy a sample website