hit_counter 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +15 -0
  2. data/.gitignore +7 -0
  3. data/.ruby-version +1 -0
  4. data/.travis.yml +4 -0
  5. data/Gemfile +1 -13
  6. data/Gemfile.lock +74 -0
  7. data/README.rdoc +19 -17
  8. data/Rakefile +5 -45
  9. data/config/mongoid.yml +6 -0
  10. data/hit_counter.gemspec +17 -86
  11. data/lib/hit_counter.rb +1 -1
  12. data/lib/version.rb +3 -0
  13. data/public/images/digits/celtic/0.gif +0 -0
  14. data/public/images/digits/celtic/2.gif +0 -0
  15. data/public/images/digits/celtic/4.gif +0 -0
  16. data/public/images/digits/celtic/7.gif +0 -0
  17. data/public/images/digits/celtic/8.gif +0 -0
  18. data/public/images/digits/celtic/9.gif +0 -0
  19. data/public/images/digits/odometer/0.gif +0 -0
  20. data/public/images/digits/odometer/1.gif +0 -0
  21. data/public/images/digits/odometer/2.gif +0 -0
  22. data/public/images/digits/odometer/3.gif +0 -0
  23. data/public/images/digits/odometer/4.gif +0 -0
  24. data/public/images/digits/odometer/5.gif +0 -0
  25. data/public/images/digits/odometer/6.gif +0 -0
  26. data/public/images/digits/odometer/7.gif +0 -0
  27. data/public/images/digits/odometer/8.gif +0 -0
  28. data/public/images/digits/odometer/9.gif +0 -0
  29. data/public/images/digits/scout/0.gif +0 -0
  30. data/public/images/digits/scout/1.gif +0 -0
  31. data/public/images/digits/scout/2.gif +0 -0
  32. data/public/images/digits/scout/3.gif +0 -0
  33. data/public/images/digits/scout/4.gif +0 -0
  34. data/public/images/digits/scout/5.gif +0 -0
  35. data/public/images/digits/scout/6.gif +0 -0
  36. data/public/images/digits/scout/7.gif +0 -0
  37. data/public/images/digits/scout/8.gif +0 -0
  38. data/public/images/digits/scout/9.gif +0 -0
  39. data/spec/lib/hit_counter_spec.rb +24 -25
  40. data/spec/spec_helper.rb +9 -1
  41. metadata +125 -112
  42. data/VERSION +0 -1
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ZGQ0YjdiZGVlZmUyNTQzOGE3NmZhMjdlN2QxY2E2ZjhmNjU1NDQ1ZA==
5
+ data.tar.gz: !binary |-
6
+ Y2M3MDc3YmNiMDMzOTVkMGM1YmMxNGM0NjZkODY5MjUzMTUyNWVlYw==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ YjgyOGJlN2E0ZjAyMjA1YWE0NThmMTUzYzQxNDUxYThlYWRmYjYwYzAwNGEx
10
+ ZWFiOGU3NmJkZTM4ZThiN2MzNGM3NGI2NzU0YzNmZDVkYzYzMDMwYzFkYTk0
11
+ MGU3ZjZlNDRiNjcwYTYzNDUxNmNlZjJmYWY3Y2MwMTgwZTgwYjM=
12
+ data.tar.gz: !binary |-
13
+ ZjA1OTA4ZDA5M2VmMTM0NWUwMzhiZTc4MTdjMzE5YzlkMzY3MmU4YWNkMmJj
14
+ NTkwMzljMTBlNGMwYmQ1YWY1YTI2MzIyZDFlZmYyZWQyZmU2MDA2MzU2YTQ5
15
+ MDE0OGUwMWZkYWQ1MTc0YmJhYTdmMTI3ODJkNjAzMGMwMzA5YjA=
data/.gitignore ADDED
@@ -0,0 +1,7 @@
1
+ .DS_Store
2
+ *.gem
3
+ .bundle
4
+ coverage
5
+ doc
6
+ git.rake
7
+ tmp
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ ruby-1.9.3-p385
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ rvm:
2
+ - 1.9.3
3
+ - 2.0.0
4
+ services: mongodb
data/Gemfile CHANGED
@@ -1,14 +1,2 @@
1
1
  source 'http://rubygems.org'
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
2
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,74 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ hit_counter (0.1.3)
5
+ addressable
6
+ bson_ext
7
+ mongoid (~> 4)
8
+ rmagick (~> 2)
9
+
10
+ GEM
11
+ remote: http://rubygems.org/
12
+ specs:
13
+ activemodel (4.1.6)
14
+ activesupport (= 4.1.6)
15
+ builder (~> 3.1)
16
+ activesupport (4.1.6)
17
+ i18n (~> 0.6, >= 0.6.9)
18
+ json (~> 1.7, >= 1.7.7)
19
+ minitest (~> 5.1)
20
+ thread_safe (~> 0.1)
21
+ tzinfo (~> 1.1)
22
+ addressable (2.3.6)
23
+ bson (2.3.0)
24
+ bson_ext (1.5.1)
25
+ builder (3.2.2)
26
+ connection_pool (2.0.0)
27
+ diff-lcs (1.2.5)
28
+ docile (1.1.5)
29
+ i18n (0.6.11)
30
+ json (1.8.1)
31
+ minitest (5.4.2)
32
+ mongoid (4.0.0)
33
+ activemodel (~> 4.0)
34
+ moped (~> 2.0.0)
35
+ origin (~> 2.1)
36
+ tzinfo (>= 0.3.37)
37
+ moped (2.0.0)
38
+ bson (~> 2.2)
39
+ connection_pool (~> 2.0)
40
+ optionable (~> 0.2.0)
41
+ multi_json (1.10.1)
42
+ optionable (0.2.0)
43
+ origin (2.1.1)
44
+ rake (10.3.2)
45
+ rmagick (2.13.3)
46
+ rspec (3.1.0)
47
+ rspec-core (~> 3.1.0)
48
+ rspec-expectations (~> 3.1.0)
49
+ rspec-mocks (~> 3.1.0)
50
+ rspec-core (3.1.4)
51
+ rspec-support (~> 3.1.0)
52
+ rspec-expectations (3.1.2)
53
+ diff-lcs (>= 1.2.0, < 2.0)
54
+ rspec-support (~> 3.1.0)
55
+ rspec-mocks (3.1.2)
56
+ rspec-support (~> 3.1.0)
57
+ rspec-support (3.1.1)
58
+ simplecov (0.9.1)
59
+ docile (~> 1.1.0)
60
+ multi_json (~> 1.0)
61
+ simplecov-html (~> 0.8.0)
62
+ simplecov-html (0.8.0)
63
+ thread_safe (0.3.4)
64
+ tzinfo (1.2.2)
65
+ thread_safe (~> 0.1)
66
+
67
+ PLATFORMS
68
+ ruby
69
+
70
+ DEPENDENCIES
71
+ hit_counter!
72
+ rake
73
+ rspec
74
+ simplecov
data/README.rdoc CHANGED
@@ -1,13 +1,17 @@
1
- = hit_counter
1
+ = HitCounter
2
2
 
3
- Ruby version of that old 90s chestnut, the web-site hit counter.
3
+ {<img src="https://badge.fury.io/rb/hit_counter.svg" alt="Gem Version" />}[http://badge.fury.io/rb/hit_counter]
4
+ {<img src="https://codeclimate.com/github/ivanoblomov/hit_counter.png" />}[https://codeclimate.com/github/ivanoblomov/hit_counter]
5
+ {<img src="https://secure.travis-ci.org/ivanoblomov/hit_counter.png"/>}[http://travis-ci.org/ivanoblomov/hit_counter]
6
+ {<img src="https://gemnasium.com/ivanoblomov/hit_counter.png" alt="Dependency Status" />}[https://gemnasium.com/ivanoblomov/hit_counter]
4
7
 
5
- == How to Install
8
+ Ruby version of that old 90s chestnut, <BLINK>the web-site hit counter</BLINK>.
6
9
 
7
- 1. Install the gem and supporting files.
10
+ == Installation
8
11
 
9
- +Gemfile+:
12
+ 1. Install the gem and supporting files.
10
13
 
14
+ +Gemfile+
11
15
  gem 'hit_counter'
12
16
 
13
17
  Run:
@@ -17,8 +21,7 @@ Ruby version of that old 90s chestnut, the web-site hit counter.
17
21
 
18
22
  2. Add a controller action to your app.
19
23
 
20
- +application_controller.rb+:
21
-
24
+ +application_controller.rb+
22
25
  def hit_counter
23
26
  return if params[:url].blank?
24
27
 
@@ -28,31 +31,30 @@ Ruby version of that old 90s chestnut, the web-site hit counter.
28
31
  # increase the tally by one
29
32
  hc.increment
30
33
 
31
- # get the image as a blog and stream it to the browser
34
+ # get the image as a blob and stream it to the browser
32
35
  send_data hc.image(params[:style]).to_blob, :disposition => 'inline', :filename => "#{hc.hits}.png", :type => :png
33
36
  end
34
37
 
35
- +routes.rb+:
36
-
38
+ +routes.rb+
37
39
  get 'hit-counter' => 'application#hit_counter' # technically should be POST/PUT, but GET makes integration simpler
38
40
 
39
41
  3. Add the hit-counter image tag to your site's HTML:
40
42
 
41
43
  <img alt="Hit Counter" border="0" src="/hit-counter?url=http://cnn.com&style=1" />
42
44
 
43
- == How to Customize the Hit-Counter Image
45
+ == Customizing the Hit-Counter Image
44
46
 
45
47
  === Use an Existing Style
46
48
 
47
- * You can use one of the three included styles by specifying a different +style+ param in the HTML:
49
+ You can use one of the three included styles by specifying a different +style+ param in the HTML:
48
50
 
49
51
  <img alt="Hit Counter" border="0" src="/hit-counter?url=cnn.com&style=1" />
50
52
 
51
- The included styles are:
53
+ The included styles are:
52
54
 
53
- http://github.com/ivanoblomov/hit_counter/raw/master/public/images/digits/odometer/1.gif odometer
54
- http://github.com/ivanoblomov/hit_counter/raw/master/public/images/digits/scout/2.gif scout
55
- http://github.com/ivanoblomov/hit_counter/raw/master/public/images/digits/celtic/3.gif Celtic
55
+ http://github.com/ivanoblomov/hit_counter/raw/master/public/images/digits/odometer/1.gif odometer
56
+ http://github.com/ivanoblomov/hit_counter/raw/master/public/images/digits/scout/2.gif scout
57
+ http://github.com/ivanoblomov/hit_counter/raw/master/public/images/digits/celtic/3.gif Celtic
56
58
 
57
59
  === Create Your Own Style
58
60
 
@@ -79,4 +81,4 @@ Ruby version of that old 90s chestnut, the web-site hit counter.
79
81
  == Copyright
80
82
 
81
83
  Copyright (c) 2011 Roderick Monje. See LICENSE.txt for
82
- further details.
84
+ further details.
data/Rakefile CHANGED
@@ -1,48 +1,8 @@
1
- # encoding: utf-8
2
-
3
- require 'rubygems'
4
1
  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'
2
+ require 'bundler/gem_tasks'
28
3
  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')
4
+ RSpec::Core::RakeTask.new(:test) do |t|
5
+ t.pattern = 'spec/*/*_spec.rb'
6
+ t.verbose = false
48
7
  end
8
+ task :default => :test
@@ -0,0 +1,6 @@
1
+ test:
2
+ sessions:
3
+ default:
4
+ database: hit_counter
5
+ hosts:
6
+ - localhost:27017
data/hit_counter.gemspec CHANGED
@@ -1,92 +1,23 @@
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 -*-
5
-
1
+ require File.expand_path '../lib/version', __FILE__
6
2
  Gem::Specification.new do |s|
7
3
  s.name = "hit_counter"
8
- s.version = "0.1.2"
9
-
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-30"
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"
4
+ s.version = HitCounter::VERSION.dup
66
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"]
67
9
 
68
- if s.respond_to? :specification_version then
69
- s.specification_version = 3
10
+ s.add_development_dependency 'rake', '>= 0'
11
+ s.add_development_dependency 'rspec', '>= 0'
12
+ s.add_development_dependency 'simplecov', '>= 0'
70
13
 
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
91
- end
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'
92
18
 
19
+ 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
data/lib/hit_counter.rb CHANGED
@@ -55,7 +55,7 @@ class HitCounter
55
55
  # - the site's HitCounter
56
56
  def self.get url, hits = 0
57
57
  args = {:url => HitCounter.normalize_url(url)}
58
- args[:hits] = hits unless HitCounter.exists? :conditions => args
58
+ args[:hits] = hits unless HitCounter.where(:conditions => args).exists?
59
59
  self.find_or_create_by args
60
60
  end
61
61
 
data/lib/version.rb ADDED
@@ -0,0 +1,3 @@
1
+ class HitCounter
2
+ VERSION = '0.1.3'.freeze unless defined?(HitCounter::VERSION)
3
+ end
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -11,12 +11,12 @@ describe HitCounter do
11
11
  before { @hit_counter2 = HitCounter.get @hit_counter.url, 10 }
12
12
 
13
13
  describe 'document count' do
14
- specify { HitCounter.count.should == 1 }
14
+ it { expect(HitCounter.count).to eq 1 }
15
15
  end
16
16
 
17
17
  context 'with starting count 10' do
18
18
  describe 'hits' do
19
- specify { @hit_counter2.hits.should == 0 }
19
+ it { expect(@hit_counter2.hits).to eq 10 }
20
20
  end
21
21
  end
22
22
  end
@@ -25,18 +25,18 @@ describe HitCounter do
25
25
  before { HitCounter.get 'www.cnn.com' }
26
26
 
27
27
  describe 'document count' do
28
- specify { HitCounter.count.should == 2 }
28
+ it { expect(HitCounter.count).to eq 2 }
29
29
  end
30
30
 
31
31
  context 'with blank starting count' do
32
32
  describe '#hits' do
33
- specify { HitCounter.get('www.nytimes.com', nil).hits.should == 0 }
33
+ it { expect(HitCounter.get('www.nytimes.com', nil).hits).to eq 0 }
34
34
  end
35
35
  end
36
36
 
37
37
  context 'with starting count 10' do
38
38
  describe '#hits' do
39
- specify { HitCounter.get('online.wsj.com', 10).hits.should == 10 }
39
+ it { expect(HitCounter.get('online.wsj.com', 10).hits).to eq 10 }
40
40
  end
41
41
  end
42
42
  end
@@ -45,62 +45,61 @@ describe HitCounter do
45
45
  describe '#hits' do
46
46
  subject { @hit_counter.hits }
47
47
 
48
- it { should == 0 }
48
+ it { expect(subject).to eq 0 }
49
49
 
50
50
  context 'when incremented' do
51
51
  before { @hit_counter.increment }
52
52
 
53
- specify { @hit_counter.hits.should == 1 }
53
+ it { expect(@hit_counter.hits).to eq 1 }
54
54
  end
55
55
  end
56
56
 
57
57
  describe '#image' do
58
58
  subject { @hit_counter.image '1' }
59
59
 
60
- it { should be_a Magick::Image }
61
- pending 'should reflect hits'
60
+ it { expect(subject).to be_a Magick::Image }
62
61
  end
63
62
 
64
63
  describe '#normalize_style_number' do
65
64
  context 'when nil' do
66
- it { HitCounter.normalize_style_number(nil).should be_zero }
65
+ it { expect(HitCounter.normalize_style_number(nil)).to be_zero }
67
66
  end
68
67
 
69
68
  context 'when empty string' do
70
- it { HitCounter.normalize_style_number('').should be_zero }
69
+ it { expect(HitCounter.normalize_style_number('')).to be_zero }
71
70
  end
72
71
 
73
72
  context 'when within range' do
74
- it 'should return 0 for 1' do
75
- HitCounter.normalize_style_number('1').should == 0
73
+ it 'returns 0 for 1' do
74
+ expect(HitCounter.normalize_style_number('1')).to eq 0
76
75
  end
77
76
 
78
- it 'should return 2 for 3' do
79
- HitCounter.normalize_style_number('3').should == 2
77
+ it 'returns 2 for 3' do
78
+ expect(HitCounter.normalize_style_number('3')).to eq 2
80
79
  end
81
80
  end
82
81
 
83
82
  context 'when outside range' do
84
- context 'and negative' do
85
- context 'should return 2 for' do
83
+ context 'with negative' do
84
+ context 'returns 2 for' do
86
85
  it -1 do
87
- HitCounter.normalize_style_number('-1').should == 2
86
+ expect(HitCounter.normalize_style_number('-1')).to eq 2
88
87
  end
89
88
 
90
89
  it -31 do
91
- HitCounter.normalize_style_number('-31').should == 2
90
+ expect(HitCounter.normalize_style_number('-31')).to eq 2
92
91
  end
93
92
  end
94
93
  end
95
94
 
96
- context 'and positive' do
97
- context 'should return 0 for' do
95
+ context 'with positive' do
96
+ context 'returns 0 for' do
98
97
  it 4 do
99
- HitCounter.normalize_style_number('4').should == 0
98
+ expect(HitCounter.normalize_style_number('4')).to eq 0
100
99
  end
101
100
 
102
101
  it 34 do
103
- HitCounter.normalize_style_number('34').should == 0
102
+ expect(HitCounter.normalize_style_number('34')).to eq 0
104
103
  end
105
104
  end
106
105
  end
@@ -109,11 +108,11 @@ describe HitCounter do
109
108
 
110
109
  describe '#normalize_url' do
111
110
  context 'with "cnn.com"' do
112
- specify { HitCounter.normalize_url('cnn.com').should == 'http://cnn.com' }
111
+ it { expect(HitCounter.normalize_url('cnn.com')).to eq 'http://cnn.com' }
113
112
  end
114
113
 
115
114
  context 'with "http://www.nytimes.com"' do
116
- specify { HitCounter.normalize_url('http://www.nytimes.com').should == 'http://www.nytimes.com' }
115
+ it { expect(HitCounter.normalize_url('http://www.nytimes.com')).to eq 'http://www.nytimes.com' }
117
116
  end
118
117
  end
119
118
  end
data/spec/spec_helper.rb CHANGED
@@ -1,9 +1,17 @@
1
1
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
2
  $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+
4
+ require 'simplecov'
5
+ SimpleCov.start
6
+
7
+ require 'addressable/uri'
8
+ require 'mongoid'
9
+ require 'RMagick'
3
10
  require 'rspec'
11
+
4
12
  require 'hit_counter'
5
13
 
6
- Mongoid::Config.from_hash 'database' => 'hit_counter'
14
+ Mongoid.load! 'config/mongoid.yml', :test
7
15
  Mongoid.logger = false
8
16
 
9
17
  # Stub Rails root during tests.
metadata CHANGED
@@ -1,114 +1,136 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: hit_counter
3
- version: !ruby/object:Gem::Version
4
- hash: 31
5
- prerelease:
6
- segments:
7
- - 0
8
- - 1
9
- - 2
10
- version: 0.1.2
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.3
11
5
  platform: ruby
12
- authors:
6
+ authors:
13
7
  - Roderick Monje
14
8
  autorequire:
15
9
  bindir: bin
16
10
  cert_chain: []
17
-
18
- date: 2011-09-30 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
21
- name: addressable
11
+ date: 2014-09-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ! '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
22
21
  prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
24
- none: false
25
- requirements:
26
- - - ">="
27
- - !ruby/object:Gem::Version
28
- hash: 3
29
- segments:
30
- - 0
31
- version: "0"
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ! '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: simplecov
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: addressable
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
32
62
  type: :runtime
33
- version_requirements: *id001
34
- - !ruby/object:Gem::Dependency
35
- name: bson_ext
36
63
  prerelease: false
37
- requirement: &id002 !ruby/object:Gem::Requirement
38
- none: false
39
- requirements:
40
- - - ">="
41
- - !ruby/object:Gem::Version
42
- hash: 3
43
- segments:
44
- - 0
45
- version: "0"
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: bson_ext
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ! '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
46
76
  type: :runtime
47
- version_requirements: *id002
48
- - !ruby/object:Gem::Dependency
49
- name: mongoid
50
77
  prerelease: false
51
- requirement: &id003 !ruby/object:Gem::Requirement
52
- none: false
53
- requirements:
54
- - - ">="
55
- - !ruby/object:Gem::Version
56
- hash: 3
57
- segments:
58
- - 0
59
- version: "0"
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ! '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: mongoid
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ~>
88
+ - !ruby/object:Gem::Version
89
+ version: '4'
60
90
  type: :runtime
61
- version_requirements: *id003
62
- - !ruby/object:Gem::Dependency
63
- name: rmagick
64
91
  prerelease: false
65
- requirement: &id004 !ruby/object:Gem::Requirement
66
- none: false
67
- requirements:
68
- - - "="
69
- - !ruby/object:Gem::Version
70
- hash: 59
71
- segments:
72
- - 2
73
- - 12
74
- - 2
75
- version: 2.12.2
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ~>
95
+ - !ruby/object:Gem::Version
96
+ version: '4'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rmagick
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ~>
102
+ - !ruby/object:Gem::Version
103
+ version: '2'
76
104
  type: :runtime
77
- version_requirements: *id004
78
- - !ruby/object:Gem::Dependency
79
- name: jeweler
80
105
  prerelease: false
81
- requirement: &id005 !ruby/object:Gem::Requirement
82
- none: false
83
- requirements:
84
- - - ">="
85
- - !ruby/object:Gem::Version
86
- hash: 3
87
- segments:
88
- - 0
89
- version: "0"
90
- type: :development
91
- version_requirements: *id005
92
- description:
93
- email: rod@seologic.com
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ~>
109
+ - !ruby/object:Gem::Version
110
+ version: '2'
111
+ description: Why roast this chestnut by that open fire, you ask? Cause thousands and
112
+ thousands of Internet vets are still using the one we wrote in PHP eons ago and
113
+ we don't want to be squandering any incidental Google juice, that's why.
114
+ email:
94
115
  executables: []
95
-
96
116
  extensions: []
97
-
98
- extra_rdoc_files:
99
- - LICENSE.txt
100
- - README.rdoc
101
- files:
117
+ extra_rdoc_files: []
118
+ files:
102
119
  - .document
120
+ - .gitignore
103
121
  - .rspec
122
+ - .ruby-version
123
+ - .travis.yml
104
124
  - Gemfile
125
+ - Gemfile.lock
105
126
  - LICENSE.txt
106
127
  - README.rdoc
107
128
  - Rakefile
108
- - VERSION
109
129
  - config/initializers/mime_types.rb
130
+ - config/mongoid.yml
110
131
  - hit_counter.gemspec
111
132
  - lib/hit_counter.rb
133
+ - lib/version.rb
112
134
  - public/images/digits/celtic/0.gif
113
135
  - public/images/digits/celtic/1.gif
114
136
  - public/images/digits/celtic/2.gif
@@ -142,37 +164,28 @@ files:
142
164
  - spec/lib/hit_counter_spec.rb
143
165
  - spec/spec_helper.rb
144
166
  homepage: http://github.com/ivanoblomov/hit_counter
145
- licenses:
146
- - MIT
167
+ licenses: []
168
+ metadata: {}
147
169
  post_install_message:
148
170
  rdoc_options: []
149
-
150
- require_paths:
171
+ require_paths:
151
172
  - lib
152
- required_ruby_version: !ruby/object:Gem::Requirement
153
- none: false
154
- requirements:
155
- - - ">="
156
- - !ruby/object:Gem::Version
157
- hash: 3
158
- segments:
159
- - 0
160
- version: "0"
161
- required_rubygems_version: !ruby/object:Gem::Requirement
162
- none: false
163
- requirements:
164
- - - ">="
165
- - !ruby/object:Gem::Version
166
- hash: 3
167
- segments:
168
- - 0
169
- version: "0"
173
+ required_ruby_version: !ruby/object:Gem::Requirement
174
+ requirements:
175
+ - - ! '>='
176
+ - !ruby/object:Gem::Version
177
+ version: '0'
178
+ required_rubygems_version: !ruby/object:Gem::Requirement
179
+ requirements:
180
+ - - ! '>='
181
+ - !ruby/object:Gem::Version
182
+ version: '0'
170
183
  requirements: []
171
-
172
184
  rubyforge_project:
173
- rubygems_version: 1.8.10
185
+ rubygems_version: 2.2.2
174
186
  signing_key:
175
- specification_version: 3
187
+ specification_version: 4
176
188
  summary: Ruby version of that old 90s chestnut, the web-site hit counter.
177
- test_files: []
178
-
189
+ test_files:
190
+ - spec/lib/hit_counter_spec.rb
191
+ - spec/spec_helper.rb
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.1.2