rwr-view_helpers 0.0.1
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 +7 -0
- data/.babelrc +3 -0
- data/.eslintrc +8 -0
- data/.gitignore +216 -0
- data/.travis.yml +48 -0
- data/CONTRIBUTING.md +17 -0
- data/Gemfile +14 -0
- data/LICENSE +22 -0
- data/README.md +69 -0
- data/Rakefile +7 -0
- data/docs/rwr-view_helpers.md +34 -0
- data/js/.eslintrc +12 -0
- data/js/src/index.js +2 -0
- data/js/src/version.js +1 -0
- data/js/test/index.spec.js +26 -0
- data/lib/assets/javascripts/rwr_view_helpers.js.erb +5 -0
- data/lib/react_webpack_rails/rwr_view_helpers/image_paths.rb +33 -0
- data/lib/react_webpack_rails/rwr_view_helpers/rails/engine.rb +8 -0
- data/lib/react_webpack_rails/rwr_view_helpers/version.rb +5 -0
- data/lib/rwr-view_helpers.rb +3 -0
- data/package.json +43 -0
- data/rwr-view_helpers/.gitignore +9 -0
- data/rwr-view_helpers/Gemfile +4 -0
- data/rwr-view_helpers/README.md +36 -0
- data/rwr-view_helpers/Rakefile +2 -0
- data/rwr-view_helpers/bin/console +14 -0
- data/rwr-view_helpers/bin/setup +8 -0
- data/rwr-view_helpers/lib/rwr/view_helpers/version.rb +5 -0
- data/rwr-view_helpers/lib/rwr/view_helpers.rb +7 -0
- data/rwr-view_helpers/rwr-view_helpers.gemspec +31 -0
- data/rwr-view_helpers.gemspec +28 -0
- data/spec/rails4_dummy_app/.babelrc +3 -0
- data/spec/rails4_dummy_app/.gitignore +216 -0
- data/spec/rails4_dummy_app/.nvmrc +1 -0
- data/spec/rails4_dummy_app/Gemfile +28 -0
- data/spec/rails4_dummy_app/Rakefile +6 -0
- data/spec/rails4_dummy_app/app/assets/images/.keep +0 -0
- data/spec/rails4_dummy_app/app/assets/images/spongebob.png +0 -0
- data/spec/rails4_dummy_app/app/assets/images/spongebob@2x.png +0 -0
- data/spec/rails4_dummy_app/app/assets/images/spongebob@3x.png +0 -0
- data/spec/rails4_dummy_app/app/assets/javascripts/application.js +20 -0
- data/spec/rails4_dummy_app/app/assets/stylesheets/application.css +15 -0
- data/spec/rails4_dummy_app/app/controllers/application_controller.rb +5 -0
- data/spec/rails4_dummy_app/app/controllers/concerns/.keep +0 -0
- data/spec/rails4_dummy_app/app/controllers/pages_controller.rb +4 -0
- data/spec/rails4_dummy_app/app/helpers/application_helper.rb +2 -0
- data/spec/rails4_dummy_app/app/mailers/.keep +0 -0
- data/spec/rails4_dummy_app/app/models/.keep +0 -0
- data/spec/rails4_dummy_app/app/models/concerns/.keep +0 -0
- data/spec/rails4_dummy_app/app/react/components/Spongebob.js +9 -0
- data/spec/rails4_dummy_app/app/react/components/Spongebob.spec.js +28 -0
- data/spec/rails4_dummy_app/app/react/index.js +5 -0
- data/spec/rails4_dummy_app/app/react/test/helpers/browser.js +20 -0
- data/spec/rails4_dummy_app/app/views/layouts/_react_hot_assets.html.erb +3 -0
- data/spec/rails4_dummy_app/app/views/layouts/application.html.erb +16 -0
- data/spec/rails4_dummy_app/app/views/pages/home.html.erb +7 -0
- data/spec/rails4_dummy_app/bin/bundle +3 -0
- data/spec/rails4_dummy_app/bin/rails +8 -0
- data/spec/rails4_dummy_app/bin/rake +8 -0
- data/spec/rails4_dummy_app/bin/setup +29 -0
- data/spec/rails4_dummy_app/bin/spring +15 -0
- data/spec/rails4_dummy_app/config/application.rb +26 -0
- data/spec/rails4_dummy_app/config/boot.rb +3 -0
- data/spec/rails4_dummy_app/config/database.yml +25 -0
- data/spec/rails4_dummy_app/config/environment.rb +5 -0
- data/spec/rails4_dummy_app/config/environments/development.rb +41 -0
- data/spec/rails4_dummy_app/config/environments/production.rb +79 -0
- data/spec/rails4_dummy_app/config/environments/test.rb +42 -0
- data/spec/rails4_dummy_app/config/initializers/assets.rb +11 -0
- data/spec/rails4_dummy_app/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/rails4_dummy_app/config/initializers/cookies_serializer.rb +3 -0
- data/spec/rails4_dummy_app/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/rails4_dummy_app/config/initializers/inflections.rb +16 -0
- data/spec/rails4_dummy_app/config/initializers/mime_types.rb +4 -0
- data/spec/rails4_dummy_app/config/initializers/session_store.rb +3 -0
- data/spec/rails4_dummy_app/config/initializers/wrap_parameters.rb +14 -0
- data/spec/rails4_dummy_app/config/locales/en.yml +23 -0
- data/spec/rails4_dummy_app/config/routes.rb +58 -0
- data/spec/rails4_dummy_app/config.ru +4 -0
- data/spec/rails4_dummy_app/db/schema.rb +16 -0
- data/spec/rails4_dummy_app/db/seeds.rb +7 -0
- data/spec/rails4_dummy_app/forever/development.json +8 -0
- data/spec/rails4_dummy_app/forever/production.json +6 -0
- data/spec/rails4_dummy_app/karma.conf.js +32 -0
- data/spec/rails4_dummy_app/lib/assets/.keep +0 -0
- data/spec/rails4_dummy_app/lib/tasks/.keep +0 -0
- data/spec/rails4_dummy_app/package.json +55 -0
- data/spec/rails4_dummy_app/public/404.html +67 -0
- data/spec/rails4_dummy_app/public/422.html +67 -0
- data/spec/rails4_dummy_app/public/500.html +66 -0
- data/spec/rails4_dummy_app/public/favicon.ico +0 -0
- data/spec/rails4_dummy_app/public/robots.txt +5 -0
- data/spec/rails4_dummy_app/spec/rails_helper.rb +57 -0
- data/spec/rails4_dummy_app/spec/spec_helper.rb +92 -0
- data/spec/rails4_dummy_app/webpack/dev.config.js +7 -0
- data/spec/rails4_dummy_app/webpack/hot-dev.config.js +13 -0
- data/spec/rails4_dummy_app/webpack/production.config.js +3 -0
- data/spec/rails4_dummy_app/webpack/tests.config.js +2 -0
- data/spec/rails4_dummy_app/webpack.config.js +39 -0
- metadata +212 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 08a6e7fbb37224a088343a6830530b9f42b87232
|
4
|
+
data.tar.gz: 4f45fbc8ccdee714c61c7d3f20b0a1f12f2629d7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f8cf7729e13c6ea7cdf79ca80ebdb97418188b04f5347d366bf70c1d9839ecef76a379254c7b402c10f32cd07355d1eb9f4b9a18afd28ba6a3241298de9806be
|
7
|
+
data.tar.gz: a1e23dc9059bd5ad3a05472cc6ff1d367c5571c3a2385cfa589ccb7eb41494cf5dec89e82c5e4819a67b537d574a377e8d30373653edc2b6c1ccee53b07e207d
|
data/.babelrc
ADDED
data/.eslintrc
ADDED
data/.gitignore
ADDED
@@ -0,0 +1,216 @@
|
|
1
|
+
#####=== Emacs ===#####
|
2
|
+
# -*- mode: gitignore; -*-
|
3
|
+
*~
|
4
|
+
\#*\#
|
5
|
+
/.emacs.desktop
|
6
|
+
/.emacs.desktop.lock
|
7
|
+
*.elc
|
8
|
+
auto-save-list
|
9
|
+
tramp
|
10
|
+
.\#*
|
11
|
+
|
12
|
+
# Org-mode
|
13
|
+
.org-id-locations
|
14
|
+
*_archive
|
15
|
+
|
16
|
+
# flymake-mode
|
17
|
+
*_flymake.*
|
18
|
+
|
19
|
+
# eshell files
|
20
|
+
/eshell/history
|
21
|
+
/eshell/lastdir
|
22
|
+
|
23
|
+
# elpa packages
|
24
|
+
/elpa/
|
25
|
+
|
26
|
+
# reftex files
|
27
|
+
*.rel
|
28
|
+
|
29
|
+
# AUCTeX auto folder
|
30
|
+
/auto/
|
31
|
+
|
32
|
+
# cask packages
|
33
|
+
.cask/
|
34
|
+
|
35
|
+
#####=== Linux ===#####
|
36
|
+
*~
|
37
|
+
|
38
|
+
# KDE directory preferences
|
39
|
+
.directory
|
40
|
+
|
41
|
+
# Linux trash folder which might appear on any partition or disk
|
42
|
+
.Trash-*
|
43
|
+
|
44
|
+
#####=== Node ===#####
|
45
|
+
|
46
|
+
# Logs
|
47
|
+
logs
|
48
|
+
*.log
|
49
|
+
|
50
|
+
# Runtime data
|
51
|
+
pids
|
52
|
+
*.pid
|
53
|
+
*.seed
|
54
|
+
|
55
|
+
# Directory for instrumented libs generated by jscoverage/JSCover
|
56
|
+
lib-cov
|
57
|
+
|
58
|
+
# Coverage directory used by tools like istanbul
|
59
|
+
coverage
|
60
|
+
|
61
|
+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
|
62
|
+
.grunt
|
63
|
+
|
64
|
+
# node-waf configuration
|
65
|
+
.lock-wscript
|
66
|
+
|
67
|
+
# Compiled binary addons (http://nodejs.org/api/addons.html)
|
68
|
+
build/Release
|
69
|
+
|
70
|
+
# Dependency directory
|
71
|
+
# https://docs.npmjs.com/misc/faq#should-i-check-my-node-modules-folder-into-git
|
72
|
+
node_modules
|
73
|
+
|
74
|
+
#####=== OSX ===#####
|
75
|
+
.DS_Store
|
76
|
+
.AppleDouble
|
77
|
+
.LSOverride
|
78
|
+
|
79
|
+
# Icon must end with two
|
80
|
+
Icon
|
81
|
+
|
82
|
+
|
83
|
+
# Thumbnails
|
84
|
+
._*
|
85
|
+
|
86
|
+
# Files that might appear in the root of a volume
|
87
|
+
.DocumentRevisions-V100
|
88
|
+
.fseventsd
|
89
|
+
.Spotlight-V100
|
90
|
+
.TemporaryItems
|
91
|
+
.Trashes
|
92
|
+
.VolumeIcon.icns
|
93
|
+
|
94
|
+
# Directories potentially created on remote AFP share
|
95
|
+
.AppleDB
|
96
|
+
.AppleDesktop
|
97
|
+
Network Trash Folder
|
98
|
+
Temporary Items
|
99
|
+
.apdisk
|
100
|
+
|
101
|
+
#####=== Rails ===#####
|
102
|
+
|
103
|
+
*.rbc
|
104
|
+
capybara-*.html
|
105
|
+
.rspec
|
106
|
+
/log
|
107
|
+
/tmp
|
108
|
+
/db/*.sqlite3
|
109
|
+
/db/*.sqlite3-journal
|
110
|
+
/public/system
|
111
|
+
/coverage/
|
112
|
+
/spec/tmp
|
113
|
+
**.orig
|
114
|
+
rerun.txt
|
115
|
+
pickle-email-*.html
|
116
|
+
|
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
|
120
|
+
|
121
|
+
## Environment normalisation:
|
122
|
+
/.bundle
|
123
|
+
/vendor/bundle
|
124
|
+
|
125
|
+
# these should all be checked in to normalise the environment:
|
126
|
+
# Gemfile.lock, .ruby-version, .ruby-gemset
|
127
|
+
|
128
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
129
|
+
.rvmrc
|
130
|
+
|
131
|
+
# if using bower-rails ignore default bower_components path bower.json files
|
132
|
+
/vendor/assets/bower_components
|
133
|
+
*.bowerrc
|
134
|
+
bower.json
|
135
|
+
|
136
|
+
# Ignore pow environment settings
|
137
|
+
.powenv
|
138
|
+
|
139
|
+
#####=== Ruby ===#####
|
140
|
+
|
141
|
+
*.gem
|
142
|
+
*.rbc
|
143
|
+
/.config
|
144
|
+
/coverage/
|
145
|
+
/InstalledFiles
|
146
|
+
/pkg/
|
147
|
+
/spec/reports/
|
148
|
+
/test/tmp/
|
149
|
+
/test/version_tmp/
|
150
|
+
/tmp/
|
151
|
+
|
152
|
+
## Specific to RubyMotion:
|
153
|
+
.dat*
|
154
|
+
.repl_history
|
155
|
+
build/
|
156
|
+
|
157
|
+
## Documentation cache and generated files:
|
158
|
+
/.yardoc/
|
159
|
+
/_yardoc/
|
160
|
+
/doc/
|
161
|
+
/rdoc/
|
162
|
+
|
163
|
+
## Environment normalisation:
|
164
|
+
/.bundle/
|
165
|
+
/vendor/bundle
|
166
|
+
/lib/bundler/man/
|
167
|
+
|
168
|
+
# for a library or gem, you might want to ignore these files since the code is
|
169
|
+
# intended to run in multiple environments; otherwise, check them in:
|
170
|
+
# Gemfile.lock
|
171
|
+
# .ruby-version
|
172
|
+
# .ruby-gemset
|
173
|
+
|
174
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
175
|
+
.rvmrc
|
176
|
+
|
177
|
+
#####=== SublimeText ===#####
|
178
|
+
# cache files for sublime text
|
179
|
+
*.tmlanguage.cache
|
180
|
+
*.tmPreferences.cache
|
181
|
+
*.stTheme.cache
|
182
|
+
|
183
|
+
# workspace files are user-specific
|
184
|
+
*.sublime-workspace
|
185
|
+
|
186
|
+
# project files should be checked into the repository, unless a significant
|
187
|
+
# proportion of contributors will probably not be using SublimeText
|
188
|
+
# *.sublime-project
|
189
|
+
|
190
|
+
# sftp configuration file
|
191
|
+
sftp-config.json
|
192
|
+
|
193
|
+
#####=== Vim ===#####
|
194
|
+
[._]*.s[a-w][a-z]
|
195
|
+
[._]s[a-w][a-z]
|
196
|
+
*.un~
|
197
|
+
Session.vim
|
198
|
+
.netrwhist
|
199
|
+
*~
|
200
|
+
|
201
|
+
# ----- OWN IGNORES ----- #
|
202
|
+
|
203
|
+
/.bundle/
|
204
|
+
/.yardoc
|
205
|
+
/Gemfile.lock
|
206
|
+
/_yardoc/
|
207
|
+
/coverage/
|
208
|
+
/doc/
|
209
|
+
/pkg/
|
210
|
+
/spec/reports/
|
211
|
+
/tmp/
|
212
|
+
/js/lib/
|
213
|
+
|
214
|
+
node_modules
|
215
|
+
rwr-alt-*.gem
|
216
|
+
spec/rails4_dummy_app/vendor
|
data/.travis.yml
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
branches:
|
2
|
+
except:
|
3
|
+
- docs
|
4
|
+
|
5
|
+
sudo: required
|
6
|
+
dist: trusty
|
7
|
+
language: ruby
|
8
|
+
addons:
|
9
|
+
# From some tests it seems you can only have one firefox addon.
|
10
|
+
# Adding two results in the last one defined being the one installed.
|
11
|
+
apt:
|
12
|
+
sources:
|
13
|
+
- google-chrome
|
14
|
+
packages:
|
15
|
+
- google-chrome-stable
|
16
|
+
- google-chrome-beta
|
17
|
+
|
18
|
+
cache:
|
19
|
+
bundler: true
|
20
|
+
directories:
|
21
|
+
- spec/test-app/node_modules
|
22
|
+
- node_modules
|
23
|
+
|
24
|
+
matrix:
|
25
|
+
include:
|
26
|
+
- rvm: 2.2.4
|
27
|
+
gemfile: spec/test-app/Gemfile
|
28
|
+
env: TEST_SUITE=test-app
|
29
|
+
- rvm: 2.2.4
|
30
|
+
gemfile: Gemfile
|
31
|
+
env: TEST_SUITE=gem
|
32
|
+
- rvm: 2.2.4
|
33
|
+
env: TEST_SUITE=node
|
34
|
+
|
35
|
+
before_install:
|
36
|
+
- sudo apt-get update -qq
|
37
|
+
|
38
|
+
before_script:
|
39
|
+
- npm install -g npm@^2.0
|
40
|
+
- npm install -g webpack@^1.12.1
|
41
|
+
- bundle exec rake setup:$TEST_SUITE
|
42
|
+
- 'export CHROME_BIN=chromium-browser'
|
43
|
+
- "export DISPLAY=:99.0" # Setup display for selenium driver
|
44
|
+
- "sh -e /etc/init.d/xvfb start"
|
45
|
+
- sleep 3 # give xvfb some time to start
|
46
|
+
|
47
|
+
script:
|
48
|
+
- bundle exec rake test:$TEST_SUITE
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# Contributing to RWR View Helpers gem
|
2
|
+
|
3
|
+
## Issues
|
4
|
+
|
5
|
+
Found a bug in RWR View Helpers? Open an issue on [GitHub Issues](https://github.com/netguru/rwr-view_helpers/issues).
|
6
|
+
|
7
|
+
## Pull requests
|
8
|
+
|
9
|
+
Interested in contributing to RWR View Helpers? That's great, and thank you for your interest!
|
10
|
+
|
11
|
+
After checking out the repo, run `bundle exec rake setup:all` to install every environment dependencies.
|
12
|
+
|
13
|
+
To get your contributions accepted, make sure:
|
14
|
+
|
15
|
+
* All the tests pass. Run `bundle exec rake test:all`.
|
16
|
+
* Any new code paths you've added are covered by tests.
|
17
|
+
* Describe your changes in pull request (what it adds, how to migrate from previous version etc.)
|
data/Gemfile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
source "https://rubygems.org"
|
2
|
+
|
3
|
+
# Declare your gem's dependencies in js_assets.gemspec.
|
4
|
+
# Bundler will treat runtime dependencies like base dependencies, and
|
5
|
+
# development dependencies will be added by default to the :development group.
|
6
|
+
gemspec
|
7
|
+
|
8
|
+
# Declare any dependencies that are still in development here instead of in
|
9
|
+
# your gemspec. These might include edge Rails or gems from your path or
|
10
|
+
# Git. Remember to move these dependencies to your gemspec before releasing
|
11
|
+
# your gem to rubygems.org.
|
12
|
+
|
13
|
+
# To use debugger
|
14
|
+
# gem 'debugger'
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Oskar Cieslik (netguru)
|
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 all
|
13
|
+
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 THE
|
21
|
+
SOFTWARE.
|
22
|
+
|
data/README.md
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
RWR View Helpers
|
2
|
+
====
|
3
|
+
|
4
|
+
This gem provides handy view helpers to be used with netguru's [react_webpack_rails](https://github.com/netguru/react_webpack_rails).
|
5
|
+
|
6
|
+
## Setup
|
7
|
+
|
8
|
+
* Javascript
|
9
|
+
```sh
|
10
|
+
$ npm install --save rwr-view-helpers
|
11
|
+
```
|
12
|
+
|
13
|
+
* Ruby
|
14
|
+
```ruby
|
15
|
+
# your Gemfile
|
16
|
+
gem 'rwr-view_helpers'
|
17
|
+
```
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
First add this require statement in your `/app/assets/javascripts/application.js`
|
22
|
+
|
23
|
+
```js
|
24
|
+
//= require rwr_view_helpers
|
25
|
+
```
|
26
|
+
|
27
|
+
Then use it in your React components
|
28
|
+
|
29
|
+
```jsx
|
30
|
+
import React from 'react';
|
31
|
+
import { imagePath } from 'rwr-view-helpers';
|
32
|
+
|
33
|
+
export default ({ alt }) => (
|
34
|
+
<img alt={alt} src={imagePath('spongebob.png')} />
|
35
|
+
);
|
36
|
+
```
|
37
|
+
|
38
|
+
## Caching
|
39
|
+
|
40
|
+
Going through all the assets on every request would be veeery slow, so rwr-view_helpers takes advantage of `/tmp/cache` in your project.
|
41
|
+
Unfortunately at the moment we don't have any mechanism to generate new cache each time new assets are added.
|
42
|
+
|
43
|
+
Current work-around is to run this task, when adding new assets to the project:
|
44
|
+
|
45
|
+
```shell
|
46
|
+
$ rake tmp:clear
|
47
|
+
```
|
48
|
+
|
49
|
+
## Contributing
|
50
|
+
|
51
|
+
#### Issues
|
52
|
+
|
53
|
+
Found a bug in rwr-view_helpers? Open an issue on [GitHub Issues](https://github.com/netguru/rwr-view_helpers/issues).
|
54
|
+
|
55
|
+
#### Pull requests
|
56
|
+
|
57
|
+
Interested in contributing to rwr-view_helpers? That's great, and thank you for your interest!
|
58
|
+
|
59
|
+
After checking out the repo, run `bundle exec rake setup:all` to install every environment dependencies.
|
60
|
+
|
61
|
+
To get your contributions accepted, make sure:
|
62
|
+
|
63
|
+
* All the tests pass. Run `bundle exec rake test:all`.
|
64
|
+
* Any new code paths you've added are covered by tests.
|
65
|
+
* Describe your changes in pull request (what it adds, how to migrate from previous version etc.)
|
66
|
+
|
67
|
+
## License
|
68
|
+
|
69
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
## Setup
|
2
|
+
|
3
|
+
* Javascript
|
4
|
+
```sh
|
5
|
+
$ npm install --save rwr-view-helpers
|
6
|
+
```
|
7
|
+
|
8
|
+
* Ruby
|
9
|
+
```ruby
|
10
|
+
# your Gemfile
|
11
|
+
gem 'rwr-view_helpers'
|
12
|
+
```
|
13
|
+
|
14
|
+
## Usage
|
15
|
+
|
16
|
+
```jsx
|
17
|
+
import React from 'react';
|
18
|
+
import { imagePath } from 'rwr-view-helpers';
|
19
|
+
|
20
|
+
export default ({ alt }) => (
|
21
|
+
<img alt={alt} src={imagePath('spongebob.png')} />
|
22
|
+
);
|
23
|
+
```
|
24
|
+
|
25
|
+
## Caching
|
26
|
+
|
27
|
+
Going through all the assets on every request would be veeery slow, so rwr-view_helpers takes advantage of `/tmp/cache` in your project.
|
28
|
+
Unfortunately at the moment we don't have any mechanism to generate new cache each time new assets are added.
|
29
|
+
|
30
|
+
Current work-around is to run this task, when adding new assets to the project:
|
31
|
+
|
32
|
+
```shell
|
33
|
+
$ rake tmp:clear
|
34
|
+
```
|
data/js/.eslintrc
ADDED
data/js/src/index.js
ADDED
data/js/src/version.js
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
export default '0.0.1';
|
@@ -0,0 +1,26 @@
|
|
1
|
+
import expect from 'expect';
|
2
|
+
import { imagePath } from '../src/index';
|
3
|
+
|
4
|
+
global.__RWR_VIEW_HELPERS__ = {
|
5
|
+
imagePaths: {},
|
6
|
+
};
|
7
|
+
|
8
|
+
describe('RWR View Helpers', function () {
|
9
|
+
it('should be a function', function () {
|
10
|
+
expect(imagePath).toBeA('function');
|
11
|
+
});
|
12
|
+
|
13
|
+
it('should return passed path when asset is not found', function() {
|
14
|
+
expect(imagePath('spongebob.png')).toBe('spongebob.png');
|
15
|
+
});
|
16
|
+
|
17
|
+
it('should return fullpath when asset is found', () => {
|
18
|
+
global.__RWR_VIEW_HELPERS__ = {
|
19
|
+
imagePaths: {
|
20
|
+
'spongebob.png': 'spongebob-HASH.png',
|
21
|
+
},
|
22
|
+
};
|
23
|
+
|
24
|
+
expect(imagePath('spongebob.png')).toBe('spongebob-HASH.png');
|
25
|
+
});
|
26
|
+
});
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module ReactWebpackRails
|
2
|
+
module RWRViewHelpers
|
3
|
+
class ImagePaths
|
4
|
+
class << self
|
5
|
+
attr_accessor :include
|
6
|
+
end
|
7
|
+
|
8
|
+
@include = ['*.gif', '*.jpg', '*.jpeg', '*.png']
|
9
|
+
|
10
|
+
def self.fetch
|
11
|
+
puts "-------------------------- FETCH ---------------------------"
|
12
|
+
project_assets = {}
|
13
|
+
env = Sprockets::Railtie.build_environment(::Rails.application)
|
14
|
+
|
15
|
+
env.logical_paths do |logical_path, filename|
|
16
|
+
next unless @include.any? { |wildcard| File.fnmatch(wildcard.to_s, logical_path) }
|
17
|
+
|
18
|
+
assets_root = ::Rails.application.config.action_controller.asset_host.present? \
|
19
|
+
? ::Rails.application.config.action_controller.asset_host \
|
20
|
+
: '/'
|
21
|
+
|
22
|
+
project_assets[logical_path] = File.join(
|
23
|
+
assets_root,
|
24
|
+
::Rails.application.config.assets.prefix,
|
25
|
+
env.file_digest(filename) ? env[logical_path].digest_path : logical_path
|
26
|
+
)
|
27
|
+
end
|
28
|
+
|
29
|
+
return project_assets
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/package.json
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
{
|
2
|
+
"name": "rwr-view-helpers",
|
3
|
+
"version": "0.0.1",
|
4
|
+
"description": "ReactWebpackRails integration with useful view helpers.",
|
5
|
+
"main": "js/lib/index.js",
|
6
|
+
"files": [
|
7
|
+
"js/lib"
|
8
|
+
],
|
9
|
+
"scripts": {
|
10
|
+
"compile": "babel --presets es2015 -d js/lib/ js/src/",
|
11
|
+
"prepublish": "npm run compile",
|
12
|
+
"test": "mocha --no-colors js/test --ui bdd --recursive --require babel-core/register"
|
13
|
+
},
|
14
|
+
"repository": {
|
15
|
+
"type": "git",
|
16
|
+
"url": "git+https://github.com/netguru/rwr-view_helpers.git"
|
17
|
+
},
|
18
|
+
"keywords": [
|
19
|
+
"react",
|
20
|
+
"rails",
|
21
|
+
"react_webpack_rails",
|
22
|
+
"rwr"
|
23
|
+
],
|
24
|
+
"author": "Oskar Cieslik",
|
25
|
+
"license": "MIT",
|
26
|
+
"bugs": {
|
27
|
+
"url": "https://github.com/netguru/rwr-view_helpers/issues"
|
28
|
+
},
|
29
|
+
"homepage": "https://github.com/netguru/rwr-view_helpers",
|
30
|
+
"devDependencies": {
|
31
|
+
"babel-cli": "^6.4.0",
|
32
|
+
"babel-core": "^6.4.0",
|
33
|
+
"babel-preset-es2015": "^6.3.0",
|
34
|
+
"babel-preset-react": "^6.3.0",
|
35
|
+
"eslint": "^1.10.3",
|
36
|
+
"eslint-config-airbnb": "^3.1.0",
|
37
|
+
"eslint-plugin-react": "^3.15.0",
|
38
|
+
"expect": "^1.13.4",
|
39
|
+
"history": "^1.17.0",
|
40
|
+
"mocha": "^2.3.4"
|
41
|
+
},
|
42
|
+
"dependencies": {}
|
43
|
+
}
|
@@ -0,0 +1,36 @@
|
|
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
|
+
|
@@ -0,0 +1,14 @@
|
|
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
|