supercache 0.3 → 0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 676adc26a6426ea816528343b45cba5d138b5bb3
4
- data.tar.gz: 9381838ba10f5f8bb545f3e7ee4d980da61a2816
3
+ metadata.gz: f9877d354bbde4b23ab391e2503df567b2635c42
4
+ data.tar.gz: 4568f4d4fb3086d1a580a47fd8318f55e78ef6cf
5
5
  SHA512:
6
- metadata.gz: a017596f8b2a7e41b991139ec2ee02a79be064d1966ab21ec749905d4a2ac3aafc0f3119d9e844fe0a66f4b430219d3ed188759d46068dfb89382628eae653f1
7
- data.tar.gz: 11580cf679a08e649c51d2116692d52a0f1abfe88e6bc127046f352ad7b6a0c29802488494904dac9bba14be63e8d94445d5a899d06c886fbd25889f279fb1e6
6
+ metadata.gz: 4b0cdb7cd2ed4788194b9558e210ceee9f903abf691b231bc16cac70c9a255a9f46c888c8ab690e9144cede39eb1a67e6045c6b7c60e81f07abaf45a2d2ccf97
7
+ data.tar.gz: 3c7ab638578e9a1f857003c179f9b21d5d963a1df9fa95ef45ac77df26384940b7ff02b1c667221c6caaab52f3e0de88fd770251a8d022c689eb3057874e73d4
data/.gitignore CHANGED
@@ -7,3 +7,4 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
+ /gemfiles/*.lock
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ supercache
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.3.1
data/.travis.yml CHANGED
@@ -1,4 +1,13 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.2.1
3
+ - 2.2.5
4
+ - 2.3.1
5
+ - ruby-head
6
+
4
7
  before_install: gem install bundler -v 1.10.6
8
+
9
+ gemfile:
10
+ - gemfiles/rails_4.0.gemfile
11
+ - gemfiles/rails_4.1.gemfile
12
+ - gemfiles/rails_4.2.gemfile
13
+ - gemfiles/rails_5.0.gemfile
data/Appraisals ADDED
@@ -0,0 +1,15 @@
1
+ appraise "rails-4.0" do
2
+ gem "rails", "4.0"
3
+ end
4
+
5
+ appraise "rails-4.1" do
6
+ gem "rails", "4.1"
7
+ end
8
+
9
+ appraise "rails-4.2" do
10
+ gem "rails", "4.2"
11
+ end
12
+
13
+ appraise "rails-5.0" do
14
+ gem "rails", "5.0"
15
+ end
data/README.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Supercache
2
2
 
3
+ [![Build Status](https://travis-ci.org/bragboy/supercache.svg?branch=master)](https://travis-ci.org/bragboy/supercache)
4
+ [![Code Climate](https://codeclimate.com/github/bragboy/supercache/badges/gpa.svg)](https://codeclimate.com/github/bragboy/supercache)
5
+ [![security](https://hakiri.io/github/bragboy/supercache/master.svg)](https://hakiri.io/github/bragboy/supercache/master)
6
+
3
7
  Supercache is a totally unobtrusive addon that runs along your Rails application rapidly improving your development time by caching ActiveRecord Queries across requests (unlike ActiveRecord QueryCache which happens only within a single request). This is especially helpful when your local database is located elsewhere and avoids costly DNS lookups for each and every query.
4
8
 
5
9
  ## Installation
@@ -7,7 +11,7 @@ Supercache is a totally unobtrusive addon that runs along your Rails application
7
11
  Add this line to your application’s Gemfile:
8
12
 
9
13
  ```ruby
10
- gem 'supercache'
14
+ gem 'supercache', group: :development
11
15
  ```
12
16
 
13
17
  And mount the dashboard in your `config/routes.rb`:
@@ -24,7 +28,17 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
24
28
 
25
29
  ## Contributing
26
30
 
27
- Bug reports and pull requests are welcome on GitHub at https://github.com/bragboy/supercache. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
31
+ Bug reports and pull requests are welcome on GitHub at https://github.com/bragboy/supercache. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
32
+
33
+ ### Running the tests
34
+
35
+ We're using the
36
+ [appraisal](https://github.com/thoughtbot/appraisal) gem to run our test
37
+ suite against multiple versions of Rails. Type `rake -T` for a complete list of
38
+ available tasks.
39
+
40
+ The RSpec test suite can be run with `rake`, or
41
+ `rake appraisal:rails4.0` to include Rails-specific specs.
28
42
 
29
43
 
30
44
  ## License
@@ -34,8 +48,6 @@ The gem is available as open source under the terms of the [MIT License](http://
34
48
  ## Scope for Contribution
35
49
 
36
50
  1. RSpec Integration
37
- 2. Travis Integration
38
- 3. Code Climate Integration
39
- 4. Moving all assets from CDN to the Gem through Vendor
40
- 5. Add Caching Support for HTTP Requests
41
- 6. Add Exceptions to Caching
51
+ 2. Add Caching Support for HTTP Requests
52
+ 3. Add RSolr Cache
53
+ 4. Add Exceptions to Caching
data/Rakefile CHANGED
@@ -1,6 +1,19 @@
1
+ require "rubygems"
2
+ require "bundler/setup"
1
3
  require "bundler/gem_tasks"
2
4
  require "rspec/core/rake_task"
5
+ require "appraisal"
3
6
 
4
7
  RSpec::Core::RakeTask.new(:spec)
5
8
 
6
- task :default => :spec
9
+ if !ENV["APPRAISAL_INITIALIZED"] && !ENV["TRAVIS"]
10
+ task :default do
11
+ system('bundle exec rake appraisal spec')
12
+ end
13
+ task :test do
14
+ system('bundle exec rake appraisal spec')
15
+ end
16
+ else
17
+ task :default => :spec
18
+ task :test => :spec
19
+ end
@@ -2,11 +2,18 @@ module Supercache
2
2
  class DashboardController < ActionController::Base
3
3
  layout 'supercache/application'
4
4
 
5
+ before_filter :load_cache, only: :flip
6
+
7
+ def index
8
+ @ar_cache = cache.read(:ar_supercache)
9
+ @http_cache = cache.read(:http_supercache)
10
+ end
11
+
5
12
  def flip
6
- if cache.read(:supercache)
7
- cache.delete(:supercache)
13
+ if cache.read(@cache)
14
+ cache.delete(@cache)
8
15
  else
9
- cache.write(:supercache, true)
16
+ cache.write(@cache, true)
10
17
  end
11
18
  redirect_to :root
12
19
  end
@@ -16,5 +23,9 @@ module Supercache
16
23
  def cache
17
24
  Rails.cache
18
25
  end
26
+
27
+ def load_cache
28
+ @cache = params[:cache]
29
+ end
19
30
  end
20
31
  end
@@ -1,17 +1,24 @@
1
1
  <!DOCTYPE html>
2
2
  <head>
3
3
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.7/css/materialize.min.css">
4
+ <style>
5
+ .container{
6
+ max-width: 600px;
7
+ }
8
+ .btn{
9
+ min-width: 90px;
10
+ }
11
+ </style>
4
12
  </head>
5
13
  <body>
6
14
  <br><br><br><br><br>
7
15
  <main>
8
16
  <div class="container">
9
- <center>
10
17
  <%= yield %>
11
- </center>
12
18
  </div>
13
19
  </main>
14
- <script src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
15
- <script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.7/js/materialize.min.js"></script>
20
+ <!-- <script src='https://cdnjs.cloudflare.com/ajax/libs/turbolinks/5.0.0/turbolinks.min.js'></script> -->
21
+ <script src='https://code.jquery.com/jquery-2.1.1.min.js'></script>
22
+ <script src='https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.7/js/materialize.min.js'></script>
16
23
  </body>
17
24
  </html>
@@ -1,13 +1,24 @@
1
- <div class="row">
2
- <div class="col s12">
3
- <p class="flow-text">
4
- Supercache is
5
- <% if Rails.cache.read(:supercache) %>
6
- <span class='teal-text'> active </span>
7
- <% else %>
8
- <span class='red-text'> stopped </span>
9
- <% end %>
10
- </p>
11
- <%= link_to 'Toggle', flip_dashboard_index_path, class: 'waves-effect waves-light btn brown' %>
12
- </div>
13
- </div>
1
+ <table class="highlight">
2
+ <tbody>
3
+ <tr>
4
+ <td><h5>Active Record Cache</h5></td>
5
+ <td>
6
+ <% if @ar_cache %>
7
+ <%= link_to 'ON', flip_dashboard_index_path(cache: 'ar_supercache'), class: 'right waves-effect waves-light btn green darken-3' %>
8
+ <% else %>
9
+ <%= link_to 'OFF', flip_dashboard_index_path(cache: 'ar_supercache'), class: 'right waves-effect waves-light btn red lighten-1' %>
10
+ <% end %>
11
+ </td>
12
+ </tr>
13
+ <tr>
14
+ <td><h5>HTTParty Cache</h5></td>
15
+ <td>
16
+ <% if @http_cache %>
17
+ <%= link_to 'ON', flip_dashboard_index_path(cache: 'http_supercache'), class: 'right waves-effect waves-light btn green darken-3' %>
18
+ <% else %>
19
+ <%= link_to 'OFF', flip_dashboard_index_path(cache: 'http_supercache'), class: 'right waves-effect waves-light btn red lighten-1' %>
20
+ <% end %>
21
+ </td>
22
+ </tr>
23
+ </tbody>
24
+ </table>
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails", "4.0"
6
+
7
+ gemspec :path => "../"
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails", "4.1"
6
+
7
+ gemspec :path => "../"
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails", "4.2"
6
+
7
+ gemspec :path => "../"
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails", "5.0"
6
+
7
+ gemspec :path => "../"
@@ -0,0 +1,17 @@
1
+ module Net
2
+ class HTTP
3
+ def request_with_superhttpcache(*args, &block)
4
+ if Rails.cache.read(:http_supercache)
5
+ Rails.cache.fetch(args[0].path.to_s.hash + args[0].body.to_s.hash) do
6
+ request_without_superhttpcache(*args, &block)
7
+ end
8
+ else
9
+ request_without_superhttpcache(*args, &block)
10
+ end
11
+ end
12
+
13
+ alias_method :request_without_superhttpcache, :request
14
+ alias_method :request, :request_with_superhttpcache
15
+
16
+ end
17
+ end
@@ -1,6 +1,6 @@
1
1
  module SuperQueryCache
2
2
  def cache_sql(sql, binds)
3
- if Rails.cache.read(:supercache)
3
+ if Rails.cache.read(:ar_supercache)
4
4
  Rails.cache.fetch("supercache_#{sql}_#{binds.to_s}".hash) do
5
5
  super(sql, binds)
6
6
  end
@@ -1,3 +1,3 @@
1
1
  module Supercache
2
- VERSION = "0.3"
2
+ VERSION = "0.4"
3
3
  end
data/lib/supercache.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require "supercache/version"
2
2
  require "supercache/engine"
3
3
  require "supercache/super_query_cache"
4
+ require "supercache/super_http_cache"
4
5
 
5
6
  module Supercache
6
7
 
data/supercache.gemspec CHANGED
@@ -22,4 +22,5 @@ Gem::Specification.new do |spec|
22
22
  spec.add_development_dependency "bundler", "~> 1.10"
23
23
  spec.add_development_dependency "rake", "~> 10.0"
24
24
  spec.add_development_dependency "rspec"
25
- end
25
+ spec.add_development_dependency "appraisal"
26
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: supercache
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.3'
4
+ version: '0.4'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bragadeesh J
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-08-22 00:00:00.000000000 Z
11
+ date: 2016-09-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: appraisal
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  description: SuperCache speeds up development time by caching recurring requests and
56
70
  lets you concentrate only on the objects you are changing/playing around with in
57
71
  a complete un-obtrusive manner
@@ -63,8 +77,10 @@ extra_rdoc_files: []
63
77
  files:
64
78
  - ".gitignore"
65
79
  - ".rspec"
80
+ - ".ruby-gemset"
81
+ - ".ruby-version"
66
82
  - ".travis.yml"
67
- - CODE_OF_CONDUCT.md
83
+ - Appraisals
68
84
  - Gemfile
69
85
  - LICENSE.txt
70
86
  - README.md
@@ -75,8 +91,13 @@ files:
75
91
  - bin/console
76
92
  - bin/setup
77
93
  - config/routes.rb
94
+ - gemfiles/rails_4.0.gemfile
95
+ - gemfiles/rails_4.1.gemfile
96
+ - gemfiles/rails_4.2.gemfile
97
+ - gemfiles/rails_5.0.gemfile
78
98
  - lib/supercache.rb
79
99
  - lib/supercache/engine.rb
100
+ - lib/supercache/super_http_cache.rb
80
101
  - lib/supercache/super_query_cache.rb
81
102
  - lib/supercache/version.rb
82
103
  - supercache.gemspec
@@ -100,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
100
121
  version: '0'
101
122
  requirements: []
102
123
  rubyforge_project:
103
- rubygems_version: 2.5.0
124
+ rubygems_version: 2.5.1
104
125
  signing_key:
105
126
  specification_version: 4
106
127
  summary: Speed up Development time
data/CODE_OF_CONDUCT.md DELETED
@@ -1,13 +0,0 @@
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, ethnicity, 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/)