Skip to content

Commit 118005a

Browse files
authored
Merge pull request #11 from FranzDiebold/refactor/reformat-code
Reformat code (using Prettier code formatter).
2 parents 8b22d45 + a605467 commit 118005a

21 files changed

+710
-514
lines changed

.github/workflows/ci.yml

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -11,51 +11,51 @@ jobs:
1111
name: Test and lint library
1212
runs-on: ubuntu-latest
1313
steps:
14-
- uses: actions/checkout@v2
15-
with:
16-
persist-credentials: false
17-
- uses: actions/setup-node@v1
18-
with:
19-
node-version: '12.x'
20-
registry-url: 'https://registry.npmjs.org'
21-
- run: make install
22-
- run: make test-lib-ci
23-
- run: make lint-lib
14+
- uses: actions/checkout@v2
15+
with:
16+
persist-credentials: false
17+
- uses: actions/setup-node@v1
18+
with:
19+
node-version: "12.x"
20+
registry-url: "https://registry.npmjs.org"
21+
- run: make install
22+
- run: make test-lib-ci
23+
- run: make lint-lib
2424

2525
lib_publish:
2626
name: Publish library
2727
needs: lib_test_and_lint
2828
if: github.event_name == 'release'
2929
runs-on: ubuntu-latest
3030
steps:
31-
- uses: actions/checkout@v2
32-
with:
33-
persist-credentials: false
34-
- uses: actions/setup-node@v1
35-
with:
36-
node-version: '12.x'
37-
registry-url: 'https://registry.npmjs.org'
38-
- run: make install
39-
- run: make publish-lib
40-
env:
41-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
31+
- uses: actions/checkout@v2
32+
with:
33+
persist-credentials: false
34+
- uses: actions/setup-node@v1
35+
with:
36+
node-version: "12.x"
37+
registry-url: "https://registry.npmjs.org"
38+
- run: make install
39+
- run: make publish-lib
40+
env:
41+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
4242

4343
demo:
4444
name: Build, test, lint and deploy demo application
4545
runs-on: ubuntu-latest
4646
steps:
47-
- uses: actions/checkout@v2
48-
with:
49-
persist-credentials: false
50-
- uses: actions/setup-node@v1
51-
with:
52-
node-version: '12.x'
53-
registry-url: 'https://registry.npmjs.org'
54-
- run: make install
55-
- run: make build-lib
56-
- run: make test-demo-ci
57-
- run: make lint-demo
58-
- run: make deploy-demo
59-
if: github.ref == 'refs/heads/main'
60-
env:
61-
GH_TOKEN: ${{ secrets.GH_TOKEN }}
47+
- uses: actions/checkout@v2
48+
with:
49+
persist-credentials: false
50+
- uses: actions/setup-node@v1
51+
with:
52+
node-version: "12.x"
53+
registry-url: "https://registry.npmjs.org"
54+
- run: make install
55+
- run: make build-lib
56+
- run: make test-demo-ci
57+
- run: make lint-demo
58+
- run: make deploy-demo
59+
if: github.ref == 'refs/heads/main'
60+
env:
61+
GH_TOKEN: ${{ secrets.GH_TOKEN }}

README.md

Lines changed: 47 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,26 @@ Use [Google Sheets](https://en.wikipedia.org/wiki/Google_Sheets) as your (read-o
1818

1919
```typescript
2020
const attributesMapping = {
21-
id: 'ID',
22-
name: 'Name',
23-
email: 'Email Address',
21+
id: "ID",
22+
name: "Name",
23+
email: "Email Address",
2424
contact: {
25-
_prefix: 'Contact',
26-
street: 'Street',
27-
streetNumber: 'Street Number',
28-
zip: 'ZIP',
29-
city: 'City'
25+
_prefix: "Contact",
26+
street: "Street",
27+
streetNumber: "Street Number",
28+
zip: "ZIP",
29+
city: "City",
3030
},
3131
skills: {
32-
_prefix: 'Skill',
33-
_listField: true
34-
}
32+
_prefix: "Skill",
33+
_listField: true,
34+
},
3535
};
3636
```
3737

3838
```ts
39-
googleSheetsDbService.get('1gSc_7WCmt-HuSLX01-Ev58VsiFuhbpYVo8krbPCvvqA', 1, attributesMapping)
39+
googleSheetsDbService
40+
.get("1gSc_7WCmt-HuSLX01-Ev58VsiFuhbpYVo8krbPCvvqA", 1, attributesMapping)
4041
.subscribe((characters: object[]) => {
4142
// Use the characters here
4243
});
@@ -59,14 +60,14 @@ npm install ng-google-sheets-db
5960
### Google Sheets
6061

6162
1. Create a [Google Sheet](https://docs.google.com/spreadsheets):
62-
- The first row **must** be the header.
63-
- The following rows are your entries, one entry per row.
64-
- You may have an *active* column, with which you can enable or disable rows/entries.
65-
- A Google Sheets demo spreadsheet is available [here](https://docs.google.com/spreadsheets/d/1gSc_7WCmt-HuSLX01-Ev58VsiFuhbpYVo8krbPCvvqA).
63+
- The first row **must** be the header.
64+
- The following rows are your entries, one entry per row.
65+
- You may have an _active_ column, with which you can enable or disable rows/entries.
66+
- A Google Sheets demo spreadsheet is available [here](https://docs.google.com/spreadsheets/d/1gSc_7WCmt-HuSLX01-Ev58VsiFuhbpYVo8krbPCvvqA).
6667
2. Share your sheet:
67-
- [File] → [Publish to the web] → (Entire Document, Web page) [Publish]
68-
- Get the *Spreadsheet ID* (i.e. `1gSc_7WCmt-HuSLX01-Ev58VsiFuhbpYVo8krbPCvvqA`): It is part of the Google spreadsheet URL.
69-
- Get the *Worksheet ID*: The Worksheet IDs are increasing numbers, starting at 1.
68+
- [File] → [Publish to the web] → (Entire Document, Web page) [Publish]
69+
- Get the _Spreadsheet ID_ (i.e. `1gSc_7WCmt-HuSLX01-Ev58VsiFuhbpYVo8krbPCvvqA`): It is part of the Google spreadsheet URL.
70+
- Get the _Worksheet ID_: The Worksheet IDs are increasing numbers, starting at 1.
7071
3. Optional: It may be a good idea to enable [2-Step Verification](https://www.google.com/landing/2step/) for your Google account, if you have not done it yet :wink:.
7172

7273
### Angular
@@ -114,50 +115,61 @@ The `attributesMapping` maps the Google spreadsheet columns to to your outcome o
114115
115116
```typescript
116117
const attributesMapping = {
117-
id: 'ID',
118-
name: 'Name',
119-
email: 'Email Address',
118+
id: "ID",
119+
name: "Name",
120+
email: "Email Address",
120121
contact: {
121-
_prefix: 'Contact',
122-
street: 'Street',
123-
streetNumber: 'Street Number',
124-
zip: 'ZIP',
125-
city: 'City'
122+
_prefix: "Contact",
123+
street: "Street",
124+
streetNumber: "Street Number",
125+
zip: "ZIP",
126+
city: "City",
126127
},
127128
skills: {
128-
_prefix: 'Skill',
129-
_listField: true
130-
}
129+
_prefix: "Skill",
130+
_listField: true,
131+
},
131132
};
132133
```
133134
134-
For example, the Google spreadsheet column *Email Address* is mapped to the outcome object attribute `email`.
135+
For example, the Google spreadsheet column _Email Address_ is mapped to the outcome object attribute `email`.
135136
136137
#### Nested objects
137138
138139
`contact` is an example of a nested object. You may define a `_prefix` as a prefix for all columns of the nested object.
139140
140141
#### Lists
141142
142-
`skills` is an example of a list. You need to set `_listField` and a `_prefix` for all columns of the list. In this example, all columns starting with *Skill* and an increasing number are part of the list, i.e. *Skill 1*, *Skill 2*, etc.
143+
`skills` is an example of a list. You need to set `_listField` and a `_prefix` for all columns of the list. In this example, all columns starting with _Skill_ and an increasing number are part of the list, i.e. _Skill 1_, _Skill 2_, etc.
143144
144145
## Methods
145146
146147
### get<T>(spreadsheetId: string, worksheetId: string | number, attributesMapping: object | string[]): Observable<T[]>
147148
148149
```typescript
149-
const allCharacters$: Observable<Character> = googleSheetsDbService.get<Character>('1gSc_7WCmt-HuSLX01-Ev58VsiFuhbpYVo8krbPCvvqA', 1, attributesMapping);
150+
const allCharacters$: Observable<Character> =
151+
googleSheetsDbService.get<Character>(
152+
"1gSc_7WCmt-HuSLX01-Ev58VsiFuhbpYVo8krbPCvvqA",
153+
1,
154+
attributesMapping
155+
);
150156
```
151157
152158
Get all rows from the Google spreadsheet as an `Observable` of objects or a given type as type variable `T`.
153159
154160
### getActive<T>(spreadsheetId: string, worksheetId: string | number, attributesMapping: object | string[], isActiveColumnName: string = 'is_active', activeValues: string[] | string = null): Observable<T[]>
155161
156162
```typescript
157-
const activeCharacters$: Observable<Character> = googleSheetsDbService.getActive<Character>('1gSc_7WCmt-HuSLX01-Ev58VsiFuhbpYVo8krbPCvvqA', 1, attributesMapping, 'Active');
163+
const activeCharacters$: Observable<Character> =
164+
googleSheetsDbService.getActive<Character>(
165+
"1gSc_7WCmt-HuSLX01-Ev58VsiFuhbpYVo8krbPCvvqA",
166+
1,
167+
attributesMapping,
168+
"Active"
169+
);
158170
```
159171
160-
Get "active" rows from the Google spreadsheet as an `Observable` of objects or a given type as type variable `T`. You may have an *active* column with name `isActiveColumnName`, with which you can enable or disable rows/entries.
172+
Get "active" rows from the Google spreadsheet as an `Observable` of objects or a given type as type variable `T`. You may have an _active_ column with name `isActiveColumnName`, with which you can enable or disable rows/entries.
161173
"Active" rows have the value `true`, `1` or `yes`. You may also define your own `activeValues`.
162174
163175
## Demo Application

projects/demo/e2e/src/app.e2e-spec.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@ describe('workspace-project App', () => {
1616
afterEach(async () => {
1717
// Assert that there are no errors emitted from the browser
1818
const logs = await browser.manage().logs().get(logging.Type.BROWSER);
19-
expect(logs).not.toContain(jasmine.objectContaining({
20-
level: logging.Level.SEVERE,
21-
} as logging.Entry));
19+
expect(logs).not.toContain(
20+
jasmine.objectContaining({
21+
level: logging.Level.SEVERE,
22+
} as logging.Entry)
23+
);
2224
});
2325
});

projects/demo/e2e/src/app.po.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ export class AppPage {
66
}
77

88
getTitleText(): Promise<string> {
9-
return element(by.css('app-root .content span')).getText() as Promise<string>;
9+
return element(
10+
by.css('app-root .content span')
11+
).getText() as Promise<string>;
1012
}
1113
}

0 commit comments

Comments
 (0)