rwr-view_helpers 0.0.1 → 0.1.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/.travis.yml +2 -2
- data/CHANGELOG.md +5 -0
- data/Rakefile +55 -5
- data/js/src/version.js +1 -1
- data/lib/assets/javascripts/rwr_view_helpers.js.erb +1 -0
- data/lib/react_webpack_rails/rwr_view_helpers/image_paths.rb +5 -1
- data/lib/react_webpack_rails/rwr_view_helpers/version.rb +1 -1
- data/lib/rwr-view_helpers.rb +5 -2
- data/package.json +1 -1
- data/rwr-view_helpers.gemspec +3 -1
- data/spec/rails4_dummy_app/.gitignore +2 -2
- data/spec/rails4_dummy_app/app/react/node_server.js +49 -0
- data/spec/rails4_dummy_app/app/views/pages/home.html.erb +3 -3
- data/spec/rails4_dummy_app/config/secrets.yml +22 -0
- data/spec/rails4_dummy_app/forever/development.json +1 -0
- data/spec/rails4_dummy_app/forever/production.json +2 -1
- data/spec/rails4_dummy_app/package.json +2 -0
- metadata +35 -13
- data/rwr-view_helpers/.gitignore +0 -9
- data/rwr-view_helpers/Gemfile +0 -4
- data/rwr-view_helpers/README.md +0 -36
- data/rwr-view_helpers/Rakefile +0 -2
- data/rwr-view_helpers/bin/console +0 -14
- data/rwr-view_helpers/bin/setup +0 -8
- data/rwr-view_helpers/lib/rwr/view_helpers/version.rb +0 -5
- data/rwr-view_helpers/lib/rwr/view_helpers.rb +0 -7
- data/rwr-view_helpers/rwr-view_helpers.gemspec +0 -31
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6de7639bd92e58b65f00515ddbc9b690190299a3
|
4
|
+
data.tar.gz: b9a0b3cbc70c366cf75e8d440db855cfa1e11b5f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e5e7e326d6d7440efa628998aa5e48b487886b77978d5c25a6cf726d6f7f2f6e76936727048d4875579dde1775f2ab24a85241b1e680d93b9a996dc1b383859
|
7
|
+
data.tar.gz: 2eb246dfa73700e128c6d961fc5695e0fa8bc2d52490b4a52fcc68a0b8138644372e0723f5b5604b596e147f402b1cc0f6feff4f5cfc35786246d0c8c9c05662
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
ADDED
data/Rakefile
CHANGED
@@ -1,7 +1,57 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rspec/core/rake_task'
|
3
|
+
|
4
|
+
namespace :test do
|
5
|
+
desc 'Run all tests'
|
6
|
+
task all: [:node, :gem, :rails4] do
|
7
|
+
puts 'Finished all tests, yay!'
|
8
|
+
end
|
9
|
+
|
10
|
+
desc 'Run node package tests'
|
11
|
+
task :node do
|
12
|
+
sh %Q(npm test)
|
13
|
+
end
|
14
|
+
|
15
|
+
desc 'Run gem tests'
|
16
|
+
task :gem do
|
17
|
+
sh %Q(bundle exec rspec spec)
|
18
|
+
end
|
19
|
+
|
20
|
+
desc 'Run rspec for rails4 application'
|
21
|
+
task :rails4 do
|
22
|
+
Bundler.with_clean_env do
|
23
|
+
sh %Q(
|
24
|
+
cd spec/rails4_dummy_app &&
|
25
|
+
npm run build &&
|
26
|
+
npm run rwr-background-node &&
|
27
|
+
sleep 4 &&
|
28
|
+
bundle exec rspec &&
|
29
|
+
npm run rwr-stop-background-node
|
30
|
+
)
|
31
|
+
end
|
32
|
+
end
|
5
33
|
end
|
6
34
|
|
7
|
-
|
35
|
+
task default: 'test:all'
|
36
|
+
|
37
|
+
namespace :setup do
|
38
|
+
desc 'Prepare every environment'
|
39
|
+
task all: [:node, :gem, :rails4] do
|
40
|
+
puts 'Prepared all, yay!'
|
41
|
+
end
|
42
|
+
|
43
|
+
desc 'Prepare node module dependencies'
|
44
|
+
task :node do
|
45
|
+
sh %Q(npm install)
|
46
|
+
end
|
47
|
+
|
48
|
+
desc 'Prepare gem dependencies'
|
49
|
+
task :gem do
|
50
|
+
sh %Q(bundle install)
|
51
|
+
end
|
52
|
+
|
53
|
+
desc 'Prepare rails4 test app dependencies'
|
54
|
+
task :rails4 do
|
55
|
+
sh %Q(npm install && cd spec/rails4_dummy_app && npm install && bundle install)
|
56
|
+
end
|
57
|
+
end
|
data/js/src/version.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export default '0.0
|
1
|
+
export default '0.1.0';
|
@@ -8,7 +8,6 @@ module ReactWebpackRails
|
|
8
8
|
@include = ['*.gif', '*.jpg', '*.jpeg', '*.png']
|
9
9
|
|
10
10
|
def self.fetch
|
11
|
-
puts "-------------------------- FETCH ---------------------------"
|
12
11
|
project_assets = {}
|
13
12
|
env = Sprockets::Railtie.build_environment(::Rails.application)
|
14
13
|
|
@@ -26,6 +25,11 @@ module ReactWebpackRails
|
|
26
25
|
)
|
27
26
|
end
|
28
27
|
|
28
|
+
Dir.mkdir(::Rails.root.join('tmp', 'cache')) unless File.exists?(::Rails.root.join('tmp', 'cache'))
|
29
|
+
open(::Rails.root.join('tmp', 'cache', 'assets-mapping.json'), 'w') do |file|
|
30
|
+
file.write project_assets.to_json
|
31
|
+
end
|
32
|
+
|
29
33
|
return project_assets
|
30
34
|
end
|
31
35
|
end
|
data/lib/rwr-view_helpers.rb
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
-
require 'react_webpack_rails/rwr_view_helpers/rails/engine'
|
2
|
-
require 'react_webpack_rails/rwr_view_helpers/image_paths'
|
3
1
|
require 'react_webpack_rails/rwr_view_helpers/version'
|
2
|
+
|
3
|
+
if defined?(Rails)
|
4
|
+
require 'react_webpack_rails/rwr_view_helpers/rails/engine'
|
5
|
+
require 'react_webpack_rails/rwr_view_helpers/image_paths'
|
6
|
+
end
|
data/package.json
CHANGED
data/rwr-view_helpers.gemspec
CHANGED
@@ -19,10 +19,12 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.files = `git ls-files`.split("\n")
|
20
20
|
s.test_files = Dir["test/**/*"]
|
21
21
|
|
22
|
-
s.add_dependency 'react_webpack_rails', '>= 0.
|
22
|
+
s.add_dependency 'react_webpack_rails', '>= 0.5.0'
|
23
23
|
s.add_dependency 'rails'
|
24
24
|
s.add_dependency 'sprockets', '>= 3.0'
|
25
25
|
|
26
26
|
s.add_development_dependency 'bundler', '~> 1.10'
|
27
|
+
s.add_development_dependency 'rspec', '~> 3.3'
|
28
|
+
s.add_development_dependency 'rake', '~> 10.0'
|
27
29
|
s.add_development_dependency "yard"
|
28
30
|
end
|
@@ -115,8 +115,8 @@ rerun.txt
|
|
115
115
|
pickle-email-*.html
|
116
116
|
|
117
117
|
# TODO Comment out these rules if you are OK with secrets being uploaded to the repo
|
118
|
-
config/initializers/secret_token.rb
|
119
|
-
config/secrets.yml
|
118
|
+
# config/initializers/secret_token.rb
|
119
|
+
# config/secrets.yml
|
120
120
|
|
121
121
|
## Environment normalisation:
|
122
122
|
/.bundle
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require('babel-core/register');
|
2
|
+
require('./index');
|
3
|
+
|
4
|
+
const fs = require('fs');
|
5
|
+
const path = require('path');
|
6
|
+
const http = require('http');
|
7
|
+
const dispatcher = require('httpdispatcher');
|
8
|
+
const { integrationsManager } = require('react-webpack-rails');
|
9
|
+
|
10
|
+
const PORT = 8081;
|
11
|
+
const ASSETS_MAPPING_PATH = 'tmp/cache/assets-mapping.json';
|
12
|
+
|
13
|
+
global.__RWR_ENV__ = {};
|
14
|
+
global.__RWR_VIEW_HELPERS__ = { imagePaths: {} };
|
15
|
+
|
16
|
+
fs.readFile(ASSETS_MAPPING_PATH, (err, data) => {
|
17
|
+
if (err) { return err; }
|
18
|
+
const imagePaths = data.toString('utf-8');
|
19
|
+
global.__RWR_VIEW_HELPERS__.imagePaths = JSON.parse(imagePaths);
|
20
|
+
});
|
21
|
+
|
22
|
+
const handleRequest = (req, res) => {
|
23
|
+
const { method, url } = req;
|
24
|
+
const reqStartTime = (new Date()).toLocaleTimeString();
|
25
|
+
|
26
|
+
console.log(`${method} "${url}" - ${reqStartTime}`);
|
27
|
+
dispatcher.dispatch(req, res);
|
28
|
+
}
|
29
|
+
|
30
|
+
dispatcher.onPost('/run', (req, res) => {
|
31
|
+
try {
|
32
|
+
const data = JSON.parse(req.body);
|
33
|
+
const result = integrationsManager.runNodeIntegration(data);
|
34
|
+
|
35
|
+
res.writeHead(200, { 'Content-Type': 'text/plain' });
|
36
|
+
res.end(result);
|
37
|
+
} catch(e) {
|
38
|
+
console.error(e);
|
39
|
+
|
40
|
+
res.writeHead(500);
|
41
|
+
res.end(`nodeRun failed:\n ${e.name}: ${e.message}`);
|
42
|
+
}
|
43
|
+
});
|
44
|
+
|
45
|
+
http
|
46
|
+
.createServer(handleRequest)
|
47
|
+
.listen(PORT, () => {
|
48
|
+
console.log(`Server listening on: http://localhost:${PORT}`)
|
49
|
+
});
|
@@ -1,7 +1,7 @@
|
|
1
|
-
<h1> Original Spongebob </h1>
|
1
|
+
<h1> Original Spongebob, rendered on server </h1>
|
2
2
|
|
3
|
-
<%= react_component('Spongebob', { server_side:
|
3
|
+
<%= react_component('Spongebob', {}, server_side: true) %>
|
4
4
|
|
5
5
|
<h1> Spongebob with size passed as prop from Rails View </h1>
|
6
6
|
|
7
|
-
<%= react_component('Spongebob', { size: 2 },
|
7
|
+
<%= react_component('Spongebob', { size: 2 }, server_side: false) %>
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Your secret key is used for verifying the integrity of signed cookies.
|
4
|
+
# If you change this key, all old signed cookies will become invalid!
|
5
|
+
|
6
|
+
# Make sure the secret is at least 30 characters and all random,
|
7
|
+
# no regular words or you'll be exposed to dictionary attacks.
|
8
|
+
# You can use `rake secret` to generate a secure secret key.
|
9
|
+
|
10
|
+
# Make sure the secrets in this file are kept private
|
11
|
+
# if you're sharing your code publicly.
|
12
|
+
|
13
|
+
development:
|
14
|
+
secret_key_base: 87fb945fc5e4bbcc51eccc2687818b1f0b00ca4e6ce973263f65585b2d82ba8c58a5c73a08cc868d708dc54137a15db13e89e4c8d59d34a8e3a32865d020ee29
|
15
|
+
|
16
|
+
test:
|
17
|
+
secret_key_base: 7295e7eb84648c8d1ecd414f984ee32148afb18f5610c8c321f24b2b5bef489e90782012b11d6666a0358e116e85efae2f54a4e58dd161c4f4fd873e45f1a9cb
|
18
|
+
|
19
|
+
# Do not keep production secrets in the repository,
|
20
|
+
# instead read values from the environment.
|
21
|
+
production:
|
22
|
+
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
|
@@ -46,6 +46,8 @@
|
|
46
46
|
"rwr-node-server": "forever -o log/rwr-server-out.log -e log/rwr-server-err.log forever/production.json",
|
47
47
|
"start": "webpack -w --config webpack/dev.config.js",
|
48
48
|
"start-hot-dev": "webpack-dev-server --hot --inline --config webpack/hot-dev.config.js",
|
49
|
+
"rwr-background-node": "forever start -o log/rwr-server-out.log -e log/rwr-server-err.log forever/production.json",
|
50
|
+
"rwr-stop-background-node": "forever stopall",
|
49
51
|
"test": "mocha --no-colors app/react/test/helpers/browser.js app/react/**/*.spec.js"
|
50
52
|
},
|
51
53
|
"license": "MIT",
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rwr-view_helpers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oskar Cieslik
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-08-
|
11
|
+
date: 2016-08-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: react_webpack_rails
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.5.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.
|
26
|
+
version: 0.5.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rails
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,6 +66,34 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '1.10'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '3.3'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '3.3'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rake
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '10.0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '10.0'
|
69
97
|
- !ruby/object:Gem::Dependency
|
70
98
|
name: yard
|
71
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -91,6 +119,7 @@ files:
|
|
91
119
|
- ".eslintrc"
|
92
120
|
- ".gitignore"
|
93
121
|
- ".travis.yml"
|
122
|
+
- CHANGELOG.md
|
94
123
|
- CONTRIBUTING.md
|
95
124
|
- Gemfile
|
96
125
|
- LICENSE
|
@@ -108,15 +137,6 @@ files:
|
|
108
137
|
- lib/rwr-view_helpers.rb
|
109
138
|
- package.json
|
110
139
|
- rwr-view_helpers.gemspec
|
111
|
-
- rwr-view_helpers/.gitignore
|
112
|
-
- rwr-view_helpers/Gemfile
|
113
|
-
- rwr-view_helpers/README.md
|
114
|
-
- rwr-view_helpers/Rakefile
|
115
|
-
- rwr-view_helpers/bin/console
|
116
|
-
- rwr-view_helpers/bin/setup
|
117
|
-
- rwr-view_helpers/lib/rwr/view_helpers.rb
|
118
|
-
- rwr-view_helpers/lib/rwr/view_helpers/version.rb
|
119
|
-
- rwr-view_helpers/rwr-view_helpers.gemspec
|
120
140
|
- spec/rails4_dummy_app/.babelrc
|
121
141
|
- spec/rails4_dummy_app/.gitignore
|
122
142
|
- spec/rails4_dummy_app/.nvmrc
|
@@ -138,6 +158,7 @@ files:
|
|
138
158
|
- spec/rails4_dummy_app/app/react/components/Spongebob.js
|
139
159
|
- spec/rails4_dummy_app/app/react/components/Spongebob.spec.js
|
140
160
|
- spec/rails4_dummy_app/app/react/index.js
|
161
|
+
- spec/rails4_dummy_app/app/react/node_server.js
|
141
162
|
- spec/rails4_dummy_app/app/react/test/helpers/browser.js
|
142
163
|
- spec/rails4_dummy_app/app/views/layouts/_react_hot_assets.html.erb
|
143
164
|
- spec/rails4_dummy_app/app/views/layouts/application.html.erb
|
@@ -165,6 +186,7 @@ files:
|
|
165
186
|
- spec/rails4_dummy_app/config/initializers/wrap_parameters.rb
|
166
187
|
- spec/rails4_dummy_app/config/locales/en.yml
|
167
188
|
- spec/rails4_dummy_app/config/routes.rb
|
189
|
+
- spec/rails4_dummy_app/config/secrets.yml
|
168
190
|
- spec/rails4_dummy_app/db/schema.rb
|
169
191
|
- spec/rails4_dummy_app/db/seeds.rb
|
170
192
|
- spec/rails4_dummy_app/forever/development.json
|
data/rwr-view_helpers/.gitignore
DELETED
data/rwr-view_helpers/Gemfile
DELETED
data/rwr-view_helpers/README.md
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
# Rwr::ViewHelpers
|
2
|
-
|
3
|
-
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/rwr/view_helpers`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
6
|
-
|
7
|
-
## Installation
|
8
|
-
|
9
|
-
Add this line to your application's Gemfile:
|
10
|
-
|
11
|
-
```ruby
|
12
|
-
gem 'rwr-view_helpers'
|
13
|
-
```
|
14
|
-
|
15
|
-
And then execute:
|
16
|
-
|
17
|
-
$ bundle
|
18
|
-
|
19
|
-
Or install it yourself as:
|
20
|
-
|
21
|
-
$ gem install rwr-view_helpers
|
22
|
-
|
23
|
-
## Usage
|
24
|
-
|
25
|
-
TODO: Write usage instructions here
|
26
|
-
|
27
|
-
## Development
|
28
|
-
|
29
|
-
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
-
|
31
|
-
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).
|
32
|
-
|
33
|
-
## Contributing
|
34
|
-
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/rwr-view_helpers.
|
36
|
-
|
data/rwr-view_helpers/Rakefile
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require "bundler/setup"
|
4
|
-
require "rwr/view_helpers"
|
5
|
-
|
6
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
-
# with your gem easier. You can also use a different console, if you like.
|
8
|
-
|
9
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
-
# require "pry"
|
11
|
-
# Pry.start
|
12
|
-
|
13
|
-
require "irb"
|
14
|
-
IRB.start
|
data/rwr-view_helpers/bin/setup
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'rwr/view_helpers/version'
|
5
|
-
|
6
|
-
Gem::Specification.new do |spec|
|
7
|
-
spec.name = "rwr-view_helpers"
|
8
|
-
spec.version = Rwr::ViewHelpers::VERSION
|
9
|
-
spec.authors = ["TODO: Write your name"]
|
10
|
-
spec.email = ["oskar.cieslik@netguru.pl"]
|
11
|
-
|
12
|
-
spec.summary = %q{TODO: Write a short summary, because Rubygems requires one.}
|
13
|
-
spec.description = %q{TODO: Write a longer description or delete this line.}
|
14
|
-
spec.homepage = "TODO: Put your gem's website or public repo URL here."
|
15
|
-
|
16
|
-
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
17
|
-
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
18
|
-
if spec.respond_to?(:metadata)
|
19
|
-
spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
|
20
|
-
else
|
21
|
-
raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
22
|
-
end
|
23
|
-
|
24
|
-
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
25
|
-
spec.bindir = "exe"
|
26
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
27
|
-
spec.require_paths = ["lib"]
|
28
|
-
|
29
|
-
spec.add_development_dependency "bundler", "~> 1.12"
|
30
|
-
spec.add_development_dependency "rake", "~> 10.0"
|
31
|
-
end
|