drg 1.4.0 → 1.5.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: 964e0e7803c99247bcf94358b6dceabd10f62243
4
- data.tar.gz: 0d1726900549c6a9f85f2832571deb121ca30c84
3
+ metadata.gz: 9eb5257b575a9f01709cf7f2cc9d2157ee09280d
4
+ data.tar.gz: 8a7ecacacffd2e400f7fc85f6a7a56debb6c1074
5
5
  SHA512:
6
- metadata.gz: 53c6cc103a83f50e8427314b216e7c30212d120d0c45337a886b8d5ff9f3d3291b59be8c8dee9b1c952934b3ab218d0b314632937cbfac1faf525e7545330c70
7
- data.tar.gz: ccd9e5f7900f8b2ffc72a3482fc477b355506fd63a05e0b30be73d72ce0feed2ede389bd576bf728ec4d07b2802b345ce8768fdcf03c719a18926ddff49accda
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
@@ -7,5 +7,6 @@ module DRG
7
7
  autoload :GemfileLine, 'drg/tasks/gemfile_line'
8
8
  autoload :Log, 'drg/tasks/log'
9
9
  autoload :SpecRunner, 'drg/tasks/spec_runner'
10
+ autoload :UpgradeFile, 'drg/tasks/upgrade_file'
10
11
  end
11
12
  end
@@ -5,6 +5,7 @@ module DRG
5
5
 
6
6
  def log(msg = nil, color = :green)
7
7
  HighLine.new.say %Q( <%= color('#{msg}', :#{color}) %>)
8
+ $stdout.flush
8
9
  end
9
10
  end
10
11
  end
@@ -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
@@ -1,3 +1,3 @@
1
1
  module DRG
2
- VERSION = '1.4.0'.freeze
2
+ VERSION = '1.5.0'.freeze
3
3
  end
@@ -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.0
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-09-16 00:00:00.000000000 Z
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