hit_counter 0.1.1 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) 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 +42 -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 +12 -12
  14. data/LICENSE.txt +17 -11
  15. data/README.md +120 -0
  16. data/Rakefile +15 -40
  17. data/SECURITY.md +16 -0
  18. data/certs/ivanoblomov.pem +25 -0
  19. data/config/initializers/mime_types.rb +3 -1
  20. data/config/mongoid.yml +6 -0
  21. data/hit_counter.gemspec +20 -87
  22. data/lib/hit_counter.rb +91 -85
  23. data/lib/tasks/install.rake +6 -0
  24. data/lib/version.rb +7 -0
  25. data/public/images/digits/celtic/0.png +0 -0
  26. data/public/images/digits/celtic/1.png +0 -0
  27. data/public/images/digits/celtic/2.png +0 -0
  28. data/public/images/digits/celtic/3.png +0 -0
  29. data/public/images/digits/celtic/4.png +0 -0
  30. data/public/images/digits/celtic/5.png +0 -0
  31. data/public/images/digits/celtic/6.png +0 -0
  32. data/public/images/digits/celtic/7.png +0 -0
  33. data/public/images/digits/celtic/8.png +0 -0
  34. data/public/images/digits/celtic/9.png +0 -0
  35. data/public/images/digits/odometer/0.png +0 -0
  36. data/public/images/digits/odometer/1.png +0 -0
  37. data/public/images/digits/odometer/2.png +0 -0
  38. data/public/images/digits/odometer/3.png +0 -0
  39. data/public/images/digits/odometer/4.png +0 -0
  40. data/public/images/digits/odometer/5.png +0 -0
  41. data/public/images/digits/odometer/6.png +0 -0
  42. data/public/images/digits/odometer/7.png +0 -0
  43. data/public/images/digits/odometer/8.png +0 -0
  44. data/public/images/digits/odometer/9.png +0 -0
  45. data/public/images/digits/scout/0.png +0 -0
  46. data/public/images/digits/scout/1.png +0 -0
  47. data/public/images/digits/scout/2.png +0 -0
  48. data/public/images/digits/scout/3.png +0 -0
  49. data/public/images/digits/scout/4.png +0 -0
  50. data/public/images/digits/scout/5.png +0 -0
  51. data/public/images/digits/scout/6.png +0 -0
  52. data/public/images/digits/scout/7.png +0 -0
  53. data/public/images/digits/scout/8.png +0 -0
  54. data/public/images/digits/scout/9.png +0 -0
  55. data/spec/lib/hit_counter_spec.rb +110 -69
  56. data/spec/spec_helper.rb +52 -3
  57. data.tar.gz.sig +0 -0
  58. metadata +157 -148
  59. metadata.gz.sig +0 -0
  60. data/README.rdoc +0 -82
  61. data/VERSION +0 -1
  62. data/public/images/digits/celtic/0.gif +0 -0
  63. data/public/images/digits/celtic/1.gif +0 -0
  64. data/public/images/digits/celtic/2.gif +0 -0
  65. data/public/images/digits/celtic/3.gif +0 -0
  66. data/public/images/digits/celtic/4.gif +0 -0
  67. data/public/images/digits/celtic/5.gif +0 -0
  68. data/public/images/digits/celtic/6.gif +0 -0
  69. data/public/images/digits/celtic/7.gif +0 -0
  70. data/public/images/digits/celtic/8.gif +0 -0
  71. data/public/images/digits/celtic/9.gif +0 -0
  72. data/public/images/digits/odometer/0.gif +0 -0
  73. data/public/images/digits/odometer/1.gif +0 -0
  74. data/public/images/digits/odometer/2.gif +0 -0
  75. data/public/images/digits/odometer/3.gif +0 -0
  76. data/public/images/digits/odometer/4.gif +0 -0
  77. data/public/images/digits/odometer/5.gif +0 -0
  78. data/public/images/digits/odometer/6.gif +0 -0
  79. data/public/images/digits/odometer/7.gif +0 -0
  80. data/public/images/digits/odometer/8.gif +0 -0
  81. data/public/images/digits/odometer/9.gif +0 -0
  82. data/public/images/digits/scout/0.gif +0 -0
  83. data/public/images/digits/scout/1.gif +0 -0
  84. data/public/images/digits/scout/2.gif +0 -0
  85. data/public/images/digits/scout/3.gif +0 -0
  86. data/public/images/digits/scout/4.gif +0 -0
  87. data/public/images/digits/scout/5.gif +0 -0
  88. data/public/images/digits/scout/6.gif +0 -0
  89. data/public/images/digits/scout/7.gif +0 -0
  90. data/public/images/digits/scout/8.gif +0 -0
  91. data/public/images/digits/scout/9.gif +0 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 7fda3c8ce5cf2522c3484d1320cf0a9c0699babc2cf5a798f33a62836bf22960
4
+ data.tar.gz: e4481b5da767e640461569f54dc0488ac2f55e8a8bb01df7e1243345140871e0
5
+ SHA512:
6
+ metadata.gz: a9c34c10421251e18abc582522669a6292f831fe1fdee1cd97d8edbe7fb1ae9812fd74698b8e3ea02aee94b90cbd645c385df7ff832f1da2a30acc12e226dcb1
7
+ data.tar.gz: 76d58f7a643749eb22c38e04b2d6c5e2cac97ba98b1233a2c7813d2c534523ba58f5eb0583358c0578f8e60a7b6fd34eb45f6ffd1f643896f6884377776a6481
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,42 @@
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: Send Code Climate coverage
31
+ uses: amancevice/setup-code-climate@v0
32
+ with:
33
+ cc_test_reporter_id: ${{ secrets.CC_TEST_REPORTER_ID }}
34
+ - run: cc-test-reporter after-build --coverage-input-type lcov
35
+ - name: Send Coveralls coverage
36
+ uses: coverallsapp/github-action@master
37
+ with:
38
+ github-token: ${{ secrets.GITHUB_TOKEN }}
39
+ - name: Run RuboCop
40
+ run: bundle exec rubocop
41
+ - name: Run Inch
42
+ run: bundle exec inch --pedantic
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/FoveaCentral/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/FoveaCentral/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/FoveaCentral/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/FoveaCentral/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,14 @@
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
3
+ source 'https://rubygems.org'
4
+ gemspec
7
5
 
8
- group :development do
9
- gem 'jeweler'
10
- end
11
-
12
- group :test do
13
- gem 'rspec'
14
- end
6
+ gem 'inch', '~> 0.8'
7
+ gem 'pry', '~> 0.14.1'
8
+ gem 'rake', '>= 12.3.3', '~> 13.0'
9
+ gem 'rspec', '~> 3'
10
+ gem 'rubocop', '< 1.24'
11
+ gem 'rubocop-rake', '~> 0'
12
+ gem 'rubocop-rspec', '~> 2'
13
+ gem 'simplecov', '~> 0.18'
14
+ gem 'simplecov-lcov', '~> 0.8'
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,120 @@
1
+ # HitCounter
2
+
3
+ [![Build status](https://github.com/FoveaCentral/hit_counter/workflows/test/badge.svg)](https://github.com/FoveaCentral/hit_counter/actions/workflows/test.yml)
4
+ [![Code Climate](https://codeclimate.com/github/FoveaCentral/hit_counter.svg)](https://codeclimate.com/github/FoveaCentral/hit_counter)
5
+ [![Coveralls](https://coveralls.io/repos/FoveaCentral/hit_counter/badge.svg?branch=master&service=github)](https://coveralls.io/github/FoveaCentral/hit_counter?branch=master)
6
+ [![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/5375/badge)](https://bestpractices.coreinfrastructure.org/projects/5375)
7
+ [![Gem Version](https://badge.fury.io/rb/hit_counter.svg)](https://badge.fury.io/rb/hit_counter)
8
+
9
+ Self-hosted Ruby version of that old 90s chestnut, `<BLINK>`the web-site hit counter`</BLINK>`.
10
+
11
+ ## Installation
12
+
13
+ 1. Install the gem and supporting files.
14
+
15
+ `Gemfile`
16
+ ```ruby
17
+ gem 'hit_counter'
18
+ ```
19
+
20
+ Run:
21
+
22
+ ```sh
23
+ bundle
24
+ rake hit_counter:install
25
+ ```
26
+
27
+ ### Security note
28
+
29
+ `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:
30
+
31
+ ```sh
32
+ gem cert --add <(curl -Ls https://raw.github.com/FoveaCentral/hit_counter/master/certs/ivanoblomov.pem)
33
+ gem install hit_counter -P HighSecurity
34
+ ```
35
+
36
+ 2. Add a controller action to your app.
37
+
38
+ `application_controller.rb`
39
+ ```ruby
40
+ def hit_counter
41
+ return if params[:url].blank?
42
+
43
+ # find or create a hit counter for this URL
44
+ hc = HitCounter.get params[:url]
45
+
46
+ # increase the tally by one
47
+ hc.increment
48
+
49
+ # get the image as a blob and stream it to the browser
50
+ send_data hc.image(params[:style]).to_blob,
51
+ disposition: 'inline',
52
+ filename: "#{hc.hits}.png",
53
+ type: :png
54
+ end
55
+ ```
56
+
57
+ `routes.rb`
58
+ ```ruby
59
+ get 'hit-counter' => 'application#hit_counter'
60
+ # technically should be POST/PUT, but GET makes integration simpler
61
+ ````
62
+
63
+ 3. Add the hit-counter image tag to your site's HTML:
64
+
65
+ ```html
66
+ <img alt="Hit Counter" border="0" src="/hit-counter?url=https://cnn.com&style=1" />
67
+ ````
68
+
69
+ Or try it out in `irb` with:
70
+
71
+ ```ruby
72
+ require './spec/spec_helper'
73
+ hc = HitCounter.get('cnn.com')
74
+ ```
75
+
76
+ ## Customizing the Hit-Counter Image
77
+
78
+ ### Use an Existing Style
79
+
80
+ | Name | Style number |
81
+ | -------- | --------------------------------------------------------------------- |
82
+ | Celtic | ![image of 3 in celtic style](/public/images/digits/celtic/3.png) |
83
+ | Odometer | ![image of 1 in odometer style](/public/images/digits/odometer/1.png) |
84
+ | Scout | ![image of 2 in scout style](/public/images/digits/scout/2.png) |
85
+
86
+ You can use one of the three included styles by specifying a different `style` param in the HTML:
87
+
88
+ ```html
89
+ <img alt="Hit Counter" border="0" src="/hit-counter?url=cnn.com&style=1" />
90
+ ```
91
+
92
+ ### Create Your Own Style
93
+
94
+ 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`.
95
+
96
+ 2. In your controller, declare a new `STYLES` constant and add the folder name to it:
97
+
98
+ ```ruby
99
+ HitCounter::STYLES = %w(odometer scout celtic folder_name)
100
+ ```
101
+
102
+ 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):
103
+
104
+ ```html
105
+ <img alt="Hit Counter" border="0" src="/hit-counter?url=cnn.com&style=4" />
106
+ ```
107
+
108
+ ## Documentation
109
+
110
+ Complete RDoc documentation is available at [RubyDoc.info](https://www.rubydoc.info/gems/hit_counter).
111
+
112
+ ## [Contributing to HitCounter](CONTRIBUTING.md)
113
+
114
+ ## Cheers!
115
+
116
+ <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>
117
+
118
+ ## Copyright
119
+
120
+ Copyright © 2011-2021 Roderick Monje. See LICENSE.txt for further details.
data/Rakefile CHANGED
@@ -1,48 +1,23 @@
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
6
 
33
- RSpec::Core::RakeTask.new(:rcov) do |spec|
34
- spec.pattern = 'spec/**/*_spec.rb'
35
- spec.rcov = true
7
+ def load_rake_tasks
8
+ Dir.glob('./lib/tasks/**/*.rake').each { |f| import f }
36
9
  end
10
+ load_rake_tasks
37
11
 
38
- task :default => :spec
39
-
40
- require 'rake/rdoctask'
41
- Rake::RDocTask.new do |rdoc|
42
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
12
+ if defined? Rails
13
+ # override Rails to include tasks
14
+ class Railtie < Rails::Railtie
15
+ rake_tasks { load_rake_tasks }
16
+ end
17
+ end
43
18
 
44
- rdoc.rdoc_dir = 'rdoc'
45
- rdoc.title = "hit_counter #{version}"
46
- rdoc.rdoc_files.include('README*')
47
- rdoc.rdoc_files.include('lib/**/*.rb')
19
+ RSpec::Core::RakeTask.new(:test) do |t|
20
+ t.pattern = 'spec/*/*_spec.rb'
21
+ t.verbose = false
48
22
  end
23
+ 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/FoveaCentral/hit_counter/pulls?q=is%3Apr+is%3Aclosed+author%3Aapp%2Fdependabot).
6
+
7
+ | Version | Supported |
8
+ | ------- | ------------------ |
9
+ | 0.1.5 | :white_check_mark: |
10
+ | < 0.1.5 | :x: |
11
+
12
+ ## Reporting a Vulnerability
13
+
14
+ 1. To report a security vulnerability, [open an issue](https://github.com/FoveaCentral/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-----
@@ -1 +1,3 @@
1
- Mime::Type.register_alias 'image/png', :png
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,92 +1,25 @@
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.1"
5
+ s.name = 'hit_counter'
6
+ s.version = HitCounter::VERSION.dup
7
+ s.summary = 'Self-hosted 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/FoveaCentral/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
- "config/initializers/mime_types.rb",
27
- "hit_counter.gemspec",
28
- "lib/hit_counter.rb",
29
- "public/images/digits/celtic/0.gif",
30
- "public/images/digits/celtic/1.gif",
31
- "public/images/digits/celtic/2.gif",
32
- "public/images/digits/celtic/3.gif",
33
- "public/images/digits/celtic/4.gif",
34
- "public/images/digits/celtic/5.gif",
35
- "public/images/digits/celtic/6.gif",
36
- "public/images/digits/celtic/7.gif",
37
- "public/images/digits/celtic/8.gif",
38
- "public/images/digits/celtic/9.gif",
39
- "public/images/digits/odometer/0.gif",
40
- "public/images/digits/odometer/1.gif",
41
- "public/images/digits/odometer/2.gif",
42
- "public/images/digits/odometer/3.gif",
43
- "public/images/digits/odometer/4.gif",
44
- "public/images/digits/odometer/5.gif",
45
- "public/images/digits/odometer/6.gif",
46
- "public/images/digits/odometer/7.gif",
47
- "public/images/digits/odometer/8.gif",
48
- "public/images/digits/odometer/9.gif",
49
- "public/images/digits/scout/0.gif",
50
- "public/images/digits/scout/1.gif",
51
- "public/images/digits/scout/2.gif",
52
- "public/images/digits/scout/3.gif",
53
- "public/images/digits/scout/4.gif",
54
- "public/images/digits/scout/5.gif",
55
- "public/images/digits/scout/6.gif",
56
- "public/images/digits/scout/7.gif",
57
- "public/images/digits/scout/8.gif",
58
- "public/images/digits/scout/9.gif",
59
- "spec/lib/hit_counter_spec.rb",
60
- "spec/spec_helper.rb"
61
- ]
62
- s.homepage = "http://github.com/ivanoblomov/hit_counter"
63
- s.licenses = ["MIT"]
64
- s.require_paths = ["lib"]
65
- s.rubygems_version = "1.8.10"
66
- s.summary = "Ruby version of that old 90s chestnut, the web-site hit counter."
17
+ s.add_runtime_dependency 'addressable', '~> 2'
18
+ s.add_runtime_dependency 'bson_ext', '~> 1'
19
+ s.add_runtime_dependency 'mongoid', '~> 7'
20
+ s.add_runtime_dependency 'rmagick', '>= 2', '< 5'
67
21
 
68
- if s.respond_to? :specification_version then
69
- s.specification_version = 3
70
-
71
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
72
- s.add_runtime_dependency(%q<addressable>, [">= 0"])
73
- s.add_runtime_dependency(%q<bson_ext>, [">= 0"])
74
- s.add_runtime_dependency(%q<mongoid>, [">= 0"])
75
- s.add_runtime_dependency(%q<rmagick>, ["= 2.12.2"])
76
- s.add_development_dependency(%q<jeweler>, [">= 0"])
77
- else
78
- s.add_dependency(%q<addressable>, [">= 0"])
79
- s.add_dependency(%q<bson_ext>, [">= 0"])
80
- s.add_dependency(%q<mongoid>, [">= 0"])
81
- s.add_dependency(%q<rmagick>, ["= 2.12.2"])
82
- s.add_dependency(%q<jeweler>, [">= 0"])
83
- end
84
- else
85
- s.add_dependency(%q<addressable>, [">= 0"])
86
- s.add_dependency(%q<bson_ext>, [">= 0"])
87
- s.add_dependency(%q<mongoid>, [">= 0"])
88
- s.add_dependency(%q<rmagick>, ["= 2.12.2"])
89
- s.add_dependency(%q<jeweler>, [">= 0"])
90
- end
22
+ s.files = `git ls-files`.split "\n"
23
+ s.require_paths = ['lib']
24
+ s.required_ruby_version = '>= 2.5'
91
25
  end
92
-