From 9e11ba9335616340b4f543116674ccf1489d69b7 Mon Sep 17 00:00:00 2001 From: Manuel Friedli Date: Fri, 31 Aug 2018 23:00:13 +0200 Subject: [PATCH] Corrected NativeLibraryWrapperService. --- src/app/app.module.ts | 2 +- src/app/converter-registry.service.ts | 2 +- src/app/converter/punycodedecoder.ts | 2 +- src/app/converter/punycodeencoder.ts | 2 +- src/app/converter/quotedprintabledecoder.ts | 2 +- src/app/converter/quotedprintableencoder.ts | 2 +- src/app/converter/utf8decoder.ts | 2 +- src/app/converter/utf8encoder.ts | 2 +- .../native-library-wrapper.service.spec.ts | 15 ++++++++++ ...e.ts => native-library-wrapper.service.ts} | 29 +++++++++++++++---- src/app/punycode.ts | 4 --- src/app/quotedprintable.ts | 4 --- src/app/utf8.ts | 4 --- 13 files changed, 46 insertions(+), 26 deletions(-) create mode 100644 src/app/native-library-wrapper.service.spec.ts rename src/app/{nativelibrarywrapper.service.ts => native-library-wrapper.service.ts} (59%) delete mode 100644 src/app/punycode.ts delete mode 100644 src/app/quotedprintable.ts delete mode 100644 src/app/utf8.ts diff --git a/src/app/app.module.ts b/src/app/app.module.ts index efad288..5e40ab8 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -3,7 +3,7 @@ import {NgModule} from '@angular/core'; import {AppComponent} from './app.component'; import {ConverterRegistryService} from './converter-registry.service'; import {InputComponentManagerService} from './input-component-manager.service'; -import {NativeLibraryWrapperService} from './nativelibrarywrapper.service'; +import {NativeLibraryWrapperService} from './native-library-wrapper.service'; import {FormsModule} from '@angular/forms'; import {VersionComponent} from './version/version.component'; diff --git a/src/app/converter-registry.service.ts b/src/app/converter-registry.service.ts index 4067b3d..84e013e 100644 --- a/src/app/converter-registry.service.ts +++ b/src/app/converter-registry.service.ts @@ -8,7 +8,7 @@ import {HexToDecConverter} from './converter/hextodecconverter'; import {HTMLEntitiesDecoder} from './converter/htmlentitiesdecoder'; import {HTMLEntitiesEncoder} from './converter/htmlentitiesencoder'; import {Injectable} from '@angular/core'; -import {NativeLibraryWrapperService} from './nativelibrarywrapper.service'; +import {NativeLibraryWrapperService} from './native-library-wrapper.service'; import {PunycodeDecoder} from './converter/punycodedecoder'; import {PunycodeEncoder} from './converter/punycodeencoder'; import {QuotedPrintableDecoder} from './converter/quotedprintabledecoder'; diff --git a/src/app/converter/punycodedecoder.ts b/src/app/converter/punycodedecoder.ts index 5f68ec6..c850e2b 100644 --- a/src/app/converter/punycodedecoder.ts +++ b/src/app/converter/punycodedecoder.ts @@ -1,5 +1,5 @@ import {Converter} from './converter'; -import {NativeLibraryWrapperService} from '../nativelibrarywrapper.service'; +import {NativeLibraryWrapperService} from '../native-library-wrapper.service'; export class PunycodeDecoder implements Converter { diff --git a/src/app/converter/punycodeencoder.ts b/src/app/converter/punycodeencoder.ts index ebf8b67..05523d6 100644 --- a/src/app/converter/punycodeencoder.ts +++ b/src/app/converter/punycodeencoder.ts @@ -1,5 +1,5 @@ import {Converter} from './converter'; -import {NativeLibraryWrapperService} from '../nativelibrarywrapper.service'; +import {NativeLibraryWrapperService} from '../native-library-wrapper.service'; export class PunycodeEncoder implements Converter { diff --git a/src/app/converter/quotedprintabledecoder.ts b/src/app/converter/quotedprintabledecoder.ts index 9c43014..d1992c5 100644 --- a/src/app/converter/quotedprintabledecoder.ts +++ b/src/app/converter/quotedprintabledecoder.ts @@ -1,5 +1,5 @@ import {Converter} from './converter'; -import {NativeLibraryWrapperService} from '../nativelibrarywrapper.service'; +import {NativeLibraryWrapperService} from '../native-library-wrapper.service'; export class QuotedPrintableDecoder implements Converter { diff --git a/src/app/converter/quotedprintableencoder.ts b/src/app/converter/quotedprintableencoder.ts index 17cbb32..b6d07b8 100644 --- a/src/app/converter/quotedprintableencoder.ts +++ b/src/app/converter/quotedprintableencoder.ts @@ -1,5 +1,5 @@ import {Converter} from './converter'; -import {NativeLibraryWrapperService} from '../nativelibrarywrapper.service'; +import {NativeLibraryWrapperService} from '../native-library-wrapper.service'; export class QuotedPrintableEncoder implements Converter { diff --git a/src/app/converter/utf8decoder.ts b/src/app/converter/utf8decoder.ts index 7f19a76..a17f502 100644 --- a/src/app/converter/utf8decoder.ts +++ b/src/app/converter/utf8decoder.ts @@ -1,5 +1,5 @@ import {Converter} from './converter'; -import {NativeLibraryWrapperService} from '../nativelibrarywrapper.service'; +import {NativeLibraryWrapperService} from '../native-library-wrapper.service'; export class UTF8Decoder implements Converter { diff --git a/src/app/converter/utf8encoder.ts b/src/app/converter/utf8encoder.ts index 7e911d4..9d47879 100644 --- a/src/app/converter/utf8encoder.ts +++ b/src/app/converter/utf8encoder.ts @@ -1,5 +1,5 @@ import {Converter} from './converter'; -import {NativeLibraryWrapperService} from '../nativelibrarywrapper.service'; +import {NativeLibraryWrapperService} from '../native-library-wrapper.service'; export class UTF8Encoder implements Converter { diff --git a/src/app/native-library-wrapper.service.spec.ts b/src/app/native-library-wrapper.service.spec.ts new file mode 100644 index 0000000..35f2936 --- /dev/null +++ b/src/app/native-library-wrapper.service.spec.ts @@ -0,0 +1,15 @@ +import { TestBed, inject } from '@angular/core/testing'; + +import { NativeLibraryWrapperService } from './native-library-wrapper.service'; + +describe('NativeLibraryWrapperService', () => { + beforeEach(() => { + TestBed.configureTestingModule({ + providers: [NativeLibraryWrapperService] + }); + }); + + it('should be created', inject([NativeLibraryWrapperService], (service: NativeLibraryWrapperService) => { + expect(service).toBeTruthy(); + })); +}); diff --git a/src/app/nativelibrarywrapper.service.ts b/src/app/native-library-wrapper.service.ts similarity index 59% rename from src/app/nativelibrarywrapper.service.ts rename to src/app/native-library-wrapper.service.ts index f3ce6af..308a14f 100644 --- a/src/app/nativelibrarywrapper.service.ts +++ b/src/app/native-library-wrapper.service.ts @@ -1,12 +1,11 @@ import {Injectable} from '@angular/core'; -import {Punycode} from './punycode'; -import {Utf8} from './utf8'; -import {QuotedPrintable} from './quotedprintable'; -import * as NativeUtf8 from 'utf8'; -import * as NativeQuotedPrintable from 'quoted-printable'; import * as NativePunycode from 'punycode'; +import * as NativeQuotedPrintable from 'quoted-printable'; +import * as NativeUtf8 from 'utf8'; -@Injectable() +@Injectable({ + providedIn: 'root' +}) export class NativeLibraryWrapperService { public utf8: Utf8; public quotedPrintable: QuotedPrintable; @@ -18,3 +17,21 @@ export class NativeLibraryWrapperService { this.punycode = NativePunycode; } } + +interface Punycode { + encode(input: string): string; + + decode(input: string): string; +} + +interface QuotedPrintable { + encode(input: string): string; + + decode(input: string): string; +} + +interface Utf8 { + encode(input: any): string; + + decode(input: string): any; +} diff --git a/src/app/punycode.ts b/src/app/punycode.ts deleted file mode 100644 index 1368326..0000000 --- a/src/app/punycode.ts +++ /dev/null @@ -1,4 +0,0 @@ -export interface Punycode { - encode(input: string): string; - decode(input: string): string; -} diff --git a/src/app/quotedprintable.ts b/src/app/quotedprintable.ts deleted file mode 100644 index 59bdfba..0000000 --- a/src/app/quotedprintable.ts +++ /dev/null @@ -1,4 +0,0 @@ -export interface QuotedPrintable { - encode(input: string): string; - decode(input: string): string; -} diff --git a/src/app/utf8.ts b/src/app/utf8.ts deleted file mode 100644 index 86706f5..0000000 --- a/src/app/utf8.ts +++ /dev/null @@ -1,4 +0,0 @@ -export interface Utf8 { - encode(input: any): string; - decode(input: string): any; -}