railspack 0.1.2 → 0.1.3
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/README.md +15 -2
 - data/lib/railspack/cli.rb +15 -18
 - data/lib/railspack/template_helper.rb +16 -0
 - data/lib/railspack/templates/index.js +2 -2
 - data/lib/railspack/version.rb +1 -1
 - metadata +3 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 212441dbc951327c53fb8721a922963da670d0c6
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 728816d54d0bc12c181439063c8074cc01f244ff
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: bc95717ba0a937f4ae29b9aa504c0f834467ac0497480e7f0ab832c57ebd5f29c8973d8e74be60ce6643789ac2c810f81d297564294a3d936981542a08d7f64c
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 4279bb674a694aa0286e98087b69eb9a17c4692ca9efc02b149a7e5f396386ee4209b29bb3490eade30d72a875869650d3f3a9a98d81889839da18c80ca7ce72
         
     | 
    
        data/README.md
    CHANGED
    
    | 
         @@ -28,12 +28,25 @@ Make sure that you run `npm install` after running the `railspack generate` 
     | 
|
| 
       28 
28 
     | 
    
         
             
            command. This will install all the dependencies defined in the `package.json`
         
     | 
| 
       29 
29 
     | 
    
         
             
            file.
         
     | 
| 
       30 
30 
     | 
    
         | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
      
 31 
     | 
    
         
            +
            If you would like `npm install` to be run for you after the files have been
         
     | 
| 
      
 32 
     | 
    
         
            +
            generated, you can pass the `--install` or `-i` option to the generate command.
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
            ```
         
     | 
| 
      
 35 
     | 
    
         
            +
            railspack generate --install
         
     | 
| 
      
 36 
     | 
    
         
            +
            ```
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
            or
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
            ```
         
     | 
| 
      
 41 
     | 
    
         
            +
            railspack generate -i
         
     | 
| 
      
 42 
     | 
    
         
            +
            ```
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
            Take a look at the [Generated Files Guide](docs/generated_files.md) page to see
         
     | 
| 
       32 
45 
     | 
    
         
             
            a full description of all the files that are generated.
         
     | 
| 
       33 
46 
     | 
    
         | 
| 
       34 
47 
     | 
    
         
             
            ## Contributing
         
     | 
| 
       35 
48 
     | 
    
         | 
| 
       36 
     | 
    
         
            -
            Please check out the [Contributing Guide](docs/contributing)
         
     | 
| 
      
 49 
     | 
    
         
            +
            Please check out the [Contributing Guide](docs/contributing.md)
         
     | 
| 
       37 
50 
     | 
    
         | 
| 
       38 
51 
     | 
    
         
             
            ## License
         
     | 
| 
       39 
52 
     | 
    
         | 
    
        data/lib/railspack/cli.rb
    CHANGED
    
    | 
         @@ -2,6 +2,8 @@ require 'thor' 
     | 
|
| 
       2 
2 
     | 
    
         
             
            require 'erubis'
         
     | 
| 
       3 
3 
     | 
    
         
             
            require 'pathname'
         
     | 
| 
       4 
4 
     | 
    
         | 
| 
      
 5 
     | 
    
         
            +
            require 'railspack/template_helper'
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
       5 
7 
     | 
    
         
             
            module Railspack
         
     | 
| 
       6 
8 
     | 
    
         
             
              class CLI < Thor
         
     | 
| 
       7 
9 
     | 
    
         
             
                include Thor::Actions
         
     | 
| 
         @@ -11,11 +13,9 @@ module Railspack 
     | 
|
| 
       11 
13 
     | 
    
         
             
                end
         
     | 
| 
       12 
14 
     | 
    
         | 
| 
       13 
15 
     | 
    
         
             
                desc "generate", "Generate all webpack files"
         
     | 
| 
      
 16 
     | 
    
         
            +
                method_option :install, aliases: '-i', desc: 'Run npm install after generating files'
         
     | 
| 
       14 
17 
     | 
    
         
             
                def generate
         
     | 
| 
       15 
     | 
    
         
            -
                   
     | 
| 
       16 
     | 
    
         
            -
                    puts "NPM not installed"
         
     | 
| 
       17 
     | 
    
         
            -
                    return
         
     | 
| 
       18 
     | 
    
         
            -
                  end
         
     | 
| 
      
 18 
     | 
    
         
            +
                  run_npm_install = options[:install]
         
     | 
| 
       19 
19 
     | 
    
         | 
| 
       20 
20 
     | 
    
         
             
                  build_package_json
         
     | 
| 
       21 
21 
     | 
    
         
             
                  copy_file("index.js", "frontend/index.js")
         
     | 
| 
         @@ -24,8 +24,16 @@ module Railspack 
     | 
|
| 
       24 
24 
     | 
    
         
             
                  copy_file("babelrc.js", ".babelrc")
         
     | 
| 
       25 
25 
     | 
    
         
             
                  copy_file("webpack.js", "webpack.config.babel.js")
         
     | 
| 
       26 
26 
     | 
    
         | 
| 
       27 
     | 
    
         
            -
                   
     | 
| 
       28 
     | 
    
         
            -
             
     | 
| 
      
 27 
     | 
    
         
            +
                  if run_npm_install
         
     | 
| 
      
 28 
     | 
    
         
            +
                    unless npm_available?
         
     | 
| 
      
 29 
     | 
    
         
            +
                      puts "NPM is not installed, please install and then run `npm install` manually"
         
     | 
| 
      
 30 
     | 
    
         
            +
                      return
         
     | 
| 
      
 31 
     | 
    
         
            +
                    end
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
                    puts "Running `npm install`"
         
     | 
| 
      
 34 
     | 
    
         
            +
                    exec("npm install")
         
     | 
| 
      
 35 
     | 
    
         
            +
                  end
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
       29 
37 
     | 
    
         
             
                end
         
     | 
| 
       30 
38 
     | 
    
         | 
| 
       31 
39 
     | 
    
         
             
                private
         
     | 
| 
         @@ -44,23 +52,12 @@ module Railspack 
     | 
|
| 
       44 
52 
     | 
    
         
             
                  directory_path.basename
         
     | 
| 
       45 
53 
     | 
    
         
             
                end
         
     | 
| 
       46 
54 
     | 
    
         | 
| 
       47 
     | 
    
         
            -
                def get_template_from_file(template_name)
         
     | 
| 
       48 
     | 
    
         
            -
                  template_path = File.join(File.dirname(__FILE__), 'templates', template_name)
         
     | 
| 
       49 
     | 
    
         
            -
                  file = File.open(template_path, "rb")
         
     | 
| 
       50 
     | 
    
         
            -
                  contents = file.read
         
     | 
| 
       51 
     | 
    
         
            -
                end
         
     | 
| 
       52 
     | 
    
         
            -
             
     | 
| 
       53 
     | 
    
         
            -
                def render_template(template_name, locals)
         
     | 
| 
       54 
     | 
    
         
            -
                  contents = get_template_from_file(template_name)
         
     | 
| 
       55 
     | 
    
         
            -
                  Erubis::Eruby.new(contents).result(locals)
         
     | 
| 
       56 
     | 
    
         
            -
                end
         
     | 
| 
       57 
     | 
    
         
            -
             
     | 
| 
       58 
55 
     | 
    
         
             
                def build_package_json
         
     | 
| 
       59 
56 
     | 
    
         
             
                  project_name = get_project_name
         
     | 
| 
       60 
57 
     | 
    
         
             
                  author_name = get_git_username
         
     | 
| 
       61 
58 
     | 
    
         | 
| 
       62 
59 
     | 
    
         
             
                  locals = { application_name: project_name, author_name: author_name }
         
     | 
| 
       63 
     | 
    
         
            -
                  contents =  
     | 
| 
      
 60 
     | 
    
         
            +
                  contents = TemplateHelper.render('package.json.erb', locals)
         
     | 
| 
       64 
61 
     | 
    
         
             
                  create_file('package.json', contents)
         
     | 
| 
       65 
62 
     | 
    
         
             
                end
         
     | 
| 
       66 
63 
     | 
    
         
             
              end
         
     | 
| 
         @@ -0,0 +1,16 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module Railspack
         
     | 
| 
      
 2 
     | 
    
         
            +
              module TemplateHelper
         
     | 
| 
      
 3 
     | 
    
         
            +
                # Given a template_name, looks in the templates/ directory
         
     | 
| 
      
 4 
     | 
    
         
            +
                # and returns the contents of the file.
         
     | 
| 
      
 5 
     | 
    
         
            +
                def self.get_from_file(template_name)
         
     | 
| 
      
 6 
     | 
    
         
            +
                  template_path = File.join(File.dirname(__FILE__), 'templates', template_name)
         
     | 
| 
      
 7 
     | 
    
         
            +
                  file = File.open(template_path, "rb")
         
     | 
| 
      
 8 
     | 
    
         
            +
                  contents = file.read
         
     | 
| 
      
 9 
     | 
    
         
            +
                end
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
                def self.render(template_name, locals)
         
     | 
| 
      
 12 
     | 
    
         
            +
                  contents = TemplateHelper.get_from_file(template_name)
         
     | 
| 
      
 13 
     | 
    
         
            +
                  Erubis::Eruby.new(contents).result(locals)
         
     | 
| 
      
 14 
     | 
    
         
            +
                end
         
     | 
| 
      
 15 
     | 
    
         
            +
              end
         
     | 
| 
      
 16 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -8,5 +8,5 @@ import { registerComponent } from 'registerComponent' 
     | 
|
| 
       8 
8 
     | 
    
         | 
| 
       9 
9 
     | 
    
         
             
            const domReadyEvent = (typeof TurboLinks !== 'undefined') ? 'turbolinks:load' : 'DOMContentLoaded'
         
     | 
| 
       10 
10 
     | 
    
         
             
            document.addEventListener(domReadyEvent, () => {
         
     | 
| 
       11 
     | 
    
         
            -
              // registerComponent(OhHai, 'oh-hai') 
     | 
| 
       12 
     | 
    
         
            -
            }
         
     | 
| 
      
 11 
     | 
    
         
            +
              // registerComponent(OhHai, 'oh-hai')
         
     | 
| 
      
 12 
     | 
    
         
            +
            })
         
     | 
    
        data/lib/railspack/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: railspack
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.1. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.1.3
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - jdmorlan
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2016-08- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2016-08-21 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: thor
         
     | 
| 
         @@ -93,6 +93,7 @@ files: 
     | 
|
| 
       93 
93 
     | 
    
         
             
            - bin/railspack
         
     | 
| 
       94 
94 
     | 
    
         
             
            - lib/railspack.rb
         
     | 
| 
       95 
95 
     | 
    
         
             
            - lib/railspack/cli.rb
         
     | 
| 
      
 96 
     | 
    
         
            +
            - lib/railspack/template_helper.rb
         
     | 
| 
       96 
97 
     | 
    
         
             
            - lib/railspack/templates/babelrc.js
         
     | 
| 
       97 
98 
     | 
    
         
             
            - lib/railspack/templates/index.js
         
     | 
| 
       98 
99 
     | 
    
         
             
            - lib/railspack/templates/package.json.erb
         
     |