asciibuild 0.1.0 → 0.2.0

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/asciibuild/extensions.rb +19 -12
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3f0d3264aa30a500f47d5f70ffa5f56c98c6db05
4
- data.tar.gz: 676e1d167b275043f72ae25b2c93e50f84a2387c
3
+ metadata.gz: 922338459b20622c2db13aa5385780ab9e7bbdf4
4
+ data.tar.gz: ae4a575e4dae19ccd3d4b857a158d1fb4d0d93eb
5
5
  SHA512:
6
- metadata.gz: 3e446ff07ce75a594d15da1d8a10319d0b29e1d1240c144c6af5e329107a8e605234a37b7213b0f8e684e6004a04f8a046607f5f35357178f91b653144c0d35c
7
- data.tar.gz: c585d03b22f012322152df6f0fa3795c763214e6a65a8d3f9a1ea3e2e2dd2752953f3f4d938af1d569d167c167abf1f3b653a3ec1b54026aa0571e4151fd34f7
6
+ metadata.gz: 67661b19371cbcb7752babe66d80315f1ccd2471f4dea93d9d0279857726850f97885c4c4439eaab936b72b29a9cf9956c0ebfe0a232716a309cd408858ae5ea
7
+ data.tar.gz: 3932987a2e67af25533e95c761085d15bf9776bc06bfe980d5f7d664958b75523661dba80e00925a2804e04bc104c6604d8c5122856676f7bbe6c15d4b685f81
@@ -32,7 +32,7 @@ def get_lang lang
32
32
  end
33
33
 
34
34
  def write_file attrs, default_name, body
35
- name = if attrs['file'] then attrs['file'] else default_name end
35
+ name = attrs['file'] ||= default_name
36
36
  mode = if attrs['overwrite'] == 'false' then File::WRONLY|File::CREAT|File::EXCL else 'w' end
37
37
  open(name, mode) do |f|
38
38
  f.write(body + "\n")
@@ -162,6 +162,13 @@ module Asciibuild
162
162
  end
163
163
 
164
164
  def process parent, reader, attrs
165
+ lang = get_lang attrs[2]
166
+ doctitle = parent.document.attributes['doctitle']
167
+ if not attrs['title']
168
+ attrs['title'] = lang
169
+ end
170
+ attrs['original_title'] = attrs['title']
171
+
165
172
  if not include_section?(parent, attrs)
166
173
  if parent.document.attributes["error"]
167
174
  puts "Section \"#{parent.title}\" skipped due to previous error."
@@ -175,8 +182,6 @@ module Asciibuild
175
182
  return create_open_block parent, ["[source,#{lang}]", "----"] + reader.lines + ["----"], attrs
176
183
  end
177
184
 
178
- doctitle = parent.document.attributes["doctitle"]
179
- attrs['original_title'] = attrs['title']
180
185
  body = Mustache.render(reader.read, parent.document.attributes)
181
186
 
182
187
  lines = []
@@ -187,8 +192,9 @@ module Asciibuild
187
192
  if not attrs['image']
188
193
  raise 'Missing image name. Add attribute of image={name} to the [asciibuild,Dockerfile] style.'
189
194
  end
195
+ fname = attrs['file'] ||= 'Dockerfile'
190
196
  write_file attrs, 'Dockerfile', body
191
- "docker build -t #{attrs['image']} #{attrs['build_opts']} -f #{name} ."
197
+ "docker build -t #{attrs['image']} #{attrs['build_opts']} -f #{fname} ."
192
198
  when 'erlang'
193
199
  write_file attrs, 'escript.erl', body
194
200
  "escript #{name} #{attrs['escript_opts']}"
@@ -196,16 +202,17 @@ module Asciibuild
196
202
  "pyspark #{attrs['spark_opts']}"
197
203
  when 'spark-shell'
198
204
  "spark-shell #{attrs['spark_opts']}"
205
+ when 'bash'
206
+ "bash -exs #{attrs['bash_opts']}"
199
207
  else
200
- if attrs['container']
201
- name = if attrs['container'] == 'true' then doctitle else attrs['container'] end
202
- container_id = parent.document.attributes["#{name} container"]
203
- "docker exec -i #{container_id} #{attrs['exec_opts']} #{attrs[2]}"
204
- else
205
- attrs[2]
206
- end
208
+ attrs[2]
209
+ end
210
+ # Check to see if we run inside a container
211
+ if attrs['container']
212
+ name = if attrs['container'] == 'true' then doctitle else attrs['container'] end
213
+ container_id = parent.document.attributes["#{name} container"]
214
+ cmd = "docker exec -i #{container_id} #{attrs['exec_opts']} #{cmd}"
207
215
  end
208
- lang = get_lang attrs[2]
209
216
 
210
217
  lines = ["[source,#{lang}]", "----", body, "", "----"]
211
218
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: asciibuild
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jon Brisbin