Skip to content

Commit f63f88e

Browse files
author
Kevin Paulisse
committed
Rename construct -> factory
1 parent 961cc7f commit f63f88e

7 files changed

Lines changed: 21 additions & 21 deletions

File tree

lib/octocatalog-diff/api/v1/catalog-diff.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def self.catalog_diff(options = nil)
5757

5858
# Return diffs and catalogs in expected format
5959
OpenStruct.new(
60-
diffs: diffs.map { |x| OctocatalogDiff::API::V1::Diff.construct(x) },
60+
diffs: diffs.map { |x| OctocatalogDiff::API::V1::Diff.factory(x) },
6161
from: OctocatalogDiff::API::V1::Catalog.new(catalogs[:from]),
6262
to: OctocatalogDiff::API::V1::Catalog.new(catalogs[:to])
6363
)

lib/octocatalog-diff/api/v1/diff.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class Diff
2424
# identical object back.
2525
# @param object_in [?] Object in
2626
# @return [OctocatalogDiff::API::V1::Diff] Object out
27-
def self.construct(object_in)
27+
def self.factory(object_in)
2828
return object_in if object_in.is_a?(OctocatalogDiff::API::V1::Diff)
2929

3030
return new(object_in) if object_in.is_a?(Array)

lib/octocatalog-diff/catalog-diff/display.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class Display
2525
def self.output(diff_in, options = {}, logger = nil)
2626
diff_x = diff_in.is_a?(OctocatalogDiff::CatalogDiff::Differ) ? diff_in.diff : diff_in
2727
raise ArgumentError, "text_output requires Array<Diff results>; passed in #{diff_in.class}" unless diff_x.is_a?(Array)
28-
diff = diff_x.map { |x| OctocatalogDiff::API::V1::Diff.construct(x) }
28+
diff = diff_x.map { |x| OctocatalogDiff::API::V1::Diff.factory(x) }
2929

3030
# req_format means 'requested format' because 'format' has a built-in meaning to Ruby
3131
req_format = options.fetch(:format, :color_text)

lib/octocatalog-diff/catalog-diff/filter.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def self.filter(result, filter_class_name, options = {})
5555
# it isn't already. The comparison is done on that array which is then applied back to the
5656
# original array.
5757
result_hash = {}
58-
result.each { |x| result_hash[x] = OctocatalogDiff::API::V1::Diff.construct(x) }
58+
result.each { |x| result_hash[x] = OctocatalogDiff::API::V1::Diff.factory(x) }
5959
obj = Kernel.const_get(filter_class_name).new(result_hash.values, options[:logger])
6060
result.reject! { |item| obj.filtered?(result_hash[item], options) }
6161
end

spec/octocatalog-diff/tests/api/v1/diff_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -349,21 +349,21 @@
349349
end
350350
end
351351

352-
describe '#self.construct' do
352+
describe '#self.factory' do
353353
it 'should return object as-is when passed a OctocatalogDiff::API::V1::Diff' do
354354
obj1 = described_class.new(chg_2)
355-
testobj = described_class.construct(obj1)
355+
testobj = described_class.factory(obj1)
356356
expect(testobj).to eq(obj1)
357357
end
358358

359359
it 'should return new OctocatalogDiff::API::V1::Diff when passed an array' do
360-
obj1 = described_class.construct(chg_2)
360+
obj1 = described_class.factory(chg_2)
361361
expect(obj1).to be_a_kind_of(OctocatalogDiff::API::V1::Diff)
362362
expect(obj1.raw).to eq(chg_2)
363363
end
364364

365365
it 'should raise error when passed something else' do
366-
expect { described_class.construct(foo: true) }.to raise_error(ArgumentError, /Cannot construct .+ from Hash/)
366+
expect { described_class.factory(foo: true) }.to raise_error(ArgumentError, /Cannot construct .+ from Hash/)
367367
end
368368
end
369369

spec/octocatalog-diff/tests/catalog-diff/filter/absent_file_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
['~', "File\f/tmp/bar\fparameters\ftarget", nil, '/tmp/foo'],
1818
['~', "Exec\f/tmp/bar\fparameters\fcommand", nil, '/tmp/foo']
1919
]
20-
obj = orig.map { |x| OctocatalogDiff::API::V1::Diff.construct(x) }
20+
obj = orig.map { |x| OctocatalogDiff::API::V1::Diff.factory(x) }
2121
testobj = described_class.new(obj)
2222
result = obj.reject { |x| testobj.filtered?(x) }
2323
expect(result).to eq(obj.values_at(0, 2, 3, 4, 5, 6, 7))

spec/octocatalog-diff/tests/catalog-diff/filter/compilation_dir_spec.rb

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
},
2727
{ 'file' => nil, 'line' => nil }
2828
]
29-
diff_obj = OctocatalogDiff::API::V1::Diff.construct(diff)
29+
diff_obj = OctocatalogDiff::API::V1::Diff.factory(diff)
3030
expect(subject.filtered?(diff_obj, opts)).to eq(true)
3131
end
3232

@@ -42,7 +42,7 @@
4242
},
4343
{ 'file' => nil, 'line' => nil }
4444
]
45-
diff_obj = OctocatalogDiff::API::V1::Diff.construct(diff)
45+
diff_obj = OctocatalogDiff::API::V1::Diff.factory(diff)
4646
expect(subject.filtered?(diff_obj, opts)).to eq(true)
4747
end
4848

@@ -58,7 +58,7 @@
5858
},
5959
{ 'file' => nil, 'line' => nil }
6060
]
61-
diff_obj = OctocatalogDiff::API::V1::Diff.construct(diff)
61+
diff_obj = OctocatalogDiff::API::V1::Diff.factory(diff)
6262
expect(subject.filtered?(diff_obj, opts)).to eq(false)
6363
end
6464
end
@@ -76,7 +76,7 @@
7676
},
7777
{ 'file' => nil, 'line' => nil }
7878
]
79-
diff_obj = OctocatalogDiff::API::V1::Diff.construct(diff)
79+
diff_obj = OctocatalogDiff::API::V1::Diff.factory(diff)
8080
expect(subject.filtered?(diff_obj, opts)).to eq(true)
8181
end
8282

@@ -92,7 +92,7 @@
9292
},
9393
{ 'file' => nil, 'line' => nil }
9494
]
95-
diff_obj = OctocatalogDiff::API::V1::Diff.construct(diff)
95+
diff_obj = OctocatalogDiff::API::V1::Diff.factory(diff)
9696
expect(subject.filtered?(diff_obj, opts)).to eq(true)
9797
end
9898

@@ -108,7 +108,7 @@
108108
},
109109
{ 'file' => nil, 'line' => nil }
110110
]
111-
diff_obj = OctocatalogDiff::API::V1::Diff.construct(diff)
111+
diff_obj = OctocatalogDiff::API::V1::Diff.factory(diff)
112112
expect(subject.filtered?(diff_obj, opts)).to eq(false)
113113
end
114114
end
@@ -123,7 +123,7 @@
123123
{ 'file' => nil, 'line' => nil },
124124
{ 'file' => nil, 'line' => nil }
125125
]
126-
diff_obj = OctocatalogDiff::API::V1::Diff.construct(diff)
126+
diff_obj = OctocatalogDiff::API::V1::Diff.factory(diff)
127127
expect(subject.filtered?(diff_obj, opts)).to eq(true)
128128
end
129129

@@ -136,7 +136,7 @@
136136
{ 'file' => nil, 'line' => nil },
137137
{ 'file' => nil, 'line' => nil }
138138
]
139-
diff_obj = OctocatalogDiff::API::V1::Diff.construct(diff)
139+
diff_obj = OctocatalogDiff::API::V1::Diff.factory(diff)
140140
expect(subject.filtered?(diff_obj, opts)).to eq(true)
141141
end
142142

@@ -149,7 +149,7 @@
149149
{ 'file' => nil, 'line' => nil },
150150
{ 'file' => nil, 'line' => nil }
151151
]
152-
diff_obj = OctocatalogDiff::API::V1::Diff.construct(diff)
152+
diff_obj = OctocatalogDiff::API::V1::Diff.factory(diff)
153153
expect(subject.filtered?(diff_obj, opts)).to eq(false)
154154
end
155155

@@ -162,7 +162,7 @@
162162
{ 'file' => nil, 'line' => nil },
163163
{ 'file' => nil, 'line' => nil }
164164
]
165-
diff_obj = OctocatalogDiff::API::V1::Diff.construct(diff)
165+
diff_obj = OctocatalogDiff::API::V1::Diff.factory(diff)
166166
expect(subject.filtered?(diff_obj, opts)).to eq(false)
167167
end
168168
end
@@ -180,12 +180,12 @@
180180
end
181181

182182
it 'should not remove changes that do not match fully' do
183-
diff_obj = OctocatalogDiff::API::V1::Diff.construct(diff)
183+
diff_obj = OctocatalogDiff::API::V1::Diff.factory(diff)
184184
expect(subject.filtered?(diff_obj, opts)).to eq(false)
185185
end
186186

187187
it 'should log warning message' do
188-
diff_obj = OctocatalogDiff::API::V1::Diff.construct(diff)
188+
diff_obj = OctocatalogDiff::API::V1::Diff.factory(diff)
189189
subject.filtered?(diff_obj, opts)
190190
expect(@logger_str.string).to match(/WARN.*Varies_Due_To_Compilation_Dir_3\[Common Title\] parameters => dir.+differences/)
191191
end

0 commit comments

Comments
 (0)