railspack 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ce857bb4c7907aa28ac9813a54c9e8c1b209495e
4
+ data.tar.gz: 34c420cbeca41d82bd5e5fa43446e9da9250cd0c
5
+ SHA512:
6
+ metadata.gz: 73ec533b59a2b22e71c95205ba2eb2e88725aaea3ea5260a698a2f736e24c45fa125e9452199d7c5022c30c10c5b985719513df8359a2468caf3ae50c6ee2067
7
+ data.tar.gz: cc48d568cc560fcbaf111ef5812684ef1c80fa39dbbfc8f4d91b09b76b145a1850f0df0bc2d263fb10d32df788ae441ec95ddcb0b2d6cefb4d17d77ac8039cd7
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 jdmorlan
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # Railspack
2
+
3
+ Easily add all the configuration files to setup Webpack in your Rails app.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```
10
+ $ gem install railspack
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ 1. Go to the root directory of your Rails project.
16
+ 2. Run `railspack generate`
17
+
18
+ ## Development
19
+
20
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
21
+
22
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
23
+
24
+ ## Contributing
25
+
26
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/railspack.
27
+
28
+
29
+ ## License
30
+
31
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/bin/railspack ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'railspack'
4
+
5
+ Railspack::CLI.start( ARGV )
@@ -0,0 +1,21 @@
1
+ require 'thor'
2
+
3
+ module Railspack
4
+ class CLI < Thor
5
+ include Thor::Actions
6
+
7
+ def self.source_root
8
+ File.join(File.dirname(__FILE__), 'templates')
9
+ end
10
+
11
+ desc "generate", "Generate all webpack files"
12
+ def generate
13
+ copy_file("index.js", "frontend/index.js")
14
+ copy_file("registerComponent.js", "frontend/registerComponent")
15
+ copy_file("react_helper.rb", "app/helpers/react_helper.rb")
16
+ copy_file("package.json", "package.json")
17
+ copy_file("babelrc.js", ".babelrc")
18
+ copy_file("webpack.js", "webpack.config.babel.js")
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,3 @@
1
+ {
2
+ "presets": ["es2015", "react"]
3
+ }
@@ -0,0 +1,10 @@
1
+ import React from 'react'
2
+ import ReactDOM from 'react-dom'
3
+
4
+ import { registerComponent } from 'componentRegistration'
5
+
6
+ // Register any components that you want to call in your Rails views
7
+ // using the react_component view_helper
8
+ document.addEventListener('DOMContentLoaded', () => {
9
+ // registerComponent('component', 'container-name')
10
+ })
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "[Enter Your App Name]",
3
+ "version": "1.0.0",
4
+ "description": "[Enter App Description]",
5
+ "main": "index.js",
6
+ "author": "[Enter Author Name]",
7
+ "scripts": {
8
+ "start-dev": "webpack -wc --config webpack.config.babel.js",
9
+ "postinstall": "webpack --config webpack.config.babel.js"
10
+ },
11
+ "dependencies": {
12
+ "babel-core": "latest",
13
+ "babel-loader": "latest",
14
+ "babel-preset-es2015": "latest",
15
+ "babel-preset-react": "latest",
16
+ "babel-preset-stage-0": "latest",
17
+ "classnames": "latest",
18
+ "lodash": "latest",
19
+ "moment": "latest",
20
+ "react": "latest",
21
+ "react-addons-css-transition-group": "latest",
22
+ "react-dom": "latest",
23
+ "react-input-slider": "latest",
24
+ "webpack": "latest"
25
+ },
26
+ "devDependencies": {
27
+ "webpack-dev-server": "latest"
28
+ }
29
+ }
@@ -0,0 +1,5 @@
1
+ module ReactHelper
2
+ def react_component(container, props=nil)
3
+ content_tag(:div, nil, data: { "react-container": container, "react-props": props })
4
+ end
5
+ end
@@ -0,0 +1,20 @@
1
+ import React from 'react'
2
+ import ReactDOM from 'react-dom'
3
+
4
+ const getProps = (container) => {
5
+ const propsString = container.getAttribute("data-react-props")
6
+ const props = propsString ? JSON.parse(propsString) : null
7
+
8
+ return props
9
+ }
10
+
11
+ export const registerComponent = (instance, containerName) => {
12
+ const selector = `[data-react-container=${containerName}]`
13
+ const container = document.querySelector(selector)
14
+
15
+ if (container) {
16
+ const props = getProps(container)
17
+ const element = React.createElement(instance, props)
18
+ ReactDOM.render(element, container)
19
+ }
20
+ }
@@ -0,0 +1,26 @@
1
+ import path from 'path'
2
+ import webpack from 'webpack'
3
+
4
+ module.exports = {
5
+ context: __dirname,
6
+
7
+ entry: {
8
+ app: path.join(__dirname, 'src', 'index.js')
9
+ },
10
+
11
+ output: {
12
+ path: path.join(__dirname, 'assets', 'javascripts'),
13
+ filename: 'frontend.js'
14
+ },
15
+
16
+ module: {
17
+ loaders: [
18
+ { test: /\.js?$/, exclude: /(node_modules)/, loader: 'babel' }
19
+ ]
20
+ },
21
+
22
+ resolve: {
23
+ root: path.resolve('./frontend'),
24
+ extensions: ['', '.js', '.jsx']
25
+ }
26
+ }
@@ -0,0 +1,3 @@
1
+ module Railspack
2
+ VERSION = "0.1.0"
3
+ end
data/lib/railspack.rb ADDED
@@ -0,0 +1,6 @@
1
+ require "railspack/version"
2
+ require 'railspack/cli'
3
+
4
+ module Railspack
5
+ # Your code goes here...
6
+ end
metadata ADDED
@@ -0,0 +1,114 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: railspack
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - jdmorlan
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-08-19 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.10'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.10'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: minitest
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Integrate webpack into your Rails app
70
+ email:
71
+ - jay.d.morlan@gmail.com
72
+ executables:
73
+ - railspack
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - LICENSE.txt
78
+ - README.md
79
+ - bin/railspack
80
+ - lib/railspack.rb
81
+ - lib/railspack/cli.rb
82
+ - lib/railspack/templates/babelrc.js
83
+ - lib/railspack/templates/index.js
84
+ - lib/railspack/templates/package.json
85
+ - lib/railspack/templates/react_helper.rb
86
+ - lib/railspack/templates/registerComponent.js
87
+ - lib/railspack/templates/webpack.js
88
+ - lib/railspack/version.rb
89
+ homepage: http://github.com/jdmorlan/railspack
90
+ licenses:
91
+ - MIT
92
+ metadata: {}
93
+ post_install_message:
94
+ rdoc_options: []
95
+ require_paths:
96
+ - lib
97
+ required_ruby_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ required_rubygems_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ requirements: []
108
+ rubyforge_project:
109
+ rubygems_version: 2.4.5.1
110
+ signing_key:
111
+ specification_version: 4
112
+ summary: Integrate webpack into your Rails app
113
+ test_files: []
114
+ has_rdoc: