Statistics
This commit is contained in:
parent
7c6e2f442e
commit
16ea9b47f3
24
README.md
24
README.md
@ -1,24 +1,34 @@
|
||||
# RakeControl
|
||||
|
||||
TODO: Write a gem description
|
||||
RakeControl is a tool for managing Rake tasks.
|
||||
|
||||
## Installation
|
||||
|
||||
Add this line to your application's Gemfile:
|
||||
|
||||
gem 'rake_control'
|
||||
```ruby
|
||||
gem 'rake_control'
|
||||
```
|
||||
|
||||
And then execute:
|
||||
```
|
||||
$ bundle
|
||||
```
|
||||
|
||||
$ bundle
|
||||
## Configuration
|
||||
|
||||
Or install it yourself as:
|
||||
|
||||
$ gem install rake_control
|
||||
Add this lines to the top of your application's Rakefile:
|
||||
```ruby
|
||||
require 'rake_control'
|
||||
RakeControl.configure do |c|
|
||||
c.storage = :active_record # or :mongoid, :mongo_mapper
|
||||
end
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
TODO: Write usage instructions here
|
||||
stats = Rake::Task['my:task:name'].stats
|
||||
stats.log
|
||||
|
||||
## Contributing
|
||||
|
||||
|
@ -7,5 +7,9 @@ module Rake
|
||||
original_execute(args)
|
||||
end
|
||||
end
|
||||
|
||||
def stats
|
||||
RakeControl::Statistics.new(name)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -2,8 +2,9 @@ require 'bundler/setup'
|
||||
require 'rake'
|
||||
require File.expand_path('../rake/task', __FILE__)
|
||||
|
||||
require 'rake_control/version'
|
||||
require 'rake_control/config'
|
||||
require 'rake_control/statistics'
|
||||
require 'rake_control/version'
|
||||
require 'rake_control/wrapper'
|
||||
|
||||
module RakeControl
|
||||
@ -11,6 +12,11 @@ module RakeControl
|
||||
@config ||= Config.new
|
||||
end
|
||||
|
||||
def configure
|
||||
yield config if block_given?
|
||||
config.apply
|
||||
end
|
||||
|
||||
def wrap(name, description, &block)
|
||||
Wrapper.new(name, description, block).execute
|
||||
end
|
||||
|
@ -6,6 +6,12 @@ module RakeControl
|
||||
@storage = :active_record
|
||||
end
|
||||
|
||||
def apply
|
||||
setup_storage_model
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def setup_storage_model
|
||||
case storage
|
||||
when :active_record, :activerecord
|
||||
|
23
lib/rake_control/statistics.rb
Normal file
23
lib/rake_control/statistics.rb
Normal file
@ -0,0 +1,23 @@
|
||||
module RakeControl
|
||||
class Statistics
|
||||
attr_reader :name
|
||||
|
||||
def initialize(name)
|
||||
@name = name
|
||||
end
|
||||
|
||||
def last
|
||||
relation.last
|
||||
end
|
||||
|
||||
def log
|
||||
relation.all
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def relation
|
||||
Run.where(name: name)
|
||||
end
|
||||
end
|
||||
end
|
Loading…
x
Reference in New Issue
Block a user