headcount 0.0.1 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. data/CHANGELOG.md +6 -0
  2. data/README.md +65 -0
  3. data/lib/headcount.rb +3 -1
  4. data/lib/headcount/configuration.rb +9 -6
  5. data/lib/headcount/support.rb +17 -5
  6. data/lib/headcount/version.rb +1 -1
  7. metadata +5 -86
  8. data/README.rdoc +0 -3
  9. data/lib/headcount/api.rb +0 -11
  10. data/spec/dummy/README.rdoc +0 -261
  11. data/spec/dummy/Rakefile +0 -7
  12. data/spec/dummy/app/assets/javascripts/application.js +0 -15
  13. data/spec/dummy/app/assets/stylesheets/application.css +0 -13
  14. data/spec/dummy/app/controllers/application_controller.rb +0 -3
  15. data/spec/dummy/app/helpers/application_helper.rb +0 -2
  16. data/spec/dummy/app/models/user.rb +0 -2
  17. data/spec/dummy/app/views/layouts/application.html.erb +0 -14
  18. data/spec/dummy/config.ru +0 -4
  19. data/spec/dummy/config/application.rb +0 -62
  20. data/spec/dummy/config/boot.rb +0 -10
  21. data/spec/dummy/config/database.yml +0 -25
  22. data/spec/dummy/config/environment.rb +0 -5
  23. data/spec/dummy/config/environments/development.rb +0 -37
  24. data/spec/dummy/config/environments/production.rb +0 -67
  25. data/spec/dummy/config/environments/test.rb +0 -37
  26. data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
  27. data/spec/dummy/config/initializers/headcount.rb +0 -15
  28. data/spec/dummy/config/initializers/inflections.rb +0 -15
  29. data/spec/dummy/config/initializers/mime_types.rb +0 -5
  30. data/spec/dummy/config/initializers/secret_token.rb +0 -7
  31. data/spec/dummy/config/initializers/session_store.rb +0 -8
  32. data/spec/dummy/config/initializers/wrap_parameters.rb +0 -14
  33. data/spec/dummy/config/locales/en.yml +0 -5
  34. data/spec/dummy/config/routes.rb +0 -58
  35. data/spec/dummy/db/development.sqlite3 +0 -0
  36. data/spec/dummy/db/migrate/20120406005419_add_users.rb +0 -7
  37. data/spec/dummy/db/schema.rb +0 -20
  38. data/spec/dummy/db/test.sqlite3 +0 -0
  39. data/spec/dummy/log/development.log +0 -21
  40. data/spec/dummy/log/test.log +0 -858
  41. data/spec/dummy/public/404.html +0 -26
  42. data/spec/dummy/public/422.html +0 -26
  43. data/spec/dummy/public/500.html +0 -25
  44. data/spec/dummy/public/favicon.ico +0 -0
  45. data/spec/dummy/script/rails +0 -6
  46. data/spec/models/api_spec.rb +0 -71
  47. data/spec/models/configuration_spec.rb +0 -28
  48. data/spec/models/persistence_spec.rb +0 -33
  49. data/spec/spec_helper.rb +0 -23
  50. data/spec/tmp/headcount.json +0 -3
@@ -1,26 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>The page you were looking for doesn't exist (404)</title>
5
- <style type="text/css">
6
- body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
- div.dialog {
8
- width: 25em;
9
- padding: 0 4em;
10
- margin: 4em auto 0 auto;
11
- border: 1px solid #ccc;
12
- border-right-color: #999;
13
- border-bottom-color: #999;
14
- }
15
- h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
- </style>
17
- </head>
18
-
19
- <body>
20
- <!-- This file lives in public/404.html -->
21
- <div class="dialog">
22
- <h1>The page you were looking for doesn't exist.</h1>
23
- <p>You may have mistyped the address or the page may have moved.</p>
24
- </div>
25
- </body>
26
- </html>
@@ -1,26 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>The change you wanted was rejected (422)</title>
5
- <style type="text/css">
6
- body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
- div.dialog {
8
- width: 25em;
9
- padding: 0 4em;
10
- margin: 4em auto 0 auto;
11
- border: 1px solid #ccc;
12
- border-right-color: #999;
13
- border-bottom-color: #999;
14
- }
15
- h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
- </style>
17
- </head>
18
-
19
- <body>
20
- <!-- This file lives in public/422.html -->
21
- <div class="dialog">
22
- <h1>The change you wanted was rejected.</h1>
23
- <p>Maybe you tried to change something you didn't have access to.</p>
24
- </div>
25
- </body>
26
- </html>
@@ -1,25 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>We're sorry, but something went wrong (500)</title>
5
- <style type="text/css">
6
- body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
- div.dialog {
8
- width: 25em;
9
- padding: 0 4em;
10
- margin: 4em auto 0 auto;
11
- border: 1px solid #ccc;
12
- border-right-color: #999;
13
- border-bottom-color: #999;
14
- }
15
- h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
- </style>
17
- </head>
18
-
19
- <body>
20
- <!-- This file lives in public/500.html -->
21
- <div class="dialog">
22
- <h1>We're sorry, but something went wrong.</h1>
23
- </div>
24
- </body>
25
- </html>
File without changes
@@ -1,6 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
-
4
- APP_PATH = File.expand_path('../../config/application', __FILE__)
5
- require File.expand_path('../../config/boot', __FILE__)
6
- require 'rails/commands'
@@ -1,71 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Headcount do
4
- before(:each) do
5
- Headcount.reset
6
- end
7
-
8
- describe '.find' do
9
- context 'when the key is unknown' do
10
- it 'should simply return nil' do
11
- Headcount.find(:missing).should be_nil
12
- end
13
- end
14
- end
15
-
16
- describe '.reset' do
17
- it 'should remove all registered keys' do
18
- Headcount.register(:users, User)
19
- Headcount.reset
20
- Headcount.find(:users).should be_nil
21
- end
22
- end
23
-
24
- describe '.register' do
25
- let(:query) { User.where(true) }
26
-
27
- it 'should register the query for the given key' do
28
- Headcount.register(:users, query)
29
- Headcount.find(:users).should eq(query)
30
- end
31
-
32
- it 'should return the registered key' do
33
- Headcount.register(:users, query).should eq(:users)
34
- end
35
-
36
- it 'should always return the key as a symbol' do
37
- Headcount.register("users", query).should eq(:users)
38
- end
39
- end
40
-
41
- describe '.registry' do
42
- it 'should not be publicly accessible' do
43
- lambda { Headcount.registry }.should raise_error(NoMethodError)
44
- end
45
- end
46
-
47
- describe '.count' do
48
- context 'when called without arguments' do
49
- it 'returns the results as a hash' do
50
- Headcount.register(:users, User)
51
- Headcount.count.should eq({:users => User.count})
52
- end
53
- end
54
-
55
- context 'when given a key' do
56
- context 'and the key is registered' do
57
- it 'returns the count for the registered key' do
58
- Headcount.register(:users, User)
59
- Headcount.count(:users).should eq(User.count)
60
- end
61
- end
62
-
63
- context 'and the key is unknown' do
64
- it 'raises a Headcount::UnknownKey error' do
65
- lambda { Headcount.count(:missing) }.should raise_error(Headcount::UnknownKey)
66
- end
67
- end
68
-
69
- end
70
- end
71
- end
@@ -1,28 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Headcount::Configuration do
4
- let(:config) { Headcount.configure }
5
-
6
- describe '#count' do
7
- it 'should return the registration key' do
8
- config.count(User).should eq(:users)
9
- end
10
-
11
- it 'should add the given query to the registry' do
12
- Headcount.find(config.count(User)).should eq(User)
13
- end
14
-
15
- context 'when key is given' do
16
- it 'should override the default key' do
17
- config.count(User, :as => :members)
18
- Headcount.find(:members).should eq(User)
19
- end
20
- end
21
-
22
- context 'when a bad query is given' do
23
- it 'throws a Headcount::UnsupportedQuery error' do
24
- lambda { config.count(Object) }.should raise_error(Headcount::UnsupportedQuery)
25
- end
26
- end
27
- end
28
- end
@@ -1,33 +0,0 @@
1
- require 'spec_helper'
2
-
3
- # has to be defined as a contant or won't be available in configure block
4
- PATH = 'spec/tmp/headcount.json'
5
-
6
- describe Headcount do
7
- before(:each) do
8
- Headcount.configure do |config|
9
- config.path = PATH
10
- config.count User
11
- end
12
-
13
- File.delete(PATH) if File.exists?(PATH)
14
- end
15
-
16
- describe '.count!' do
17
- # right now a json file is the only supported form of persistence
18
- it 'writes the current headcount out to the persistence layer' do
19
- Headcount.count!
20
- File.exists?(PATH).should be_true
21
- end
22
-
23
- it 'appends to the existing contents' do
24
- 3.times do
25
- Headcount.count!
26
- end
27
-
28
- File.open(PATH, 'r') do |file|
29
- file.readlines.should have(3).items
30
- end
31
- end
32
- end
33
- end
data/spec/spec_helper.rb DELETED
@@ -1,23 +0,0 @@
1
- require 'rubygems'
2
- require 'spork'
3
- #uncomment the following line to use spork with the debugger
4
- #require 'spork/ext/ruby-debug'
5
-
6
- Spork.prefork do
7
- ENV["RAILS_ENV"] ||= 'test'
8
- require File.expand_path("../dummy/config/environment", __FILE__)
9
- require 'rspec/rails'
10
- require 'rspec/autorun'
11
-
12
- Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
13
-
14
- RSpec.configure do |config|
15
- config.fixture_path = "#{::Rails.root}/spec/fixtures"
16
- config.use_transactional_fixtures = true
17
- config.infer_base_class_for_anonymous_controllers = false
18
- end
19
- end
20
-
21
- Spork.each_run do
22
- # This code will be run each time you run your specs.
23
- end
@@ -1,3 +0,0 @@
1
- {"users":0,"members":0}
2
- {"users":0,"members":0}
3
- {"users":0,"members":0}