Skip to content

Commit

Permalink
Merge pull request #268 from estebanlm/dev-0.4
Browse files Browse the repository at this point in the history
first shot to plugins (and GitHub PR as test case)
  • Loading branch information
npasserini authored Feb 3, 2017
2 parents 79f01af + 237aa21 commit 4ddee27
Show file tree
Hide file tree
Showing 161 changed files with 803 additions and 112 deletions.
5 changes: 2 additions & 3 deletions BaselineOfIceberg.package/.filetree
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"separateMethodMetaAndSource" : false,
"noMethodMetaData" : true,
"useCypressPropertiesFile" : true
}
"separateMethodMetaAndSource" : false,
"useCypressPropertiesFile" : true }
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,16 @@ baseline: spec
with: [ spec requires: #('ProcessWrapper') ] ];

package: 'Iceberg';
package: 'Iceberg-Metacello-Integration' with: [ spec requires: #(Iceberg)];
package: 'Iceberg-UI' with: [ spec requires: #(Iceberg) ];
package: 'Iceberg-Tests' with: [ spec requires: #(Iceberg 'Iceberg-GitCommand') ];
package: 'Iceberg-Plugin';
package: 'Iceberg-Metacello-Integration' with: [ spec requires: #('Iceberg')];
package: 'Iceberg-UI' with: [ spec requires: #('Iceberg' 'Iceberg-Plugin') ];
package: 'Iceberg-Tests' with: [ spec requires: #('Iceberg' 'Iceberg-GitCommand') ];
package: 'Iceberg-UI-Tests' with: [ spec requires: #('Iceberg-UI' 'Iceberg-Tests')];
package: 'Iceberg-GitFileTree' with: [ spec requires: #(Iceberg FileTree) ];
package: 'Iceberg-GitFileTree' with: [ spec requires: #('Iceberg' 'FileTree') ];
package: 'Iceberg-GitFileTree-Tests' with: [ spec requires: #('Iceberg-GitFileTree' 'Iceberg-Tests') ];
package: 'Iceberg-Libgit' with: [ spec requires: #(Iceberg LibGit) ];
package: 'Iceberg-Libgit' with: [ spec requires: #('Iceberg' 'LibGit') ];

group: 'minimal' with: #(Iceberg 'Iceberg-Libgit');
group: 'minimal' with: #('Iceberg' 'Iceberg-Libgit');
group: 'default' with: #(minimal 'Iceberg-Metacello-Integration' 'Iceberg-UI');
group: 'allTests' with: #('Iceberg-Tests' 'LibGit-Tests' 'Iceberg-GitFileTree-Tests' 'Iceberg-UI-Tests' );
group: 'development' with: #(default 'Iceberg-GitFileTree' allTests)
Expand Down

This file was deleted.

19 changes: 11 additions & 8 deletions BaselineOfIceberg.package/BaselineOfIceberg.class/properties.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
{
"commentStamp" : "",
"super" : "BaselineOf",
"category" : "BaselineOfIceberg",
"classinstvars" : [ ],
"pools" : [ ],
"classvars" : [ ],
"instvars" : [ ],
"classinstvars" : [
],
"classvars" : [
],
"commentStamp" : "",
"instvars" : [
],
"name" : "BaselineOfIceberg",
"type" : "normal"
}
"pools" : [
],
"super" : "BaselineOf",
"type" : "normal" }
3 changes: 2 additions & 1 deletion BaselineOfIceberg.package/properties.json
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
{ }
{
}
4 changes: 4 additions & 0 deletions Iceberg-Plugin.package/.filetree
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"noMethodMetaData" : true,
"separateMethodMetaAndSource" : false,
"useCypressPropertiesFile" : true }
2 changes: 2 additions & 0 deletions Iceberg-Plugin.package/IceGitHubAPI.class/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
I represent an access point to the GitHub API.
I provide different high level abstractions to interact with GitHub, following the speciphications you can find here: https://developer.github.com/v3/
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
credentials: anObject
credentials := anObject
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
credentials
^ credentials
6 changes: 6 additions & 0 deletions Iceberg-Plugin.package/IceGitHubAPI.class/instance/get..st
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
private requesting
get: aString
^ self withResponseValidationDo: [
(self newRequestTo: aString)
get;
response ]
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
private factory
newRequestTo: aString
^ ZnClient new
username: self credentials username password: self credentials password;
headerAt: 'Accept' put: 'application/vnd.github.v3+json';
url: 'https://api.github.com/', aString;
yourself
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
private requesting
post: aString with: aBlock
^ self withResponseValidationDo: [
(self newRequestTo: aString)
in: aBlock;
post;
response ]
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
requesting
postPullRequestTo: owner project: projectName data: aDictionary
^ self
post: 'repos/', owner, '/', projectName, '/pulls'
with: [ :client |
client
entity: (ZnEntity text: (STON toJsonString: aDictionary));
contentType: ZnMimeType applicationJson ]
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
requesting
requestBranchesFrom: owner project: projectName
^ self get: 'repos/', owner,'/', projectName, '/branches'
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
requesting
requestRepositoryFrom: owner project: projectName
^ self get: 'repos/', owner,'/', projectName
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
private requesting
withResponseValidationDo: aBlock
| response |

response := aBlock value.
response isSuccess
ifFalse: [ IceGitHubError signalFor: response ].
^ response contents
14 changes: 14 additions & 0 deletions Iceberg-Plugin.package/IceGitHubAPI.class/properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"category" : "Iceberg-Plugin-GitHub",
"classinstvars" : [
],
"classvars" : [
],
"commentStamp" : "<historical>",
"instvars" : [
"credentials" ],
"name" : "IceGitHubAPI",
"pools" : [
],
"super" : "Object",
"type" : "normal" }
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
I'm an error that happens when credentials are bad.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
testing
isAppropriateFor: aResponse
^ aResponse status = 401
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
messageBody
^ 'Credentials provided are wrong'
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"category" : "Iceberg-Plugin-GitHub",
"classinstvars" : [
],
"classvars" : [
],
"commentStamp" : "<historical>",
"instvars" : [
],
"name" : "IceGitHubBadCredentialsError",
"pools" : [
],
"super" : "IceGitHubError",
"type" : "normal" }
1 change: 1 addition & 0 deletions Iceberg-Plugin.package/IceGitHubError.class/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
I'm an error that happens when something fails when performing a GitHub action.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
private
errorClassFor: aResponse
^ self allSubclasses
detect: [ :each | each isAppropriateFor: aResponse ]
ifNone: [ self ]
5 changes: 5 additions & 0 deletions Iceberg-Plugin.package/IceGitHubError.class/class/for..st
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
instance creation
for: aResponse
^ (self errorClassFor: aResponse) new
response: aResponse;
yourself
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
testing
isAppropriateFor: aResponse
^ false
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
instance creation
signalFor: aResponse
^ (self for: aResponse) signal
3 changes: 3 additions & 0 deletions Iceberg-Plugin.package/IceGitHubError.class/instance/code.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
code
^ self response status
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
contents
^ self response contents
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
private
customError: aDictionary
^ aDictionary at: #message

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
private
errorToString: aDictionary
(aDictionary at: #code) = 'custom' ifTrue: [ ^ self customError: aDictionary ].
(aDictionary at: #code) = 'invalid' ifTrue: [ ^ self invalidError: aDictionary ].

^ self unknownError: aDictionary
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
private
invalidError: aDictionary
^ 'Invalid field: ', (aDictionary at: #field)


Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
jsonContents
^ jsonContents ifNil: [ jsonContents := STON fromString: self contents ]

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
accessing
messageBody
| errors |
errors := self jsonContents at: #errors ifAbsent: [ ^ '' ].
^ String streamContents: [ :stream |
errors
do: [ :each | stream << (self errorToString: each) ]
separatedBy: [ stream cr ] ].
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
messageText
^ self jsonContents at: #message
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
response: anObject
response := anObject
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
response
^ response
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
private
unknownError: aDictionary
^ String streamContents: [ :stream |
(aDictionary associations sorted: [ :a :b | a key < b key ])
do: [ :each | stream << each key << ': ' << each value ]
separatedBy: [ stream << ', ' ] ]
15 changes: 15 additions & 0 deletions Iceberg-Plugin.package/IceGitHubError.class/properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"category" : "Iceberg-Plugin-GitHub",
"classinstvars" : [
],
"classvars" : [
],
"commentStamp" : "EstebanLorenzano 2/1/2017 17:15",
"instvars" : [
"response",
"jsonContents" ],
"name" : "IceGitHubError",
"pools" : [
],
"super" : "Error",
"type" : "normal" }
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
I'm an error that happens when something went wrong on GitHub API operations.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
testing
isAppropriateFor: aResponse
^ aResponse status = 422
14 changes: 14 additions & 0 deletions Iceberg-Plugin.package/IceGitHubGenericError.class/properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"category" : "Iceberg-Plugin-GitHub",
"classinstvars" : [
],
"classvars" : [
],
"commentStamp" : "<historical>",
"instvars" : [
],
"name" : "IceGitHubGenericError",
"pools" : [
],
"super" : "IceGitHubError",
"type" : "normal" }
2 changes: 2 additions & 0 deletions Iceberg-Plugin.package/IceGitHubPullRequest.class/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
I am a pull request.
I can be sent using ==#sendWithCredentials:== protocol.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
baseBranchName: anObject
baseBranchName := anObject
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
baseBranchName
^ baseBranchName
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
baseRemote: anObject
baseRemote := anObject
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
baseRemote
^ baseRemote
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
body: anObject
body := anObject
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
body
^ body
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
credentials: anObject
credentials := anObject
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
credentials
^ credentials
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
headBranchName: anObject
headBranchName := anObject
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
headBranchName
^ headBranchName
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
headRemote: anObject
headRemote := anObject
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
headRemote
^ headRemote
Loading

0 comments on commit 4ddee27

Please sign in to comment.