hit_counter 0.1.0 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. checksums.yaml +7 -0
  2. checksums.yaml.gz.sig +0 -0
  3. data/.github/ISSUE_TEMPLATE/bug_report.md +23 -0
  4. data/.github/ISSUE_TEMPLATE/feature_request.md +17 -0
  5. data/.github/ISSUE_TEMPLATE/task.md +21 -0
  6. data/.github/PULL_REQUEST_TEMPLATE.md +31 -0
  7. data/.github/dependabot.yml +11 -0
  8. data/.github/workflows/test.yml +35 -0
  9. data/.gitignore +8 -0
  10. data/.simplecov +15 -0
  11. data/CODE_OF_CONDUCT.md +10 -0
  12. data/CONTRIBUTING.md +34 -0
  13. data/Gemfile +3 -13
  14. data/LICENSE.txt +17 -11
  15. data/README.md +121 -0
  16. data/Rakefile +6 -44
  17. data/SECURITY.md +16 -0
  18. data/certs/ivanoblomov.pem +25 -0
  19. data/config/initializers/mime_types.rb +3 -0
  20. data/config/mongoid.yml +6 -0
  21. data/hit_counter.gemspec +30 -85
  22. data/lib/hit_counter.rb +82 -72
  23. data/lib/version.rb +6 -0
  24. data/public/images/digits/celtic/0.png +0 -0
  25. data/public/images/digits/celtic/1.png +0 -0
  26. data/public/images/digits/celtic/2.png +0 -0
  27. data/public/images/digits/celtic/3.png +0 -0
  28. data/public/images/digits/celtic/4.png +0 -0
  29. data/public/images/digits/celtic/5.png +0 -0
  30. data/public/images/digits/celtic/6.png +0 -0
  31. data/public/images/digits/celtic/7.png +0 -0
  32. data/public/images/digits/celtic/8.png +0 -0
  33. data/public/images/digits/celtic/9.png +0 -0
  34. data/public/images/digits/odometer/0.png +0 -0
  35. data/public/images/digits/odometer/1.png +0 -0
  36. data/public/images/digits/odometer/2.png +0 -0
  37. data/public/images/digits/odometer/3.png +0 -0
  38. data/public/images/digits/odometer/4.png +0 -0
  39. data/public/images/digits/odometer/5.png +0 -0
  40. data/public/images/digits/odometer/6.png +0 -0
  41. data/public/images/digits/odometer/7.png +0 -0
  42. data/public/images/digits/odometer/8.png +0 -0
  43. data/public/images/digits/odometer/9.png +0 -0
  44. data/public/images/digits/scout/0.png +0 -0
  45. data/public/images/digits/scout/1.png +0 -0
  46. data/public/images/digits/scout/2.png +0 -0
  47. data/public/images/digits/scout/3.png +0 -0
  48. data/public/images/digits/scout/4.png +0 -0
  49. data/public/images/digits/scout/5.png +0 -0
  50. data/public/images/digits/scout/6.png +0 -0
  51. data/public/images/digits/scout/7.png +0 -0
  52. data/public/images/digits/scout/8.png +0 -0
  53. data/public/images/digits/scout/9.png +0 -0
  54. data/spec/lib/hit_counter_spec.rb +104 -70
  55. data/spec/spec_helper.rb +10 -3
  56. data.tar.gz.sig +0 -0
  57. metadata +262 -147
  58. metadata.gz.sig +0 -0
  59. data/README.rdoc +0 -82
  60. data/VERSION +0 -1
  61. data/public/images/digits/celtic/0.gif +0 -0
  62. data/public/images/digits/celtic/1.gif +0 -0
  63. data/public/images/digits/celtic/2.gif +0 -0
  64. data/public/images/digits/celtic/3.gif +0 -0
  65. data/public/images/digits/celtic/4.gif +0 -0
  66. data/public/images/digits/celtic/5.gif +0 -0
  67. data/public/images/digits/celtic/6.gif +0 -0
  68. data/public/images/digits/celtic/7.gif +0 -0
  69. data/public/images/digits/celtic/8.gif +0 -0
  70. data/public/images/digits/celtic/9.gif +0 -0
  71. data/public/images/digits/odometer/0.gif +0 -0
  72. data/public/images/digits/odometer/1.gif +0 -0
  73. data/public/images/digits/odometer/2.gif +0 -0
  74. data/public/images/digits/odometer/3.gif +0 -0
  75. data/public/images/digits/odometer/4.gif +0 -0
  76. data/public/images/digits/odometer/5.gif +0 -0
  77. data/public/images/digits/odometer/6.gif +0 -0
  78. data/public/images/digits/odometer/7.gif +0 -0
  79. data/public/images/digits/odometer/8.gif +0 -0
  80. data/public/images/digits/odometer/9.gif +0 -0
  81. data/public/images/digits/scout/0.gif +0 -0
  82. data/public/images/digits/scout/1.gif +0 -0
  83. data/public/images/digits/scout/2.gif +0 -0
  84. data/public/images/digits/scout/3.gif +0 -0
  85. data/public/images/digits/scout/4.gif +0 -0
  86. data/public/images/digits/scout/5.gif +0 -0
  87. data/public/images/digits/scout/6.gif +0 -0
  88. data/public/images/digits/scout/7.gif +0 -0
  89. data/public/images/digits/scout/8.gif +0 -0
  90. data/public/images/digits/scout/9.gif +0 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 36573d86b5005fa7d992427ba4446c6ab7b4d1ac5fb2519cc9163d0404aee5ac
4
+ data.tar.gz: 61a10766d8d156b6bd2fe6316230c2102d8271952ef9f6419d50f99e4aea4043
5
+ SHA512:
6
+ metadata.gz: 67e2bf0e5375f4a133c4770b351694c4b91b15dbd09b387dd6f00b3ac5070d354dee1505b5accb3892ceca10d8cc2f51285a2111b50892eade3a5b96f12ce868
7
+ data.tar.gz: 25c5224c5004299e810a37a59dcb5db135f7178887255027c929f0992df8d45e580f838bebf9208c1651e7ef13d675336fa36d9822b1a8ada7edb7c9d76a997f
checksums.yaml.gz.sig ADDED
Binary file
@@ -0,0 +1,23 @@
1
+ ---
2
+ name: Bug report
3
+ about: Create a report to help us improve
4
+ labels: 'bug'
5
+ ---
6
+
7
+ # Description
8
+
9
+ Provide as much background as you need to get the implementer up to speed on the problem to be solved. This can also include screenshots and links to other issues or pull requests.
10
+
11
+ # Steps to Reproduce
12
+
13
+ Don't forget to point out the difference between what *should* happen and what *does* happen. Here's an example:
14
+
15
+ 1. Try getting the count on cnn.com:
16
+ ```ruby
17
+ HitCounter.get 'cnn.com'
18
+ ```
19
+ 2. The returned count is nil:
20
+ ```ruby
21
+ HitCounter.get 'cnn.com'
22
+ => nil
23
+ ```
@@ -0,0 +1,17 @@
1
+ ---
2
+ name: Feature request
3
+ about: Suggest an idea for this project
4
+ labels: 'feature'
5
+ ---
6
+
7
+ # Goal
8
+ Explain this issue's purpose. Focus on the problem that needs to be solved and *not* a particular solution. For example: "Make it easier for users to reset their passwords."
9
+
10
+ # Description
11
+ 1. Provide as much background as you need to familiarize the implementer with the problem to be solved.
12
+ 2. Include:
13
+ * screenshots
14
+ * links to other issues or pull requests
15
+
16
+ # Success Criteria
17
+ How would a stakeholder test whether the feature was completed successfully?
@@ -0,0 +1,21 @@
1
+ ---
2
+ name: Task
3
+ about: Define a task to complete
4
+ title: ''
5
+ labels: 'task'
6
+ assignees: ''
7
+
8
+ ---
9
+ # Task
10
+
11
+ ## Goal
12
+
13
+ Explain the goal of this task.
14
+
15
+ ## Description
16
+
17
+ Provide whatever background the assignee would need to complete the task. This can include screenshots or links to other issues or pull requests.
18
+
19
+ ## Success Criteria
20
+
21
+ How can stakeholders tell whether the task was completed successfully or not?
@@ -0,0 +1,31 @@
1
+ Closes: #
2
+
3
+ # Goal
4
+ What problem does this pull request solve? This should be close to the goal of the issue this pull request addresses.
5
+
6
+ # Approach
7
+ 1. **Describe, in numbered steps, the approach you chose** to solve the above problem.
8
+ 1. This will help code reviewers get oriented quickly.
9
+ 2. It will also document for future maintainers exactly what changed (and why) when this PR was merged.
10
+ 2. **Add specs** that either *reproduce the bug* or *cover the new feature*. In the former's case, *make sure it fails without the fix!*
11
+ 3. Document any new public methods using standard RDoc syntax, or update the existing RDoc for any modified public methods. As an example, see the RDoc for `HitCounter.get`:
12
+
13
+ ```ruby
14
+ # Returns a <code>HitCounter</code> matching the specified URL. The HitCounter
15
+ # is created if no matching one is found. In the latter case, the hits
16
+ # argument specifies the starting count.
17
+ #
18
+ # @param url [String] the URL for the site being counted
19
+ # @param hits [Integer] the number of hits to start with
20
+ # @return [HitCounter] the site's HitCounter
21
+ # @example
22
+ # hc = HitCounter.get 'cnn.com'
23
+ # hc = HitCounter.get 'cnn.com', 100
24
+ def self.get(url, hits = 0)
25
+ args = { url: normalize_url(url) }
26
+ args[:hits] = hits unless where(conditions: args).exists?
27
+ find_or_create_by args
28
+ end
29
+ ```
30
+
31
+ Signed-off-by: YOUR NAME <YOUR.EMAIL@EXAMPLE.COM>
@@ -0,0 +1,11 @@
1
+ # To get started with Dependabot version updates, you'll need to specify which
2
+ # package ecosystems to update and where the package manifests are located.
3
+ # Please see the documentation for all configuration options:
4
+ # https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5
+
6
+ version: 2
7
+ updates:
8
+ - package-ecosystem: 'bundler' # See documentation for possible values
9
+ directory: '/' # Location of package manifests
10
+ schedule:
11
+ interval: 'daily'
@@ -0,0 +1,35 @@
1
+ # Download the latest Ruby patch versions, install dependencies, and run tests.
2
+ name: test
3
+ on:
4
+ push:
5
+ paths-ignore:
6
+ - '**.md'
7
+ - '**.txt'
8
+ jobs:
9
+ test:
10
+ environment: staging
11
+ runs-on: ubuntu-latest
12
+ name: Ruby ${{ matrix.ruby-version }}
13
+ strategy:
14
+ matrix:
15
+ ruby-version: [2.5, 2.6, 2.7, '3.0']
16
+ steps:
17
+ - name: Checkout code
18
+ uses: actions/checkout@v2
19
+ - name: Set up Ruby ${{ matrix.ruby-version }}
20
+ uses: ruby/setup-ruby@v1
21
+ with:
22
+ ruby-version: ${{ matrix.ruby-version }}
23
+ bundler-cache: true # 'bundle install' and cache
24
+ - name: Start MongoDB
25
+ uses: supercharge/mongodb-github-action@1.7.0
26
+ with:
27
+ mongodb-version: '4.4'
28
+ - name: Run tests
29
+ run: bundle exec rake
30
+ - name: Coveralls
31
+ uses: coverallsapp/github-action@master
32
+ with:
33
+ github-token: ${{ secrets.GITHUB_TOKEN }}
34
+ - name: Rubocop
35
+ run: bundle exec rubocop
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ *.gem
2
+ .DS_Store
3
+ .bundle
4
+ Gemfile.lock
5
+ coverage
6
+ doc
7
+ git.rake
8
+ tmp
data/.simplecov ADDED
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'simplecov-lcov'
4
+
5
+ SimpleCov::Formatter::LcovFormatter.config do |c|
6
+ c.report_with_single_file = true
7
+ c.single_report_path = 'coverage/lcov.info'
8
+ end
9
+ SimpleCov.formatters = SimpleCov::Formatter::MultiFormatter.new(
10
+ [
11
+ SimpleCov::Formatter::HTMLFormatter,
12
+ SimpleCov::Formatter::LcovFormatter
13
+ ]
14
+ )
15
+ SimpleCov.start
@@ -0,0 +1,10 @@
1
+ # The Ruby Community Conduct Guideline
2
+
3
+ We have picked the following conduct guideline based on an early proposed draft of the PostgreSQL CoC, for Ruby developers community for safe, productive collaboration. Each Ruby related community (conference etc.) may pick their own Code of Conduct.
4
+
5
+ This document provides community guidelines for a safe, respectful, productive, and collaborative place for any person who is willing to contribute to the Ruby community. It applies to all “collaborative space”, which is defined as community communications channels (such as mailing lists, submitted patches, commit comments, etc.).
6
+
7
+ * Participants will be tolerant of opposing views.
8
+ * Participants must ensure that their language and actions are free of personal attacks and disparaging personal remarks.
9
+ * When interpreting the words and actions of others, participants should always assume good intentions.
10
+ * Behaviour which can be reasonably considered harassment will not be tolerated.
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,34 @@
1
+ # How to contribute
2
+
3
+ ## **New to open-source?**
4
+
5
+ Try your hand at one of the small tasks ideal for new or casual contributors that are [up-for-grabs](https://github.com/ivanoblomov/hit_counter/issues?q=is%3Aissue+is%3Aopen+label%3Aup-for-grabs). Welcome to the community!
6
+
7
+ ## **Did you find a bug?**
8
+
9
+ 1. **Ensure the bug was not already reported** by searching on GitHub under [Issues](https://github.com/ivanoblomov/hit_counter/issues).
10
+
11
+ 2. If you're unable to find an open issue addressing the problem, [open a new one](https://github.com/ivanoblomov/hit_counter/issues/new/choose). Be sure to include:
12
+ 1. a **title and clear description**
13
+ 2. as much **relevant information** as possible
14
+ 3. a **code sample** or an **executable test case** demonstrating the expected behavior that is not occurring.
15
+
16
+ ## **Did you write a patch that fixes a bug or adds a new feature?**
17
+
18
+ 1. **Add specs** that either *reproduce the bug* or *cover the new feature*. In the former's case, *make sure it fails without the fix!*
19
+
20
+ 2. **Confirm your last build passes** on your GitHub branch or PR.
21
+
22
+ 3. **Update the inline documentation.** Format it with [YARD](https://www.rubydoc.info/gems/yard/file/docs/GettingStarted.md). For example, see [`HitCounter.get`](../lib/hit_counter/hit_counter.rb).
23
+
24
+ 4. [Open a pull request](https://github.com/ivanoblomov/hit_counter/compare) with the patch or feature. Follow the template's directions.
25
+
26
+ ## Developer Certificate of Origin (DCO)
27
+
28
+ All contributions (including pull requests) must agree to the [Developer Certificate of Origin (DCO) version 1.1](https://developercertificate.org). This is a developer's certification that he or she has the right to submit the patch for inclusion into the project.
29
+
30
+ Simply submitting a contribution implies this agreement, however, please include a `Signed-off-by` tag in the PR (this tag is a conventional way to confirm that you agree to the DCO).
31
+
32
+ It's not practical to fix old contributions in git, so if one is forgotten, do not try to fix them. We presume that if someone sometimes used a DCO, a commit without a DCO is an accident and the DCO still applies.
33
+
34
+ ## Thanks for contributing!
data/Gemfile CHANGED
@@ -1,14 +1,4 @@
1
- source 'http://rubygems.org'
1
+ # frozen_string_literal: true
2
2
 
3
- gem 'addressable', :require => 'addressable/uri'
4
- gem 'bson_ext'
5
- gem 'mongoid', :require => 'mongoid'
6
- gem 'rmagick', '2.12.2', :require => 'RMagick'# version compatible with heroku
7
-
8
- group :development do
9
- gem 'jeweler'
10
- end
11
-
12
- group :test do
13
- gem 'rspec'
14
- end
3
+ source 'https://rubygems.org'
4
+ gemspec
data/LICENSE.txt CHANGED
@@ -1,14 +1,20 @@
1
- Copyright (c) 2011 Roderick Monje
1
+ Copyright (c) 2011-2021 Roderick Monje
2
2
 
3
- This program is free software: you can redistribute it and/or modify
4
- it under the terms of the GNU General Public License as published by
5
- the Free Software Foundation, either version 3 of the License, or
6
- (at your option) any later version.
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
7
10
 
8
- This program is distributed in the hope that it will be useful,
9
- but WITHOUT ANY WARRANTY; without even the implied warranty of
10
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
- GNU General Public License for more details.
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
12
13
 
13
- You should have received a copy of the GNU General Public License
14
- along with this program. If not, see <http://www.gnu.org/licenses/>.
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,121 @@
1
+ # HitCounter
2
+
3
+ ![Build status](https://github.com/ivanoblomov/hit_counter/workflows/test/badge.svg)
4
+ [![Code Climate](https://codeclimate.com/github/ivanoblomov/hit_counter.png)](https://codeclimate.com/github/ivanoblomov/hit_counter)
5
+ [![Coveralls](https://coveralls.io/repos/ivanoblomov/hit_counter/badge.svg?branch=master&service=github)](https://coveralls.io/github/ivanoblomov/hit_counter?branch=master)
6
+ [![Inch CI](https://inch-ci.org/github/ivanoblomov/hit_counter.svg?branch=master&amp;style=flat)](https://inch-ci.org/github/ivanoblomov/hit_counter)
7
+ [![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/5375/badge)](https://bestpractices.coreinfrastructure.org/projects/5375)
8
+ [![Gem Version](https://badge.fury.io/rb/hit_counter.svg)](https://badge.fury.io/rb/hit_counter)
9
+
10
+ Ruby version of that old 90s chestnut, `<BLINK>`the web-site hit counter`</BLINK>`.
11
+
12
+ ## Installation
13
+
14
+ 1. Install the gem and supporting files.
15
+
16
+ `Gemfile`
17
+ ```ruby
18
+ gem 'hit_counter'
19
+ ```
20
+
21
+ Run:
22
+
23
+ ```sh
24
+ bundle
25
+ rake hit_counter:install
26
+ ```
27
+
28
+ ### Security note
29
+
30
+ `HitCounter` is cryptographically signed. To insure the gem you install hasn’t been tampered with, add my public key as a trusted certificate and then install:
31
+
32
+ ```sh
33
+ gem cert --add <(curl -Ls https://raw.github.com/ivanoblomov/hit_counter/master/certs/ivanoblomov.pem)
34
+ gem install hit_counter -P HighSecurity
35
+ ```
36
+
37
+ 2. Add a controller action to your app.
38
+
39
+ `application_controller.rb`
40
+ ```ruby
41
+ def hit_counter
42
+ return if params[:url].blank?
43
+
44
+ # find or create a hit counter for this URL
45
+ hc = HitCounter.get params[:url]
46
+
47
+ # increase the tally by one
48
+ hc.increment
49
+
50
+ # get the image as a blob and stream it to the browser
51
+ send_data hc.image(params[:style]).to_blob,
52
+ disposition: 'inline',
53
+ filename: "#{hc.hits}.png",
54
+ type: :png
55
+ end
56
+ ```
57
+
58
+ `routes.rb`
59
+ ```ruby
60
+ get 'hit-counter' => 'application#hit_counter'
61
+ # technically should be POST/PUT, but GET makes integration simpler
62
+ ````
63
+
64
+ Or try it out in `irb` with:
65
+
66
+ ```ruby
67
+ require './spec/spec_helper'
68
+ hc = HitCounter.get('cnn.com')
69
+ ```
70
+
71
+ 3. Add the hit-counter image tag to your site's HTML:
72
+
73
+ ```html
74
+ <img alt="Hit Counter" border="0" src="/hit-counter?url=https://cnn.com&style=1" />
75
+ ````
76
+
77
+ ## Customizing the Hit-Counter Image
78
+
79
+ ### Use an Existing Style
80
+
81
+ | Name | Image |
82
+ | -------- | --------------------------------------------------------------------- |
83
+ | Celtic | ![image of 3 in celtic style](/public/images/digits/celtic/3.png) |
84
+ | Odometer | ![image of 1 in odometer style](/public/images/digits/odometer/1.png) |
85
+ | Scout | ![image of 2 in scout style](/public/images/digits/scout/2.png) |
86
+
87
+ You can use one of the three included styles by specifying a different `style` param in the HTML:
88
+
89
+ ```html
90
+ <img alt="Hit Counter" border="0" src="/hit-counter?url=cnn.com&style=1" />
91
+ ```
92
+
93
+ ### Create Your Own Style
94
+
95
+ 1. To add your own style, create a PNG for each of the digits, `0.png` through `9.png`. Save the images in a folder named after your new style in `public/images/digits`.
96
+
97
+ 2. In your controller, declare a new `STYLES` constant and add the folder name to it:
98
+
99
+ ```ruby
100
+ HitCounter::STYLES = %w(odometer scout celtic folder_name)
101
+ ```
102
+
103
+ 3. In your HTML, specify the new style with a `style` param equal to its index in the array plus one (unlike arrays, the `style` param's index is one-based):
104
+
105
+ ```html
106
+ <img alt="Hit Counter" border="0" src="/hit-counter?url=cnn.com&style=4" />
107
+ ```
108
+
109
+ ## Documentation
110
+
111
+ Complete RDoc documentation is available at [RubyDoc.info](https://www.rubydoc.info/gems/hit_counter).
112
+
113
+ ## [Contributing to HitCounter](CONTRIBUTING.md)
114
+
115
+ ## Cheers!
116
+
117
+ <a href="https://www.buymeacoffee.com/oblomov" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-green.png" alt="Buy Me A Coffee" height="41" width="174" ></a>
118
+
119
+ ## Copyright
120
+
121
+ Copyright © 2011-2021 Roderick Monje. See LICENSE.txt for further details.
data/Rakefile CHANGED
@@ -1,48 +1,10 @@
1
- # encoding: utf-8
1
+ # frozen_string_literal: true
2
2
 
3
- require 'rubygems'
4
3
  require 'bundler'
5
- begin
6
- Bundler.setup(:default, :development, :test)
7
- rescue Bundler::BundlerError => e
8
- $stderr.puts e.message
9
- $stderr.puts "Run `bundle install` to install missing gems"
10
- exit e.status_code
11
- end
12
- require 'rake'
13
-
14
- require 'jeweler'
15
- Jeweler::Tasks.new do |gem|
16
- # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
- gem.name = "hit_counter"
18
- gem.homepage = "http://github.com/ivanoblomov/hit_counter"
19
- gem.license = "MIT"
20
- gem.summary = %Q{Ruby version of that old 90s chestnut, the web-site hit counter.}
21
- gem.email = "rod@seologic.com"
22
- gem.authors = ["Roderick Monje"]
23
- # dependencies defined in Gemfile
24
- end
25
- Jeweler::RubygemsDotOrgTasks.new
26
-
27
- require 'rspec/core'
4
+ require 'bundler/gem_tasks'
28
5
  require 'rspec/core/rake_task'
29
- RSpec::Core::RakeTask.new(:spec) do |spec|
30
- spec.pattern = FileList['spec/**/*_spec.rb']
31
- end
32
-
33
- RSpec::Core::RakeTask.new(:rcov) do |spec|
34
- spec.pattern = 'spec/**/*_spec.rb'
35
- spec.rcov = true
36
- end
37
-
38
- task :default => :spec
39
-
40
- require 'rake/rdoctask'
41
- Rake::RDocTask.new do |rdoc|
42
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
43
-
44
- rdoc.rdoc_dir = 'rdoc'
45
- rdoc.title = "hit_counter #{version}"
46
- rdoc.rdoc_files.include('README*')
47
- rdoc.rdoc_files.include('lib/**/*.rb')
6
+ RSpec::Core::RakeTask.new(:test) do |t|
7
+ t.pattern = 'spec/*/*_spec.rb'
8
+ t.verbose = false
48
9
  end
10
+ task default: :test
data/SECURITY.md ADDED
@@ -0,0 +1,16 @@
1
+ # Security Policy
2
+
3
+ ## Supported Versions
4
+
5
+ [Dependabot](https://docs.github.com/en/code-security/supply-chain-security/keeping-your-dependencies-updated-automatically/about-dependabot-version-updates) automatically [patches known vulnerabilities](https://github.com/ivanoblomov/hit_counter/pulls?q=is%3Apr+is%3Aclosed+author%3Aapp%2Fdependabot).
6
+
7
+ | Version | Supported |
8
+ | ------- | ------------------ |
9
+ | 0.1.4 | :white_check_mark: |
10
+ | < 0.1.4 | :x: |
11
+
12
+ ## Reporting a Vulnerability
13
+
14
+ 1. To report a security vulnerability, [open an issue](https://github.com/ivanoblomov/hit_counter/issues/new/choose).
15
+ 2. Updates are made within 48 hours.
16
+ 3. If the vulnerability is accepted, we'll try to patch it within a week.
@@ -0,0 +1,25 @@
1
+ -----BEGIN CERTIFICATE-----
2
+ MIIEQDCCAqigAwIBAgIBATANBgkqhkiG9w0BAQsFADAlMSMwIQYDVQQDDBpyb2Qv
3
+ REM9Zm92ZWFjZW50cmFsL0RDPWNvbTAeFw0yMTExMTUwMzEwMTRaFw0yMjExMTUw
4
+ MzEwMTRaMCUxIzAhBgNVBAMMGnJvZC9EQz1mb3ZlYWNlbnRyYWwvREM9Y29tMIIB
5
+ ojANBgkqhkiG9w0BAQEFAAOCAY8AMIIBigKCAYEAsMm8RdCTuhYTnbH5a8pesLYn
6
+ BD7cLPkeNfPWp8ohGVXL3988lRBYHwI/LRhxKXncmwmjYFWjuyR1m3e+EgmpBO3e
7
+ gCn4G9paWlwvPF+dSBF4pjhPtYBSXMFDfoeUTyHuNCcQOFJUMSAxo1pg9S9KvslC
8
+ Y1fpstOJtVnUjoeT8BRQAqV0WZuzFhgj74oSoHP/ETEd7Uzw/ST/kKgtNGcxoIYu
9
+ FEqAfEsqEpV0d6FbExYmVTR12288MaGGrfc6Y/QC1VC6RhEYG8Sn8a3utqkn7y47
10
+ 0J6SROECo5x9TWU0s3HDco06jYb5sV1cGsDYXFpEczxJ9i1YVX2IDvYrpZsSJLzq
11
+ tfCdJ2jIj4rnMjGMg/kschfDnBKRIt8p7LlDhc0p/m0fYO4JQpWbvCc/F5vmUzpF
12
+ kRbiNr30dkYqDbfvcdQUWBOa5rSyZOIQiW6kfK9ZbLjBGFeP8pwSNME+yfJsZObS
13
+ AIiSqYtcP4mMriBLi+x981z1kpjTGZSWOpZrgAELAgMBAAGjezB5MAkGA1UdEwQC
14
+ MAAwCwYDVR0PBAQDAgSwMB0GA1UdDgQWBBQzajljgeoJIjO/4h4X7ve/jYWVSDAf
15
+ BgNVHREEGDAWgRRyb2RAZm92ZWFjZW50cmFsLmNvbTAfBgNVHRIEGDAWgRRyb2RA
16
+ Zm92ZWFjZW50cmFsLmNvbTANBgkqhkiG9w0BAQsFAAOCAYEAqqybBWM9gIPn8Quj
17
+ R8L0HPEE/1NjNLrlNG1DhJ8MAbYFA7mo4bWp4kjXwVdw+TMQZfrLjXLgmfiTvzxV
18
+ cE10liYjCWQNxectkkYmOsCBlEDfOngNKdl3QJ+Y5+SEsqfKYhZXZypn+SwuXx8F
19
+ LuVPsP7/R6VlrI8WbtPU1oSfM+rmdpUZzDcvmtvy1S+tPfFWalo8tSXPg0gE3Nis
20
+ UZAwHu8x3v5N7lxtjJa+s9ARkH/BO5Uytz1XrUmUWLQqo9ZJtqbZ/iV9HEWhG+xx
21
+ lR8SnXcsohvP/eIY2BTyBay0eOb9BwGHmnAVRiiAfLvCftzHtBEBr6jCKESSYDuc
22
+ bUIRDNLzRjl2KOoNLjKymicWrBdz1roBpy8cFIDzi6ebE45ve/xoZbsGJ3zaLo9T
23
+ G5iWAeYsmSjJxz7iOZOsx+vPCwMy7j6nWF2CDbaxioGR/hIqNbVBveCCRyjyunD3
24
+ kvv576EuULmQcLpOKwB3RlxAG7j8JJl4ueqjF+rz7x1lBqEU
25
+ -----END CERTIFICATE-----
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ Mime::Type.register_alias 'image/png', :png
@@ -0,0 +1,6 @@
1
+ test:
2
+ clients:
3
+ default:
4
+ database: hit_counter
5
+ hosts:
6
+ - localhost:27017
data/hit_counter.gemspec CHANGED
@@ -1,91 +1,36 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
- # -*- encoding: utf-8 -*-
1
+ # frozen_string_literal: true
5
2
 
3
+ require File.expand_path 'lib/version', __dir__
6
4
  Gem::Specification.new do |s|
7
- s.name = "hit_counter"
8
- s.version = "0.1.0"
5
+ s.name = 'hit_counter'
6
+ s.version = HitCounter::VERSION.dup
7
+ s.summary = 'Ruby version of that old 90s chestnut, the web-site hit counter.'
8
+ s.description = 'Why roast this chestnut by that open fire, you ask? Cause '\
9
+ 'thousands and thousands of Internet vets are still using the one we '\
10
+ "wrote in PHP eons ago and we don't want to be squandering any incidental "\
11
+ "Google juice, that's why."
12
+ s.homepage = 'https://github.com/ivanoblomov/hit_counter'
13
+ s.authors = ['Roderick Monje']
14
+ s.cert_chain = ['certs/ivanoblomov.pem']
15
+ s.signing_key = File.expand_path('~/.ssh/gem-private_key.pem') if $PROGRAM_NAME =~ /gem\z/
9
16
 
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Roderick Monje"]
12
- s.date = "2011-09-25"
13
- s.email = "rod@seologic.com"
14
- s.extra_rdoc_files = [
15
- "LICENSE.txt",
16
- "README.rdoc"
17
- ]
18
- s.files = [
19
- ".document",
20
- ".rspec",
21
- "Gemfile",
22
- "LICENSE.txt",
23
- "README.rdoc",
24
- "Rakefile",
25
- "VERSION",
26
- "hit_counter.gemspec",
27
- "lib/hit_counter.rb",
28
- "public/images/digits/celtic/0.gif",
29
- "public/images/digits/celtic/1.gif",
30
- "public/images/digits/celtic/2.gif",
31
- "public/images/digits/celtic/3.gif",
32
- "public/images/digits/celtic/4.gif",
33
- "public/images/digits/celtic/5.gif",
34
- "public/images/digits/celtic/6.gif",
35
- "public/images/digits/celtic/7.gif",
36
- "public/images/digits/celtic/8.gif",
37
- "public/images/digits/celtic/9.gif",
38
- "public/images/digits/odometer/0.gif",
39
- "public/images/digits/odometer/1.gif",
40
- "public/images/digits/odometer/2.gif",
41
- "public/images/digits/odometer/3.gif",
42
- "public/images/digits/odometer/4.gif",
43
- "public/images/digits/odometer/5.gif",
44
- "public/images/digits/odometer/6.gif",
45
- "public/images/digits/odometer/7.gif",
46
- "public/images/digits/odometer/8.gif",
47
- "public/images/digits/odometer/9.gif",
48
- "public/images/digits/scout/0.gif",
49
- "public/images/digits/scout/1.gif",
50
- "public/images/digits/scout/2.gif",
51
- "public/images/digits/scout/3.gif",
52
- "public/images/digits/scout/4.gif",
53
- "public/images/digits/scout/5.gif",
54
- "public/images/digits/scout/6.gif",
55
- "public/images/digits/scout/7.gif",
56
- "public/images/digits/scout/8.gif",
57
- "public/images/digits/scout/9.gif",
58
- "spec/lib/hit_counter_spec.rb",
59
- "spec/spec_helper.rb"
60
- ]
61
- s.homepage = "http://github.com/ivanoblomov/hit_counter"
62
- s.licenses = ["MIT"]
63
- s.require_paths = ["lib"]
64
- s.rubygems_version = "1.8.10"
65
- s.summary = "Ruby version of that old 90s chestnut, the web-site hit counter."
17
+ s.add_development_dependency 'rake', '>= 12.3.3', '~> 13.0'
18
+ s.add_development_dependency 'rspec', '~> 3'
19
+ s.add_development_dependency 'rubocop', '< 1.24'
20
+ s.add_development_dependency 'rubocop-rake', '~> 0'
21
+ s.add_development_dependency 'rubocop-rspec', '~> 2'
22
+ s.add_development_dependency 'simplecov', '~> 0.18'
23
+ s.add_development_dependency 'simplecov-lcov', '~> 0.8'
66
24
 
67
- if s.respond_to? :specification_version then
68
- s.specification_version = 3
25
+ s.add_runtime_dependency 'addressable', '~> 2'
26
+ s.add_runtime_dependency 'bson_ext', '~> 1'
27
+ s.add_runtime_dependency 'mongoid', '~> 7'
28
+ s.add_runtime_dependency 'rmagick', '>= 2', '< 5'
69
29
 
70
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
71
- s.add_runtime_dependency(%q<addressable>, [">= 0"])
72
- s.add_runtime_dependency(%q<bson_ext>, [">= 0"])
73
- s.add_runtime_dependency(%q<mongoid>, [">= 0"])
74
- s.add_runtime_dependency(%q<rmagick>, ["= 2.12.2"])
75
- s.add_development_dependency(%q<jeweler>, [">= 0"])
76
- else
77
- s.add_dependency(%q<addressable>, [">= 0"])
78
- s.add_dependency(%q<bson_ext>, [">= 0"])
79
- s.add_dependency(%q<mongoid>, [">= 0"])
80
- s.add_dependency(%q<rmagick>, ["= 2.12.2"])
81
- s.add_dependency(%q<jeweler>, [">= 0"])
82
- end
83
- else
84
- s.add_dependency(%q<addressable>, [">= 0"])
85
- s.add_dependency(%q<bson_ext>, [">= 0"])
86
- s.add_dependency(%q<mongoid>, [">= 0"])
87
- s.add_dependency(%q<rmagick>, ["= 2.12.2"])
88
- s.add_dependency(%q<jeweler>, [">= 0"])
89
- end
30
+ s.files = `git ls-files`.split "\n"
31
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split "\n"
32
+ s.executables = `git ls-files -- bin/*`.split("\n")
33
+ .map { |f| File.basename f }
34
+ s.require_paths = ['lib']
35
+ s.required_ruby_version = '>= 2.5'
90
36
  end
91
-