Repackaging from SmalltalkHub.
This commit is contained in:
parent
dc3fbba26d
commit
09a303e18a
76
ConfigurationOfShortener/ConfigurationOfShortener.class.st
Normal file
76
ConfigurationOfShortener/ConfigurationOfShortener.class.st
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
Class {
|
||||||
|
#name : #ConfigurationOfShortener,
|
||||||
|
#superclass : #Object,
|
||||||
|
#instVars : [
|
||||||
|
'project'
|
||||||
|
],
|
||||||
|
#classVars : [
|
||||||
|
'LastVersionLoad'
|
||||||
|
],
|
||||||
|
#category : #ConfigurationOfShortener
|
||||||
|
}
|
||||||
|
|
||||||
|
{ #category : #'development support' }
|
||||||
|
ConfigurationOfShortener class >> DevelopmentSupport [
|
||||||
|
|
||||||
|
"See the methods in the 'development support' category on the class-side of MetacelloBaseConfiguration. Decide what development support methods you would like to use and copy them the the class-side of your configuration."
|
||||||
|
<apiDocumentation>
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #category : #private }
|
||||||
|
ConfigurationOfShortener class >> ensureMetacelloBaseConfiguration [
|
||||||
|
Smalltalk
|
||||||
|
at: #'ConfigurationOf'
|
||||||
|
ifAbsent: [
|
||||||
|
| repository version |
|
||||||
|
repository := MCHttpRepository
|
||||||
|
location: 'http://smalltalkhub.com/mc/dkh/metacello/main'
|
||||||
|
user: ''
|
||||||
|
password: ''.
|
||||||
|
repository
|
||||||
|
versionReaderForFileNamed: 'Metacello-Base-dkh.107'
|
||||||
|
do: [ :reader |
|
||||||
|
version := reader version.
|
||||||
|
version load.
|
||||||
|
version workingCopy repositoryGroup addRepository: repository ] ]
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #category : #'development support' }
|
||||||
|
ConfigurationOfShortener class >> validate [
|
||||||
|
"Check the configuration for Errors, Critical Warnings, and Warnings (see class comment for MetacelloMCVersionValidator for more information).
|
||||||
|
Errors identify specification issues that will result in unexpected behaviour when you load the configuration.
|
||||||
|
Critical Warnings identify specification issues that may result in unexpected behavior when you load the configuration.
|
||||||
|
Warnings identify specification issues that are technically correct, but are worth take a look at."
|
||||||
|
|
||||||
|
"self validate"
|
||||||
|
|
||||||
|
<apiDocumentation>
|
||||||
|
self ensureMetacello.
|
||||||
|
^ ((Smalltalk at: #MetacelloToolBox) validateConfiguration: self debug: #() recurse: false) explore
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
ConfigurationOfShortener >> customProjectAttributes [
|
||||||
|
"Edit to return a collection of any custom attributes e.g. for conditional loading: Array with: #'Condition1' with: #'Condition2.
|
||||||
|
For more information see: http://code.google.com/p/metacello/wiki/CustomProjectAttrributes "
|
||||||
|
|
||||||
|
^ #()
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
ConfigurationOfShortener >> project [
|
||||||
|
^ project
|
||||||
|
ifNil: [
|
||||||
|
"Bootstrap Metacello if it is not already loaded"
|
||||||
|
self class ensureMetacello.
|
||||||
|
project := MetacelloMCProject new projectAttributes: self customProjectAttributes. "Create the Metacello project"
|
||||||
|
(Smalltalk at: #'MetacelloVersionConstructor') on: self project: project. "Construct the project"
|
||||||
|
project loadType: #'linear'. "change to #atomic if desired"
|
||||||
|
project ]
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #category : #'symbolic versions' }
|
||||||
|
ConfigurationOfShortener >> stable: spec [
|
||||||
|
<symbolicVersion: #'stable'>
|
||||||
|
spec for: #common version: '1'
|
||||||
|
]
|
1
ConfigurationOfShortener/package.st
Normal file
1
ConfigurationOfShortener/package.st
Normal file
@ -0,0 +1 @@
|
|||||||
|
Package { #name : #ConfigurationOfShortener }
|
28
Shortener/Shortener.class.st
Normal file
28
Shortener/Shortener.class.st
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
"
|
||||||
|
Please comment me using the following template inspired by Class Responsibility Collaborator (CRC) design:
|
||||||
|
|
||||||
|
For the Class part: State a one line summary. For example, ""I represent a paragraph of text"".
|
||||||
|
I represent a wrapper for the is.gd ethical shortener that doesn't track its users and is carbon neutral
|
||||||
|
(see https://is.gd/ethics.php for more details).
|
||||||
|
|
||||||
|
I use the public API as described in https://is.gd/apishorteningreference.php#restrict.
|
||||||
|
"
|
||||||
|
Class {
|
||||||
|
#name : #Shortener,
|
||||||
|
#superclass : #Object,
|
||||||
|
#category : #Shortener
|
||||||
|
}
|
||||||
|
|
||||||
|
{ #category : #'as yet unclassified' }
|
||||||
|
Shortener class >> enlarge: url [
|
||||||
|
"Given a shortened url in is.gd (or v.gd), I return the original url."
|
||||||
|
|
||||||
|
^ (ZnEasy get: 'https://is.gd/forward.php?format=simple&shorturl=', url) contents
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #category : #'accessing structure variables' }
|
||||||
|
Shortener class >> shorten: url [
|
||||||
|
"I return the shortened url string as returned by https//is.gd ."
|
||||||
|
|
||||||
|
^ (ZnEasy get: 'https://is.gd/create.php?format=simple&url=', url) contents
|
||||||
|
]
|
29
Shortener/ShortenerTest.class.st
Normal file
29
Shortener/ShortenerTest.class.st
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
"
|
||||||
|
A ShortenerTest is a test class for testing the behavior of Shortener
|
||||||
|
"
|
||||||
|
Class {
|
||||||
|
#name : #ShortenerTest,
|
||||||
|
#superclass : #TestCase,
|
||||||
|
#category : #'Shortener-Tests'
|
||||||
|
}
|
||||||
|
|
||||||
|
{ #category : #tests }
|
||||||
|
ShortenerTest >> testEnlarging [
|
||||||
|
"I thist that an already shortened address gives the proper result."
|
||||||
|
| shortenUrl |
|
||||||
|
shortenUrl := Shortener shorten: 'https://pharo.org'.
|
||||||
|
self assert: (Shortener enlarge: shortenUrl) equals: 'https://pharo.org'
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #category : #tests }
|
||||||
|
ShortenerTest >> testIsShortenerUp [
|
||||||
|
self assert: ((ZnEasy get: 'https://is.gd') isSuccess)
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #category : #tests }
|
||||||
|
ShortenerTest >> testShortening [
|
||||||
|
"I thist that an already shortened address gives the proper result."
|
||||||
|
| shortenUrl |
|
||||||
|
shortenUrl := Shortener shorten: 'https://pharo.org'.
|
||||||
|
self assert: (Shortener shorten: 'https://pharo.org') equals: shortenUrl
|
||||||
|
]
|
1
Shortener/package.st
Normal file
1
Shortener/package.st
Normal file
@ -0,0 +1 @@
|
|||||||
|
Package { #name : #Shortener }
|
Loading…
Reference in New Issue
Block a user