gauges-rails 0.0.1 → 0.2.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,20 @@
1
+ *.gem
2
+ *.rbc
3
+ *.swp
4
+ .bundle
5
+ .config
6
+ .rvmrc
7
+ .yardoc
8
+ Gemfile.lock
9
+ InstalledFiles
10
+ _yardoc
11
+ bin
12
+ coverage
13
+ doc/
14
+ lib/bundler/man
15
+ pkg
16
+ rdoc
17
+ spec/reports
18
+ test/tmp
19
+ test/version_tmp
20
+ tmp
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile CHANGED
@@ -1,2 +1,3 @@
1
- source "http://rubygems.org"
1
+ source 'https://rubygems.org'
2
+
2
3
  gemspec
@@ -1,4 +1,6 @@
1
- Copyright 2011 Jason Coene
1
+ Copyright (c) 2012 Tyler Hunt
2
+
3
+ MIT License
2
4
 
3
5
  Permission is hereby granted, free of charge, to any person obtaining
4
6
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -1,36 +1,54 @@
1
- # Gauges-rails
1
+ # Gauges::Rails
2
+
3
+ A Rails engine to add [Gauges][] tracking code to Rails apps.
4
+
5
+ [gauges]: http://gaug.es/
2
6
 
3
- Easily (and neatly) add Gaug.es to your Rails 3 application!
4
7
 
5
8
  ## Installation
6
9
 
7
- **First, add gauges-rails to your Gemfile:**
10
+ Add this line to your application's Gemfile:
8
11
 
9
12
  gem 'gauges-rails'
10
13
 
11
- **Next, set your Gaug.es site id in your config/application.rb file:**
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install gauges-rails
21
+
22
+
23
+ ## Configuration
24
+
25
+ Set your Gauges site ID in the `config/application.rb` file:
26
+
27
+ config.gauges.site_id = GAUGES_SITE_ID
28
+
29
+ Your site ID can be found on the Gauges dashboard under "Tracking Code".
12
30
 
13
- # Set our Gaug.es site id
14
- config.gauges.site_id = 'YOUR_SITE_ID_HERE'
15
31
 
16
- You can obtain the site id from your Gaug.es dashboard. It should resemble an MD5 hash.
32
+ ## Usage
17
33
 
18
- **Finally, include the tracking code in one of your views.**
34
+ Include the JavaScript tracking code at the bottom of your layout template:
19
35
 
20
- You can do this in a layout file (typically app/views/layouts/application.html.erb), or on a per-view basis (such as in app/views/dingdongs/index.html.erb). Insert the code as follows:
36
+ <%= javascript_include_tag('gauges') %>
21
37
 
22
- <%= gauges_tracking_code %>
38
+ Or, if your template is using Haml:
23
39
 
24
- *Gauges-rails should work fine with any view template engine. For instancing, HAML users will want to use:*
40
+ = javascript_include_tag('gauges')
25
41
 
26
- = gauges_tracking_code
27
42
 
28
- ## Customization
43
+ ## Contributing
29
44
 
30
- ### Using more than one site id
45
+ 1. Fork it.
46
+ 2. Create your feature branch (`git checkout -b my-new-feature`).
47
+ 3. Commit your changes (`git commit -am 'Added some feature'`).
48
+ 4. Push to the branch (`git push origin my-new-feature`).
49
+ 5. Create a new Pull Request.
31
50
 
32
- You can pass a hash of arguments to the *gauges_tracking_code* helper method. Example:
33
51
 
34
- <%= gauges_tracking_code :site_id => 'MY_CUSTOM_SITE_ID_HERE' %>
52
+ ## Copyright
35
53
 
36
- That's all for now, folks!
54
+ Copyright © 2012 Tyler Hunt. See LICENSE for details.
data/Rakefile CHANGED
@@ -1,34 +1,3 @@
1
- # encoding: UTF-8
2
- require 'rubygems'
3
- begin
4
- require 'bundler/setup'
5
- rescue LoadError
6
- puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
7
- end
1
+ #!/usr/bin/env rake
8
2
 
9
- $LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
10
- require 'gauges/rails/version'
11
-
12
- require 'rake'
13
-
14
- require 'rspec/core'
15
- require 'rspec/core/rake_task'
16
-
17
- RSpec::Core::RakeTask.new(:spec)
18
-
19
- task :build do
20
- system "gem build gauges-rails.gemspec"
21
- end
22
-
23
- task :install => :build do
24
- system "gem install gauges-rails-#{Gauges::Rails::VERSION}.gem"
25
- end
26
-
27
- task :release => :build do
28
- system "git tag -a #{Gauges::Rails::VERSION} -m 'Tagging #{Gauges::Rails::VERSION}'"
29
- system "git push --tags"
30
- system "gem push gauges-rails-#{Gauges::Rails::VERSION}.gem"
31
- system "rm gauges-rails-#{Gauges::Rails::VERSION}.gem"
32
- end
33
-
34
- task :default => :spec
3
+ require 'bundler/gem_tasks'
@@ -0,0 +1,20 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/gauges/rails/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ['Tyler Hunt']
6
+ gem.email = ['tyler@tylerhunt.com']
7
+ gem.description = %q{An engine to add Gauges tracking code to Rails apps.}
8
+ gem.summary = %q{An engine to add Gauges tracking code to Rails apps.}
9
+ gem.homepage = 'http://github.com/tylerhunt/gauges-rails'
10
+
11
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
12
+ gem.files = `git ls-files`.split("\n")
13
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
14
+ gem.name = 'gauges-rails'
15
+ gem.require_paths = ['lib']
16
+ gem.version = Gauges::Rails::VERSION
17
+
18
+ gem.add_dependency 'rails', '~> 3.1'
19
+ gem.add_development_dependency 'rspec', '~> 2.0'
20
+ end
@@ -1 +1 @@
1
- require 'gauges/rails/railtie' if defined?(Rails)
1
+ require 'gauges/rails/engine'
@@ -0,0 +1,10 @@
1
+ require 'gauges/rails/version'
2
+
3
+ module Gauges
4
+ module Rails
5
+ class Engine < ::Rails::Engine
6
+ config.gauges = ActiveSupport::OrderedOptions.new
7
+ config.gauges.site_id = nil
8
+ end
9
+ end
10
+ end
@@ -1,5 +1,5 @@
1
1
  module Gauges
2
2
  module Rails
3
- VERSION = '0.0.1'
3
+ VERSION = '0.2.0'
4
4
  end
5
5
  end
@@ -0,0 +1,35 @@
1
+ require 'spec_helper'
2
+
3
+ describe Gauges::Rails::Engine do
4
+ let(:site_id) { SecureRandom.hex(12) }
5
+
6
+ subject { described_class }
7
+
8
+ context 'configuration' do
9
+ subject { GaugesRailsTestApp.config.gauges }
10
+
11
+ it { should be_a(ActiveSupport::OrderedOptions) }
12
+
13
+ its(:site_id) { should be_nil }
14
+
15
+ context 'site_id=' do
16
+ specify do
17
+ subject.site_id = site_id
18
+ expect { subject.site_id = nil }.to change(subject, :site_id).to(nil)
19
+ end
20
+ end
21
+ end
22
+
23
+ describe 'assets' do
24
+ include Rack::Test::Methods
25
+
26
+ let(:app) { GaugesRailsTestApp }
27
+
28
+ before { GaugesRailsTestApp.config.gauges.site_id = site_id }
29
+
30
+ it 'interpolates the site_id' do
31
+ get '/assets/gauges.js'
32
+ last_response.body.should include(site_id)
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,20 @@
1
+ require 'rails'
2
+ require 'active_support/core_ext/numeric'
3
+ require 'action_controller/railtie'
4
+ require 'sprockets/railtie'
5
+
6
+ require 'gauges/rails'
7
+
8
+ GaugesRailsTestApp = Class.new(Rails::Application) do
9
+ config.active_support.deprecation = :stderr
10
+ config.secret_token = SecureRandom.uuid
11
+ config.logger = Logger.new('/dev/null')
12
+
13
+ config.assets.enabled = true
14
+ config.assets.cache_store = [:memory_store, :size => 1.megabyte]
15
+ end
16
+
17
+ GaugesRailsTestApp.initialize!
18
+ GaugesRailsTestApp.routes.clear!
19
+
20
+ Rails.application = GaugesRailsTestApp
@@ -0,0 +1,11 @@
1
+ var _gauges = _gauges || [];
2
+ (function() {
3
+ var t = document.createElement('script');
4
+ t.type = 'text/javascript';
5
+ t.async = true;
6
+ t.id = 'gauges-tracker';
7
+ t.setAttribute('data-site-id', '<%= Rails.application.config.gauges.site_id %>');
8
+ t.src = '//secure.gaug.es/track.js';
9
+ var s = document.getElementsByTagName('script')[0];
10
+ s.parentNode.insertBefore(t, s);
11
+ })();
metadata CHANGED
@@ -1,88 +1,60 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gauges-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
8
- - Jason Coene
8
+ - Tyler Hunt
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-08-19 00:00:00.000000000Z
12
+ date: 2012-03-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
16
- requirement: &70180790271600 !ruby/object:Gem::Requirement
16
+ requirement: &70200658128380 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
20
20
  - !ruby/object:Gem::Version
21
- version: 3.1.0.rc
22
- type: :development
23
- prerelease: false
24
- version_requirements: *70180790271600
25
- - !ruby/object:Gem::Dependency
26
- name: rspec-rails
27
- requirement: &70180790269660 !ruby/object:Gem::Requirement
28
- none: false
29
- requirements:
30
- - - ~>
31
- - !ruby/object:Gem::Version
32
- version: 2.6.1
33
- type: :development
34
- prerelease: false
35
- version_requirements: *70180790269660
36
- - !ruby/object:Gem::Dependency
37
- name: capybara
38
- requirement: &70180790267680 !ruby/object:Gem::Requirement
39
- none: false
40
- requirements:
41
- - - ~>
42
- - !ruby/object:Gem::Version
43
- version: 1.0.1
44
- type: :development
21
+ version: '3.1'
22
+ type: :runtime
45
23
  prerelease: false
46
- version_requirements: *70180790267680
24
+ version_requirements: *70200658128380
47
25
  - !ruby/object:Gem::Dependency
48
- name: sqlite3
49
- requirement: &70180790256520 !ruby/object:Gem::Requirement
26
+ name: rspec
27
+ requirement: &70200658127860 !ruby/object:Gem::Requirement
50
28
  none: false
51
29
  requirements:
52
30
  - - ~>
53
31
  - !ruby/object:Gem::Version
54
- version: 1.3.4
32
+ version: '2.0'
55
33
  type: :development
56
34
  prerelease: false
57
- version_requirements: *70180790256520
58
- - !ruby/object:Gem::Dependency
59
- name: launchy
60
- requirement: &70180790255000 !ruby/object:Gem::Requirement
61
- none: false
62
- requirements:
63
- - - ~>
64
- - !ruby/object:Gem::Version
65
- version: 2.0.5
66
- type: :development
67
- prerelease: false
68
- version_requirements: *70180790255000
69
- description: Simple helper to add Gaug.es support to your Rails application.
35
+ version_requirements: *70200658127860
36
+ description: An engine to add Gauges tracking code to Rails apps.
70
37
  email:
71
- - jcoene@gmail.com
38
+ - tyler@tylerhunt.com
72
39
  executables: []
73
40
  extensions: []
74
41
  extra_rdoc_files: []
75
42
  files:
76
- - lib/gauges/rails/helper.rb
77
- - lib/gauges/rails/railtie.rb
78
- - lib/gauges/rails/version.rb
79
- - lib/gauges/rails.rb
80
- - lib/gauges-rails.rb
81
- - MIT-LICENSE
82
- - Rakefile
43
+ - .gitignore
44
+ - .rspec
83
45
  - Gemfile
46
+ - LICENSE
84
47
  - README.md
85
- homepage: http://github.com/jcoene/gauges-rails
48
+ - Rakefile
49
+ - gauges-rails.gemspec
50
+ - lib/gauges-rails.rb
51
+ - lib/gauges/rails.rb
52
+ - lib/gauges/rails/engine.rb
53
+ - lib/gauges/rails/version.rb
54
+ - spec/gauges-rails_spec.rb
55
+ - spec/spec_helper.rb
56
+ - vendor/assets/javascripts/gauges.js.erb
57
+ homepage: http://github.com/tylerhunt/gauges-rails
86
58
  licenses: []
87
59
  post_install_message:
88
60
  rdoc_options: []
@@ -94,22 +66,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
94
66
  - - ! '>='
95
67
  - !ruby/object:Gem::Version
96
68
  version: '0'
97
- segments:
98
- - 0
99
- hash: -3602843286404034390
100
69
  required_rubygems_version: !ruby/object:Gem::Requirement
101
70
  none: false
102
71
  requirements:
103
72
  - - ! '>='
104
73
  - !ruby/object:Gem::Version
105
74
  version: '0'
106
- segments:
107
- - 0
108
- hash: -3602843286404034390
109
75
  requirements: []
110
76
  rubyforge_project:
111
77
  rubygems_version: 1.8.6
112
78
  signing_key:
113
79
  specification_version: 3
114
- summary: Use Gaug.es with your Rails app.
115
- test_files: []
80
+ summary: An engine to add Gauges tracking code to Rails apps.
81
+ test_files:
82
+ - spec/gauges-rails_spec.rb
83
+ - spec/spec_helper.rb
@@ -1,15 +0,0 @@
1
- module Gauges
2
- module Rails
3
- module Helper
4
- def gauges_tracking_code(options={})
5
- options[:site_id] = ::Rails.application.config.gauges.site_id unless options.key?(:site_id)
6
- if options[:site_id].nil?
7
- raise "Please set a Gaug.es site ID in your application configuration or as an argument to gauges_tracking_code, example: gauges_tracking_code(:site_id => '12345')"
8
- else
9
- "<script type=\"text/javascript\"> var _gauges = _gauges || []; (function() { var t = document.createElement('script'); t.type = 'text/javascript'; t.async = true; t.id = 'gauges-tracker'; t.setAttribute('data-site-id', '#{options[:site_id]}'); t.src = '//secure.gaug.es/track.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(t, s); })(); </script>".html_safe
10
- end
11
- end
12
- end
13
- end
14
- end
15
-
@@ -1,19 +0,0 @@
1
- require 'rails/railtie'
2
- require 'gauges/rails/helper'
3
-
4
- module Gauges
5
- module Rails
6
- class Railtie < ::Rails::Railtie
7
-
8
- config.gauges = ActiveSupport::OrderedOptions.new
9
- config.gauges.site_id = nil
10
-
11
- initializer :setup_gauges_rails do |app|
12
- ActiveSupport.on_load(:action_view) do
13
- include Gauges::Rails::Helper
14
- end
15
- end
16
-
17
- end
18
- end
19
- end