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.
- checksums.yaml +4 -4
- data/lib/asciibuild/extensions.rb +19 -12
- metadata +1 -1
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 922338459b20622c2db13aa5385780ab9e7bbdf4
         | 
| 4 | 
            +
              data.tar.gz: ae4a575e4dae19ccd3d4b857a158d1fb4d0d93eb
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 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 =  | 
| 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 #{ | 
| 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 | 
            -
                       | 
| 201 | 
            -
             | 
| 202 | 
            -
             | 
| 203 | 
            -
             | 
| 204 | 
            -
                      else
         | 
| 205 | 
            -
             | 
| 206 | 
            -
                       | 
| 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 |  |