You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 5, 2025. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -36,13 +36,13 @@ The developer-friendly, opinionated Ruby SDK for [Spotify]. Works on Ruby 2.4+
36
36
37
37
Hey! I'm a Developer Advocate at [Spotify], and I wrote this Ruby SDK to explore how to build a SDK that is TADA:
38
38
39
-
-**🧒 Thoughtfully inclusive for beginners.** Everything we do should think about beginners from the start. From having an enforced [Code of Conduct] policy to building great documentation, tooling, and an empathetic feedback process. Designing for beginners is designing for longevity.
39
+
1.**🧒 Thoughtfully inclusive for beginners.** Everything we do should think about beginners from the start. From having an enforced [Code of Conduct] policy to building great documentation, tooling, and an empathetic feedback process. Designing for beginners is designing for longevity.
40
40
41
-
-**☁️ Agnostic to minor changes.** APIs change all the time. We should be opinionated enough that our software should break with major changes, but flexible enough to work perfectly fine with minor changes. Our code should only depend on critical data, such as IDs.
41
+
1.**☁️ Agnostic to minor changes.** APIs change all the time. We should be opinionated enough that our software should break with major changes, but flexible enough to work perfectly fine with minor changes. Our code should only depend on critical data, such as IDs.
42
42
43
-
-**🌈 Delightful for developers.** Writing the SDK and using the SDK should be equally delightful. Granted, this is a challenging goal; but with solid information architecture, well-crafted opinions, clear and helpful error messages, and software that doesn't get in your way - we will create quite lovely software.
43
+
1.**🌈 Delightful for developers.** Writing the SDK and using the SDK should be equally delightful. Granted, this is a challenging goal; but with solid information architecture, well-crafted opinions, clear and helpful error messages, and software that doesn't get in your way - we will create quite lovely software.
44
44
45
-
-**✨ A maintained production-level.** It doesn't take experts to write production-level code; all it takes is considerate guidance from the community. We should write software that we and others [trust to do what it is intended to do](https://hackernoon.com/im-harvesting-credit-card-numbers-and-passwords-from-your-site-here-s-how-9a8cb347c5b5). We care about [Semantic Versioning] for clear version changes.
45
+
1.**✨ A maintained production-level.** It doesn't take experts to write production-level code; all it takes is considerate guidance from the community. We should write software that we and others [trust to do what it is intended to do](https://hackernoon.com/im-harvesting-credit-card-numbers-and-passwords-from-your-site-here-s-how-9a8cb347c5b5). We care about [Semantic Versioning] for clear version changes.
46
46
47
47
_Disclaimer: This SDK is NOT owned or supported by Spotify. It remains a personal project of mine. If you are a commercial partner of Spotify and wish to use this SDK, be aware you are using it at your own risk._
@@ -38,13 +38,13 @@ Even more importantly, we're focusing on building software that isn't just expec
38
38
39
39
As mentioned in our `README.md`, we have four objectives with this SDK:
40
40
41
-
-**🧒 Thoughtfully inclusive for beginners.** Everything we do should think about beginners from the start. From having an enforced [Code of Conduct] policy to building great documentation, tooling, and an empathetic feedback process. Designing for beginners is designing for longevity.
41
+
1.**🧒 Thoughtfully inclusive for beginners.** Everything we do should think about beginners from the start. From having an enforced [Code of Conduct] policy to building great documentation, tooling, and an empathetic feedback process. Designing for beginners is designing for longevity.
42
42
43
-
-**☁️ Agnostic to minor changes.** APIs change all the time. We should be opinionated enough that our software should break with major changes, but flexible enough to work perfectly fine with minor changes. Our code should only depend on critical data, such as IDs.
43
+
1.**☁️ Agnostic to minor changes.** APIs change all the time. We should be opinionated enough that our software should break with major changes, but flexible enough to work perfectly fine with minor changes. Our code should only depend on critical data, such as IDs.
44
44
45
-
-**🌈 Delightful for developers.** Writing the SDK and using the SDK should be equally delightful. Granted, this is a challenging goal; but with solid information architecture, well-crafted opinions, clear and helpful error messages, and software that doesn't get in your way - we will create quite lovely software.
45
+
1.**🌈 Delightful for developers.** Writing the SDK and using the SDK should be equally delightful. Granted, this is a challenging goal; but with solid information architecture, well-crafted opinions, clear and helpful error messages, and software that doesn't get in your way - we will create quite lovely software.
46
46
47
-
-**✨ A maintained production-level.** It doesn't take experts to write production-level code; all it takes is considerate guidance from the community. We should write software that we and others [trust to do what it is intended to do](https://hackernoon.com/im-harvesting-credit-card-numbers-and-passwords-from-your-site-here-s-how-9a8cb347c5b5). We care about [Semantic Versioning] for clear version changes.
47
+
1.**✨ A maintained production-level.** It doesn't take experts to write production-level code; all it takes is considerate guidance from the community. We should write software that we and others [trust to do what it is intended to do](https://hackernoon.com/im-harvesting-credit-card-numbers-and-passwords-from-your-site-here-s-how-9a8cb347c5b5). We care about [Semantic Versioning] for clear version changes.
48
48
49
49
# Getting Started
50
50
@@ -60,7 +60,6 @@ There's multiple ways you can contribute, and we'll cover all of them:
60
60
-[Adding a Component](#adding-a-component)
61
61
-[Adding a Model](#adding-a-model)
62
62
-[Testing](#testing)
63
-
-[Documentation](#documentation)
64
63
65
64
## Website
66
65
@@ -212,9 +211,11 @@ $ ls -l spec/**/*_spec.rb
212
211
213
212
### Adding a Component
214
213
214
+
Components are subclasses of `Spotify::SDK` and typically represent a category of features for the [Spotify Platform]. For example, `Connect` represents a category of features - listing devices, controlling them, reading current playback, etc. Another example would be `Me` - listing my information, my top tracks, my saved tracks, etc.
215
+
215
216
In the `bin/` folder, we have provided a Rails-like generator that will generate the relevant files for you to add a new component:
216
217
217
-
#### Generate
218
+
#### Generating Component
218
219
219
220
For example, if you'd like to generate a component called `Friends` run the following command:
In our generated `spec/lib/spotify/sdk/friends_spec.rb` file, we can write some [RSpec] tests:
297
303
@@ -314,7 +320,7 @@ end
314
320
315
321
And then you can execute tests by running `rake ci` in the root directory.
316
322
317
-
#### Sample Implementation
323
+
#### Sample Component Implementation
318
324
319
325
For an example of a good implementation, see the following files for `Spotify::SDK::Me` component:
320
326
@@ -328,9 +334,186 @@ For an example of a good implementation, see the following files for `Spotify::S
328
334
329
335
### Adding a Model
330
336
337
+
Models are typically classes that hold data. They often contain functions to manipulate or perform actions with that data. An example is a `Device` model, it would contain a method like `pause!` which will take the `id` and send a `PUT /v1/me/player/pause?device_id={id}` HTTP command.
338
+
339
+
**Protip:** The models we write use Ruby's [OpenStruct] data structure; it is designed for flexible Hash objects. It fits in our [second objective](#objectives) of "being agnostic to minor changes"; in cases where Spotify may return `null` or contain additional fields, our codebase will not break.
340
+
341
+
In our `bin/` folder, similarly to components, we have a Rails-like generator that will generate the relevant files for you to add a new model:
342
+
343
+
#### Generating Model
344
+
345
+
For example, if you'd like to generate a model called `Device` run the following command:
346
+
347
+
```sh
348
+
$ bin/generate_model device
349
+
```
350
+
351
+
It will then generate the following files for you:
352
+
353
+
```sh
354
+
$ cat lib/spotify/sdk/device.rb
355
+
$ cat spec/lib/spotify/sdk/device_spec.rb
356
+
$ cat spec/factories/device.rb
357
+
```
358
+
359
+
#### Mounting a Model
360
+
361
+
Then you'll need to do one step in `lib/spotify/sdk.rb`:
362
+
363
+
- Include the model at the top:
364
+
```ruby
365
+
# Models
366
+
require"spotify/sdk/device"
367
+
```
368
+
369
+
#### Writing Model Logic
370
+
371
+
In our model, we can create a method called `pause!`:
For models, we have a slightly different approach to testing them. As they handle API response data from [Spotify], we would need to mock what those responses look like to ensure the SDK is able to respond in the way we expect it to.
430
+
431
+
Usually we'd need to add the following:
432
+
433
+
- Mock Ruby model object: [FactoryBot]
434
+
435
+
- Typically adding this Ruby code to `spec/factories.rb`:
0 commit comments