Skip to content

Commit

Permalink
Merge pull request #38 from splitrb/update-hash-syntax
Browse files Browse the repository at this point in the history
Fix Rubocop Style/HashSyntax: Use the new Ruby 1.9 hash syntax
  • Loading branch information
andrehjr authored Feb 22, 2022
2 parents 46976fb + 1617b8b commit f08588d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ require 'rspec/core/rake_task'

RSpec::Core::RakeTask.new('spec')

task :default => :spec
task default: :spec
22 changes: 11 additions & 11 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ The split gem and its dependencies.
If you are using bundler add split to your Gemfile:

```ruby
gem 'split-analytics', :require => 'split/analytics'
gem 'split-analytics', require: 'split/analytics'
```

Then run:
Expand Down Expand Up @@ -45,13 +45,13 @@ Use in your application layout template
erb example:

```erb
<%= tracking_code(:account => 'UA-12345-6') %>
<%= tracking_code(account: 'UA-12345-6') %>
```

haml example:

```haml
= tracking_code(:account => 'UA-12345-6')
= tracking_code(account: 'UA-12345-6')
```

### With Tracking Methods
Expand All @@ -60,23 +60,23 @@ See [Google Analytics Tracking Methods](https://developers.google.com/analytics/

```ruby
tracker_methods = {
:setDomainName => "example.com", # String argument
:setAllowLinker => true, # Boolean argument
:require => ['inpage_linkid', '//www.google-analytics.com/plugins/ga/inpage_linkid.js'] # Array argument (will be splattered)
:clearOrganic => "" # No argument
setDomainName: "example.com", # String argument
setAllowLinker: true, # Boolean argument
require: ['inpage_linkid', '//www.google-analytics.com/plugins/ga/inpage_linkid.js'] # Array argument (will be splattered)
clearOrganic: "" # No argument
}
```

erb example:

```erb
<%= tracking_code(:account => 'UA-12345-6', :tracker_methods => tracker_methods) %>
<%= tracking_code(account: 'UA-12345-6', tracker_methods: tracker_methods) %>
```

haml example:

```haml
= tracking_code(:account => 'UA-12345-6', :tracker_methods => tracker_methods)
= tracking_code(account: 'UA-12345-6', tracker_methods: tracker_methods)
```
### Other Tracking URLs

Expand All @@ -85,13 +85,13 @@ You can use other Tracking URLs with the option tracker_url and ssl_tracker_url.
erb example:

```erb
<%= tracking_code(:account => 'UA-12345-6', :tracker_url => 'stats.g.doubleclick.net/dc.js', :ssl_tracker_url => 'stats.g.doubleclick.net/dc.js') %>
<%= tracking_code(account: 'UA-12345-6', tracker_url: 'stats.g.doubleclick.net/dc.js', ssl_tracker_url: 'stats.g.doubleclick.net/dc.js') %>
```

haml example:

```haml
= tracking_code(:account => 'UA-12345-6', :tracker_url => 'stats.g.doubleclick.net/dc.js', :ssl_tracker_url => 'stats.g.doubleclick.net/dc.js')
= tracking_code(account: 'UA-12345-6', tracker_url: 'stats.g.doubleclick.net/dc.js', ssl_tracker_url: 'stats.g.doubleclick.net/dc.js')
```

## Contributing
Expand Down
4 changes: 2 additions & 2 deletions spec/analytics_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
setAllowLinker: true, # Boolean argument
clearOrganic: '' # No argument
}
tracking_code = tracking_code(:account => 'UA-12345-6', :tracker_methods => tracker_methods)
tracking_code = tracking_code(account: 'UA-12345-6', tracker_methods: tracker_methods)
expect(tracking_code).to eql(%Q{ <script type=\"text/javascript\">\n var _gaq = _gaq || [];\n _gaq.push(["_setAccount", "UA-12345-6"]);\n _gaq.push(["_setDomainName", "example.com"]);\n_gaq.push(["_setAllowLinker", true]);\n_gaq.push(["_clearOrganic"]);\n \n _gaq.push(["_trackPageview"]);\n (function() {\n var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;\n ga.src = ('https:' == document.location.protocol ? 'https://ssl.google-analytics.com/ga.js' : 'http://www.google-analytics.com/ga.js');\n var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);\n })();\n </script>\n})
end

Expand All @@ -26,7 +26,7 @@
end

it 'uses doubleclick as tracker url' do
tracking_code = tracking_code(account: "UA-12345-6", tracker_url: 'stats.g.doubleclick.net/dc.js', :ssl_tracker_url => 'stats.g.doubleclick.net/dc.js')
tracking_code = tracking_code(account: "UA-12345-6", tracker_url: 'stats.g.doubleclick.net/dc.js', ssl_tracker_url: 'stats.g.doubleclick.net/dc.js')
expect(tracking_code).to eql(%Q{ <script type=\"text/javascript\">\n var _gaq = _gaq || [];\n _gaq.push(["_setAccount", "UA-12345-6"]);\n \n \n _gaq.push(["_trackPageview"]);\n (function() {\n var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;\n ga.src = ('https:' == document.location.protocol ? 'https://stats.g.doubleclick.net/dc.js' : 'http://stats.g.doubleclick.net/dc.js');\n var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);\n })();\n </script>\n})
end
end

0 comments on commit f08588d

Please sign in to comment.