best_practice_project 0.0.2 → 0.0.3

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: 7476699c6b4511029adeecf0d84827384f943a9b
4
- data.tar.gz: d21a33dcb8e43f164cdc06446d061c299da1bedf
3
+ metadata.gz: f6a03a30e37d96eb2b4c872098a93d1715184fbf
4
+ data.tar.gz: 3ef0ccbf70a7a5eb44c0c6027ba6e7cc0e2425a4
5
5
  SHA512:
6
- metadata.gz: e7a57f1f55926c87e7a2b11741b6c5b1bf8b88d85b9caf66f7c2b6f3d8c005b623232003dc014abd0d88cade9e8a100c027a24ce3927ad24db950ee54a4ef7d1
7
- data.tar.gz: 412447dde027d00e4d9fecfd4d9994ad709c5eb93dc1354a9dcf4c780762951fe8597c75925d88cf9986feeaa9cbdd41e1d432971542869eeca26b36b6db5412
6
+ metadata.gz: 8eab271030250e7d4eaa943be8e89584498089cafcb0b349027e31f12d5ded5c829b3298589744cac06d3660ec078a202aa9e34d6f55b206b7aafcea0c6836c5
7
+ data.tar.gz: 524dd44b8db85126d4eaeb5888af61e19f2b55bfca0fada7d2371bfe39403e4401c7a500055a13254470df537da8caa039dee7a351bd1a2e9b241ff073864162
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.2
1
+ 0.0.3
@@ -2,11 +2,11 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: best_practice_project 0.0.2 ruby lib
5
+ # stub: best_practice_project 0.0.3 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "best_practice_project"
9
- s.version = "0.0.2"
9
+ s.version = "0.0.3"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
@@ -29,8 +29,8 @@ Gem::Specification.new do |s|
29
29
  "VERSION",
30
30
  "best_practice_project.gemspec",
31
31
  "lib/best_practice_project.rb",
32
+ "lib/best_practice_project/config/rubocop.yml",
32
33
  "lib/best_practice_project/rubocop_handler.rb",
33
- "lib/config/rubocop.yml",
34
34
  "lib/tasks/best_practice_project.rake",
35
35
  "shippable.yml",
36
36
  "spec/best_practice_project_spec.rb",
@@ -1,7 +1,7 @@
1
1
  class BestPracticeProject::RubocopHandler
2
2
  def initialize(args)
3
3
  @bpp = args.fetch(:best_practice_project)
4
- @actual_config_path = File.realpath("#{File.dirname(__FILE__)}/../../config/rubocop.yml")
4
+ @actual_config_path = File.realpath("#{File.dirname(__FILE__)}/config/rubocop.yml")
5
5
 
6
6
  if rails?
7
7
  @config_path = Rails.root.join("config", "rubocop.yml").to_s
@@ -47,6 +47,8 @@ class BestPracticeProject::RubocopHandler
47
47
  fp.write(YAML.dump(generated_config))
48
48
  end
49
49
 
50
+ reset_best_practice_path
51
+
50
52
  puts "Generated Rubocop config in #{@config_path}"
51
53
  end
52
54
 
@@ -63,7 +65,10 @@ class BestPracticeProject::RubocopHandler
63
65
  File.rename(todo_file_path, todo_backup_file_path)
64
66
  end
65
67
 
66
- system("rubocop --rails --display-cop-names --auto-gen-config --config=#{@actual_config_path}")
68
+ rubocop_command = "rubocop --display-cop-names --auto-gen-config --config=#{@actual_config_path}"
69
+ rubocop_command << " --rails" if @bpp.rails?
70
+
71
+ system(rubocop_command)
67
72
 
68
73
  raise "Todo-file was not generated" unless File.exist?(todo_file_path)
69
74
 
@@ -88,7 +93,23 @@ private
88
93
 
89
94
  def inherit_from_to=(new_inherit_from)
90
95
  todo_config = File.read(@todo_path)
91
- todo_config.gsub!(/^inherit_from: (.+)$/, "inherit_from: \"#{new_inherit_from}\"")
96
+
97
+ replace_with = "inherit_from: \"#{new_inherit_from}\""
98
+
99
+ if todo_config.include?("inherit_from:")
100
+ replace_what = /^inherit_from: (.+)$/
101
+ elsif todo_config.start_with?("---\n")
102
+ replace_what = /\A---\n/
103
+ replace_with.prepend("---\n")
104
+ replace_with << "\n\n"
105
+ else
106
+ replace_what = /\A/
107
+ replace_with << "\n\n"
108
+ end
109
+
110
+ todo_config.gsub!(replace_what, replace_with)
111
+
112
+ raise "Couldn't insert dynamic config" unless todo_config.include?(replace_with)
92
113
 
93
114
  File.open(@todo_path, "w") do |fp|
94
115
  fp.write(todo_config)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: best_practice_project
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - kaspernj
@@ -112,8 +112,8 @@ files:
112
112
  - VERSION
113
113
  - best_practice_project.gemspec
114
114
  - lib/best_practice_project.rb
115
+ - lib/best_practice_project/config/rubocop.yml
115
116
  - lib/best_practice_project/rubocop_handler.rb
116
- - lib/config/rubocop.yml
117
117
  - lib/tasks/best_practice_project.rake
118
118
  - shippable.yml
119
119
  - spec/best_practice_project_spec.rb