1057
|
1 |
"{ Package: 'stx:goodies/monticello' }"
|
|
2 |
|
|
3 |
"{ NameSpace: Smalltalk }"
|
|
4 |
|
|
5 |
MCHttpRepository subclass:#MCSmalltalkhubRepository
|
|
6 |
instanceVariableNames:'owner project'
|
|
7 |
classVariableNames:''
|
|
8 |
poolDictionaries:''
|
|
9 |
category:'SCM-Monticello-RemoteRepositories'
|
|
10 |
!
|
|
11 |
|
|
12 |
MCSmalltalkhubRepository comment:'I am specialized version of an MCHttpRepository for http://smalltalkhub.com.
|
|
13 |
I support a faster mcz listing that does not rely on parsing an html size.'
|
|
14 |
!
|
|
15 |
|
|
16 |
|
|
17 |
!MCSmalltalkhubRepository class methodsFor:'instance creation'!
|
|
18 |
|
|
19 |
owner: owner project: project
|
|
20 |
^ self
|
|
21 |
owner: owner
|
|
22 |
project: project
|
|
23 |
user: String empty
|
|
24 |
password: String empty
|
|
25 |
!
|
|
26 |
|
|
27 |
owner: owner project: project user: user password: password
|
|
28 |
^ self new
|
|
29 |
owner: owner;
|
|
30 |
project: project;
|
|
31 |
user: user;
|
|
32 |
password: password;
|
|
33 |
yourself
|
|
34 |
! !
|
|
35 |
|
|
36 |
!MCSmalltalkhubRepository class methodsFor:'accessing'!
|
|
37 |
|
|
38 |
baseURL
|
|
39 |
^ self smalltalkhubUrl, 'mc/'
|
|
40 |
!
|
|
41 |
|
|
42 |
description
|
|
43 |
^ 'smalltalkhub.com'
|
|
44 |
!
|
|
45 |
|
|
46 |
hostName
|
|
47 |
^ 'smalltalkhub.com'
|
|
48 |
!
|
|
49 |
|
|
50 |
smalltalkhubUrl
|
|
51 |
^ 'http://', self hostName, '/'
|
|
52 |
! !
|
|
53 |
|
|
54 |
!MCSmalltalkhubRepository class methodsFor:'creation template'!
|
|
55 |
|
|
56 |
creationTemplate
|
|
57 |
^self creationTemplateOwner: ''
|
|
58 |
project: ''
|
|
59 |
user: ''
|
|
60 |
password: ''
|
|
61 |
!
|
|
62 |
|
|
63 |
creationTemplateOwner: owner project: project user: user password: password
|
|
64 |
^ String streamContents: [ :s|
|
|
65 |
s
|
|
66 |
nextPutAll: self name; cr;
|
|
67 |
tab; nextPutAll: 'owner: '; print: owner; cr;
|
|
68 |
tab; nextPutAll: 'project: '; print: project; cr;
|
|
69 |
tab; nextPutAll: 'user: '; print: user; cr;
|
|
70 |
tab; nextPutAll: 'password: '; print: password ].
|
|
71 |
! !
|
|
72 |
|
|
73 |
!MCSmalltalkhubRepository class methodsFor:'testing'!
|
|
74 |
|
|
75 |
isResponsibleFor: aUrl
|
|
76 |
^ aUrl includesSubstring: self hostName
|
|
77 |
! !
|
|
78 |
|
|
79 |
!MCSmalltalkhubRepository methodsFor:'*Komitter-Models'!
|
|
80 |
|
|
81 |
koRemote
|
|
82 |
|
|
83 |
^ KomitSmalltalkhubRemote new
|
|
84 |
remote: self;
|
|
85 |
yourself
|
|
86 |
! !
|
|
87 |
|
|
88 |
!MCSmalltalkhubRepository methodsFor:'accessing'!
|
|
89 |
|
|
90 |
location
|
|
91 |
^ 'http://smalltalkhub.com/mc/', self owner, '/', self project, '/main/'
|
|
92 |
!
|
|
93 |
|
|
94 |
location: aUrlString
|
|
95 |
| pathSegments |
|
|
96 |
(self class isResponsibleFor: aUrlString)
|
|
97 |
ifFalse: [ Error signal: 'Please provide a smalltalkhub url' ].
|
|
98 |
"extract the smalltalkhub properties from the path part in the given URL"
|
|
99 |
pathSegments := aUrlString asZnUrl pathSegments reject: [ :each | each = 'mc' ].
|
|
100 |
self owner: pathSegments first.
|
|
101 |
self project: pathSegments second.
|
|
102 |
!
|
|
103 |
|
|
104 |
locationWithTrailingSlash
|
|
105 |
^ self location
|
|
106 |
!
|
|
107 |
|
|
108 |
owner
|
|
109 |
|
|
110 |
^ owner
|
|
111 |
!
|
|
112 |
|
|
113 |
owner: aString
|
|
114 |
|
|
115 |
owner := aString
|
|
116 |
!
|
|
117 |
|
|
118 |
project
|
|
119 |
|
|
120 |
^ project
|
|
121 |
!
|
|
122 |
|
|
123 |
project: aString
|
|
124 |
|
|
125 |
project := aString
|
|
126 |
! !
|
|
127 |
|
|
128 |
!MCSmalltalkhubRepository methodsFor:'converting'!
|
|
129 |
|
|
130 |
asCreationTemplate
|
|
131 |
^self class
|
|
132 |
creationTemplateOwner: self owner project: self project user: user password: password
|
|
133 |
! !
|
|
134 |
|
|
135 |
!MCSmalltalkhubRepository methodsFor:'interface'!
|
|
136 |
|
|
137 |
includesFileNamed: aString
|
|
138 |
"avoid the slower default method and simply do a head request "
|
|
139 |
self httpClient
|
|
140 |
numberOfRetries: 0;
|
|
141 |
ifFail: [ :exception |
|
|
142 |
((exception isKindOf: ZnHttpUnsuccessful) and: [ exception response isNotFound ])
|
|
143 |
ifTrue: [ ^ false ].
|
|
144 |
exception pass];
|
|
145 |
head: (self urlForFileNamed: aString).
|
|
146 |
^ true
|
|
147 |
!
|
|
148 |
|
|
149 |
includesVersionNamed: aString
|
|
150 |
"directly do a filename check since squeaksource only stores mcz"
|
|
151 |
^ self includesFileNamed: aString, '.mcz'
|
|
152 |
!
|
|
153 |
|
|
154 |
loadAllFileNames
|
|
155 |
| client |
|
|
156 |
client := self httpClient.
|
|
157 |
client
|
|
158 |
ifFail: [ :exception | self error: 'Could not access ', self location, ': ', exception printString ];
|
|
159 |
url: self locationWithTrailingSlash;
|
|
160 |
queryAt: 'format' put: 'raw';
|
|
161 |
get.
|
|
162 |
self assertNonBinaryResponse: client response.
|
|
163 |
^ self parseFileNamesFromStream: client contents
|
|
164 |
!
|
|
165 |
|
|
166 |
parseFileNamesFromStream: aNewLineDelimitedString
|
|
167 |
^ aNewLineDelimitedString
|
|
168 |
ifNil: [ ^ OrderedCollection new ]
|
|
169 |
ifNotNil: [ aNewLineDelimitedString substrings: String crlf ]
|
|
170 |
! !
|
|
171 |
|
|
172 |
!MCSmalltalkhubRepository class methodsFor:'documentation'!
|
|
173 |
|
|
174 |
version
|
|
175 |
^ '$Header$'
|
|
176 |
!
|
|
177 |
|
|
178 |
version_CVS
|
|
179 |
^ '$Header$'
|
|
180 |
! !
|
|
181 |
|