clockwork_database_events 0.1.2 → 0.2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 87508efecb9788fa959e51e2a59ada47dfb14142
4
- data.tar.gz: d082da4c55f1d4f7032bf13a01ccdfff7861803d
3
+ metadata.gz: f4f32fe87c840fce7293b27422d68774f68008b5
4
+ data.tar.gz: bb9f90713dde95bdb5cba885c1b6deaac9448504
5
5
  SHA512:
6
- metadata.gz: ac563a8e77dad784716ca92720b563f06be20d494559c9009c45bfe965a02b45c19b3095cefb40480511160c723a532a3f03a34cc79495882c180d75c95ca0eb
7
- data.tar.gz: 2ae2666718ebaf053bfc48849dae06b478ca6da34b1330e48a74cd0fec8d5db200c3f49254144e8352592922c4b9603f1a2540076cb368aea7cbd4e6d6855417
6
+ metadata.gz: 1c1e87f09f61683b0e4d6b941171380ddac5687849376a8df831154f97455294d94fbcb223ea60aaca3e60ae638cb5764681f7152d0373db4f69101a4c1da042
7
+ data.tar.gz: f6337f8689eb63a62c5a819b88e4b957d6f6f760a9d55df07c033d74b86f2cf29106624e351dd59ba065b65a5c778e10b9bac95766206922316445a4b0bff5d7
data/Rakefile CHANGED
@@ -1,22 +1,21 @@
1
1
  require 'bundler/gem_tasks'
2
2
  require 'rubocop/rake_task'
3
+ require 'sequel'
3
4
 
4
5
  RuboCop::RakeTask.new
5
6
 
6
7
  namespace :db do
8
+ db = Sequel.connect(ENV.fetch('DATABASE_URL', 'sqlite://'))
9
+
7
10
  desc 'migrate the database to the latest version'
8
11
  task :migrate do
9
- require 'sequel'
10
- Sequel.extension :migration
11
- DB = Sequel.connect(ENV.fetch('DATABASE_URL', 'sqlite://'))
12
- Sequel::Migrator.run(DB, 'db/migrations')
12
+ require 'clockwork_database_events'
13
+ ClockworkDatabaseEvents.migrate(db)
13
14
  end
14
15
 
15
16
  desc 'seed the database with frequencies'
16
17
  task seed: :migrate do
17
- require 'clockwork_database_events'
18
- [:second, :minute, :hour, :day, :week, :month].each do |period|
19
- FrequencyPeriod.create(name: period)
20
- end
18
+ require 'clockwork_database_events/models'
19
+ ClockworkDatabaseEvents.seed
21
20
  end
22
21
  end
@@ -1,12 +1,14 @@
1
- require 'sequel'
2
- require 'active_support/time'
3
-
4
- Sequel::Model.plugin :timestamps, update_on_create: true
5
-
6
1
  require 'clockwork_database_events/version'
7
- require 'clockwork_database_events/models/clockwork_database_event'
8
- require 'clockwork_database_events/models/frequency_period'
9
2
 
10
3
  # clockwork database events
11
4
  module ClockworkDatabaseEvents
5
+ def migrate(db)
6
+ require 'sequel'
7
+ Sequel.extension :migration
8
+ migrations = File.expand_path('../../db/migrations', __FILE__)
9
+ return if Sequel::Migrator.is_current?(db, migrations)
10
+ Sequel::Migrator.run(db, migrations)
11
+ end
12
+
13
+ module_function :migrate
12
14
  end
@@ -0,0 +1,17 @@
1
+ require 'active_support/time'
2
+
3
+ Sequel::Model.plugin :timestamps, update_on_create: true
4
+
5
+ require 'clockwork_database_events/models/clockwork_database_event'
6
+ require 'clockwork_database_events/models/frequency_period'
7
+
8
+ # clockwork database events
9
+ module ClockworkDatabaseEvents
10
+ def seed
11
+ %w(second minute hour day week month).each do |period|
12
+ FrequencyPeriod.find_or_create(name: period)
13
+ end
14
+ end
15
+
16
+ module_function :seed
17
+ end
@@ -1,4 +1,4 @@
1
1
  # version
2
2
  module ClockworkDatabaseEvents
3
- VERSION = '0.1.2'
3
+ VERSION = '0.2.0'
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: clockwork_database_events
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Englund
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-29 00:00:00.000000000 Z
11
+ date: 2015-06-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sequel
@@ -112,8 +112,9 @@ files:
112
112
  - bin/console
113
113
  - bin/setup
114
114
  - clockwork_database_events.gemspec
115
- - db/migrations/201505300840_initial.rb
115
+ - db/migrations/201505290840_initial.rb
116
116
  - lib/clockwork_database_events.rb
117
+ - lib/clockwork_database_events/models.rb
117
118
  - lib/clockwork_database_events/models/clockwork_database_event.rb
118
119
  - lib/clockwork_database_events/models/frequency_period.rb
119
120
  - lib/clockwork_database_events/version.rb