rails_react_components 0.1.1

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: 4bbfe456c56c0a706ed87a338b97ba4198555f4e
4
+ data.tar.gz: 8bb44c1352f47e870849dfa74142c912b84ad0da
5
+ SHA512:
6
+ metadata.gz: 36b648de21fd051ffa0195aab43ba7c29075d96f36c01f6b14f955d1c4fb160b0a8b6e0b64e1aa60a7d7a4e57c0e24f8cec15aae46a239d5ca2a67fc4eace156
7
+ data.tar.gz: a74674431e56181a289ac3350ff6ba57e42053f81f3078b561af315d429f73222c470a75195de2fa62766ea40446f6772b4be941f994993a2808b87663b44325
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.0
5
+ before_install: gem install bundler -v 1.14.6
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rails_react_components.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Adam Stomski
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,36 @@
1
+ # RailsReactComponents
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/rails_react_components`. 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 'rails_react_components'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install rails_react_components
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+
28
+ ## Contributing
29
+
30
+ Bug reports and pull requests are welcome on GitHub at https://github.com/Adam-Stomski/rails_react_components.
31
+
32
+
33
+ ## License
34
+
35
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
36
+
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,6 @@
1
+ module RailsReactComponentsHelper
2
+ def render_react_component(klass, options = {})
3
+ component = klass.new(options)
4
+ react_component(component.component, component.component_options)
5
+ end
6
+ end
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "rails_react_components"
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(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,61 @@
1
+ require_relative "components/prop"
2
+ require_relative "components/dsl"
3
+
4
+ module RailsReactComponents
5
+ class Component
6
+ extend RailsReactComponents::Components::Dsl
7
+
8
+ def initialize(methods = {})
9
+ @_methods = methods
10
+ end
11
+
12
+ def method_missing(method_name, *args)
13
+ if respond_to_missing?(method_name)
14
+ _methods[method_name]
15
+ else
16
+ super
17
+ end
18
+ end
19
+
20
+ def respond_to_missing?(method_name, include_private = false)
21
+ _methods.has_key?(method_name.to_sym) || super
22
+ end
23
+
24
+ def component_options
25
+ {
26
+ props: props,
27
+ id: self.class.id,
28
+ html_options: self.class.html_options,
29
+ trace: self.class.trace?,
30
+ replay_console: self.class.replay_console?,
31
+ raise_on_prerender_error: self.class.raise_on_prerender_error?,
32
+ prerender: self.class.prerender?
33
+ }
34
+ end
35
+
36
+ def props
37
+ @props ||= {}.tap do |props_hash|
38
+ self.class.props.each do |prop|
39
+ prop_data = prop.build(self)
40
+
41
+ if prop.include_blank? || prop_data.present?
42
+ props_hash[prop.name] = prop_data
43
+ end
44
+ end
45
+ end
46
+ end
47
+
48
+ def component
49
+ @component ||= \
50
+ if self.class.component.is_a?(Symbol)
51
+ send(self.class.component)
52
+ else
53
+ self.class.component
54
+ end
55
+ end
56
+
57
+ private
58
+
59
+ attr_reader :_methods
60
+ end
61
+ end
@@ -0,0 +1,47 @@
1
+ module RailsReactComponents
2
+ module Components
3
+ module Dsl
4
+ def props
5
+ @_props ||= []
6
+ end
7
+
8
+ def prop(name, options = {})
9
+ props << RailsReactComponents::Components::Prop.new(name, options)
10
+ end
11
+
12
+ def component(name = nil)
13
+ if name.nil?
14
+ @_component ||= self.name.demodulize
15
+ else
16
+ @_component = name
17
+ end
18
+ end
19
+
20
+ def id(name = nil)
21
+ if name.nil?
22
+ @_id
23
+ else
24
+ @_id = name
25
+ end
26
+ end
27
+
28
+ def html_options
29
+ @_html_options ||= {}
30
+ end
31
+
32
+ def html_option(name, value)
33
+ html_options[name] = value
34
+ end
35
+
36
+ %w(prerender trace replay_console raise_on_prerender_error).each do |method|
37
+ define_method method do
38
+ instance_variable_set("@_#{method}", true)
39
+ end
40
+
41
+ define_method "#{method}?" do
42
+ instance_variable_get("@_#{method}")
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,32 @@
1
+ module RailsReactComponents
2
+ module Components
3
+ class Prop
4
+ attr_reader :name
5
+
6
+ def initialize(name, options)
7
+ @name = name.to_sym
8
+ @options = options
9
+ end
10
+
11
+ def build(component)
12
+ if on.present?
13
+ component.send(on).send(name)
14
+ else
15
+ component.send(name)
16
+ end
17
+ end
18
+
19
+ def include_blank?
20
+ options.fetch(:include_blank, true)
21
+ end
22
+
23
+ private
24
+
25
+ attr_reader :options
26
+
27
+ def on
28
+ @on ||= options[:on] || options[:delegate]
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,4 @@
1
+ module RailsReactComponents
2
+ class Engine < Rails::Engine
3
+ end
4
+ end
@@ -0,0 +1,3 @@
1
+ module RailsReactComponents
2
+ VERSION = "0.1.1"
3
+ end
@@ -0,0 +1,8 @@
1
+ require "rails"
2
+ require "rails_react_components/engine"
3
+
4
+ module RailsReactComponents
5
+ end
6
+
7
+ require "rails_react_components/version"
8
+ require "rails_react_components/component"
@@ -0,0 +1,31 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'rails_react_components/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "rails_react_components"
8
+ spec.version = RailsReactComponents::VERSION
9
+ spec.authors = ["Adam Stomski"]
10
+ spec.email = ["adam.stomski@gmail.com"]
11
+
12
+ spec.summary = %q{Component objects for Rails and React}
13
+ spec.description = %q{Component objects for Rails and React}
14
+ spec.homepage = "https://github.com/Adam-Stomski/rails_react_components"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+
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.14"
26
+ spec.add_development_dependency "rake", "~> 10.0"
27
+ spec.add_development_dependency "rspec", "~> 3.0"
28
+ spec.add_development_dependency "pry"
29
+
30
+ spec.add_dependency "react_on_rails"
31
+ end
metadata ADDED
@@ -0,0 +1,131 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rails_react_components
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Adam Stomski
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-04-06 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.14'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.14'
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.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry
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
+ - !ruby/object:Gem::Dependency
70
+ name: react_on_rails
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: Component objects for Rails and React
84
+ email:
85
+ - adam.stomski@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - ".rspec"
92
+ - ".travis.yml"
93
+ - Gemfile
94
+ - LICENSE.txt
95
+ - README.md
96
+ - Rakefile
97
+ - app/helpers/rails_react_components_helper.rb
98
+ - bin/console
99
+ - bin/setup
100
+ - lib/rails_react_components.rb
101
+ - lib/rails_react_components/component.rb
102
+ - lib/rails_react_components/components/dsl.rb
103
+ - lib/rails_react_components/components/prop.rb
104
+ - lib/rails_react_components/engine.rb
105
+ - lib/rails_react_components/version.rb
106
+ - rails_react_components.gemspec
107
+ homepage: https://github.com/Adam-Stomski/rails_react_components
108
+ licenses:
109
+ - MIT
110
+ metadata: {}
111
+ post_install_message:
112
+ rdoc_options: []
113
+ require_paths:
114
+ - lib
115
+ required_ruby_version: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ required_rubygems_version: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ requirements: []
126
+ rubyforge_project:
127
+ rubygems_version: 2.6.8
128
+ signing_key:
129
+ specification_version: 4
130
+ summary: Component objects for Rails and React
131
+ test_files: []