hit_counter 0.1.3 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. checksums.yaml +5 -13
  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 +2 -1
  10. data/.simplecov +15 -0
  11. data/CODE_OF_CONDUCT.md +10 -0
  12. data/CONTRIBUTING.md +34 -0
  13. data/Gemfile +14 -2
  14. data/LICENSE.txt +17 -11
  15. data/README.md +120 -0
  16. data/Rakefile +16 -1
  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 +2 -2
  21. data/hit_counter.gemspec +20 -18
  22. data/lib/hit_counter.rb +86 -90
  23. data/lib/tasks/install.rake +6 -0
  24. data/lib/version.rb +5 -1
  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 +103 -71
  56. data/spec/spec_helper.rb +47 -6
  57. data.tar.gz.sig +0 -0
  58. metadata +106 -110
  59. metadata.gz.sig +0 -0
  60. data/.ruby-version +0 -1
  61. data/.travis.yml +0 -4
  62. data/Gemfile.lock +0 -74
  63. data/README.rdoc +0 -84
  64. data/public/images/digits/celtic/0.gif +0 -0
  65. data/public/images/digits/celtic/1.gif +0 -0
  66. data/public/images/digits/celtic/2.gif +0 -0
  67. data/public/images/digits/celtic/3.gif +0 -0
  68. data/public/images/digits/celtic/4.gif +0 -0
  69. data/public/images/digits/celtic/5.gif +0 -0
  70. data/public/images/digits/celtic/6.gif +0 -0
  71. data/public/images/digits/celtic/7.gif +0 -0
  72. data/public/images/digits/celtic/8.gif +0 -0
  73. data/public/images/digits/celtic/9.gif +0 -0
  74. data/public/images/digits/odometer/0.gif +0 -0
  75. data/public/images/digits/odometer/1.gif +0 -0
  76. data/public/images/digits/odometer/2.gif +0 -0
  77. data/public/images/digits/odometer/3.gif +0 -0
  78. data/public/images/digits/odometer/4.gif +0 -0
  79. data/public/images/digits/odometer/5.gif +0 -0
  80. data/public/images/digits/odometer/6.gif +0 -0
  81. data/public/images/digits/odometer/7.gif +0 -0
  82. data/public/images/digits/odometer/8.gif +0 -0
  83. data/public/images/digits/odometer/9.gif +0 -0
  84. data/public/images/digits/scout/0.gif +0 -0
  85. data/public/images/digits/scout/1.gif +0 -0
  86. data/public/images/digits/scout/2.gif +0 -0
  87. data/public/images/digits/scout/3.gif +0 -0
  88. data/public/images/digits/scout/4.gif +0 -0
  89. data/public/images/digits/scout/5.gif +0 -0
  90. data/public/images/digits/scout/6.gif +0 -0
  91. data/public/images/digits/scout/7.gif +0 -0
  92. data/public/images/digits/scout/8.gif +0 -0
  93. data/public/images/digits/scout/9.gif +0 -0
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- ZGQ0YjdiZGVlZmUyNTQzOGE3NmZhMjdlN2QxY2E2ZjhmNjU1NDQ1ZA==
5
- data.tar.gz: !binary |-
6
- Y2M3MDc3YmNiMDMzOTVkMGM1YmMxNGM0NjZkODY5MjUzMTUyNWVlYw==
2
+ SHA256:
3
+ metadata.gz: fbfb2c9bd1a00b297d719291b41b16dcb09797054bab4f62c468e7888f9ddc29
4
+ data.tar.gz: 991c88922dfac1d2919797477c237afb0bf7df57ab829d6c6ee77104b51367e7
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- YjgyOGJlN2E0ZjAyMjA1YWE0NThmMTUzYzQxNDUxYThlYWRmYjYwYzAwNGEx
10
- ZWFiOGU3NmJkZTM4ZThiN2MzNGM3NGI2NzU0YzNmZDVkYzYzMDMwYzFkYTk0
11
- MGU3ZjZlNDRiNjcwYTYzNDUxNmNlZjJmYWY3Y2MwMTgwZTgwYjM=
12
- data.tar.gz: !binary |-
13
- ZjA1OTA4ZDA5M2VmMTM0NWUwMzhiZTc4MTdjMzE5YzlkMzY3MmU4YWNkMmJj
14
- NTkwMzljMTBlNGMwYmQ1YWY1YTI2MzIyZDFlZmYyZWQyZmU2MDA2MzU2YTQ5
15
- MDE0OGUwMWZkYWQ1MTc0YmJhYTdmMTI3ODJkNjAzMGMwMzA5YjA=
6
+ metadata.gz: c4d905febab9681d24ecbf406a4c83f8be4a40646d23c45f863dde1af2f156f2e800d511e497695f4eaa200a25de1a0cd624203e5f5c6bda35983296d62de157
7
+ data.tar.gz: 0e2bd9bac43d79b253277dabc8bfbdf531d45deac42a9f48202822c646a254257c405c9128ddd120f93700a5f0a30b2cbe0327861dfdf91d90673069092ba7ef
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 CHANGED
@@ -1,6 +1,7 @@
1
- .DS_Store
2
1
  *.gem
2
+ .DS_Store
3
3
  .bundle
4
+ Gemfile.lock
4
5
  coverage
5
6
  doc
6
7
  git.rake
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,2 +1,14 @@
1
- source 'http://rubygems.org'
2
- gemspec
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+ gemspec
5
+
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.26'
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-2022 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-2022 Roderick Monje. See LICENSE.txt for further details.
data/Rakefile CHANGED
@@ -1,8 +1,23 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'bundler'
2
4
  require 'bundler/gem_tasks'
3
5
  require 'rspec/core/rake_task'
6
+
7
+ def load_rake_tasks
8
+ Dir.glob('./lib/tasks/**/*.rake').each { |f| import f }
9
+ end
10
+ load_rake_tasks
11
+
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
18
+
4
19
  RSpec::Core::RakeTask.new(:test) do |t|
5
20
  t.pattern = 'spec/*/*_spec.rb'
6
21
  t.verbose = false
7
22
  end
8
- task :default => :test
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.6 | :white_check_mark: |
10
+ | < 0.1.6 | :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
data/config/mongoid.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  test:
2
- sessions:
2
+ clients:
3
3
  default:
4
4
  database: hit_counter
5
5
  hosts:
6
- - localhost:27017
6
+ - localhost:27017
data/hit_counter.gemspec CHANGED
@@ -1,23 +1,25 @@
1
- require File.expand_path '../lib/version', __FILE__
1
+ # frozen_string_literal: true
2
+
3
+ require File.expand_path 'lib/version', __dir__
2
4
  Gem::Specification.new do |s|
3
- s.name = "hit_counter"
5
+ s.name = 'hit_counter'
4
6
  s.version = HitCounter::VERSION.dup
5
- s.summary = "Ruby version of that old 90s chestnut, the web-site hit counter."
6
- s.description = "Why roast this chestnut by that open fire, you ask? Cause thousands and thousands of Internet vets are still using the one we wrote in PHP eons ago and we don't want to be squandering any incidental Google juice, that's why."
7
- s.homepage = "http://github.com/ivanoblomov/hit_counter"
8
- s.authors = ["Roderick Monje"]
9
-
10
- s.add_development_dependency 'rake', '>= 0'
11
- s.add_development_dependency 'rspec', '>= 0'
12
- s.add_development_dependency 'simplecov', '>= 0'
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/
13
16
 
14
- s.add_runtime_dependency 'addressable', '>= 0'
15
- s.add_runtime_dependency 'bson_ext', '>= 0'
16
- s.add_runtime_dependency 'mongoid', '~> 4'
17
- s.add_runtime_dependency 'rmagick', '~> 2'
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'
18
21
 
19
22
  s.files = `git ls-files`.split "\n"
20
- s.test_files = `git ls-files -- {test,spec,features}/*`.split "\n"
21
- s.executables = `git ls-files -- bin/*`.split("\n").map{|f| File.basename f}
22
- s.require_paths = ["lib"]
23
- end
23
+ s.require_paths = ['lib']
24
+ s.required_ruby_version = '>= 2.5'
25
+ end