From 4aedf781ac7bfcca0261f381f5cd6162bbe70dcd Mon Sep 17 00:00:00 2001 From: Benoit Verhaeghe Date: Fri, 13 Sep 2024 15:40:39 +0200 Subject: [PATCH] more with files properties to generic importer --- .../GHModelImporter.class.st | 28 +-------- .../GLHModelImporter.class.st | 25 +------- .../GPModelImporter.class.st | 59 +++++++++++++++++++ .../package.st | 1 + 4 files changed, 64 insertions(+), 49 deletions(-) create mode 100644 src/GitProjectHealth-Model-Importer/GPModelImporter.class.st create mode 100644 src/GitProjectHealth-Model-Importer/package.st diff --git a/src/GitHubHealth-Model-Importer/GHModelImporter.class.st b/src/GitHubHealth-Model-Importer/GHModelImporter.class.st index 3ac4417..00d3c00 100644 --- a/src/GitHubHealth-Model-Importer/GHModelImporter.class.st +++ b/src/GitHubHealth-Model-Importer/GHModelImporter.class.st @@ -3,8 +3,7 @@ Class { #superclass : 'GPModelImporter', #instVars : [ 'api', - 'glhModel', - 'withFiles' + 'glhModel' ], #category : 'GitHubHealth-Model-Importer', #package : 'GitHubHealth-Model-Importer' @@ -22,18 +21,6 @@ GHModelImporter >> api: anObject [ api := anObject ] -{ #category : 'accessing' } -GHModelImporter >> beWithFiles [ - - withFiles := true -] - -{ #category : 'accessing' } -GHModelImporter >> beWithoutFiles [ - - withFiles := false -] - { #category : 'private' } GHModelImporter >> convertApiFileAsFile: aAPIFile [ @@ -161,6 +148,7 @@ GHModelImporter >> importRepositoriesOfGroup: groupResult [ { #category : 'initialization' } GHModelImporter >> initialize [ + super initialize. self api: GHApi new. withFiles := false @@ -255,15 +243,3 @@ GHModelImporter >> privateToken [ GHModelImporter >> privateToken: aTokenString [ ^ self api privateToken: aTokenString ] - -{ #category : 'accessing' } -GHModelImporter >> withFiles [ - - ^ withFiles -] - -{ #category : 'accessing' } -GHModelImporter >> withFiles: anObject [ - - withFiles := anObject -] diff --git a/src/GitLabHealth-Model-Importer/GLHModelImporter.class.st b/src/GitLabHealth-Model-Importer/GLHModelImporter.class.st index 170c5f5..800c2d5 100644 --- a/src/GitLabHealth-Model-Importer/GLHModelImporter.class.st +++ b/src/GitLabHealth-Model-Importer/GLHModelImporter.class.st @@ -4,7 +4,6 @@ Class { #instVars : [ 'glhModel', 'glhApi', - 'withFiles', 'withCommitDiffs', 'withInitialCommits', 'withInitialMergeRequest', @@ -50,16 +49,6 @@ GLHModelImporter >> addGroupResultToModel: groupResult [ ^ group ] -{ #category : 'accessing' } -GLHModelImporter >> beWithFiles [ - withFiles := true -] - -{ #category : 'accessing' } -GLHModelImporter >> beWithouFiles [ - withFiles := false -] - { #category : 'as yet unclassified' } GLHModelImporter >> blockEqualityOn: aSymbol [ ^ [ :existing :new | @@ -788,12 +777,12 @@ GLHModelImporter >> initReader [ { #category : 'initialization' } GLHModelImporter >> initialize [ - withFiles := false. + super initialize. withCommitDiffs := false. withInitialCommits := false. withInitialMergeRequest := false. self initReader. - currentImporter := self. + currentImporter := self ] { #category : 'importer' } @@ -1089,16 +1078,6 @@ GLHModelImporter >> withCommitDiffs: anObject [ withCommitDiffs := anObject ] -{ #category : 'accessing' } -GLHModelImporter >> withFiles [ - ^ withFiles -] - -{ #category : 'accessing' } -GLHModelImporter >> withFiles: aBoolean [ - withFiles := aBoolean -] - { #category : 'accessing' } GLHModelImporter >> withInitialCommits: boolean [ withInitialCommits := boolean diff --git a/src/GitProjectHealth-Model-Importer/GPModelImporter.class.st b/src/GitProjectHealth-Model-Importer/GPModelImporter.class.st new file mode 100644 index 0000000..b88e291 --- /dev/null +++ b/src/GitProjectHealth-Model-Importer/GPModelImporter.class.st @@ -0,0 +1,59 @@ +" +I am a superclass for Model importer. +I am a try of normalization for the different importer. + +I also define some contract so it is easier to switch from one importer to another +" +Class { + #name : 'GPModelImporter', + #superclass : 'Object', + #instVars : [ + 'withCommitsSince', + 'withFiles' + ], + #category : 'GitProjectHealth-Model-Importer', + #package : 'GitProjectHealth-Model-Importer' +} + +{ #category : 'accessing' } +GPModelImporter >> beWithFiles [ + + withFiles := true +] + +{ #category : 'accessing' } +GPModelImporter >> beWithoutFiles [ + + withFiles := false +] + +{ #category : 'initialization' } +GPModelImporter >> initialize [ + + super initialize. + self withCommitsSince: (Date today - 1 week) asDateAndTime +] + +{ #category : 'accessing' } +GPModelImporter >> withCommitsSince [ + + ^ withCommitsSince +] + +{ #category : 'accessing' } +GPModelImporter >> withCommitsSince: anObject [ + + withCommitsSince := anObject +] + +{ #category : 'accessing' } +GPModelImporter >> withFiles [ + + ^ withFiles +] + +{ #category : 'accessing' } +GPModelImporter >> withFiles: anObject [ + + withFiles := anObject +] diff --git a/src/GitProjectHealth-Model-Importer/package.st b/src/GitProjectHealth-Model-Importer/package.st new file mode 100644 index 0000000..8668e89 --- /dev/null +++ b/src/GitProjectHealth-Model-Importer/package.st @@ -0,0 +1 @@ +Package { #name : 'GitProjectHealth-Model-Importer' }