File tree Expand file tree Collapse file tree 3 files changed +88
-0
lines changed
cookbooks/fb_bookworm/files/default/bookworm Expand file tree Collapse file tree 3 files changed +88
-0
lines changed Original file line number Diff line number Diff line change 1+ # Copyright (c) 2022-present, Meta, Inc.
2+ # All rights reserved.
3+ #
4+ # Licensed under the Apache License, Version 2.0 (the "License");
5+ # you may not use this file except in compliance with the License.
6+ # You may obtain a copy of the License at
7+ #
8+ # http://www.apache.org/licenses/LICENSE-2.0
9+ #
10+ # Unless required by applicable law or agreed to in writing, software
11+ # distributed under the License is distributed on an "AS IS" BASIS,
12+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ # See the License for the specific language governing permissions and
14+ # limitations under the License.
15+ description 'Cross-reference the cookbook name to the maintainer_email in a CSV fashion'
16+ needs_rules [ 'MetadatarbAttributeLiterals' ]
17+
18+ def to_a
19+ buffer = Set . new
20+ @kb . metadatarbs . each do |_ , metadata |
21+ cb = metadata [ 'MetadatarbAttributeLiterals' ]
22+ buffer << "#{ cb [ :name ] } ,#{ cb [ :maintainer_email ] } "
23+ end
24+ buffer . sort . to_a
25+ end
26+
27+ def output
28+ to_a
29+ end
Original file line number Diff line number Diff line change 1+ # Copyright (c) 2022-present, Meta, Inc.
2+ # All rights reserved.
3+ #
4+ # Licensed under the Apache License, Version 2.0 (the "License");
5+ # you may not use this file except in compliance with the License.
6+ # You may obtain a copy of the License at
7+ #
8+ # http://www.apache.org/licenses/LICENSE-2.0
9+ #
10+ # Unless required by applicable law or agreed to in writing, software
11+ # distributed under the License is distributed on an "AS IS" BASIS,
12+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ # See the License for the specific language governing permissions and
14+ # limitations under the License.
15+ description 'Scrapes metadata attribute string literals'
16+ keys [ 'metadatarb' ]
17+
18+ # TODO Search *all* possible attributes
19+
20+ def_node_search :attribute_literals , '`(send nil? ${:name :maintainer :maintainer_email} (str $_))'
21+
22+ def output
23+ attribute_literals ( @metadata [ 'ast' ] ) &.to_h
24+ end
Original file line number Diff line number Diff line change 1+ # Copyright (c) 2022-present, Meta, Inc.
2+ # All rights reserved.
3+ #
4+ # Licensed under the Apache License, Version 2.0 (the "License");
5+ # you may not use this file except in compliance with the License.
6+ # You may obtain a copy of the License at
7+ #
8+ # http://www.apache.org/licenses/LICENSE-2.0
9+ #
10+ # Unless required by applicable law or agreed to in writing, software
11+ # distributed under the License is distributed on an "AS IS" BASIS,
12+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ # See the License for the specific language governing permissions and
14+ # limitations under the License.
15+ require_relative './helper'
16+
17+ describe Bookworm ::InferRules ::MetadatarbAttributeLiterals do
18+ let ( :ast ) do
19+ generate_ast ( <<~RUBY )
20+ name "fb_example"
21+ maintainer "Dave"
22+ maintainer_email "dave@example.org"
23+ RUBY
24+ end
25+ it 'captures the metadata literals' do
26+ rule = described_class . new ( { 'ast' => ast } )
27+ expect ( rule . output ) . to eq (
28+ {
29+ :name => 'fb_example' ,
30+ :maintainer => 'Dave' ,
31+ :maintainer_email => 'dave@example.org' ,
32+ } ,
33+ )
34+ end
35+ end
You can’t perform that action at this time.
0 commit comments