Skip to content

Commit

Permalink
Merge branch 'refs/heads/develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
GeekTree0101 committed Aug 29, 2021
2 parents 9abf0db + 0b4e283 commit 3ce1544
Show file tree
Hide file tree
Showing 22 changed files with 48 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import (
"strings"
)

type Copyright interface {
type Creator interface {
Get() (string, error)
}

type CopyrightImpl struct {
type CreatorImpl struct {
}

func (c CopyrightImpl) Get() (string, error) {
func (c CreatorImpl) Get() (string, error) {

gitUsername, err := c.getGitUsername()

Expand All @@ -30,7 +30,7 @@ func (c CopyrightImpl) Get() (string, error) {
return "", err
}

func (c CopyrightImpl) getGitUsername() (string, error) {
func (c CreatorImpl) getGitUsername() (string, error) {

gitCmd := exec.Command("git", "config", "--global", "user.name")
nameBytes, err := gitCmd.Output()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,23 @@ import (

// MARK: - Test Double

type CopyrightStub struct {
type CreatorStub struct {
GetSuccessStub string
GetErrorStub error
}

func (c CopyrightStub) Get() (string, error) {
func (c CreatorStub) Get() (string, error) {

return c.GetSuccessStub, c.GetErrorStub
}

// MARK: - Test Case

func TestCopyright(t *testing.T) {
func TestCreator(t *testing.T) {

t.Run("get copyright", func(t *testing.T) {
t.Run("get Creator", func(t *testing.T) {
// given
sut := converter.CopyrightImpl{}
sut := converter.CreatorImpl{}

// when
out, err := sut.Get()
Expand Down
13 changes: 7 additions & 6 deletions internal/converter/header.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ import (
)

type HeaderConverter struct {
copyright Copyright
creator Creator
targetProjectName string
copyrightDefaultValue string
date time.Time
}

func NewHeaderConverter(
copyright Copyright,
creator Creator,
config *model.Config,
date time.Time) *HeaderConverter {

return &HeaderConverter{
copyright: copyright,
creator: creator,
targetProjectName: config.TargetProjectName,
copyrightDefaultValue: config.Copyright,
date: date,
Expand All @@ -37,18 +37,19 @@ func (header *HeaderConverter) Render(source string, sceneName string) string {

dateStr := fmt.Sprintf("%d/%d/%d", day, month, year)

copyright, err := header.copyright.Get()
creator, err := header.creator.Get()

if err != nil {
copyright = header.copyrightDefaultValue
creator = "clean-swift-scaffold"
}

var replacedSource string = source
replacedSource = strings.ReplaceAll(replacedSource, "__SCENE_NAME__", sceneName)
replacedSource = strings.ReplaceAll(replacedSource, "__TARGET_PROJECT_NAME__", header.targetProjectName)
replacedSource = strings.ReplaceAll(replacedSource, "__DATE__", dateStr)
replacedSource = strings.ReplaceAll(replacedSource, "__YEAR__", strconv.Itoa(year))
replacedSource = strings.ReplaceAll(replacedSource, "__COPYRIGHT__", copyright)
replacedSource = strings.ReplaceAll(replacedSource, "__COPYRIGHT__", header.copyrightDefaultValue)
replacedSource = strings.ReplaceAll(replacedSource, "__CREATOR__", creator)

return replacedSource
}
10 changes: 5 additions & 5 deletions internal/converter/header_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const dummySourceCode string = `//
// __SCENE_NAME__Model.swift
// __TARGET_PROJECT_NAME__
//
// Created by clean-swift-scaffold on __DATE__.
// Created by __CREATOR__ on __DATE__.
// Copyright © __YEAR__ __COPYRIGHT__. All rights reserved.
//
Expand All @@ -25,8 +25,8 @@ const expectedSourceCode string = `//
// ArticleDetailModel.swift
// Miro
//
// Created by clean-swift-scaffold on 12/10/2020.
// Copyright © 2020 Geektree0101. All rights reserved.
// Created by Geektree0101 on 12/10/2020.
// Copyright © 2020 miro. All rights reserved.
//
enum ArticleDetailModel {
Expand All @@ -40,13 +40,13 @@ func TestHeader(t *testing.T) {
// given
config := model.Config{
TargetProjectName: "Miro",
Copyright: "David Ha",
Copyright: "miro",
TemplatePath: "",
}

date := time.Date(2020, 10, 12, 0, 0, 0, 0, time.UTC)
sut := converter.NewHeaderConverter(
CopyrightStub{
CreatorStub{
GetSuccessStub: "Geektree0101",
GetErrorStub: nil,
},
Expand Down
4 changes: 2 additions & 2 deletions internal/converter/source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ func createSource() *converter.SourceConverter {

config := &model.Config{
TargetProjectName: "Miro",
Copyright: "David Ha",
Copyright: "miro",
TemplatePath: "../../templates",
SourceDir: "./Playground/Sources",
TestDir: "./Playground/Tests",
Indentation: 2,
}

header := converter.NewHeaderConverter(
CopyrightStub{
CreatorStub{
GetSuccessStub: "Geektree0101",
GetErrorStub: nil,
},
Expand Down
2 changes: 1 addition & 1 deletion internal/gen/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func (gen *Generator) Run() error {
gen.flag.Name,
strings.Split(gen.flag.UsecasesString, ","),
converter.NewHeaderConverter(
converter.CopyrightImpl{},
converter.CreatorImpl{},
config,
today,
),
Expand Down
2 changes: 1 addition & 1 deletion templates/src/Interactor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// __SCENE_NAME__Interactor.swift
// __TARGET_PROJECT_NAME__
//
// Created by clean-swift-scaffold on __DATE__.
// Created by __CREATOR__ on __DATE__.
// Copyright © __YEAR__ __COPYRIGHT__. All rights reserved.
//

Expand Down
2 changes: 1 addition & 1 deletion templates/src/Model.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// __SCENE_NAME__Model.swift
// __TARGET_PROJECT_NAME__
//
// Created by clean-swift-scaffold on __DATE__.
// Created by __CREATOR__ on __DATE__.
// Copyright © __YEAR__ __COPYRIGHT__. All rights reserved.
//

Expand Down
2 changes: 1 addition & 1 deletion templates/src/Presenter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// __SCENE_NAME__Presenter.swift
// __TARGET_PROJECT_NAME__
//
// Created by clean-swift-scaffold on __DATE__.
// Created by __CREATOR__ on __DATE__.
// Copyright © __YEAR__ __COPYRIGHT__. All rights reserved.
//

Expand Down
2 changes: 1 addition & 1 deletion templates/src/Router.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// __SCENE_NAME__Router.swift
// __TARGET_PROJECT_NAME__
//
// Created by clean-swift-scaffold on __DATE__.
// Created by __CREATOR__ on __DATE__.
// Copyright © __YEAR__ __COPYRIGHT__. All rights reserved.
//

Expand Down
2 changes: 1 addition & 1 deletion templates/src/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// __SCENE_NAME__ViewController.swift
// __TARGET_PROJECT_NAME__
//
// Created by clean-swift-scaffold on __DATE__.
// Created by __CREATOR__ on __DATE__.
// Copyright © __YEAR__ __COPYRIGHT__. All rights reserved.
//

Expand Down
2 changes: 1 addition & 1 deletion templates/test/Interactor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// __SCENE_NAME__InteractorTests.swift
// __TARGET_PROJECT_NAME__Tests
//
// Created by clean-swift-scaffold on __DATE__.
// Created by __CREATOR__ on __DATE__.
// Copyright © __YEAR__ __COPYRIGHT__. All rights reserved.
//

Expand Down
2 changes: 1 addition & 1 deletion templates/test/Presenter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// __SCENE_NAME__PresenterTests.swift
// __TARGET_PROJECT_NAME__Tests
//
// Created by clean-swift-scaffold on __DATE__.
// Created by __CREATOR__ on __DATE__.
// Copyright © __YEAR__ __COPYRIGHT__. All rights reserved.
//

Expand Down
2 changes: 1 addition & 1 deletion templates/test/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// __SCENE_NAME__ViewControllerTests.swift
// __TARGET_PROJECT_NAME__Tests
//
// Created by clean-swift-scaffold on __DATE__.
// Created by __CREATOR__ on __DATE__.
// Copyright © __YEAR__ __COPYRIGHT__. All rights reserved.
//

Expand Down
4 changes: 2 additions & 2 deletions test/ArticleDetailInteractor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// ArticleDetailInteractor.swift
// Miro
//
// Created by clean-swift-scaffold on 12/10/2020.
// Copyright © 2020 Geektree0101. All rights reserved.
// Created by Geektree0101 on 12/10/2020.
// Copyright © 2020 miro. All rights reserved.
//

import Foundation
Expand Down
4 changes: 2 additions & 2 deletions test/ArticleDetailInteractorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// ArticleDetailInteractorTests.swift
// MiroTests
//
// Created by clean-swift-scaffold on 12/10/2020.
// Copyright © 2020 Geektree0101. All rights reserved.
// Created by Geektree0101 on 12/10/2020.
// Copyright © 2020 miro. All rights reserved.
//

import XCTest
Expand Down
4 changes: 2 additions & 2 deletions test/ArticleDetailModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// ArticleDetailModel.swift
// Miro
//
// Created by clean-swift-scaffold on 12/10/2020.
// Copyright © 2020 Geektree0101. All rights reserved.
// Created by Geektree0101 on 12/10/2020.
// Copyright © 2020 miro. All rights reserved.
//

enum ArticleDetailModel {
Expand Down
4 changes: 2 additions & 2 deletions test/ArticleDetailPresenter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// ArticleDetailPresenter.swift
// Miro
//
// Created by clean-swift-scaffold on 12/10/2020.
// Copyright © 2020 Geektree0101. All rights reserved.
// Created by Geektree0101 on 12/10/2020.
// Copyright © 2020 miro. All rights reserved.
//

import UIKit
Expand Down
4 changes: 2 additions & 2 deletions test/ArticleDetailPresenterTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// ArticleDetailPresenterTests.swift
// MiroTests
//
// Created by clean-swift-scaffold on 12/10/2020.
// Copyright © 2020 Geektree0101. All rights reserved.
// Created by Geektree0101 on 12/10/2020.
// Copyright © 2020 miro. All rights reserved.
//

import XCTest
Expand Down
4 changes: 2 additions & 2 deletions test/ArticleDetailRouter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// ArticleDetailRouter.swift
// Miro
//
// Created by clean-swift-scaffold on 12/10/2020.
// Copyright © 2020 Geektree0101. All rights reserved.
// Created by Geektree0101 on 12/10/2020.
// Copyright © 2020 miro. All rights reserved.
//

import UIKit
Expand Down
4 changes: 2 additions & 2 deletions test/ArticleDetailViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// ArticleDetailViewController.swift
// Miro
//
// Created by clean-swift-scaffold on 12/10/2020.
// Copyright © 2020 Geektree0101. All rights reserved.
// Created by Geektree0101 on 12/10/2020.
// Copyright © 2020 miro. All rights reserved.
//

import UIKit
Expand Down
4 changes: 2 additions & 2 deletions test/ArticleDetailViewControllerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// ArticleDetailViewControllerTests.swift
// MiroTests
//
// Created by clean-swift-scaffold on 12/10/2020.
// Copyright © 2020 Geektree0101. All rights reserved.
// Created by Geektree0101 on 12/10/2020.
// Copyright © 2020 miro. All rights reserved.
//

import XCTest
Expand Down

0 comments on commit 3ce1544

Please sign in to comment.