activerecord_settings 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 852311e5e27b535340fa0f8e64bafe3a333f78a3
4
- data.tar.gz: 61f359029594c66c2290f74ba4b3421da7190bbf
3
+ metadata.gz: 48a87bf726834d2f83bc7f033e5621a493b61696
4
+ data.tar.gz: 7950f1f8a72055f21839812c54777f130c7b5ec9
5
5
  SHA512:
6
- metadata.gz: 54a9d497937e21a818ab26b79729f9429ff0f13feeae02e2d254fae55efcfcc01914df5dbbe06da5b63f8591dbd1280d913a314f45f7081dc0853081d89f1a1a
7
- data.tar.gz: 071455fb4096a577f5573ca77e5fd025463153dba12f417b32382a1dc25012ea7233952fef451c0b94e449fea62bc6cf3ebfb9c8f89427e674ff113a3eed273d
6
+ metadata.gz: 0f199104198669eadeab3e3c498ae948f67503d9828c25887694772e989872ab893091a70ceec40583f0cdd9a887eb07e7a98112231f759f5dc0df257d2ddf89
7
+ data.tar.gz: 971c701e6f0028d2a37a2687610fe823948a5bfaafa3000c61ffb1d7f615f0a8ed7b2ff9653ce49c6f6415b983f1d653aaa67b77b75e98016c063e64f1776b7b
data/Gemfile.lock ADDED
@@ -0,0 +1,103 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ activerecord_settings (0.0.1)
5
+ activerecord (>= 3.0, < 5.2)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ actionpack (3.2.22.5)
11
+ activemodel (= 3.2.22.5)
12
+ activesupport (= 3.2.22.5)
13
+ builder (~> 3.0.0)
14
+ erubis (~> 2.7.0)
15
+ journey (~> 1.0.4)
16
+ rack (~> 1.4.5)
17
+ rack-cache (~> 1.2)
18
+ rack-test (~> 0.6.1)
19
+ sprockets (~> 2.2.1)
20
+ activemodel (3.2.22.5)
21
+ activesupport (= 3.2.22.5)
22
+ builder (~> 3.0.0)
23
+ activerecord (3.2.22.5)
24
+ activemodel (= 3.2.22.5)
25
+ activesupport (= 3.2.22.5)
26
+ arel (~> 3.0.2)
27
+ tzinfo (~> 0.3.29)
28
+ activesupport (3.2.22.5)
29
+ i18n (~> 0.6, >= 0.6.4)
30
+ multi_json (~> 1.0)
31
+ arel (3.0.3)
32
+ builder (3.0.4)
33
+ concurrent-ruby (1.0.5)
34
+ diff-lcs (1.3)
35
+ erubis (2.7.0)
36
+ generator_spec (0.9.4)
37
+ activesupport (>= 3.0.0)
38
+ railties (>= 3.0.0)
39
+ hike (1.2.3)
40
+ i18n (0.9.3)
41
+ concurrent-ruby (~> 1.0)
42
+ journey (1.0.4)
43
+ json (1.8.6)
44
+ multi_json (1.13.1)
45
+ power_assert (0.2.6)
46
+ rack (1.4.7)
47
+ rack-cache (1.7.1)
48
+ rack (>= 0.4)
49
+ rack-ssl (1.3.4)
50
+ rack
51
+ rack-test (0.6.3)
52
+ rack (>= 1.0)
53
+ railties (3.2.22.5)
54
+ actionpack (= 3.2.22.5)
55
+ activesupport (= 3.2.22.5)
56
+ rack-ssl (~> 1.3.2)
57
+ rake (>= 0.8.7)
58
+ rdoc (~> 3.4)
59
+ thor (>= 0.14.6, < 2.0)
60
+ rake (10.5.0)
61
+ rdoc (3.12.2)
62
+ json (~> 1.4)
63
+ rspec (3.7.0)
64
+ rspec-core (~> 3.7.0)
65
+ rspec-expectations (~> 3.7.0)
66
+ rspec-mocks (~> 3.7.0)
67
+ rspec-core (3.7.1)
68
+ rspec-support (~> 3.7.0)
69
+ rspec-expectations (3.7.0)
70
+ diff-lcs (>= 1.2.0, < 2.0)
71
+ rspec-support (~> 3.7.0)
72
+ rspec-mocks (3.7.0)
73
+ diff-lcs (>= 1.2.0, < 2.0)
74
+ rspec-support (~> 3.7.0)
75
+ rspec-support (3.7.1)
76
+ sprockets (2.2.3)
77
+ hike (~> 1.2)
78
+ multi_json (~> 1.0)
79
+ rack (~> 1.0)
80
+ tilt (~> 1.1, != 1.3.0)
81
+ sqlite3 (1.3.13)
82
+ test-unit (3.1.5)
83
+ power_assert
84
+ thor (0.20.0)
85
+ tilt (1.4.1)
86
+ timecop (0.9.1)
87
+ tzinfo (0.3.53)
88
+
89
+ PLATFORMS
90
+ ruby
91
+
92
+ DEPENDENCIES
93
+ activerecord_settings!
94
+ bundler (~> 1.16)
95
+ generator_spec (~> 0)
96
+ rake (~> 10.0)
97
+ rspec (~> 3.0)
98
+ sqlite3 (~> 1.0)
99
+ test-unit (~> 3.0)
100
+ timecop (~> 0.9)
101
+
102
+ BUNDLED WITH
103
+ 1.16.1
@@ -1,3 +1,3 @@
1
1
  module ActiverecordSettings
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -0,0 +1,2 @@
1
+ Description:
2
+ Generates (but does not run) a migration to add a settings table.
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rails/generators"
4
+ require "rails/generators/migration"
5
+
6
+ module ActiverecordSettings
7
+ module Generators
8
+ # Installs ActiverecordSettings in a rails app.
9
+ class InstallGenerator < ::Rails::Generators::Base
10
+ include ::Rails::Generators::Migration
11
+ source_root File.expand_path('../templates', __FILE__)
12
+
13
+ class_option :auto_run_migrations, type: :boolean, default: false
14
+
15
+ def self.next_migration_number(path)
16
+ next_migration_number = current_migration_number(path) + 1
17
+ ActiveRecord::Migration.next_migration_number(next_migration_number)
18
+ end
19
+
20
+ def add_migrations
21
+ template = "create_activerecord_settings"
22
+ migration_dir = File.expand_path("db/migrate")
23
+ if self.class.migration_exists?(migration_dir, template)
24
+ ::Kernel.warn "Migration already exists: #{template}"
25
+ else
26
+ migration_template(
27
+ "#{template}.rb.erb",
28
+ "db/migrate/#{template}.rb",
29
+ migration_version: migration_version
30
+ )
31
+ end
32
+ end
33
+
34
+ def run_migrations
35
+ return if ENV["RAILS_ENV"] == 'test'
36
+ run_migrations = options[:auto_run_migrations] || ['y', 'Y'].include?(ask 'Would you like to run the migrations now? [Y/n]')
37
+ if run_migrations
38
+ run 'bundle exec rake db:migrate'
39
+ else
40
+ puts 'Skipping rake db:migrate, don\'t forget to run it!'
41
+ end
42
+ end
43
+
44
+ protected
45
+
46
+ def migration_version
47
+ major = ActiveRecord::VERSION::MAJOR
48
+ if major >= 5
49
+ "[#{major}.#{ActiveRecord::VERSION::MINOR}]"
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,13 @@
1
+ class CreateActiverecordSettings < ActiveRecord::Migration<%= migration_version %>
2
+ def change
3
+ create_table :activerecord_settings do |t|
4
+ t.string :key, null: false
5
+ t.text :value, null: false
6
+ t.timestamp :expires
7
+
8
+ t.timestamps null: false
9
+ end
10
+
11
+ add_index :activerecord_settings, :key, unique: true
12
+ end
13
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord_settings
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Singerman
@@ -142,6 +142,7 @@ files:
142
142
  - ".rspec"
143
143
  - ".travis.yml"
144
144
  - Gemfile
145
+ - Gemfile.lock
145
146
  - LICENSE.txt
146
147
  - README.md
147
148
  - Rakefile
@@ -150,6 +151,9 @@ files:
150
151
  - bin/setup
151
152
  - lib/activerecord_settings.rb
152
153
  - lib/activerecord_settings/version.rb
154
+ - lib/generators/activerecord_settings/USAGE
155
+ - lib/generators/activerecord_settings/install_generator.rb
156
+ - lib/generators/activerecord_settings/templates/create_activerecord_settings.rb.erb
153
157
  homepage: https://github.com/dansingerman/activerecord_settings
154
158
  licenses:
155
159
  - MIT