one_offs 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,27 @@
1
+ require 'one_offs/tracker'
2
+
3
+ module OneOffs
4
+ class Runner
5
+ class << self
6
+ def run
7
+ Dir.glob(File.join(Dir.pwd, "lib", "one_offs", "*.rb")).sort.each do |one_off|
8
+ execute(one_off)
9
+ end
10
+ end
11
+
12
+ private
13
+ def execute(one_off)
14
+ one_off_name = File.basename(one_off, ".rb")
15
+
16
+ if(!Tracker.complete?(one_off_name))
17
+ puts "Running #{one_off}"
18
+ require one_off
19
+ one_off_class = one_off_name.scan(/\d_(.*)/).to_s.classify
20
+ Object.const_get(one_off_class).send(:process)
21
+
22
+ Tracker.complete(one_off_name)
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -1,12 +1,13 @@
1
+ require 'one_offs/runner'
1
2
  namespace :one_offs do
2
- desc "run all the one-off scripts"
3
+ desc "Run all the one-off scripts"
3
4
  task :run => :environment do
4
- Dir.glob(File.join(RAILS_ROOT, "db", "one_offs", "*.rb")).sort.each do |one_off|
5
- puts "Running #{one_off}"
6
- require one_off
7
- one_off_name = File.basename(one_off, ".rb")
8
- one_off_class = one_off_name.scan(/\d_(.*)/).to_s.classify
9
- Object.const_get(one_off_class).send(:process)
10
- end
5
+ OneOffs::Runner.run
6
+ end
7
+
8
+
9
+ desc "Create a one off tracker table"
10
+ task :generate_tracker_table do
11
+ `script/generate migration CreateOneOffTracker name:string`
11
12
  end
12
13
  end
@@ -0,0 +1,18 @@
1
+ require 'active_record'
2
+
3
+ module OneOffs
4
+ class Tracker < ActiveRecord::Base
5
+ set_table_name "one_off_tracker"
6
+
7
+ class << self
8
+ def complete?(name)
9
+ find_by_name(name).present?
10
+ end
11
+
12
+ def complete(name)
13
+ create(:name => name)
14
+ end
15
+ end
16
+ end
17
+ end
18
+
@@ -1,3 +1,3 @@
1
1
  module OneOffs
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/lib/one_offs.rb CHANGED
@@ -1,4 +1,2 @@
1
+ require "one_offs"
1
2
  require "one_offs/version"
2
-
3
- module OneOffs
4
- end
data/one_offs.gemspec CHANGED
@@ -3,22 +3,20 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
  require "one_offs/version"
4
4
 
5
5
  Gem::Specification.new do |s|
6
- s.name = "one_offs"
6
+ s.name = 'one_offs'
7
7
  s.version = OneOffs::VERSION
8
- s.authors = ["Jatin Naik"]
9
- s.email = ["jsnaik@gmail.com"]
10
- s.homepage = "http://github.com/tinygrasshopper/one_offs"
11
- s.summary = "Track and manage your one off scripts"
12
- s.description = "Track and manage your one off scripts with rake"
8
+ s.authors = ['Jatin Naik']
9
+ s.email = ['jsnaik@gmail.com']
10
+ s.homepage = 'http://github.com/tinygrasshopper/one_offs'
11
+ s.summary = 'Track and manage your one off scripts'
12
+ s.description = 'Track and manage your one off scripts with rake'
13
13
 
14
- s.rubyforge_project = "one_offs"
14
+ s.rubyforge_project = 'one_offs'
15
15
 
16
16
  s.files = `git ls-files`.split("\n")
17
17
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
18
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
19
  s.require_paths = ["lib"]
20
20
 
21
- # specify any dependencies here; for example:
22
- # s.add_development_dependency "rspec"
23
- # s.add_runtime_dependency "rest-client"
21
+ s.add_dependency(%q<activerecord>, ['< 3.0.0', '>= 1.15.6'])
24
22
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: one_offs
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jatin Naik
@@ -15,9 +15,32 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-03-01 00:00:00 Z
19
- dependencies: []
20
-
18
+ date: 2012-03-08 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: activerecord
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - <
27
+ - !ruby/object:Gem::Version
28
+ hash: 7
29
+ segments:
30
+ - 3
31
+ - 0
32
+ - 0
33
+ version: 3.0.0
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ hash: 39
37
+ segments:
38
+ - 1
39
+ - 15
40
+ - 6
41
+ version: 1.15.6
42
+ type: :runtime
43
+ version_requirements: *id001
21
44
  description: Track and manage your one off scripts with rake
22
45
  email:
23
46
  - jsnaik@gmail.com
@@ -33,7 +56,9 @@ files:
33
56
  - LICENCE
34
57
  - Rakefile
35
58
  - lib/one_offs.rb
59
+ - lib/one_offs/runner.rb
36
60
  - lib/one_offs/tasks.rb
61
+ - lib/one_offs/tracker.rb
37
62
  - lib/one_offs/version.rb
38
63
  - one_offs.gemspec
39
64
  homepage: http://github.com/tinygrasshopper/one_offs