knife-tidy 0.3.1 → 0.3.2

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: 86a06790188fb399074453b78a289aa193e8bbfe
4
- data.tar.gz: 01cb25a9b19338ce0cbaa5f121295d32f785fdf4
3
+ metadata.gz: a70a4795b84f11eff9639e474e9517b260137d11
4
+ data.tar.gz: 98fbf0c01305a8813471f5524400f973db06be34
5
5
  SHA512:
6
- metadata.gz: d8f7c576dce15f9a36e78b53249245e247c89244e8a3cb325bc17ddbe168b9b374ac8001283463062093df9818a3750555cb62974ef47ce89e544c84a25efc6d
7
- data.tar.gz: 34660b3e329937c01977c4dd901d3818cabed14f4a7025fbe4d52d9be58441328229c5621a9e2dba154717f901c19c58acbc2ff701c4349d906cfecfd30e8df7
6
+ metadata.gz: 84caa9803916b69388488d6f101aa41379d8ad30714a8c5275c42e3af1ac279d2ab7b68868fdd33647ff914b898b7097086711def57e378b2dafae15e79bd40f
7
+ data.tar.gz: 37262614ee1db11e62eb29039fd84963e5f70cd4bb695cfb2adc1630bda1712721588e1e92a36110119b2bacde777ea04a0c54e027076e06367ab7f312458740
data/CHANGELOG.md CHANGED
@@ -1,7 +1,22 @@
1
1
  # Change Log
2
2
 
3
- ## [0.1.0](https://github.com/chef-customers/knife-tidy/tree/0.1.0) (2017-09-14)
4
- [Full Changelog](https://github.com/chef-customers/knife-tidy/compare/0.2.4...0.1.0)
3
+ ## [0.3.2](https://github.com/chef-customers/knife-tidy/tree/0.3.2) (2017-09-14)
4
+ [Full Changelog](https://github.com/chef-customers/knife-tidy/compare/0.3.1...0.3.2)
5
+
6
+ **Merged pull requests:**
7
+
8
+ - fixed name mismatch in metadata.json [\#22](https://github.com/chef-customers/knife-tidy/pull/22) ([jeremymv2](https://github.com/jeremymv2))
9
+
10
+ ## [0.3.1](https://github.com/chef-customers/knife-tidy/tree/0.3.1) (2017-09-14)
11
+ [Full Changelog](https://github.com/chef-customers/knife-tidy/compare/0.3.0...0.3.1)
12
+
13
+ **Merged pull requests:**
14
+
15
+ - generate a metadata.rb if needed [\#21](https://github.com/chef-customers/knife-tidy/pull/21) ([jeremymv2](https://github.com/jeremymv2))
16
+ - newline for action needed messages [\#20](https://github.com/chef-customers/knife-tidy/pull/20) ([jeremymv2](https://github.com/jeremymv2))
17
+
18
+ ## [0.3.0](https://github.com/chef-customers/knife-tidy/tree/0.3.0) (2017-09-14)
19
+ [Full Changelog](https://github.com/chef-customers/knife-tidy/compare/0.2.4...0.3.0)
5
20
 
6
21
  **Closed issues:**
7
22
 
@@ -95,10 +95,24 @@ class Chef
95
95
  def fix_cookbook_names(org)
96
96
  for_each_cookbook_path(org) do |cookbook_path|
97
97
  rb_path = ::File.join(cookbook_path, 'metadata.rb')
98
- next unless ::File.exist?(rb_path)
98
+ json_path = ::File.join(cookbook_path, 'metadata.json')
99
+ # next unless ::File.exist?(rb_path)
99
100
  cookbook_name = tidy.cookbook_name_from_path(cookbook_path)
100
- lines = ::File.readlines(rb_path).select { |line| line =~ /^name.*['"]#{cookbook_name}['"]/ }
101
- add_cookbook_name_to_metadata(cookbook_name, rb_path) if lines.empty?
101
+ if ::File.exist?(rb_path)
102
+ lines = ::File.readlines(rb_path).select { |line| line =~ /^name.*['"]#{cookbook_name}['"]/ }
103
+ add_cookbook_name_to_metadata(cookbook_name, rb_path) if lines.empty?
104
+ else
105
+ if ::File.exist?(json_path)
106
+ metadata = FFI_Yajl::Parser.parse(::File.read(json_path), symbolize_names: false)
107
+ if metadata['name'] != cookbook_name
108
+ metadata['name'] = cookbook_name
109
+ puts "REPAIRING: Correcting `name` in #{json_path}`"
110
+ ::File.open(json_path, 'w') do |f|
111
+ f.write(Chef::JSONCompat.to_json_pretty(metadata))
112
+ end
113
+ end
114
+ end
115
+ end
102
116
  end
103
117
  end
104
118
 
@@ -1,4 +1,4 @@
1
1
  module KnifeTidy
2
- VERSION = '0.3.1'
2
+ VERSION = '0.3.2'
3
3
  MAJOR, MINOR, TINY = VERSION.split('.')
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knife-tidy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Miller