livereload_rails 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +9 -0
  3. data/.rspec +2 -0
  4. data/CODE_OF_CONDUCT.md +13 -0
  5. data/Gemfile +3 -0
  6. data/LICENSE.txt +21 -0
  7. data/README.md +40 -0
  8. data/Rakefile +6 -0
  9. data/bin/console +7 -0
  10. data/bin/setup +5 -0
  11. data/example/Gemfile +8 -0
  12. data/example/Gemfile.lock +119 -0
  13. data/example/Rakefile +6 -0
  14. data/example/app/assets/images/.keep +0 -0
  15. data/example/app/assets/javascripts/application.js +1 -0
  16. data/example/app/assets/stylesheets/application.css +3 -0
  17. data/example/app/controllers/application_controller.rb +8 -0
  18. data/example/app/views/application/home.html.erb +10 -0
  19. data/example/app/views/layouts/application.html.erb +14 -0
  20. data/example/bin/bundle +3 -0
  21. data/example/bin/rails +4 -0
  22. data/example/bin/rake +4 -0
  23. data/example/bin/setup +29 -0
  24. data/example/config.ru +4 -0
  25. data/example/config/application.rb +26 -0
  26. data/example/config/boot.rb +3 -0
  27. data/example/config/environment.rb +5 -0
  28. data/example/config/environments/development.rb +35 -0
  29. data/example/config/initializers/livereload_rails.rb +5 -0
  30. data/example/config/routes.rb +3 -0
  31. data/example/config/secrets.yml +14 -0
  32. data/example/log/.gitignore +2 -0
  33. data/example/public/favicon.ico +0 -0
  34. data/example/tmp/.gitignore +2 -0
  35. data/lib/livereload_rails.rb +48 -0
  36. data/lib/livereload_rails/client.rb +67 -0
  37. data/lib/livereload_rails/middleware.rb +56 -0
  38. data/lib/livereload_rails/railtie.rb +10 -0
  39. data/lib/livereload_rails/stream.rb +145 -0
  40. data/lib/livereload_rails/version.rb +3 -0
  41. data/lib/livereload_rails/watcher.rb +40 -0
  42. data/lib/livereload_rails/web_socket.rb +150 -0
  43. data/livereload_rails.gemspec +32 -0
  44. data/vendor/assets/javascripts/livereload.js +1183 -0
  45. metadata +229 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 20909a36f07c3bc32c266d8786dc116eba75ec7a
4
+ data.tar.gz: 0c5c2b18c5a39e6838226b8b6a8301a5b52ee3ed
5
+ SHA512:
6
+ metadata.gz: 733a7078b4db6d71b316ae281c04168006fd7bc62e1a9c0b23e25bbe52d4ca90ffdf05f2e76123f7428e8eb0f49e629cfe82603d56950e93430161e1cebcb127
7
+ data.tar.gz: b8efd10aa49149b9f5c37b8cf7941e4922b2fb4124144778981891d2ee2c7509ac87a39086825d50c510996c8792033083b03a871112c496b673732ea246971a
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Kim Burgestrand
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,40 @@
1
+ # LivereloadRails::Rails
2
+
3
+ ## Installation
4
+
5
+ ```ruby
6
+ gem "livereload_rails", group: :development
7
+ ```
8
+
9
+ That's it. Your CSS now livereloads. A few notes that could be of interest:
10
+
11
+ - requires a threaded webserver, so puma is a runtime dependency for ease of installation.
12
+ - adds middleware `Rack:LiveReload` which automatically includes `livereload.js`
13
+ - adds middleware `LivereloadRails::Middleware` which acts as websocket/livereload server
14
+
15
+ ## Development
16
+
17
+ If you wish to contribute to this gem, here are some notes I hope will help you:
18
+
19
+ - `bin/setup`: run to install development dependencies.
20
+ - `bin/console`: run to start an interactive console to experiment with the code.
21
+ - `rake`: run the automated test suite.
22
+
23
+ ### Implementation Notes
24
+
25
+ LivereloadRails::Rails consists of the following parts:
26
+
27
+ - [Watcher](./lib/livereload_rails/watcher.rb) - responsible for watching the asset paths for file changes.
28
+ - [WebSocket](./lib/livereload_rails/web_socket.rb) - websocket server handler for rack.
29
+ - [Client](./lib/livereload_rails/client.rb) - livereload server handler.
30
+ - [Middleware](./lib/livereload_rails/middleware.rb) - rack middleware to accept websocket connections.
31
+ - [Railtie](./lib/livereload_rails/railtie.rb) - rails engine to automatically hook rails up with livereload.
32
+
33
+ ### Contributing
34
+
35
+ Contributions are very welcome! Follow these steps:
36
+
37
+ 1. [Fork the code](https://github.com/Burgestrand/livereload_rails/fork): https://help.github.com/articles/fork-a-repo/
38
+ 2. Create a new pull request with your changes: https://help.github.com/articles/using-pull-requests/
39
+
40
+ It's perfectly fine to create a pull request with your code and continue a discussion from your changes from there.
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ require "rspec/core/rake_task"
4
+ RSpec::Core::RakeTask.new
5
+
6
+ task default: :spec
data/bin/console ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "livereload_rails"
5
+
6
+ require "pry"
7
+ Pry.start
data/bin/setup ADDED
@@ -0,0 +1,5 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
data/example/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'rails', '4.2.1'
4
+
5
+ group :development do
6
+ gem 'livereload_rails', path: '../'
7
+ end
8
+
@@ -0,0 +1,119 @@
1
+ PATH
2
+ remote: ../
3
+ specs:
4
+ livereload_rails (1.0.0)
5
+ filewatcher
6
+ nio4r
7
+ puma
8
+ rack-livereload
9
+ railties (~> 4.0)
10
+ websocket
11
+
12
+ GEM
13
+ remote: https://rubygems.org/
14
+ specs:
15
+ actionmailer (4.2.1)
16
+ actionpack (= 4.2.1)
17
+ actionview (= 4.2.1)
18
+ activejob (= 4.2.1)
19
+ mail (~> 2.5, >= 2.5.4)
20
+ rails-dom-testing (~> 1.0, >= 1.0.5)
21
+ actionpack (4.2.1)
22
+ actionview (= 4.2.1)
23
+ activesupport (= 4.2.1)
24
+ rack (~> 1.6)
25
+ rack-test (~> 0.6.2)
26
+ rails-dom-testing (~> 1.0, >= 1.0.5)
27
+ rails-html-sanitizer (~> 1.0, >= 1.0.1)
28
+ actionview (4.2.1)
29
+ activesupport (= 4.2.1)
30
+ builder (~> 3.1)
31
+ erubis (~> 2.7.0)
32
+ rails-dom-testing (~> 1.0, >= 1.0.5)
33
+ rails-html-sanitizer (~> 1.0, >= 1.0.1)
34
+ activejob (4.2.1)
35
+ activesupport (= 4.2.1)
36
+ globalid (>= 0.3.0)
37
+ activemodel (4.2.1)
38
+ activesupport (= 4.2.1)
39
+ builder (~> 3.1)
40
+ activerecord (4.2.1)
41
+ activemodel (= 4.2.1)
42
+ activesupport (= 4.2.1)
43
+ arel (~> 6.0)
44
+ activesupport (4.2.1)
45
+ i18n (~> 0.7)
46
+ json (~> 1.7, >= 1.7.7)
47
+ minitest (~> 5.1)
48
+ thread_safe (~> 0.3, >= 0.3.4)
49
+ tzinfo (~> 1.1)
50
+ arel (6.0.0)
51
+ builder (3.2.2)
52
+ erubis (2.7.0)
53
+ filewatcher (0.5.1)
54
+ trollop (~> 2.0)
55
+ globalid (0.3.5)
56
+ activesupport (>= 4.1.0)
57
+ i18n (0.7.0)
58
+ json (1.8.2)
59
+ loofah (2.0.2)
60
+ nokogiri (>= 1.5.9)
61
+ mail (2.6.3)
62
+ mime-types (>= 1.16, < 3)
63
+ mime-types (2.6.1)
64
+ mini_portile (0.6.2)
65
+ minitest (5.7.0)
66
+ nio4r (1.1.0)
67
+ nokogiri (1.6.6.2)
68
+ mini_portile (~> 0.6.0)
69
+ puma (2.11.3)
70
+ rack (>= 1.1, < 2.0)
71
+ rack (1.6.1)
72
+ rack-livereload (0.3.15)
73
+ rack
74
+ rack-test (0.6.3)
75
+ rack (>= 1.0)
76
+ rails (4.2.1)
77
+ actionmailer (= 4.2.1)
78
+ actionpack (= 4.2.1)
79
+ actionview (= 4.2.1)
80
+ activejob (= 4.2.1)
81
+ activemodel (= 4.2.1)
82
+ activerecord (= 4.2.1)
83
+ activesupport (= 4.2.1)
84
+ bundler (>= 1.3.0, < 2.0)
85
+ railties (= 4.2.1)
86
+ sprockets-rails
87
+ rails-deprecated_sanitizer (1.0.3)
88
+ activesupport (>= 4.2.0.alpha)
89
+ rails-dom-testing (1.0.6)
90
+ activesupport (>= 4.2.0.beta, < 5.0)
91
+ nokogiri (~> 1.6.0)
92
+ rails-deprecated_sanitizer (>= 1.0.1)
93
+ rails-html-sanitizer (1.0.2)
94
+ loofah (~> 2.0)
95
+ railties (4.2.1)
96
+ actionpack (= 4.2.1)
97
+ activesupport (= 4.2.1)
98
+ rake (>= 0.8.7)
99
+ thor (>= 0.18.1, < 2.0)
100
+ rake (10.4.2)
101
+ sprockets (3.1.0)
102
+ rack (~> 1.0)
103
+ sprockets-rails (2.3.1)
104
+ actionpack (>= 3.0)
105
+ activesupport (>= 3.0)
106
+ sprockets (>= 2.8, < 4.0)
107
+ thor (0.19.1)
108
+ thread_safe (0.3.5)
109
+ trollop (2.1.2)
110
+ tzinfo (1.2.2)
111
+ thread_safe (~> 0.1)
112
+ websocket (1.2.2)
113
+
114
+ PLATFORMS
115
+ ruby
116
+
117
+ DEPENDENCIES
118
+ livereload_rails!
119
+ rails (= 4.2.1)
data/example/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require File.expand_path('../config/application', __FILE__)
5
+
6
+ Rails.application.load_tasks
File without changes
@@ -0,0 +1 @@
1
+ console.log("JS file loaded!");
@@ -0,0 +1,3 @@
1
+ body {
2
+ color: blue;
3
+ }
@@ -0,0 +1,8 @@
1
+ class ApplicationController < ActionController::Base
2
+ # Prevent CSRF attacks by raising an exception.
3
+ # For APIs, you may want to use :null_session instead.
4
+ protect_from_forgery with: :exception
5
+
6
+ def home
7
+ end
8
+ end
@@ -0,0 +1,10 @@
1
+ <p>
2
+ You may change the CSS, HTML or JS of this page and the page will reload accordingly!
3
+ </p>
4
+
5
+ <p>See:</p>
6
+ <ul>
7
+ <li>app/views/application/home.html.erb</li>
8
+ <li>app/assets/stylesheets/application.css</li>
9
+ <li>app/assets/javascripts/application.js</li>
10
+ </ul>
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Example</title>
5
+ <%= stylesheet_link_tag 'application', media: 'all' %>
6
+ <%= javascript_include_tag 'application' %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3
+ load Gem.bin_path('bundler', 'bundle')
data/example/bin/rails ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
3
+ require_relative '../config/boot'
4
+ require 'rails/commands'
data/example/bin/rake ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative '../config/boot'
3
+ require 'rake'
4
+ Rake.application.run
data/example/bin/setup ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ require 'pathname'
3
+
4
+ # path to your application root.
5
+ APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
6
+
7
+ Dir.chdir APP_ROOT do
8
+ # This script is a starting point to setup your application.
9
+ # Add necessary setup steps to this file:
10
+
11
+ puts "== Installing dependencies =="
12
+ system "gem install bundler --conservative"
13
+ system "bundle check || bundle install"
14
+
15
+ # puts "\n== Copying sample files =="
16
+ # unless File.exist?("config/database.yml")
17
+ # system "cp config/database.yml.sample config/database.yml"
18
+ # end
19
+
20
+ puts "\n== Preparing database =="
21
+ system "bin/rake db:setup"
22
+
23
+ puts "\n== Removing old logs and tempfiles =="
24
+ system "rm -f log/*"
25
+ system "rm -rf tmp/cache"
26
+
27
+ puts "\n== Restarting application server =="
28
+ system "touch tmp/restart.txt"
29
+ end
data/example/config.ru ADDED
@@ -0,0 +1,4 @@
1
+ # This file is used by Rack-based servers to start the application.
2
+
3
+ require ::File.expand_path('../config/environment', __FILE__)
4
+ run Rails.application
@@ -0,0 +1,26 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ require "rails"
4
+ require "action_controller/railtie"
5
+ require "action_view/railtie"
6
+ require "sprockets/railtie"
7
+
8
+ # Require the gems listed in Gemfile, including any gems
9
+ # you've limited to :test, :development, or :production.
10
+ Bundler.require(*Rails.groups)
11
+
12
+ module Example
13
+ class Application < Rails::Application
14
+ # Settings in config/environments/* take precedence over those specified here.
15
+ # Application configuration should go into files in config/initializers
16
+ # -- all .rb files in that directory are automatically loaded.
17
+
18
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
19
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
20
+ # config.time_zone = 'Central Time (US & Canada)'
21
+
22
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
23
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
24
+ # config.i18n.default_locale = :de
25
+ end
26
+ end
@@ -0,0 +1,3 @@
1
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
2
+
3
+ require 'bundler/setup' # Set up gems listed in the Gemfile.
@@ -0,0 +1,5 @@
1
+ # Load the Rails application.
2
+ require File.expand_path('../application', __FILE__)
3
+
4
+ # Initialize the Rails application.
5
+ Rails.application.initialize!
@@ -0,0 +1,35 @@
1
+ Rails.application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb.
3
+
4
+ # In the development environment your application's code is reloaded on
5
+ # every request. This slows down response time but is perfect for development
6
+ # since you don't have to restart the web server when you make code changes.
7
+ config.cache_classes = false
8
+
9
+ # Do not eager load code on boot.
10
+ config.eager_load = false
11
+
12
+ # Show full error reports and disable caching.
13
+ config.consider_all_requests_local = true
14
+ config.action_controller.perform_caching = false
15
+
16
+ # Print deprecation notices to the Rails logger.
17
+ config.active_support.deprecation = :log
18
+
19
+ # Debug mode disables concatenation and preprocessing of assets.
20
+ # This option may cause significant delays in view rendering with a large
21
+ # number of complex assets.
22
+ config.assets.debug = true
23
+
24
+ # Asset digests allow you to set far-future HTTP expiration dates on all assets,
25
+ # yet still be able to expire them through the digest params.
26
+ config.assets.digest = true
27
+
28
+ # Adds additional error checking when serving assets at runtime.
29
+ # Checks for improperly declared sprockets dependencies.
30
+ # Raises helpful error messages.
31
+ config.assets.raise_runtime_errors = true
32
+
33
+ # Raises error for missing translations
34
+ # config.action_view.raise_on_missing_translations = true
35
+ end