Skip to content

Commit 8abb9c2

Browse files
committed
initial release
0 parents  commit 8abb9c2

16 files changed

Lines changed: 216 additions & 0 deletions

‎.gitignore‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/.bundle/
2+
/.yardoc
3+
/Gemfile.lock
4+
/_yardoc/
5+
/coverage/
6+
/doc/
7+
/pkg/
8+
/spec/reports/
9+
/tmp/

‎.rspec‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
--format documentation
2+
--color

‎.travis.yml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
language: ruby
2+
rvm:
3+
- 2.1.2
4+
before_install: gem install bundler -v 1.10.4

‎Gemfile‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
source 'https://rubygems.org'
2+
3+
# Specify your gem's dependencies in react-rails-benchmark_renderer.gemspec
4+
gemspec

‎README.md‎

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# React::Rails::BenchmarkRenderer
2+
3+
This idea started with a PR I sent to actual react-rails before it hit 1.0 release. I didn't have time to finish it then,
4+
and the structure of the react-rails codebase changed considerably, so it is now quite easy to write a renderer as a plugin.
5+
6+
This gem is a plugin to ract-rails providing two things:
7+
8+
1. `React::ServerRendering::Concern::Instrumentation`
9+
- benchmarking instrumentation of the sort found in rails view rendering
10+
- can be included into any Renderer to add Benchmarking to it
11+
2. `React::ServerRendering::BenchmarkRenderer`
12+
- a reference implementation of `React::ServerRendering::Concern::Instrumentation`
13+
14+
## Installation
15+
16+
Add this line to your application's Gemfile:
17+
18+
```ruby
19+
gem 'react-rails-benchmark_renderer'
20+
```
21+
22+
And then execute:
23+
24+
$ bundle
25+
26+
Or install it yourself as:
27+
28+
$ gem install react-rails-benchmark_renderer
29+
30+
## Usage
31+
32+
To simply use the reference implementation, just edit your application.rb with:
33+
34+
```
35+
config.react.server_renderer = React::ServerRendering::BenchmarkRenderer
36+
```
37+
38+
To roll your own renderer:
39+
40+
Use `Concern::Implementation` to enhance any React ServerRendering Renderer with benchmarking.
41+
42+
Usage is just like you can see in the reference implementation:
43+
44+
```ruby
45+
require "react/server_rendering/concerns/instrumentation"
46+
# Extends SprocketsRenderer for benchmarking in the Rails environment
47+
# - benchmarks rendering in the same manner as Rails view rendering is benchmarked by Rails
48+
module React
49+
module ServerRendering
50+
class BenchmarkRenderer < SprocketsRenderer
51+
include Concerns::Instrumentation
52+
end
53+
end
54+
end
55+
```
56+
57+
## Development
58+
59+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
60+
61+
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` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
62+
63+
## Contributing
64+
65+
1. Fork it ( https://github.com/[my-github-username]/react-rails-benchmark_renderer/fork )
66+
2. Create your feature branch (`git checkout -b my-new-feature`)
67+
3. Commit your changes (`git commit -am 'Add some feature'`)
68+
4. Push to the branch (`git push origin my-new-feature`)
69+
5. Create a new Pull Request

‎Rakefile‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

‎bin/console‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env ruby
2+
3+
require "bundler/setup"
4+
require "react/rails/benchmark_renderer"
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

‎bin/setup‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
IFS=$'\n\t'
4+
5+
bundle install
6+
7+
# Do any other automated setup that you need to do here
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
require "react/rails/benchmark_renderer"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
require "react/rails/benchmark_renderer/version"
2+
require "react/server_rendering/concerns/instrumentation"
3+
require "react/server_rendering/benchmark_renderer"

0 commit comments

Comments
 (0)