Skip to content

Commit

Permalink
Adds rails 4 support. Switch client-side to coffee script. Bump versi…
Browse files Browse the repository at this point in the history
…on since these changes are incompatible. Adds coffeescript support in generator
  • Loading branch information
elthariel committed Oct 26, 2013
1 parent f8c8dc0 commit 76646fc
Show file tree
Hide file tree
Showing 10 changed files with 107 additions and 83 deletions.
127 changes: 62 additions & 65 deletions Gemfile.lock
@@ -1,98 +1,95 @@
PATH PATH
remote: . remote: .
specs: specs:
rails-client-logger (0.0.2) rails-client-logger (1.0.0)
rails (>= 3.1) rails (>= 4.0)


GEM GEM
remote: http://rubygems.org/ remote: http://rubygems.org/
specs: specs:
actionmailer (3.2.11) actionmailer (4.0.0)
actionpack (= 3.2.11) actionpack (= 4.0.0)
mail (~> 2.4.4) mail (~> 2.5.3)
actionpack (3.2.11) actionpack (4.0.0)
activemodel (= 3.2.11) activesupport (= 4.0.0)
activesupport (= 3.2.11) builder (~> 3.1.0)
builder (~> 3.0.0)
erubis (~> 2.7.0) erubis (~> 2.7.0)
journey (~> 1.0.4) rack (~> 1.5.2)
rack (~> 1.4.0) rack-test (~> 0.6.2)
rack-cache (~> 1.2) activemodel (4.0.0)
rack-test (~> 0.6.1) activesupport (= 4.0.0)
sprockets (~> 2.2.1) builder (~> 3.1.0)
activemodel (3.2.11) activerecord (4.0.0)
activesupport (= 3.2.11) activemodel (= 4.0.0)
builder (~> 3.0.0) activerecord-deprecated_finders (~> 1.0.2)
activerecord (3.2.11) activesupport (= 4.0.0)
activemodel (= 3.2.11) arel (~> 4.0.0)
activesupport (= 3.2.11) activerecord-deprecated_finders (1.0.3)
arel (~> 3.0.2) activesupport (4.0.0)
tzinfo (~> 0.3.29) i18n (~> 0.6, >= 0.6.4)
activeresource (3.2.11) minitest (~> 4.2)
activemodel (= 3.2.11) multi_json (~> 1.3)
activesupport (= 3.2.11) thread_safe (~> 0.1)
activesupport (3.2.11) tzinfo (~> 0.3.37)
i18n (~> 0.6) arel (4.0.1)
multi_json (~> 1.0) atomic (1.1.14)
arel (3.0.2) builder (3.1.4)
builder (3.0.4)
erubis (2.7.0) erubis (2.7.0)
hike (1.2.1) hike (1.2.3)
i18n (0.6.1) i18n (0.6.5)
journey (1.0.4)
jquery-rails (2.2.0) jquery-rails (2.2.0)
railties (>= 3.0, < 5.0) railties (>= 3.0, < 5.0)
thor (>= 0.14, < 2.0) thor (>= 0.14, < 2.0)
json (1.7.6) mail (2.5.4)
mail (2.4.4)
i18n (>= 0.4.0)
mime-types (~> 1.16) mime-types (~> 1.16)
treetop (~> 1.4.8) treetop (~> 1.4.8)
mime-types (1.20.1) mime-types (1.25)
multi_json (1.5.0) minitest (4.7.5)
multi_json (1.8.2)
polyglot (0.3.3) polyglot (0.3.3)
rack (1.4.4) protected_attributes (1.0.3)
rack-cache (1.2) activemodel (>= 4.0.0, < 5.0)
rack (>= 0.4) rack (1.5.2)
rack-ssl (1.3.3)
rack
rack-test (0.6.2) rack-test (0.6.2)
rack (>= 1.0) rack (>= 1.0)
rails (3.2.11) rails (4.0.0)
actionmailer (= 3.2.11) actionmailer (= 4.0.0)
actionpack (= 3.2.11) actionpack (= 4.0.0)
activerecord (= 3.2.11) activerecord (= 4.0.0)
activeresource (= 3.2.11) activesupport (= 4.0.0)
activesupport (= 3.2.11) bundler (>= 1.3.0, < 2.0)
bundler (~> 1.0) railties (= 4.0.0)
railties (= 3.2.11) sprockets-rails (~> 2.0.0)
railties (3.2.11) railties (4.0.0)
actionpack (= 3.2.11) actionpack (= 4.0.0)
activesupport (= 3.2.11) activesupport (= 4.0.0)
rack-ssl (~> 1.3.2)
rake (>= 0.8.7) rake (>= 0.8.7)
rdoc (~> 3.4) thor (>= 0.18.1, < 2.0)
thor (>= 0.14.6, < 2.0) rake (10.1.0)
rake (10.0.3) sprockets (2.10.0)
rdoc (3.12)
json (~> 1.4)
sprockets (2.2.2)
hike (~> 1.2) hike (~> 1.2)
multi_json (~> 1.0) multi_json (~> 1.0)
rack (~> 1.0) rack (~> 1.0)
tilt (~> 1.1, != 1.3.0) tilt (~> 1.1, != 1.3.0)
sprockets-rails (2.0.1)
actionpack (>= 3.0)
activesupport (>= 3.0)
sprockets (~> 2.8)
sqlite3 (1.3.7) sqlite3 (1.3.7)
thor (0.17.0) thor (0.18.1)
tilt (1.3.3) thread_safe (0.1.3)
treetop (1.4.12) atomic
tilt (1.4.1)
treetop (1.4.15)
polyglot polyglot
polyglot (>= 0.3.1) polyglot (>= 0.3.1)
tzinfo (0.3.35) tzinfo (0.3.38)


PLATFORMS PLATFORMS
ruby ruby


DEPENDENCIES DEPENDENCIES
jquery-rails jquery-rails
protected_attributes
rails-client-logger! rails-client-logger!
sqlite3 sqlite3
9 changes: 7 additions & 2 deletions README.md
@@ -1,3 +1,8 @@
# About this fork

This forks adds Rails 4 support (permitted parameters) as well as a
CoffeeScript implementation of the client-side code.

# What is that for? # What is that for?


Rails engine to log from Client side (Browser) javascript to server log file. To catch those nasty production Javascript errors. Provides a variety of safe logging functions e.g. jsLogger.debug(), jsLogger.error(). Rails engine to log from Client side (Browser) javascript to server log file. To catch those nasty production Javascript errors. Provides a variety of safe logging functions e.g. jsLogger.debug(), jsLogger.error().
Expand All @@ -11,7 +16,7 @@ Add this line to your application's Gemfile:
```ruby ```ruby
gem 'rails-client-logger' gem 'rails-client-logger'
``` ```

And then execute: And then execute:


```bash ```bash
Expand All @@ -32,7 +37,7 @@ $ rails g rails_client_logger
jsLogger.info("simple info message"); jsLogger.info("simple info message");
jsLogger.warn("a warning"); jsLogger.warn("a warning");
``` ```

### Log Error ### Log Error


```ruby ```ruby
Expand Down
Expand Up @@ -8,5 +8,9 @@ def log
head :bad_request head :bad_request
end end
end end

def log_params
params.permit(:level, :message)
end
end end
end end
@@ -1,19 +1,34 @@
class RailsClientLoggerGenerator < Rails::Generators::Base class RailsClientLoggerGenerator < Rails::Generators::Base
source_root File.expand_path('../templates', __FILE__) source_root File.expand_path('../templates', __FILE__)

desc "inserts required routes and requires the javascript files" desc "inserts required routes and requires the javascript files"
def generate def generate
# add route # add route
route(%Q{mount RailsClientLogger::Engine, :at => "logger"}) route(%Q{mount RailsClientLogger::Engine, :at => "logger"})


mode = :coffee
if File.exists? "app/assets/javascripts/application.js.coffee"
path = "app/assets/javascripts/application.js.coffee"
elsif File.exists? "app/assets/javascripts/application.coffee"
path = "app/assets/javascripts/application.coffee"
elsif File.exists? "app/assets/javascripts/application.js"
mode = :js
path = "app/assets/javascripts/application.js"
end

# add to application.js manifest # add to application.js manifest
original_js = File.binread("app/assets/javascripts/application.js") original = File.binread(path)
if original_js.include?("require rails_client_logger") if original.include?("require rails_client_logger")
say_status("skipped", "insert into app/assets/javascripts/application.js", :yellow) say_status("skipped", "insert into #{path}", :yellow)
else else
insert_into_file "app/assets/javascripts/application.js", :after => %r{//= require ['"]?jquery['"]?\s*$} do if mode == :coffee
insert_into_file path, :after => %r{#= require ['"]?jquery['"]?\s*$} do
"\n#= require rails_client_logger"
else
insert_into_file path, :after => %r{//= require ['"]?jquery['"]?\s*$} do
"\n//= require rails_client_logger" "\n//= require rails_client_logger"
end end
end
end end
end end
end end
2 changes: 1 addition & 1 deletion lib/rails-client-logger/version.rb
@@ -1,3 +1,3 @@
module RailsClientLogger module RailsClientLogger
VERSION = "0.0.2" VERSION = "1.0.0"
end end
7 changes: 4 additions & 3 deletions rails-client-logger.gemspec
Expand Up @@ -7,17 +7,18 @@ require "rails-client-logger/version"
Gem::Specification.new do |s| Gem::Specification.new do |s|
s.name = "rails-client-logger" s.name = "rails-client-logger"
s.version = RailsClientLogger::VERSION s.version = RailsClientLogger::VERSION
s.authors = ["Girish Sonawane"] s.authors = ["Girish Sonawane", "Julien 'Lta' Ballet"]
s.email = ["girish.sonawane@gmail.com"] s.email = ["girish.sonawane@gmail.com", "elthariel@gmail.com"]
s.homepage = "https://github.com/girishso/rails-client-logger" s.homepage = "https://github.com/girishso/rails-client-logger"
s.summary = "Rails engine for logging from Browser Javascript to server" s.summary = "Rails engine for logging from Browser Javascript to server"
s.description = "Rails engine for logging from Browser Javascript to server" s.description = "Rails engine for logging from Browser Javascript to server"


s.files = Dir["{app,config,db,lib,vendor}/**/*"] + ["MIT-LICENSE", "Rakefile", "README.md"] s.files = Dir["{app,config,db,lib,vendor}/**/*"] + ["MIT-LICENSE", "Rakefile", "README.md"]
s.test_files = Dir["test/**/*"] s.test_files = Dir["test/**/*"]


s.add_dependency "rails", ">= 3.1" s.add_dependency "rails", ">= 4.0"
# s.add_dependency "jquery-rails" # s.add_dependency "jquery-rails"


s.add_development_dependency "sqlite3" s.add_development_dependency "sqlite3"
s.add_development_dependency "protected_attributes"
end end
2 changes: 2 additions & 0 deletions test/dummy/config/application.rb
Expand Up @@ -54,6 +54,8 @@ class Application < Rails::Application


# Version of your assets, change this if you want to expire all your assets # Version of your assets, change this if you want to expire all your assets
config.assets.version = '1.0' config.assets.version = '1.0'

config.secret_key_base = "ThisIsADummyAppSoLeaveMeAlone"
end end
end end


8 changes: 4 additions & 4 deletions test/dummy/config/environments/test.rb
Expand Up @@ -11,9 +11,6 @@
config.serve_static_assets = true config.serve_static_assets = true
config.static_cache_control = "public, max-age=3600" config.static_cache_control = "public, max-age=3600"


# Log error messages when you accidentally call methods on nil
config.whiny_nils = true

# Show full error reports and disable caching # Show full error reports and disable caching
config.consider_all_requests_local = true config.consider_all_requests_local = true
config.action_controller.perform_caching = false config.action_controller.perform_caching = false
Expand All @@ -30,8 +27,11 @@
config.action_mailer.delivery_method = :test config.action_mailer.delivery_method = :test


# Raise exception on mass assignment protection for Active Record models # Raise exception on mass assignment protection for Active Record models
config.active_record.mass_assignment_sanitizer = :strict # config.active_record.mass_assignment_sanitizer = :strict


# Print deprecation notices to the stderr # Print deprecation notices to the stderr
config.active_support.deprecation = :stderr config.active_support.deprecation = :stderr

# Rails 4 new stuff
config.eager_load = false
end end
Empty file added test/dummy/db/.gitkeep
Empty file.
2 changes: 1 addition & 1 deletion test/functional/js_logger/js_loggers_controller_test.rb
Expand Up @@ -6,6 +6,6 @@ class JsLoggersControllerTest < ActionController::TestCase
get :log get :log
assert_response :success assert_response :success
end end

end end
end end

0 comments on commit 76646fc

Please sign in to comment.