sheets_v4 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 27e014c65904a88e3fb4df001a8b28c64c307363b3cd658da252a951c55da992
4
- data.tar.gz: c6900f0d163abdb621a49080295ca7e59f82b89bae69d5e5729aa74aac765a1b
3
+ metadata.gz: a6357385eeb33468356dd974f8fda49f92e09b30b9911a825c562509bf5f70dd
4
+ data.tar.gz: a289b95495fd49e8221a89e037168aaae903ca40af2f9167cff60c75c0f28acc
5
5
  SHA512:
6
- metadata.gz: e60614708c5f348d05388a1bfe7b51603a92797e852aa20445d37451a493655aac69ea86fd901d500a9898a289f469d9a3780fdbe2f2756cfb80a65110641455
7
- data.tar.gz: 71ea62ff3e93faf9d9ece533ccd98f5491dea2f04d00d01c01020dd501a251a3b0b61544e0e57e85643fc0afedbfe97e92250d71b5968c63650822f0e3338433
6
+ metadata.gz: 59b81fbfa525ee8f5810d1aeeb3d6168dfffe0ffd1a8c19792d8f27548cdb1b2106748a30f499f8619bd83cd73d773c5647f0b7fd57640c990af2eb7e9d5fd7b
7
+ data.tar.gz: '09ffa389430c102e6e4df4370bc42f2e8769399f78cabbfe61441372ed6bf4a87378a124a3c17fe0c7f53a73255fae7f153cd08df67e93589c5bcbb49360166e'
data/.rubocop.yml CHANGED
@@ -28,6 +28,7 @@ Metrics/ModuleLength:
28
28
 
29
29
  # When writing minitest tests, it is very hard to limit test class length:
30
30
  Metrics/ClassLength:
31
+ CountAsOne: ['hash']
31
32
  Exclude:
32
33
  - "test/**/*_test.rb"
33
34
 
data/CHANGELOG.md CHANGED
@@ -4,6 +4,17 @@ Changes for each release are listed in this file.
4
4
 
5
5
  This project adheres to [Semantic Versioning](https://semver.org/) for its releases.
6
6
 
7
+ ## v0.4.0 (2023-09-29)
8
+
9
+ [Full Changelog](https://github.com/main-branch/sheets_v4/compare/v0.3.0..v0.4.0)
10
+
11
+ Changes since v0.3.0:
12
+
13
+ * 843c1b5 Add SheetsV4.sheets_service (#13)
14
+ * 16a73f5 Refactor ValidateApiObject (#12)
15
+ * 1525cd3 Add a link in the README to the Sheet V4 API Discover Doc (#11)
16
+ * 6d5bfb3 Improve color api and documentation (#10)
17
+
7
18
  ## v0.3.0 (2023-09-28)
8
19
 
9
20
  [Full Changelog](https://github.com/main-branch/sheets_v4/compare/v0.2.0..v0.3.0)
data/README.md CHANGED
@@ -15,6 +15,8 @@ Unofficial helpers for the Google Sheets V4 API
15
15
  * [Other Links](#other-links)
16
16
  * [Installation](#installation)
17
17
  * [Usage](#usage)
18
+ * [Obtaining an authenticated SheetsService](#obtaining-an-authenticated-sheetsservice)
19
+ * [Colors](#colors)
18
20
  * [Development](#development)
19
21
  * [Creating a Google API Service Account](#creating-a-google-api-service-account)
20
22
  * [Contributing](#contributing)
@@ -27,6 +29,7 @@ Unofficial helpers for the Google Sheets V4 API
27
29
  * [Google Sheets API Overview](https://developers.google.com/sheets/api)
28
30
  * [Google Sheets API Reference](https://developers.google.com/sheets/api/reference/rest)
29
31
  * [Batch Update Requests](https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/request)
32
+ * [Discovery Document for the Sheets API](https://sheets.googleapis.com/$discovery/rest?version=v4)
30
33
 
31
34
  ### Ruby Implementation of the Sheets API
32
35
 
@@ -55,6 +58,60 @@ gem install sheets_v4
55
58
 
56
59
  [Detailed API documenation](https://rubydoc.info/gems/sheets_v4/) is hosted on rubygems.org.
57
60
 
61
+ ### Obtaining an authenticated SheetsService
62
+
63
+ Typically, to construct an authenticated SheetsService object where the credential
64
+ is read from a file, the following code is required:
65
+
66
+ ```Ruby
67
+ sheets_service = Google::Apis::SheetsV4::SheetsService.new
68
+ credential = File.read(File.expand_path('~/google-api-credential.json')) do |credential_source|
69
+ scopes = Google::Apis::SheetsV4::AUTH_SPREADSHEETS
70
+ options = { json_key_io: credential_source, scope: scopes }
71
+ Google::Auth::DefaultCredentials.make_creds(options).tap(&:fetch_access_token)
72
+ end
73
+ sheets_service.authorization = credential
74
+ ```
75
+
76
+ The `SheetsV4.sheets_service` method simplifies this a bit.
77
+
78
+ By default, the credential is read from `~/.google-api-credential.json`. In that case,
79
+ an authenticated SheetsService object can be obtained with one method call:
80
+
81
+ ```Ruby
82
+ sheets_service = SheetsV4.sheets_service
83
+ ```
84
+
85
+ If the credential is stored elsewhere, pass the credential_source to `SheetsV4.sheets_service`
86
+ manually. `credential_source` can be a String:
87
+
88
+ ```Ruby
89
+ sheets_service = SheetsV4.sheets_service(credential_sourvce: File.read('credential.json'))
90
+ ```
91
+
92
+ an IO object:
93
+
94
+ ```Ruby
95
+ sheets_service = File.open('credential.json') do |credential_source|
96
+ SheetsV4.sheets_service(credential_sourvce:)
97
+ end
98
+ ```
99
+
100
+ or an already constructed `Google::Auth::*`` object.
101
+
102
+ ### Colors
103
+
104
+ Color objects (with appropriate :red, :green, :blue values) can be retrieved by name
105
+ using `SheetsV4.color(:black)` or `SheetsV4::Color.black` (these are equivalent).
106
+
107
+ Color names can be listed using `SheetsV4.color_names`.
108
+
109
+ The color object returned is a Hash as follows:
110
+
111
+ ```Ruby
112
+ SheetsV4::Color.black #=> {:red=>0.0, :green=>0.0, :blue=>0.0}
113
+ ```
114
+
58
115
  ## Development
59
116
 
60
117
  After checking out the repo, run `bin/setup` to install dependencies. Then, run
data/examples/README.md CHANGED
@@ -3,6 +3,7 @@
3
3
  * [ ] Creating a Google API service account [1](https://www.youtube.com/watch?v=sAgWCbGMzTo&list=PL3JVwFmb_BnSee8RFaRPZ3nykuMRlaQp1&index=1)
4
4
  [2](https://www.youtube.com/watch?v=sVURhxyc6jE&list=PL3JVwFmb_BnSee8RFaRPZ3nykuMRlaQp1&index=43)
5
5
  * [ ] Create a SheetsService instance
6
+ * [X] Set background color
6
7
  * [ ] Creating Google Sheets files [1](https://www.youtube.com/watch?v=JRUxeQ6ZCy0&list=PL3JVwFmb_BnSee8RFaRPZ3nykuMRlaQp1&index=2)
7
8
  * [ ] Writing data to a sheet [1](https://www.youtube.com/watch?v=YF7Ad-7pvks&list=PL3JVwFmb_BnSee8RFaRPZ3nykuMRlaQp1&index=3)
8
9
  * [ ] Reading data from a sheet [1](https://www.youtube.com/watch?v=gkglr8GID5E&list=PL3JVwFmb_BnSee8RFaRPZ3nykuMRlaQp1&index=4)
@@ -0,0 +1,52 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'sheets_v4'
5
+ require 'googleauth'
6
+
7
+ # Example to show using the SheetsV4 module to set the background color of a cell
8
+ #
9
+ # GIVEN the credential file is at ~/.google-api-credential.json
10
+ # AND the spreadsheet id is 18FAcgotK7nDfLTOTQuGCIjKwxkJMAguhn1OVzpFFgWY
11
+ # AND the spreadsheet has a sheet whose id is 0
12
+ # WHEN the script is run
13
+ # THEN the sheet whose id is 0 will have the background color names starting at A2
14
+ # AND the background color of the cells in column B will be set to the color matching the color name in column A
15
+
16
+ # Build the requests
17
+
18
+ def name_rows
19
+ SheetsV4.color_names.map do |color_name|
20
+ { values: [{ user_entered_value: { string_value: color_name.to_s } }] }
21
+ end
22
+ end
23
+
24
+ def write_names
25
+ rows = name_rows
26
+ fields = 'user_entered_value'
27
+ start = { sheet_id: 0, row_index: 1, column_index: 0 }
28
+ { update_cells: { rows:, fields:, start: } }
29
+ end
30
+
31
+ def background_color_rows
32
+ SheetsV4.color_names.map { |color_name| SheetsV4.color(color_name) }.map do |color|
33
+ { values: [{ user_entered_format: { background_color: color } }] }
34
+ end
35
+ end
36
+
37
+ def set_background_colors
38
+ rows = background_color_rows
39
+ fields = 'user_entered_format'
40
+ start = { sheet_id: 0, row_index: 1, column_index: 1 }
41
+ { update_cells: { rows:, fields:, start: } }
42
+ end
43
+
44
+ def requests = { requests: [write_names, set_background_colors] }
45
+
46
+ # SheetsV4.validate_api_object(
47
+ # schema_name: 'BatchUpdateSpreadsheetRequest', object: request,
48
+ # logger: Logger.new(STDOUT, level: Logger::ERROR)
49
+ # )
50
+
51
+ spreadsheet_id = '18FAcgotK7nDfLTOTQuGCIjKwxkJMAguhn1OVzpFFgWY'
52
+ SheetsV4.sheets_service.batch_update_spreadsheet(spreadsheet_id, requests)
@@ -3,30 +3,195 @@
3
3
  require 'json_schemer'
4
4
 
5
5
  module SheetsV4
6
- # Predefined color objects
6
+ # Returns predefined color objects by name
7
+ #
8
+ # A method is implemented for each color name. The list of available colors is
9
+ # given by `SheetsV4.color_names`.
10
+ #
11
+ # @example
12
+ # # Get a color object by name:
13
+ # SheetsV4::Color.black #=> { "red" => 0.0, "green" => 0.0, "blue" => 0.0 }
14
+ #
15
+ # @see SheetsV4.color a method that returns a color object by name
16
+ # @see SheetsV4.color_names an array of predefined color names
17
+ #
7
18
  # @api public
19
+ #
8
20
  class Color
9
21
  class << self
10
- # Return a color object for the given name from SheetsV4::COLORS or call super
22
+ # Return a color object for the given name from SheetsV4.color_names or call super
11
23
  #
12
- # @param method_name [Symbol] the name of the color
24
+ # @param method_name [#to_sym] the name of the color
13
25
  # @param arguments [Array] ignored
14
26
  # @param block [Proc] ignored
15
27
  # @return [Hash] the color object
16
28
  # @api private
17
29
  def method_missing(method_name, *arguments, &)
18
- SheetsV4::COLORS[method_name.to_sym] || super
30
+ COLORS[method_name.to_sym] || super
19
31
  end
20
32
 
21
33
  # Return true if the given method name is a color name or call super
22
34
  #
23
- # @param method_name [Symbol] the name of the color
35
+ # @param method_name [#to_sym] the name of the color
24
36
  # @param include_private [Boolean] ignored
25
37
  # @return [Boolean] true if the method name is a color name
26
38
  # @api private
27
39
  def respond_to_missing?(method_name, include_private = false)
28
- SheetsV4::COLORS.key?(method_name.to_sym) || super
40
+ COLORS.key?(method_name.to_sym) || super
29
41
  end
30
42
  end
43
+
44
+ # Colors to use in the Google Sheets API
45
+ COLORS = {
46
+ # Standard Google Sheets colors
47
+ #
48
+ black: { red: 0.00000000000, green: 0.00000000000, blue: 0.00000000000 },
49
+ dark_gray4: { red: 0.26274509804, green: 0.26274509804, blue: 0.26274509804 },
50
+ dark_gray3: { red: 0.40000000000, green: 0.40000000000, blue: 0.40000000000 },
51
+ dark_gray2: { red: 0.60000000000, green: 0.60000000000, blue: 0.60000000000 },
52
+ dark_gray1: { red: 0.71764705882, green: 0.71764705882, blue: 0.71764705882 },
53
+ gray: { red: 0.80000000000, green: 0.80000000000, blue: 0.80000000000 },
54
+ light_gray1: { red: 0.85098039216, green: 0.85098039216, blue: 0.85098039216 },
55
+ light_gray2: { red: 0.93725490196, green: 0.93725490196, blue: 0.93725490196 },
56
+ light_gray3: { red: 0.95294117647, green: 0.95294117647, blue: 0.95294117647 },
57
+ white: { red: 1.00000000000, green: 1.00000000000, blue: 1.00000000000 },
58
+ red_berry: { red: 0.59607843137, green: 0.00000000000, blue: 0.00000000000 },
59
+ red: { red: 1.00000000000, green: 0.00000000000, blue: 0.00000000000 },
60
+ orange: { red: 1.00000000000, green: 0.60000000000, blue: 0.00000000000 },
61
+ yellow: { red: 1.00000000000, green: 1.00000000000, blue: 0.00000000000 },
62
+ green: { red: 0.00000000000, green: 1.00000000000, blue: 0.00000000000 },
63
+ cyan: { red: 0.00000000000, green: 1.00000000000, blue: 1.00000000000 },
64
+ cornflower_blue: { red: 0.29019607843, green: 0.52549019608, blue: 0.90980392157 },
65
+ blue: { red: 0.00000000000, green: 0.00000000000, blue: 1.00000000000 },
66
+ purple: { red: 0.60000000000, green: 0.00000000000, blue: 1.00000000000 },
67
+ magenta: { red: 1.00000000000, green: 0.00000000000, blue: 1.00000000000 },
68
+ light_red_berry3: { red: 0.90196078431, green: 0.72156862745, blue: 0.68627450980 },
69
+ light_red3: { red: 0.95686274510, green: 0.80000000000, blue: 0.80000000000 },
70
+ light_orange3: { red: 0.98823529412, green: 0.89803921569, blue: 0.80392156863 },
71
+ light_yellow3: { red: 1.00000000000, green: 0.94901960784, blue: 0.80000000000 },
72
+ light_green3: { red: 0.85098039216, green: 0.91764705882, blue: 0.82745098039 },
73
+ light_cyan3: { red: 0.81568627451, green: 0.87843137255, blue: 0.89019607843 },
74
+ light_cornflower_blue3: { red: 0.78823529412, green: 0.85490196078, blue: 0.97254901961 },
75
+ light_blue3: { red: 0.81176470588, green: 0.88627450980, blue: 0.95294117647 },
76
+ light_purple3: { red: 0.85098039216, green: 0.82352941176, blue: 0.91372549020 },
77
+ light_magenta3: { red: 0.91764705882, green: 0.81960784314, blue: 0.86274509804 },
78
+ light_red_berry2: { red: 0.86666666667, green: 0.49411764706, blue: 0.41960784314 },
79
+ light_red2: { red: 0.91764705882, green: 0.60000000000, blue: 0.60000000000 },
80
+ light_orange2: { red: 0.97647058824, green: 0.79607843137, blue: 0.61176470588 },
81
+ light_yellow2: { red: 1.00000000000, green: 0.89803921569, blue: 0.60000000000 },
82
+ light_green2: { red: 0.71372549020, green: 0.84313725490, blue: 0.65882352941 },
83
+ light_cyan2: { red: 0.63529411765, green: 0.76862745098, blue: 0.78823529412 },
84
+ light_cornflower_blue2: { red: 0.64313725490, green: 0.76078431373, blue: 0.95686274510 },
85
+ light_blue2: { red: 0.62352941176, green: 0.77254901961, blue: 0.90980392157 },
86
+ light_purple2: { red: 0.70588235294, green: 0.65490196078, blue: 0.83921568627 },
87
+ light_magenta2: { red: 0.83529411765, green: 0.65098039216, blue: 0.74117647059 },
88
+ light_red_berry1: { red: 0.80000000000, green: 0.25490196078, blue: 0.14509803922 },
89
+ light_red1: { red: 0.87843137255, green: 0.40000000000, blue: 0.40000000000 },
90
+ light_orange1: { red: 0.96470588235, green: 0.69803921569, blue: 0.41960784314 },
91
+ light_yellow1: { red: 1.00000000000, green: 0.85098039216, blue: 0.40000000000 },
92
+ light_green1: { red: 0.57647058824, green: 0.76862745098, blue: 0.49019607843 },
93
+ light_cyan1: { red: 0.46274509804, green: 0.64705882353, blue: 0.68627450980 },
94
+ light_cornflower_blue1: { red: 0.42745098039, green: 0.61960784314, blue: 0.92156862745 },
95
+ light_blue1: { red: 0.43529411765, green: 0.65882352941, blue: 0.86274509804 },
96
+ light_purple1: { red: 0.55686274510, green: 0.48627450980, blue: 0.76470588235 },
97
+ light_magenta1: { red: 0.76078431373, green: 0.48235294118, blue: 0.62745098039 },
98
+ dark_red_berry1: { red: 0.65098039216, green: 0.10980392157, blue: 0.00000000000 },
99
+ dark_red1: { red: 0.80000000000, green: 0.00000000000, blue: 0.00000000000 },
100
+ dark_orange1: { red: 0.90196078431, green: 0.56862745098, blue: 0.21960784314 },
101
+ dark_yellow1: { red: 0.94509803922, green: 0.76078431373, blue: 0.19607843137 },
102
+ dark_green1: { red: 0.41568627451, green: 0.65882352941, blue: 0.30980392157 },
103
+ dark_cyan1: { red: 0.27058823529, green: 0.50588235294, blue: 0.55686274510 },
104
+ dark_cornflower_blue1: { red: 0.23529411765, green: 0.47058823529, blue: 0.84705882353 },
105
+ dark_blue1: { red: 0.23921568627, green: 0.52156862745, blue: 0.77647058824 },
106
+ dark_purple1: { red: 0.40392156863, green: 0.30588235294, blue: 0.65490196078 },
107
+ dark_magenta1: { red: 0.65098039216, green: 0.30196078431, blue: 0.47450980392 },
108
+ dark_red_berry2: { red: 0.52156862745, green: 0.12549019608, blue: 0.04705882353 },
109
+ dark_red2: { red: 0.60000000000, green: 0.00000000000, blue: 0.00000000000 },
110
+ dark_orange2: { red: 0.70588235294, green: 0.37254901961, blue: 0.02352941176 },
111
+ dark_yellow2: { red: 0.74901960784, green: 0.56470588235, blue: 0.00000000000 },
112
+ dark_green2: { red: 0.21960784314, green: 0.46274509804, blue: 0.11372549020 },
113
+ dark_cyan2: { red: 0.07450980392, green: 0.30980392157, blue: 0.36078431373 },
114
+ dark_cornflower_blue2: { red: 0.06666666667, green: 0.33333333333, blue: 0.80000000000 },
115
+ dark_blue2: { red: 0.04313725490, green: 0.32549019608, blue: 0.58039215686 },
116
+ dark_purple2: { red: 0.20784313725, green: 0.10980392157, blue: 0.45882352941 },
117
+ dark_magenta2: { red: 0.45490196078, green: 0.10588235294, blue: 0.27843137255 },
118
+ dark_red_berry3: { red: 0.35686274510, green: 0.05882352941, blue: 0.00000000000 },
119
+ dark_red3: { red: 0.40000000000, green: 0.00000000000, blue: 0.00000000000 },
120
+ dark_orange3: { red: 0.47058823529, green: 0.24705882353, blue: 0.01568627451 },
121
+ dark_yellow3: { red: 0.49803921569, green: 0.37647058824, blue: 0.00000000000 },
122
+ dark_green3: { red: 0.15294117647, green: 0.30588235294, blue: 0.07450980392 },
123
+ darn_cyan3: { red: 0.04705882353, green: 0.20392156863, blue: 0.23921568627 },
124
+ dark_cornflower_blue3: { red: 0.10980392157, green: 0.27058823529, blue: 0.52941176471 },
125
+ dark_blue3: { red: 0.02745098039, green: 0.21568627451, blue: 0.38823529412 },
126
+ dark_purple3: { red: 0.12549019608, green: 0.07058823529, blue: 0.30196078431 },
127
+ dark_magenta3: { red: 0.29803921569, green: 0.06666666667, blue: 0.18823529412 },
128
+
129
+ # Yahoo brand colors
130
+ #
131
+ grape_jelly: { red: 0.37647058824, green: 0.00392156863, blue: 0.82352941176 },
132
+ hulk_pants: { red: 0.49411764706, green: 0.12156862745, blue: 1.00000000000 },
133
+ malbec: { red: 0.22352941176, green: 0.00000000000, blue: 0.49019607843 },
134
+ tumeric: { red: 1.00000000000, green: 0.65490196078, blue: 0.00000000000 },
135
+ mulah: { red: 0.10196078431, green: 0.77254901961, blue: 0.40392156863 },
136
+ dory: { red: 0.05882352941, green: 0.41176470588, blue: 1.00000000000 },
137
+ malibu: { red: 1.00000000000, green: 0.00000000000, blue: 0.50196078431 },
138
+ sea_foam: { red: 0.06666666667, green: 0.82745098039, blue: 0.80392156863 },
139
+ tumeric_tint: { red: 0.98039215686, green: 0.86666666667, blue: 0.69411764706 },
140
+ mulah_tint: { red: 0.73333333333, green: 0.90196078431, blue: 0.77647058824 },
141
+ dory_tint: { red: 0.66274509804, green: 0.77254901961, blue: 0.98431372549 },
142
+ malibu_tint: { red: 0.96862745098, green: 0.68235294118, blue: 0.80000000000 },
143
+ sea_foam_tint: { red: 0.74901960784, green: 0.92549019608, blue: 0.92156862745 },
144
+
145
+ # Yahoo health colors
146
+ #
147
+ health_green: { red: 0.00000000000, green: 0.69019607843, blue: 0.31372549020 },
148
+ health_yellow: { red: 1.00000000000, green: 0.65490196078, blue: 0.00000000000 },
149
+ health_red: { red: 1.00000000000, green: 0.00000000000, blue: 0.00000000000 },
150
+
151
+ # Yahoo Fuji design color palette
152
+ #
153
+ fuji_color_watermelon: { red: 1.00000000000, green: 0.32156862745, blue: 0.34117647059 },
154
+ fuji_color_solo_cup: { red: 0.92156862745, green: 0.05882352941, blue: 0.16078431373 },
155
+ fuji_color_malibu: { red: 1.00000000000, green: 0.00000000000, blue: 0.50196078431 },
156
+ fuji_color_barney: { red: 0.80000000000, green: 0.00000000000, blue: 0.54901960784 },
157
+ fuji_color_mimosa: { red: 1.00000000000, green: 0.82745098039, blue: 0.20000000000 },
158
+ fuji_color_turmeric: { red: 1.00000000000, green: 0.65490196078, blue: 0.00000000000 },
159
+ fuji_color_cheetos: { red: 0.99215686275, green: 0.38039215686, blue: 0.00000000000 },
160
+ fuji_color_carrot_juice: { red: 1.00000000000, green: 0.32156862745, blue: 0.05098039216 },
161
+ fuji_color_mulah: { red: 0.10196078431, green: 0.77254901961, blue: 0.40392156863 },
162
+ fuji_color_bonsai: { red: 0.00000000000, green: 0.52941176471, blue: 0.31764705882 },
163
+ fuji_color_spirulina: { red: 0.00000000000, green: 0.62745098039, blue: 0.62745098039 },
164
+ fuji_color_sea_foam: { red: 0.06666666667, green: 0.82745098039, blue: 0.80392156863 },
165
+ fuji_color_peeps: { red: 0.49019607843, green: 0.79607843137, blue: 1.00000000000 },
166
+ fuji_color_sky: { red: 0.07058823529, green: 0.66274509804, blue: 1.00000000000 },
167
+ fuji_color_dory: { red: 0.05882352941, green: 0.41176470588, blue: 1.00000000000 },
168
+ fuji_color_scooter: { red: 0.00000000000, green: 0.38823529412, blue: 0.92156862745 },
169
+ fuji_color_cobalt: { red: 0.00000000000, green: 0.22745098039, blue: 0.73725490196 },
170
+ fuji_color_denim: { red: 0.10196078431, green: 0.05098039216, blue: 0.67058823529 },
171
+ fuji_color_blurple: { red: 0.36470588235, green: 0.36862745098, blue: 1.00000000000 },
172
+ fuji_color_hendrix: { red: 0.97254901961, green: 0.95686274510, blue: 1.00000000000 },
173
+ fuji_color_thanos: { red: 0.56470588235, green: 0.48627450980, blue: 1.00000000000 },
174
+ fuji_color_starfish: { red: 0.46666666667, green: 0.34901960784, blue: 1.00000000000 },
175
+ fuji_color_hulk_pants: { red: 0.49411764706, green: 0.12156862745, blue: 1.00000000000 },
176
+ fuji_color_grape_jelly: { red: 0.37647058824, green: 0.00392156863, blue: 0.82352941176 },
177
+ fuji_color_mulberry: { red: 0.31372549020, green: 0.08235294118, blue: 0.69019607843 },
178
+ fuji_color_malbec: { red: 0.22352941176, green: 0.00000000000, blue: 0.49019607843 },
179
+ fuji_grayscale_black: { red: 0.00000000000, green: 0.00000000000, blue: 0.00000000000 },
180
+ fuji_grayscale_midnight: { red: 0.06274509804, green: 0.08235294118, blue: 0.09411764706 },
181
+ fuji_grayscale_inkwell: { red: 0.11372549020, green: 0.13333333333, blue: 0.15686274510 },
182
+ fuji_grayscale_batcave: { red: 0.13725490196, green: 0.16470588235, blue: 0.19215686275 },
183
+ fuji_grayscale_ramones: { red: 0.17254901961, green: 0.21176470588, blue: 0.24705882353 },
184
+ fuji_grayscale_charcoal: { red: 0.27450980392, green: 0.30588235294, blue: 0.33725490196 },
185
+ fuji_grayscale_battleship: { red: 0.35686274510, green: 0.38823529412, blue: 0.41568627451 },
186
+ fuji_grayscale_dolphin: { red: 0.43137254902, green: 0.46666666667, blue: 0.50196078431 },
187
+ fuji_grayscale_shark: { red: 0.50980392157, green: 0.54117647059, blue: 0.57647058824 },
188
+ fuji_grayscale_gandalf: { red: 0.59215686275, green: 0.61960784314, blue: 0.65882352941 },
189
+ fuji_grayscale_bob: { red: 0.69019607843, green: 0.72549019608, blue: 0.75686274510 },
190
+ fuji_grayscale_pebble: { red: 0.78039215686, green: 0.80392156863, blue: 0.82352941176 },
191
+ fuji_grayscale_dirty_seagull: { red: 0.87843137255, green: 0.89411764706, blue: 0.91372549020 },
192
+ fuji_grayscale_grey_hair: { red: 0.94117647059, green: 0.95294117647, blue: 0.96078431373 },
193
+ fuji_grayscale_marshmallow: { red: 0.96078431373, green: 0.97254901961, blue: 0.98039215686 },
194
+ fuji_grayscale_white: { red: 1.00000000000, green: 1.00000000000, blue: 1.00000000000 }
195
+ }.freeze.each_value(&:freeze)
31
196
  end
32
197
  end
@@ -0,0 +1,93 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'json_schemer'
4
+
5
+ module SheetsV4
6
+ # Creates a Google API credential with an access token
7
+ #
8
+ class CredentialCreator
9
+ # Creates a Google API credential with an access token
10
+ #
11
+ # This wraps the boiler plate code into one function to make constructing a
12
+ # credential easy and less error prone.
13
+ #
14
+ # @example Constructing a credential from the contents of ~/.credential
15
+ # credential_source = File.read(File.join(Dir.home, '.credential'))
16
+ # scope = Google::Apis::SheetsV4::AUTH_SPREADSHEETS
17
+ # credential = GoogleApisHelpers.credential(credential_source, scope)
18
+ #
19
+ # @param [Google::Auth::*, String, IO, nil] credential_source may be one of four things:
20
+ # (1) a previously created credential that you want to reuse, (2) a credential read
21
+ # into a string, (3) an IO object with the credential ready to be read, or (4)
22
+ # if nill, the credential is read from ~/.google-api-credential.json
23
+ # @param scopes [Object, Array] one or more scopes to access.
24
+ # @param credential_factory [#make_creds] Used inject the credential_factory for tests
25
+ #
26
+ # @return [Object] a credential object with an access token
27
+ #
28
+ def self.call(
29
+ credential_source, scopes, credential_factory = Google::Auth::DefaultCredentials
30
+ )
31
+ return credential_source if credential?(credential_source)
32
+
33
+ credential_source ||= default_credential_source
34
+ options = make_creds_options(credential_source, scopes)
35
+ credential_factory.make_creds(options).tap(&:fetch_access_token)
36
+ end
37
+
38
+ private
39
+
40
+ # Reads credential source from `~/.google-api-credential.json`
41
+ #
42
+ # @return [String] the credential as a string
43
+ #
44
+ # @api private
45
+ #
46
+ private_class_method def self.default_credential_source
47
+ File.read(File.expand_path('~/.google-api-credential.json'))
48
+ end
49
+
50
+ # Constructs creds_options needed to create a credential
51
+ #
52
+ # @param [Google::Auth::*, String, #read] credential_source a credential (which
53
+ # is an object whose class is in the Google::Auth module), a String containing
54
+ # the credential, or a IO object with the credential ready to be read.
55
+ #
56
+ # @return [Hash] returns the cred_options
57
+ #
58
+ # @api private
59
+ #
60
+ private_class_method def self.make_creds_options(credential_source, scopes)
61
+ { json_key_io: to_io(credential_source), scope: scopes }
62
+ end
63
+
64
+ # Wraps a credential_source that is a string in a StringIO
65
+ #
66
+ # @param [Google::Auth::*, String, #read] credential_source a credential (which
67
+ # is an object whose class is in the Google::Auth module), a String containing
68
+ # the credential, or a IO object with the credential ready to be read.
69
+ #
70
+ # @return [IO, StringIO] returns a StringIO object is a String was passed in.
71
+ #
72
+ # @api private
73
+ #
74
+ private_class_method def self.to_io(credential_source)
75
+ credential_source.is_a?(String) ? StringIO.new(credential_source) : credential_source
76
+ end
77
+
78
+ # Determines if a credential_source is already a credential
79
+ #
80
+ # @param [Google::Auth::*, String, #read] credential_source a credential (which
81
+ # is an object whose class is in the Google::Auth module), a String containing
82
+ # the credential, or a IO object with the credential ready to be read.
83
+ #
84
+ # @return [Boolean] true if the credential source is an object whose class is in the
85
+ # Google::Auth module.
86
+ #
87
+ # @api private
88
+ #
89
+ private_class_method def self.credential?(credential_source)
90
+ credential_source.class.name.start_with?('Google::Auth::')
91
+ end
92
+ end
93
+ end
@@ -121,12 +121,54 @@ module SheetsV4
121
121
  def call(ref)
122
122
  schema_name = ref.path[1..]
123
123
  logger.debug { "Reading schema #{schema_name}" }
124
- schema_object = SheetsV4.api_object_schemas[schema_name]
124
+ schema_object = self.class.api_object_schemas[schema_name]
125
125
  raise "Schema for #{ref} not found" unless schema_object
126
126
 
127
127
  schema_object.to_h.tap do |schema|
128
128
  schema['unevaluatedProperties'] = false
129
129
  end
130
130
  end
131
+
132
+ # A hash of schemas keyed by the schema name loaded from the Google Discovery API
133
+ #
134
+ # @example
135
+ # SheetsV4.api_object_schemas #=> { 'PersonSchema' => { 'type' => 'object', ... } ... }
136
+ #
137
+ # @return [Hash<String, Object>] a hash of schemas keyed by schema name
138
+ #
139
+ def self.api_object_schemas
140
+ schema_load_semaphore.synchronize { @api_object_schemas ||= load_api_object_schemas }
141
+ end
142
+
143
+ # Validate
144
+ # A mutex used to synchronize access to the schemas so they are only loaded
145
+ # once.
146
+ #
147
+ @schema_load_semaphore = Thread::Mutex.new
148
+
149
+ class << self
150
+ # A mutex used to synchronize access to the schemas so they are only loaded once
151
+ #
152
+ # @return [Thread::Mutex]
153
+ #
154
+ # @api private
155
+ #
156
+ attr_reader :schema_load_semaphore
157
+ end
158
+
159
+ # Load the schemas from the Google Discovery API
160
+ #
161
+ # @return [Hash<String, Object>] a hash of schemas keyed by schema name
162
+ #
163
+ # @api private
164
+ #
165
+ def self.load_api_object_schemas
166
+ source = 'https://sheets.googleapis.com/$discovery/rest?version=v4'
167
+ resp = Net::HTTP.get_response(URI.parse(source))
168
+ data = resp.body
169
+ JSON.parse(data)['schemas'].tap do |schemas|
170
+ schemas.each { |_name, schema| schema['unevaluatedProperties'] = false }
171
+ end
172
+ end
131
173
  end
132
174
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  module SheetsV4
4
4
  # The version of this gem
5
- VERSION = '0.3.0'
5
+ VERSION = '0.4.0'
6
6
  end
data/lib/sheets_v4.rb CHANGED
@@ -2,8 +2,10 @@
2
2
 
3
3
  require_relative 'sheets_v4/version'
4
4
  require_relative 'sheets_v4/color'
5
+ require_relative 'sheets_v4/credential_creator'
5
6
  require_relative 'sheets_v4/validate_api_object'
6
7
 
8
+ require 'google/apis/sheets_v4'
7
9
  require 'json'
8
10
  require 'logger'
9
11
  require 'net/http'
@@ -13,6 +15,38 @@ require 'net/http'
13
15
  # @api public
14
16
  #
15
17
  module SheetsV4
18
+ # Create a new Google::Apis::SheetsV4::SheetsService object
19
+ #
20
+ # Simplifies creating and configuring a the credential.
21
+ #
22
+ # @example using the crednetial in `~/.google-api-credential`
23
+ # SheetsV4.sheets_service
24
+ #
25
+ # @example using a credential passed in as a string
26
+ # credential_source = File.read(File.join(Dir.home, '.credential'))
27
+ # SheetsV4.sheets_service(credential_source:
28
+ #
29
+ # @param credential_source [nil, String, IO, Google::Auth::*] may
30
+ # be either an already constructed credential, the credential read into a String or
31
+ # an open file with the credential ready to be read. Passing `nil` will result
32
+ # in the credential being read from `~/.google-api-credential.json`.
33
+ #
34
+ # @param scopes [Object, Array] one or more scopes to access.
35
+ #
36
+ # @param credential_creator [#credential] Used to inject the credential creator for
37
+ # testing.
38
+ #
39
+ # @return a new SheetsService instance
40
+ #
41
+ def self.sheets_service(credential_source: nil, scopes: nil, credential_creator: SheetsV4::CredentialCreator)
42
+ credential_source ||= File.read(File.expand_path('~/.google-api-credential.json'))
43
+ scopes ||= [Google::Apis::SheetsV4::AUTH_SPREADSHEETS]
44
+
45
+ Google::Apis::SheetsV4::SheetsService.new.tap do |service|
46
+ service.authorization = credential_creator.call(credential_source, scopes)
47
+ end
48
+ end
49
+
16
50
  # Validate the object using the named JSON schema
17
51
  #
18
52
  # The JSON schemas are loaded from the Google Disocvery API. The schemas names are
@@ -35,208 +69,33 @@ module SheetsV4
35
69
  ValidateApiObject.new(logger).call(schema_name, object)
36
70
  end
37
71
 
38
- # A hash of schemas keyed by the schema name loaded from the Google Discovery API
39
- #
40
- # @example
41
- # SheetsV4.api_object_schemas #=> { 'PersonSchema' => { 'type' => 'object', ... } ... }
42
- #
43
- # @return [Hash<String, Object>] a hash of schemas keyed by schema name
72
+ # Given the name of the color, return a Google Sheets API color object
44
73
  #
45
- def self.api_object_schemas
46
- schema_load_semaphore.synchronize { @api_object_schemas ||= load_api_object_schemas }
47
- end
48
-
49
- # Validate
50
- # A mutex used to synchronize access to the schemas so they are only loaded
51
- # once.
52
- #
53
- @schema_load_semaphore = Thread::Mutex.new
54
-
55
- # A mutex used to synchronize access to the schemas so they are only loaded once
74
+ # Available color names are listed using `SheetsV4.color_names`.
56
75
  #
57
- # @return [Thread::Mutex]
76
+ # The object returned is frozen. If you want a color you can change (for instance,
77
+ # to adjust the `alpha` attribute), you must clone the object returned.
58
78
  #
59
- # @api private
79
+ # @example
80
+ # SheetsV4::Color.color(:red) #=> { "red": 1.0, "green": 0.0, "blue": 0.0 }
60
81
  #
61
- def self.schema_load_semaphore = @schema_load_semaphore
62
-
63
- # Load the schemas from the Google Discovery API
82
+ # @param name [#to_sym] the name of the color requested
64
83
  #
65
- # @return [Hash<String, Object>] a hash of schemas keyed by schema name
84
+ # @return [Hash] The color requested e.g. `{ "red": 1.0, "green": 0.0, "blue": 0.0 }`
66
85
  #
67
- # @api private
86
+ # @api public
68
87
  #
69
- def self.load_api_object_schemas
70
- source = 'https://sheets.googleapis.com/$discovery/rest?version=v4'
71
- resp = Net::HTTP.get_response(URI.parse(source))
72
- data = resp.body
73
- JSON.parse(data)['schemas'].tap do |schemas|
74
- schemas.each { |_name, schema| schema['unevaluatedProperties'] = false }
75
- end
88
+ def self.color(name)
89
+ SheetsV4::Color::COLORS[name.to_sym] || raise("Color #{name} not found")
76
90
  end
77
91
 
78
- # Return a color object for the given name from SheetsV4::COLORS
92
+ # List the names of the colors available to use in the Google Sheets API
79
93
  #
80
94
  # @example
81
- # SheetsV4::Color.color(:red) #=> { "red": 1.0, "green": 0.0, "blue": 0.0 }
95
+ # SheetsV4::Color.color_names #=> [:black, :white, :red, :green, :blue, :yellow, :magenta, :cyan, ...]
82
96
  #
83
- # @param name [Symbol] the name of the color
84
- # @return [Hash] the color object
97
+ # @return [Array<Symbol>] the names of the colors available
85
98
  # @api public
86
- def self.color(name)
87
- SheetsV4::COLORS[name.to_sym]
88
- end
89
-
90
- # Colors to use in the Google Sheets API
91
- COLORS = {
92
- # Standard Google Sheets colors
93
-
94
- black: { red: 0.000000000, green: 0.000000000, blue: 0.000000000 },
95
- dark_gray4: { red: 0.262745098, green: 0.262745098, blue: 0.262745098 },
96
- dark_gray3: { red: 0.400000000, green: 0.400000000, blue: 0.400000000 },
97
- dark_gray2: { red: 0.600000000, green: 0.600000000, blue: 0.600000000 },
98
- dark_gray1: { red: 0.717647059, green: 0.717647059, blue: 0.717647059 },
99
- gray: { red: 0.800000000, green: 0.800000000, blue: 0.800000000 },
100
- light_gray1: { red: 0.850980392, green: 0.850980392, blue: 0.850980392 },
101
- light_gray2: { red: 0.937254902, green: 0.937254902, blue: 0.937254902 },
102
- light_gray3: { red: 0.952941176, green: 0.952941176, blue: 0.952941176 },
103
- white: { red: 1.000000000, green: 1.000000000, blue: 1.000000000 },
104
- red_berry: { red: 0.596078431, green: 0.000000000, blue: 0.000000000 },
105
- red: { red: 1.000000000, green: 0.000000000, blue: 0.000000000 },
106
- orange: { red: 1.000000000, green: 0.600000000, blue: 0.000000000 },
107
- yellow: { red: 1.000000000, green: 1.000000000, blue: 0.000000000 },
108
- green: { red: 0.000000000, green: 1.000000000, blue: 0.000000000 },
109
- cyan: { red: 0.000000000, green: 1.000000000, blue: 1.000000000 },
110
- cornflower_blue: { red: 0.290196078, green: 0.525490196, blue: 0.909803922 },
111
- blue: { red: 0.000000000, green: 0.000000000, blue: 1.000000000 },
112
- purple: { red: 0.600000000, green: 0.000000000, blue: 1.000000000 },
113
- magenta: { red: 1.000000000, green: 0.000000000, blue: 1.000000000 },
114
- light_red_berry3: { red: 0.901960784, green: 0.721568627, blue: 0.686274510 },
115
- light_red3: { red: 0.956862745, green: 0.800000000, blue: 0.800000000 },
116
- light_orange3: { red: 0.988235294, green: 0.898039216, blue: 0.803921569 },
117
- light_yellow3: { red: 1.000000000, green: 0.949019608, blue: 0.800000000 },
118
- light_green3: { red: 0.850980392, green: 0.917647059, blue: 0.827450980 },
119
- light_cyan3: { red: 0.815686275, green: 0.878431373, blue: 0.890196078 },
120
- light_cornflower_blue3: { red: 0.788235294, green: 0.854901961, blue: 0.972549020 },
121
- light_blue3: { red: 0.811764706, green: 0.886274510, blue: 0.952941176 },
122
- light_purple3: { red: 0.850980392, green: 0.823529412, blue: 0.913725490 },
123
- light_magenta3: { red: 0.917647059, green: 0.819607843, blue: 0.862745098 },
124
- light_red_berry2: { red: 0.866666667, green: 0.494117647, blue: 0.419607843 },
125
- light_red2: { red: 0.917647059, green: 0.600000000, blue: 0.600000000 },
126
- light_orange2: { red: 0.976470588, green: 0.796078431, blue: 0.611764706 },
127
- light_yellow2: { red: 1.000000000, green: 0.898039216, blue: 0.600000000 },
128
- light_green2: { red: 0.713725490, green: 0.843137255, blue: 0.658823529 },
129
- light_cyan2: { red: 0.635294118, green: 0.768627451, blue: 0.788235294 },
130
- light_cornflower_blue2: { red: 0.643137255, green: 0.760784314, blue: 0.956862745 },
131
- light_blue2: { red: 0.623529412, green: 0.772549020, blue: 0.909803922 },
132
- light_purple2: { red: 0.705882353, green: 0.654901961, blue: 0.839215686 },
133
- light_magenta2: { red: 0.835294118, green: 0.650980392, blue: 0.741176471 },
134
- light_red_berry1: { red: 0.800000000, green: 0.254901961, blue: 0.145098039 },
135
- light_red1: { red: 0.878431373, green: 0.400000000, blue: 0.400000000 },
136
- light_orange1: { red: 0.964705882, green: 0.698039216, blue: 0.419607843 },
137
- light_yellow1: { red: 1.000000000, green: 0.850980392, blue: 0.400000000 },
138
- light_green1: { red: 0.576470588, green: 0.768627451, blue: 0.490196078 },
139
- light_cyan1: { red: 0.462745098, green: 0.647058824, blue: 0.686274510 },
140
- light_cornflower_blue1: { red: 0.427450980, green: 0.619607843, blue: 0.921568627 },
141
- light_blue1: { red: 0.435294118, green: 0.658823529, blue: 0.862745098 },
142
- light_purple1: { red: 0.556862745, green: 0.486274510, blue: 0.764705882 },
143
- light_magenta1: { red: 0.760784314, green: 0.482352941, blue: 0.627450980 },
144
- dark_red_berry1: { red: 0.650980392, green: 0.109803922, blue: 0.000000000 },
145
- dark_red1: { red: 0.800000000, green: 0.000000000, blue: 0.000000000 },
146
- dark_orange1: { red: 0.901960784, green: 0.568627451, blue: 0.219607843 },
147
- dark_yellow1: { red: 0.945098039, green: 0.760784314, blue: 0.196078431 },
148
- dark_green1: { red: 0.415686275, green: 0.658823529, blue: 0.309803922 },
149
- dark_cyan1: { red: 0.270588235, green: 0.505882353, blue: 0.556862745 },
150
- dark_cornflower_blue1: { red: 0.235294118, green: 0.470588235, blue: 0.847058824 },
151
- dark_blue1: { red: 0.239215686, green: 0.521568627, blue: 0.776470588 },
152
- dark_purple1: { red: 0.403921569, green: 0.305882353, blue: 0.654901961 },
153
- dark_magenta1: { red: 0.650980392, green: 0.301960784, blue: 0.474509804 },
154
- dark_red_berry2: { red: 0.521568627, green: 0.125490196, blue: 0.047058824 },
155
- dark_red2: { red: 0.600000000, green: 0.000000000, blue: 0.000000000 },
156
- dark_orange2: { red: 0.705882353, green: 0.372549020, blue: 0.023529412 },
157
- dark_yellow2: { red: 0.749019608, green: 0.564705882, blue: 0.000000000 },
158
- dark_green2: { red: 0.219607843, green: 0.462745098, blue: 0.113725490 },
159
- dark_cyan2: { red: 0.074509804, green: 0.309803922, blue: 0.360784314 },
160
- dark_cornflower_blue2: { red: 0.066666667, green: 0.333333333, blue: 0.800000000 },
161
- dark_blue2: { red: 0.043137255, green: 0.325490196, blue: 0.580392157 },
162
- dark_purple2: { red: 0.207843137, green: 0.109803922, blue: 0.458823529 },
163
- dark_magenta2: { red: 0.454901961, green: 0.105882353, blue: 0.278431373 },
164
- dark_red_berry3: { red: 0.356862745, green: 0.058823529, blue: 0.000000000 },
165
- dark_red3: { red: 0.400000000, green: 0.000000000, blue: 0.000000000 },
166
- dark_orange3: { red: 0.470588235, green: 0.247058824, blue: 0.015686275 },
167
- dark_yellow3: { red: 0.498039216, green: 0.376470588, blue: 0.000000000 },
168
- dark_green3: { red: 0.152941176, green: 0.305882353, blue: 0.074509804 },
169
- darn_cyan3: { red: 0.047058824, green: 0.203921569, blue: 0.239215686 },
170
- dark_cornflower_blue3: { red: 0.109803922, green: 0.270588235, blue: 0.529411765 },
171
- dark_blue3: { red: 0.027450980, green: 0.215686275, blue: 0.388235294 },
172
- dark_purple3: { red: 0.125490196, green: 0.070588235, blue: 0.301960784 },
173
- dark_magenta3: { red: 0.298039216, green: 0.066666667, blue: 0.188235294 },
174
-
175
- # Yahoo brand colors
176
-
177
- grape_jelly: { red: 0.376470588, green: 0.003921569, blue: 0.823529412 },
178
- hulk_pants: { red: 0.494117647, green: 0.121568627, blue: 1.000000000 },
179
- malbec: { red: 0.223529412, green: 0.000000000, blue: 0.490196078 },
180
- tumeric: { red: 1.000000000, green: 0.654901961, blue: 0.000000000 },
181
- mulah: { red: 0.101960784, green: 0.772549020, blue: 0.403921569 },
182
- dory: { red: 0.058823529, green: 0.411764706, blue: 1.000000000 },
183
- malibu: { red: 1.000000000, green: 0.000000000, blue: 0.501960784 },
184
- sea_foam: { red: 0.066666667, green: 0.827450980, blue: 0.803921569 },
185
- tumeric_tint: { red: 0.980392157, green: 0.866666667, blue: 0.694117647 },
186
- mulah_tint: { red: 0.733333333, green: 0.901960784, blue: 0.776470588 },
187
- dory_tint: { red: 0.662745098, green: 0.772549020, blue: 0.984313725 },
188
- malibu_tint: { red: 0.968627451, green: 0.682352941, blue: 0.800000000 },
189
- sea_foam_tint: { red: 0.749019608, green: 0.925490196, blue: 0.921568627 },
190
-
191
- # Yahoo health colors
192
-
193
- health_green: { red: 0.000000000, green: 0.690196078, blue: 0.313725490 },
194
- health_yellow: { red: 1.000000000, green: 0.654901961, blue: 0.000000000 },
195
- health_red: { red: 1.000000000, green: 0.000000000, blue: 0.000000000 },
196
-
197
- # Yahoo Fuji design color palette
198
-
199
- fuji_color_watermelon: { red: 1.000000000, green: 0.321568627, blue: 0.341176471 },
200
- fuji_color_solo_cup: { red: 0.921568627, green: 0.058823529, blue: 0.160784314 },
201
- fuji_color_malibu: { red: 1.000000000, green: 0.000000000, blue: 0.501960784 },
202
- fuji_color_barney: { red: 0.800000000, green: 0.000000000, blue: 0.549019608 },
203
- fuji_color_mimosa: { red: 1.000000000, green: 0.827450980, blue: 0.200000000 },
204
- fuji_color_turmeric: { red: 1.000000000, green: 0.654901961, blue: 0.000000000 },
205
- fuji_color_cheetos: { red: 0.992156863, green: 0.380392157, blue: 0.000000000 },
206
- fuji_color_carrot_juice: { red: 1.000000000, green: 0.321568627, blue: 0.050980392 },
207
- fuji_color_mulah: { red: 0.101960784, green: 0.772549020, blue: 0.403921569 },
208
- fuji_color_bonsai: { red: 0.000000000, green: 0.529411765, blue: 0.317647059 },
209
- fuji_color_spirulina: { red: 0.000000000, green: 0.627450980, blue: 0.627450980 },
210
- fuji_color_sea_foam: { red: 0.066666667, green: 0.827450980, blue: 0.803921569 },
211
- fuji_color_peeps: { red: 0.490196078, green: 0.796078431, blue: 1.000000000 },
212
- fuji_color_sky: { red: 0.070588235, green: 0.662745098, blue: 1.000000000 },
213
- fuji_color_dory: { red: 0.058823529, green: 0.411764706, blue: 1.000000000 },
214
- fuji_color_scooter: { red: 0.000000000, green: 0.388235294, blue: 0.921568627 },
215
- fuji_color_cobalt: { red: 0.000000000, green: 0.227450980, blue: 0.737254902 },
216
- fuji_color_denim: { red: 0.101960784, green: 0.050980392, blue: 0.670588235 },
217
- fuji_color_blurple: { red: 0.364705882, green: 0.368627451, blue: 1.000000000 },
218
- fuji_color_hendrix: { red: 0.972549020, green: 0.956862745, blue: 1.000000000 },
219
- fuji_color_thanos: { red: 0.564705882, green: 0.486274510, blue: 1.000000000 },
220
- fuji_color_starfish: { red: 0.466666667, green: 0.349019608, blue: 1.000000000 },
221
- fuji_color_hulk_pants: { red: 0.494117647, green: 0.121568627, blue: 1.000000000 },
222
- fuji_color_grape_jelly: { red: 0.376470588, green: 0.003921569, blue: 0.823529412 },
223
- fuji_color_mulberry: { red: 0.313725490, green: 0.082352941, blue: 0.690196078 },
224
- fuji_color_malbec: { red: 0.223529412, green: 0.000000000, blue: 0.490196078 },
225
- fuji_grayscale_black: { red: 0.000000000, green: 0.000000000, blue: 0.000000000 },
226
- fuji_grayscale_midnight: { red: 0.062745098, green: 0.082352941, blue: 0.094117647 },
227
- fuji_grayscale_inkwell: { red: 0.113725490, green: 0.133333333, blue: 0.156862745 },
228
- fuji_grayscale_batcave: { red: 0.137254902, green: 0.164705882, blue: 0.192156863 },
229
- fuji_grayscale_ramones: { red: 0.172549020, green: 0.211764706, blue: 0.247058824 },
230
- fuji_grayscale_charcoal: { red: 0.274509804, green: 0.305882353, blue: 0.337254902 },
231
- fuji_grayscale_battleship: { red: 0.356862745, green: 0.388235294, blue: 0.415686275 },
232
- fuji_grayscale_dolphin: { red: 0.431372549, green: 0.466666667, blue: 0.501960784 },
233
- fuji_grayscale_shark: { red: 0.509803922, green: 0.541176471, blue: 0.576470588 },
234
- fuji_grayscale_gandalf: { red: 0.592156863, green: 0.619607843, blue: 0.658823529 },
235
- fuji_grayscale_bob: { red: 0.690196078, green: 0.725490196, blue: 0.756862745 },
236
- fuji_grayscale_pebble: { red: 0.780392157, green: 0.803921569, blue: 0.823529412 },
237
- fuji_grayscale_dirty_seagull: { red: 0.878431373, green: 0.894117647, blue: 0.913725490 },
238
- fuji_grayscale_grey_hair: { red: 0.941176471, green: 0.952941176, blue: 0.960784314 },
239
- fuji_grayscale_marshmallow: { red: 0.960784314, green: 0.972549020, blue: 0.980392157 },
240
- fuji_grayscale_white: { red: 1.000000000, green: 1.000000000, blue: 1.000000000 }
241
- }.freeze
99
+ #
100
+ def self.color_names = SheetsV4::Color::COLORS.keys
242
101
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sheets_v4
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Couball
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-09-29 00:00:00.000000000 Z
11
+ date: 2023-09-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler-audit
@@ -257,8 +257,10 @@ files:
257
257
  - README.md
258
258
  - Rakefile
259
259
  - examples/README.md
260
+ - examples/set_background_color
260
261
  - lib/sheets_v4.rb
261
262
  - lib/sheets_v4/color.rb
263
+ - lib/sheets_v4/credential_creator.rb
262
264
  - lib/sheets_v4/validate_api_object.rb
263
265
  - lib/sheets_v4/version.rb
264
266
  homepage: https://github.com/main-branch/sheets_v4