From 1910b685a6a4307d57a20aac033f80ce18887c2f Mon Sep 17 00:00:00 2001 From: Offray Luna Date: Sat, 17 Mar 2018 19:59:58 +0000 Subject: [PATCH] Supporting raw content import in file repositories. --- repository/Fossil/FossilRepo.class.st | 71 ++++------------------- repository/Fossil/FossilRepoTest.class.st | 8 +++ repository/Fossil/ManifestFossil.class.st | 13 ----- 3 files changed, 19 insertions(+), 73 deletions(-) create mode 100644 repository/Fossil/FossilRepoTest.class.st delete mode 100644 repository/Fossil/ManifestFossil.class.st diff --git a/repository/Fossil/FossilRepo.class.st b/repository/Fossil/FossilRepo.class.st index 493583b..bf830bc 100644 --- a/repository/Fossil/FossilRepo.class.st +++ b/repository/Fossil/FossilRepo.class.st @@ -47,54 +47,6 @@ FossilRepo >> checkinsFor: relativeFilePath [ ^ payload at: 'checkins' ] -{ #category : #querying } -FossilRepo >> commitsByDate [ - "I present the sum of all commit organized by date." - | result | - result := Dictionary new. - self timeline do: [ :commit | | key | - key := (DateAndTime fromUnixTime: (commit at: 'timestamp' )) asDate. - result at: key - ifPresent: [ result at: key put: (result at: key) + 1 ] - ifAbsent: [ result at: key put: 1 ] ]. - ^ result -] - -{ #category : #'data visualization' } -FossilRepo >> commitsCalendarFrom: startYear to: endYear colored: colorsPalette [ - "I" - - | b colors dictionary valuedColors | - dictionary := self commitsByDate. - colors := RTColorPalette sequential colors: 9 scheme: 'Blues'. - valuedColors := self commitsByDate collect: [ :v | colors at: v // 2 + 1 ]. - b := RTCalendarBuilder new. - b dateShape rectangle - size: 15; - color: Color white; - borderColor: Color lightGray. - b monthShape shape: (b monthShapePath: 15.0). - b yearShape - composite: [ :comp | - comp - add: - (RTLabel new - text: [ :d | d year ]; - height: 20). - comp add: (RTBox new color: Color transparent) ]. - b dates: ((Year year: startYear) to: (Year year: endYear)). - b dateLayout gapSize: 0. - b monthLayout month. - b yearLayout horizontalLine. - b dateShape - if: [ :d | dictionary includesKey: d ] - color: [ :d | valuedColors at: d ]. - b dateInteraction popup. - b build. - (b view elements select: [ :e | e model isKindOf: Month ]) pushFront. - ^ b view -] - { #category : #wiki } FossilRepo >> createPage: pageName [ ^ NeoJSONReader fromString: (self jsonWikiDataFor: 'create/', pageName) @@ -114,8 +66,8 @@ FossilRepo >> jsonDataFor: anUrlSegment [ { #category : #querying } FossilRepo >> jsonStringFor: aFileName [ | baseUrl queryForJSONData | - baseUrl := self remote. - baseUrl addPathSegments: #('json' 'finfo'). + baseUrl := self remote asString. + baseUrl := baseUrl asUrl addPathSegments: #('json' 'finfo'). queryForJSONData := baseUrl queryAt: 'name' put: aFileName. ^ (ZnEasy get: queryForJSONData) contents. ] @@ -172,6 +124,15 @@ FossilRepo >> rawCapabilities [ ^ NeoJSONReader fromString: (self jsonDataFor: 'cap') ] +{ #category : #utility } +FossilRepo >> rawContentFor: aFilePath [ + "I provide the file contents of a given file path that exist in the repository." + | checksum | + self remote ifNil: [ ^ self ]. + checksum := self lastHashNumberFor: aFilePath. + ^ (self remote asString, 'raw/', aFilePath, '?name=', checksum) asUrl retrieveContents. +] + { #category : #accessing } FossilRepo >> remote [ ^ remote @@ -182,16 +143,6 @@ FossilRepo >> remote: anUrlString [ remote := anUrlString asUrl ] -{ #category : #accessing } -FossilRepo >> timeline [ - "I return all information of all commits in a repository timeline." - | baseUrl queryForJSONData | - baseUrl := self remote addPathSegments: #('json' 'timeline' 'checkin'). - queryForJSONData := baseUrl queryAt: 'limit' put: 0. - ^ ((NeoJSONReader fromString: (queryForJSONData asUrl retrieveContents)) - at: 'payload') at: 'timeline' -] - { #category : #authentication } FossilRepo >> whoAmI [ ^ NeoJSONReader fromString: (self jsonDataFor: 'whoami') diff --git a/repository/Fossil/FossilRepoTest.class.st b/repository/Fossil/FossilRepoTest.class.st new file mode 100644 index 0000000..9d1d10b --- /dev/null +++ b/repository/Fossil/FossilRepoTest.class.st @@ -0,0 +1,8 @@ +" +A FossilRepoTest is a test class for testing the behavior of FossilRepo +" +Class { + #name : #FossilRepoTest, + #superclass : #TestCase, + #category : #'Fossil-Tests' +} diff --git a/repository/Fossil/ManifestFossil.class.st b/repository/Fossil/ManifestFossil.class.st deleted file mode 100644 index c91bf31..0000000 --- a/repository/Fossil/ManifestFossil.class.st +++ /dev/null @@ -1,13 +0,0 @@ -" -I store metadata for this package. These meta data are used by other tools such as the SmalllintManifestChecker and the critics Browser -" -Class { - #name : #ManifestFossil, - #superclass : #PackageManifest, - #category : #Fossil -} - -{ #category : #'code-critics' } -ManifestFossil class >> ruleRBBadMessageRuleV1FalsePositive [ - ^ #(#(#(#RGMethodDefinition #(#FossilRepo #commitsCalendarFrom:to:colored: #false)) #'2017-10-12T15:19:50.932072-05:00') ) -]