data_maintenance 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: ba86066fefbd92cab3678775a900988726d7dc7250dbe336e5401731241a3a62
4
+ data.tar.gz: e8037ec5be6e3433d29ec4ffa96ce1341ae6ad99d76398ad765546006ab21ca1
5
+ SHA512:
6
+ metadata.gz: a0f6a618b3b38551bf5fc7fe66c02f1f3a3492b8da9ed17700a53d49569883e22daec53657f8fd6e96be46094a922513af80c314646280e2e885120849bb5f95
7
+ data.tar.gz: 66d93ded353ab298d2a9e897c7445b01faa041dc6b04577b1af747910d85a3e5e3bc6ded9035036a1e644a43c24ac8eb62f9292acde3352039f7238a4f5a7e79
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.5.0
5
+ before_install: gem install bundler -v 1.16.2
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in data_maintenance.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,72 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ data_maintenance (0.1.0)
5
+ railties (>= 3.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ actionpack (5.2.0)
11
+ actionview (= 5.2.0)
12
+ activesupport (= 5.2.0)
13
+ rack (~> 2.0)
14
+ rack-test (>= 0.6.3)
15
+ rails-dom-testing (~> 2.0)
16
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
17
+ actionview (5.2.0)
18
+ activesupport (= 5.2.0)
19
+ builder (~> 3.1)
20
+ erubi (~> 1.4)
21
+ rails-dom-testing (~> 2.0)
22
+ rails-html-sanitizer (~> 1.0, >= 1.0.3)
23
+ activesupport (5.2.0)
24
+ concurrent-ruby (~> 1.0, >= 1.0.2)
25
+ i18n (>= 0.7, < 2)
26
+ minitest (~> 5.1)
27
+ tzinfo (~> 1.1)
28
+ builder (3.2.3)
29
+ concurrent-ruby (1.0.5)
30
+ crass (1.0.4)
31
+ erubi (1.7.1)
32
+ i18n (1.0.1)
33
+ concurrent-ruby (~> 1.0)
34
+ loofah (2.2.2)
35
+ crass (~> 1.0.2)
36
+ nokogiri (>= 1.5.9)
37
+ method_source (0.9.0)
38
+ mini_portile2 (2.3.0)
39
+ minitest (5.11.3)
40
+ nokogiri (1.8.4)
41
+ mini_portile2 (~> 2.3.0)
42
+ rack (2.0.5)
43
+ rack-test (1.0.0)
44
+ rack (>= 1.0, < 3)
45
+ rails-dom-testing (2.0.3)
46
+ activesupport (>= 4.2.0)
47
+ nokogiri (>= 1.6)
48
+ rails-html-sanitizer (1.0.4)
49
+ loofah (~> 2.2, >= 2.2.2)
50
+ railties (5.2.0)
51
+ actionpack (= 5.2.0)
52
+ activesupport (= 5.2.0)
53
+ method_source
54
+ rake (>= 0.8.7)
55
+ thor (>= 0.18.1, < 2.0)
56
+ rake (10.5.0)
57
+ thor (0.20.0)
58
+ thread_safe (0.3.6)
59
+ tzinfo (1.2.5)
60
+ thread_safe (~> 0.1)
61
+
62
+ PLATFORMS
63
+ ruby
64
+
65
+ DEPENDENCIES
66
+ bundler (~> 1.16)
67
+ data_maintenance!
68
+ minitest (~> 5.0)
69
+ rake (~> 10.0)
70
+
71
+ BUNDLED WITH
72
+ 1.16.2
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Tomohisa KURANARI
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,49 @@
1
+ # DataMaintenance
2
+ DataMaintenance provides a generator to generate boilerplate of data maintenance for Rails apps.
3
+
4
+ ## Installation
5
+
6
+ Add this line to your application's Gemfile:
7
+
8
+ ```ruby
9
+ gem 'data_maintenance'
10
+ ```
11
+
12
+ And then execute:
13
+
14
+ ```
15
+ $ bundle
16
+ ```
17
+
18
+ Or install it yourself as:
19
+
20
+ ```
21
+ $ gem install data_maintenance
22
+ ```
23
+
24
+ ## Usage
25
+
26
+ Run the following generator command, then edit the generated file.
27
+
28
+ ```
29
+ $ rails g data_maintenance set_user_status
30
+ ```
31
+
32
+ You can execute the generated script with the following command
33
+ ```
34
+ $ rails r db/maintenances/set_user_status.rb
35
+ ```
36
+
37
+ ## Development
38
+
39
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
40
+
41
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
42
+
43
+ ## Contributing
44
+
45
+ Bug reports and pull requests are welcome on GitHub at https://github.com/kuranari/data_maintenance.
46
+
47
+ ## License
48
+
49
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList["test/**/*_test.rb"]
8
+ end
9
+
10
+ task :default => :test
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "data_maintenance"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,30 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "data_maintenance/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "data_maintenance"
8
+ spec.version = DataMaintenance::VERSION
9
+ spec.authors = ["Tomohisa KURANARI"]
10
+ spec.email = ["tomohisa.kuranari@gmail.com"]
11
+
12
+ spec.summary = %q{Stubs out a new data maintenance script.}
13
+ spec.description = %q{Stubs out a new data maintenance script.}
14
+ spec.homepage = "https://github.com/kuranari/data_maintenance"
15
+ spec.license = "MIT"
16
+
17
+ # Specify which files should be added to the gem when it is released.
18
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
19
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
20
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
21
+ end
22
+ spec.bindir = "exe"
23
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
+ spec.require_paths = ["lib"]
25
+
26
+ spec.add_runtime_dependency 'railties', '>= 3.0'
27
+ spec.add_development_dependency "bundler", "~> 1.16"
28
+ spec.add_development_dependency "rake", "~> 10.0"
29
+ spec.add_development_dependency "minitest", "~> 5.0"
30
+ end
@@ -0,0 +1,5 @@
1
+ require "data_maintenance/version"
2
+
3
+ module DataMaintenance
4
+ # Your code goes here...
5
+ end
@@ -0,0 +1,3 @@
1
+ module DataMaintenance
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,11 @@
1
+ Description:
2
+ Stubs out a new data maintenance script.
3
+ Pass the maintenance script name either CamelCased or under_scored.
4
+
5
+ A maintenance script is generated in db/maintenances.
6
+
7
+ Example:
8
+ rails generate data_maintenance fix_user_name
9
+
10
+ This will create:
11
+ db/maintenances/fix_user_name.rb
@@ -0,0 +1,10 @@
1
+ class DataMaintenanceGenerator < ::Rails::Generators::NamedBase
2
+ source_root File.expand_path('templates', __dir__)
3
+ check_class_collision suffix: "Maintenance"
4
+
5
+ def create_data_maintenance_file
6
+ template "data_maintenance.erb", File.join('db/maintenances', "#{file_name}.rb")
7
+ end
8
+
9
+ hook_for :test_framework
10
+ end
@@ -0,0 +1,13 @@
1
+ <% module_namespacing do -%>
2
+ class <%= class_name %>Maintenance
3
+ def self.execute
4
+ # do something
5
+ end
6
+ end
7
+
8
+ realtime = Benchmark.realtime do
9
+ <%= class_name -%>Maintenance.execute
10
+ end
11
+ puts "realtime: #{realtime}"
12
+
13
+ <% end -%>
@@ -0,0 +1,11 @@
1
+ module Rspec
2
+ module Generators
3
+ class DataMaintenanceGenerator < ::Rails::Generators::NamedBase
4
+ source_root File.expand_path('templates', __dir__)
5
+
6
+ def create_data_maintenance_spec
7
+ template 'data_maintenance_spec.rb', File.join('spec/db/maintenances', "#{file_name}_spec.rb")
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,8 @@
1
+ require '<%= File.exists?('spec/rails_helper.rb') ? 'rails_helper' : 'spec_helper' %>'
2
+ require '<%= "./db/maintenances/#{file_name}" -%>'
3
+
4
+ RSpec.describe <%= class_name %>Maintenance do
5
+ describe '.execute' do
6
+ pending "add some examples to (or delete) #{__FILE__}"
7
+ end
8
+ end
@@ -0,0 +1,11 @@
1
+ module TestUnit
2
+ module Generators
3
+ class DataMaintenanceGenerator < ::Rails::Generators::NamedBase
4
+ source_root File.expand_path('templates', __dir__)
5
+
6
+ def create_maintenance_test
7
+ template 'data_maintenance_test.rb', File.join('test/db/maintenances', "#{file_name}_test.rb")
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,10 @@
1
+ require 'test_helper'
2
+ require '<%= "./db/maintenances/#{file_name}" -%>'
3
+
4
+ <% module_namespacing do -%>
5
+ class <%= class_name %>MaintenanceTest < ActiveSupport::TestCase
6
+ test "execute" do
7
+ flunk "add some examples to (or delete) #{__FILE__}"
8
+ end
9
+ end
10
+ <% end -%>
metadata ADDED
@@ -0,0 +1,120 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: data_maintenance
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Tomohisa KURANARI
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-07-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: railties
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '3.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '3.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.16'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.16'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: minitest
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '5.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '5.0'
69
+ description: Stubs out a new data maintenance script.
70
+ email:
71
+ - tomohisa.kuranari@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".rspec"
78
+ - ".travis.yml"
79
+ - Gemfile
80
+ - Gemfile.lock
81
+ - LICENSE.txt
82
+ - README.md
83
+ - Rakefile
84
+ - bin/console
85
+ - bin/setup
86
+ - data_maintenance.gemspec
87
+ - lib/data_maintenance.rb
88
+ - lib/data_maintenance/version.rb
89
+ - lib/generators/data_maintenance/USAGE
90
+ - lib/generators/data_maintenance/data_maintenance_generator.rb
91
+ - lib/generators/data_maintenance/templates/data_maintenance.erb
92
+ - lib/generators/rspec/data_maintenance_generator.rb
93
+ - lib/generators/rspec/templates/data_maintenance_spec.rb
94
+ - lib/generators/test_unit/data_maintenance_generator.rb
95
+ - lib/generators/test_unit/templates/data_maintenance_test.rb
96
+ homepage: https://github.com/kuranari/data_maintenance
97
+ licenses:
98
+ - MIT
99
+ metadata: {}
100
+ post_install_message:
101
+ rdoc_options: []
102
+ require_paths:
103
+ - lib
104
+ required_ruby_version: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ required_rubygems_version: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - ">="
112
+ - !ruby/object:Gem::Version
113
+ version: '0'
114
+ requirements: []
115
+ rubyforge_project:
116
+ rubygems_version: 2.7.7
117
+ signing_key:
118
+ specification_version: 4
119
+ summary: Stubs out a new data maintenance script.
120
+ test_files: []