rwr-alt 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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d42b8b57033cc3b15229727ec4abf2745d9efa60
4
+ data.tar.gz: 1a330b61cc3511c11e1ff1552f1ae7db645a2f0f
5
+ SHA512:
6
+ metadata.gz: 0893614f5c83882b6425e1cc4562ef9c00f0fd708dcab11e037abe7f5beb47e732b76b4d3f9f8360b43b1e8df48cd1f16a8237d964f45f630e0a3ba13e07af6b
7
+ data.tar.gz: b8ed01319c187446b0050a01e21e3edb80399b0096fc61aeb3be717d1a0ef8e3055b7a69c80e0856136eae97460b7b6601b08daf7e2c400e048e107fe5097e21
@@ -0,0 +1,3 @@
1
+ {
2
+ "presets": ["es2015", "react"]
3
+ }
@@ -0,0 +1,13 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ /js/lib/
11
+
12
+ node_modules
13
+ rwr-alt-*.gem
@@ -0,0 +1 @@
1
+ js/src/
@@ -0,0 +1,34 @@
1
+ branches:
2
+ except:
3
+ - docs
4
+
5
+ language: ruby
6
+
7
+ cache:
8
+ bundler: true
9
+ directories:
10
+ - node_modules
11
+ - spec/rails4_dummy_app/node_modules
12
+
13
+ matrix:
14
+ include:
15
+ # - rvm: 2.2.4
16
+ # gemfile: spec/rails4_dummy_app/Gemfile
17
+ # env: TEST_SUITE=rails4
18
+ - rvm: 2.2.4
19
+ gemfile: Gemfile
20
+ env: TEST_SUITE=gem
21
+ - rvm: 2.2.4
22
+ env: TEST_SUITE=node
23
+
24
+ before_script:
25
+ - npm install -g npm@^2.0
26
+ - npm install -g webpack@^1.12.1
27
+ - bundle exec rake setup:$TEST_SUITE
28
+ - 'export CHROME_BIN=chromium-browser'
29
+ - "export DISPLAY=:99.0" # Setup display for selenium driver
30
+ - "sh -e /etc/init.d/xvfb start"
31
+ - sleep 3 # give xvfb some time to start
32
+
33
+ script:
34
+ - bundle exec rake test:$TEST_SUITE
@@ -0,0 +1,3 @@
1
+ ## 0.1.0 Initial release (February 21, 2016)
2
+ * `alt_store` view helper for populating alt stores with data from rails level.
3
+ * `RWRAlt` npm package.
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in react_webpack_rails.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Rafał Gawlik
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.
@@ -0,0 +1,49 @@
1
+ rwr-alt
2
+ ====
3
+ [![Build Status](https://travis-ci.org/netguru/rwr-alt.svg?branch=master)](https://travis-ci.org/netguru/rwr-alt)
4
+
5
+ [Alt.js](http://alt.js.org/) integration plugin for [react_webpack_rails](https://github.com/netguru/react_webpack_rails).
6
+
7
+ This integration makes it possible to populate and share Alt stores between react component located in different part of rails views.
8
+
9
+ ## Setup
10
+ * Add `rwr-alt` to your Gemfile:
11
+
12
+ ```
13
+ gem 'rwr-alt'
14
+ ```
15
+
16
+ * Install rwr-alt package:
17
+ ```
18
+ $ npm install --save rwr-alt
19
+ ```
20
+
21
+ ## Usage
22
+ In chosen view, before components are rendered, add:
23
+
24
+ ```erb
25
+ <%= alt_store('exampleStoreName', foo: @bar) %>
26
+ ```
27
+
28
+ Then connect to store state in components like you [usually do in alt ](http://alt.js.org/guide/view/).
29
+
30
+ ## Contributing
31
+ ## Issues
32
+
33
+ Found a bug in rwr-alt? Open an issue on [GitHub Issues](https://github.com/netguru/rwr-alt/issues).
34
+
35
+ ## Pull requests
36
+
37
+ Interested in contributing to rwr-alt? That's great, and thank you for your interest!
38
+
39
+ After checking out the repo, run `bundle exec rake setup:all` to install every environment dependencies.
40
+
41
+ To get your contributions accepted, make sure:
42
+
43
+ * All the tests pass. Run `bundle exec rake test:all`.
44
+ * Any new code paths you've added are covered by tests.
45
+ * Describe your changes in pull request (what it adds, how to migrate from previous version etc.)
46
+
47
+ ## License
48
+
49
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -0,0 +1,50 @@
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/rwr_alt.rb)
18
+ end
19
+
20
+ desc 'Run rspec for rails4 application'
21
+ task :rails4 do
22
+ Bundler.with_clean_env do
23
+ sh %Q(cd spec/rails4_dummy_app && npm run build && bundle exec rspec && npm test)
24
+ end
25
+ end
26
+ end
27
+
28
+ task default: 'test:all'
29
+
30
+ namespace :setup do
31
+ desc 'Prepare every environment'
32
+ task all: [:node, :gem, :rails4] do
33
+ puts 'Prepared all, yay!'
34
+ end
35
+
36
+ desc 'Prepare node module dependencies'
37
+ task :node do
38
+ sh %Q(npm install)
39
+ end
40
+
41
+ desc 'Prepare gem dependencies'
42
+ task :gem do
43
+ sh %Q(bundle install)
44
+ end
45
+
46
+ desc 'Prepare rails4 test app dependencies'
47
+ task :rails4 do
48
+ sh %Q(npm install && cd spec/rails4_dummy_app && npm install && bundle install)
49
+ end
50
+ end
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'react_webpack_rails/alt_integration/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'rwr-alt'
8
+ spec.version = ReactWebpackRails::AltIntegration::VERSION
9
+ spec.authors = ['Rafał Gawlik']
10
+ spec.email = ['react@netguru.co']
11
+
12
+ spec.summary = 'Alt.js integration plugin for react_webpack_rails'
13
+ spec.description = 'This integration makes it possible to populate and share Alt stores between react component located in different part of rails views.'
14
+ spec.homepage = 'https://github.com/netguru/rwr-alt'
15
+ spec.license = 'MIT'
16
+
17
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
18
+ # delete this section to allow pushing this gem to any host.
19
+
20
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
21
+ spec.bindir = 'exe'
22
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
+ spec.require_paths = ['lib']
24
+
25
+ spec.add_development_dependency 'bundler', '~> 1.10'
26
+ spec.add_development_dependency 'rake', '~> 10.0'
27
+ spec.add_development_dependency 'rspec', '~> 3.3'
28
+
29
+ spec.add_dependency 'react_webpack_rails', '>= 0.1.0'
30
+ end
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "react_webpack_rails"
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
@@ -0,0 +1,5 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle exec rake setup:all
@@ -0,0 +1,22 @@
1
+ RWRAlt (rwr-alt package)
2
+ =====
3
+
4
+ ```js
5
+ import RWRAlt from 'rwr-alt';
6
+ ```
7
+
8
+ * #### initializeStore
9
+ ```js
10
+ RWRAlt.alt_store(String storeName[, Object data])
11
+ ```
12
+
13
+ Initialize chosen alt store with provided data. It uses `Object.assign` to merge current store state with passed object allowing to build initial state in parts.
14
+
15
+ ReactWebpackRails::AltIntegration (rwr-alt gem)
16
+ ====
17
+ * #### alt_store
18
+ ```ruby
19
+ alt_store(String store_name[, Object data])
20
+ ```
21
+
22
+ View helper. Use it to populate store with data directly in view. `initializeStore` is used under hood.
@@ -0,0 +1,12 @@
1
+ {
2
+ "extends": "airbnb",
3
+ "globals": {
4
+ "__RWR_ENV__": true
5
+ },
6
+ "env": {
7
+ "mocha": true
8
+ },
9
+ "rules": {
10
+ func-names: 0
11
+ }
12
+ }
@@ -0,0 +1,24 @@
1
+ import version from './version';
2
+
3
+ class RWRAlt {
4
+ constructor(alt) {
5
+ this.version = version;
6
+ this.alt = alt;
7
+ }
8
+
9
+ initializeStore(storeName, data) {
10
+ const store = this.alt.stores[storeName];
11
+ Object.assign(store.state, data);
12
+ store.emitChange();
13
+ }
14
+
15
+ get integrationWrapper() {
16
+ return {
17
+ mount: function _mount(_node, payload) {
18
+ this.initializeStore(payload.storeName, payload.data);
19
+ }.bind(this),
20
+ };
21
+ }
22
+ }
23
+
24
+ export default RWRAlt;
@@ -0,0 +1 @@
1
+ export default '0.1.0-alpha1';
@@ -0,0 +1,12 @@
1
+ import expect from 'expect';
2
+ import RWRAlt from '../src/index';
3
+
4
+ const subject = new RWRAlt();
5
+
6
+ describe('RWRAlt', function () {
7
+ describe('.version', function () {
8
+ it('is present', function () {
9
+ expect(subject.version).toNotEqual(undefined);
10
+ });
11
+ });
12
+ });
@@ -0,0 +1,6 @@
1
+ module ReactWebpackRails
2
+ module AltIntegration
3
+ class Engine < ::Rails::Engine
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,11 @@
1
+ require 'react_webpack_rails/alt_integration/view_helpers'
2
+
3
+ module ReactWebpackRails
4
+ module AltIntegration
5
+ class Railtie < ::Rails::Railtie
6
+ initializer 'react_webpack_rails.alt_helpers.view_helpers' do
7
+ ActionView::Base.send :include, ViewHelpers
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,5 @@
1
+ module ReactWebpackRails
2
+ module AltIntegration
3
+ VERSION = '0.1.0'
4
+ end
5
+ end
@@ -0,0 +1,9 @@
1
+ module ReactWebpackRails
2
+ module AltIntegration
3
+ module ViewHelpers
4
+ def alt_store(store, data)
5
+ react_element('alt-store', storeName: store, data: data)
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,4 @@
1
+ require 'react_webpack_rails/alt_integration/version'
2
+
3
+ require 'react_webpack_rails/alt_integration/engine' if defined?(Rails)
4
+ require 'react_webpack_rails/alt_integration/railtie' if defined?(Rails)
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "rwr-alt",
3
+ "version": "0.1.0",
4
+ "description": "This integration makes it possible to populate and share Alt stores between react component located in different part of rails views.",
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 js/test --ui bdd --recursive --require babel-core/register"
13
+ },
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://github.com/netguru/rwr-alt.git"
17
+ },
18
+ "keywords": [
19
+ "alt",
20
+ "alt integration",
21
+ "react",
22
+ "rails",
23
+ "react_webpack_rails",
24
+ "rwr"
25
+ ],
26
+ "author": "Rafał Gawlik",
27
+ "license": "MIT",
28
+ "bugs": {
29
+ "url": "https://github.com/netguru/rwr-alt/issues"
30
+ },
31
+ "homepage": "https://github.com/netguru/rwr-alt",
32
+ "peerDependencies": {
33
+ "react": "^0.14.0",
34
+ "react-dom": "^0.14.0"
35
+ },
36
+ "dependencies": {
37
+ "react-webpack-rails": "^0.2.0"
38
+ },
39
+ "devDependencies": {
40
+ "babel-cli": "^6.4.0",
41
+ "babel-core": "^6.4.0",
42
+ "babel-preset-es2015": "^6.3.0",
43
+ "babel-preset-react": "^6.3.0",
44
+ "eslint": "^1.10.3",
45
+ "eslint-config-airbnb": "^3.1.0",
46
+ "eslint-plugin-react": "^3.15.0",
47
+ "expect": "^1.13.4",
48
+ "history": "^1.17.0",
49
+ "mocha": "^2.3.4"
50
+ }
51
+ }
metadata ADDED
@@ -0,0 +1,124 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rwr-alt
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Rafał Gawlik
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-02-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.10'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: react_webpack_rails
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: 0.1.0
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: 0.1.0
69
+ description: This integration makes it possible to populate and share Alt stores between
70
+ react component located in different part of rails views.
71
+ email:
72
+ - react@netguru.co
73
+ executables: []
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".babelrc"
78
+ - ".gitignore"
79
+ - ".npmignore"
80
+ - ".travis.yml"
81
+ - CHANGELOG.md
82
+ - Gemfile
83
+ - LICENSE.txt
84
+ - README.md
85
+ - Rakefile
86
+ - alt_integration.gemspec
87
+ - bin/console
88
+ - bin/setup
89
+ - docs/api.md
90
+ - js/.eslintrc
91
+ - js/src/index.js
92
+ - js/src/version.js
93
+ - js/test/index.js
94
+ - lib/react_webpack_rails/alt_integration/engine.rb
95
+ - lib/react_webpack_rails/alt_integration/railtie.rb
96
+ - lib/react_webpack_rails/alt_integration/version.rb
97
+ - lib/react_webpack_rails/alt_integration/view_helpers.rb
98
+ - lib/rwr-alt.rb
99
+ - package.json
100
+ homepage: https://github.com/netguru/rwr-alt
101
+ licenses:
102
+ - MIT
103
+ metadata: {}
104
+ post_install_message:
105
+ rdoc_options: []
106
+ require_paths:
107
+ - lib
108
+ required_ruby_version: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ version: '0'
113
+ required_rubygems_version: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ requirements: []
119
+ rubyforge_project:
120
+ rubygems_version: 2.4.5.1
121
+ signing_key:
122
+ specification_version: 4
123
+ summary: Alt.js integration plugin for react_webpack_rails
124
+ test_files: []