drg 1.4.0 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/lib/drg/tasks.rb +1 -0
- data/lib/drg/tasks/log.rb +1 -0
- data/lib/drg/tasks/upgrade_file.rb +44 -0
- data/lib/drg/version.rb +1 -1
- data/lib/tasks/drg.rake +6 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9eb5257b575a9f01709cf7f2cc9d2157ee09280d
|
4
|
+
data.tar.gz: 8a7ecacacffd2e400f7fc85f6a7a56debb6c1074
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 390561f33b2736a95054d6dddfe8245cef9b0fd607659f5a09bb0f93c0a6dded3d579dfd2e4aac443cb3dd750f0303af3ece707a437fbdce434db1b7435de198
|
7
|
+
data.tar.gz: 29d37bc0364fecfc678688f66d7f14f68491769dcb4fae0afaac54a71c2ceb713532f2df28fc16c2980515cdd88151f859fb4eab56c6c2ed7f0349bdc59db649
|
data/README.md
CHANGED
@@ -26,6 +26,7 @@ rake drg:pin:latest[gem] # Pin the given gem to the latest version (defau
|
|
26
26
|
rake drg:pin:minor_latest[gem] # Pin the given gem to the latest available patch version (defaults to all gems)
|
27
27
|
rake drg:pin:patch_latest[gem] # Pin the given gem to the latest available minor version (defaults to all gems)
|
28
28
|
rake drg:unpin # Unpin the gems in your Gemfile
|
29
|
+
rake drg:upgrade_file[file] # Updates the file to use Ruby 2 hash syntax and fixes RSpec and FactoryGirl deprecations
|
29
30
|
```
|
30
31
|
|
31
32
|
### drg:pin
|
data/lib/drg/tasks.rb
CHANGED
data/lib/drg/tasks/log.rb
CHANGED
@@ -0,0 +1,44 @@
|
|
1
|
+
module DRG
|
2
|
+
module Tasks
|
3
|
+
class UpgradeFile
|
4
|
+
include Log
|
5
|
+
|
6
|
+
attr_accessor :file
|
7
|
+
|
8
|
+
def initialize(file_name)
|
9
|
+
@file = Bundler.root.join(file_name.to_s)
|
10
|
+
end
|
11
|
+
|
12
|
+
def call
|
13
|
+
ruby_files.each do |ruby_file|
|
14
|
+
contents = File.read(ruby_file)
|
15
|
+
log %(Updating "#{ruby_file}")
|
16
|
+
contents.gsub! /:(\w+)\s?=>/, '\1:'
|
17
|
+
contents.gsub!(/([A-Z]*[a-z0-9_!?.\[\]'()+=>:,&]+)\.(should)\s?==/, 'expect(\1).to eq')
|
18
|
+
contents.gsub! /Factory\.create/, 'create'
|
19
|
+
contents.gsub! /Factory\.build/, 'build'
|
20
|
+
contents.gsub! /Factory\.next/, 'generate'
|
21
|
+
contents.gsub! /Factory\(/, 'create('
|
22
|
+
contents.gsub! /Factory\.attributes_for/, 'FactoryGirl.attributes_for'
|
23
|
+
File.write(ruby_file, contents)
|
24
|
+
end
|
25
|
+
if ruby_files.empty?
|
26
|
+
log %(No files found for "#{file}")
|
27
|
+
end
|
28
|
+
log 'Done.'
|
29
|
+
end
|
30
|
+
|
31
|
+
def ruby_files
|
32
|
+
if File.directory?(file)
|
33
|
+
Dir[File.join(file, '**', '*.rb')]
|
34
|
+
else
|
35
|
+
if file.extname.empty?
|
36
|
+
["#{file}.rb"]
|
37
|
+
else
|
38
|
+
[file]
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/lib/drg/version.rb
CHANGED
data/lib/tasks/drg.rake
CHANGED
@@ -46,4 +46,10 @@ namespace :drg do
|
|
46
46
|
task latest_minor: :minor_latest
|
47
47
|
task latest_patch: :patch_latest
|
48
48
|
end
|
49
|
+
|
50
|
+
desc 'Upgrade files with the latest syntax for Ruby 2, FactoryGirl 3, and RSpec 3'
|
51
|
+
task :upgrade_file, [:file_name] do |_, options|
|
52
|
+
file = options[:file_name] || Bundler.root.join('spec', '**', '*_spec.rb')
|
53
|
+
DRG::Tasks::UpgradeFile.new(file).call
|
54
|
+
end
|
49
55
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: drg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Buckley
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-12-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -101,6 +101,7 @@ files:
|
|
101
101
|
- lib/drg/tasks/log.rb
|
102
102
|
- lib/drg/tasks/pinner.rb
|
103
103
|
- lib/drg/tasks/updater.rb
|
104
|
+
- lib/drg/tasks/upgrade_file.rb
|
104
105
|
- lib/drg/version.rb
|
105
106
|
- lib/tasks/drg.rake
|
106
107
|
homepage: https://github.com/ridiculous/drg
|