google_spreadsheet_fetcher 1.8.1 → 1.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/main.yml +40 -0
- data/.github/workflows/release.yml +33 -0
- data/.rspec +1 -0
- data/lib/google_spreadsheet_fetcher/error.rb +1 -0
- data/lib/google_spreadsheet_fetcher/sheet_url.rb +58 -0
- data/lib/google_spreadsheet_fetcher/version.rb +1 -1
- data/lib/google_spreadsheet_fetcher.rb +2 -0
- metadata +9 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8b6d94fea13b2f79415f7f890b6286d427efc2510d583c166178ec873d6f7154
|
4
|
+
data.tar.gz: ed22e78b3d512387121ff938c8768319a2d3ba670f6ef3729683d314b2d5a552
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e6f43fc91a0613c39e79e09d0cc806202bab013f92b6926978439f492c3766fff71aa97779caf6d672f132ea9ead485188234f34c9e691b7b64108898ca93600
|
7
|
+
data.tar.gz: 1e64e297e726be3625750c72dd54187f9a48d64a6c257356b309ce79240d2e9c190e3a01bca4b0ba590de6083febe97720d544f7a631ae321c18bc44cbf087da
|
@@ -0,0 +1,40 @@
|
|
1
|
+
name: rspec
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- main
|
7
|
+
|
8
|
+
pull_request:
|
9
|
+
branches:
|
10
|
+
- main
|
11
|
+
|
12
|
+
env:
|
13
|
+
RAILS_ENV: test
|
14
|
+
|
15
|
+
jobs:
|
16
|
+
test:
|
17
|
+
runs-on: ubuntu-latest
|
18
|
+
strategy:
|
19
|
+
fail-fast: false
|
20
|
+
|
21
|
+
matrix:
|
22
|
+
ruby:
|
23
|
+
- 2.6
|
24
|
+
- 2.7
|
25
|
+
- 3.0
|
26
|
+
- 3.1
|
27
|
+
|
28
|
+
steps:
|
29
|
+
- uses: actions/checkout@v2
|
30
|
+
|
31
|
+
- name: Set up Ruby
|
32
|
+
uses: ruby/setup-ruby@v1
|
33
|
+
with:
|
34
|
+
ruby-version: ${{ matrix.ruby }}
|
35
|
+
bundler-cache: true
|
36
|
+
|
37
|
+
- name: Run tests
|
38
|
+
run: |
|
39
|
+
bundle exec rspec
|
40
|
+
continue-on-error: ${{ matrix.allow_failures == 'true' }}
|
@@ -0,0 +1,33 @@
|
|
1
|
+
name: Release gem
|
2
|
+
|
3
|
+
on:
|
4
|
+
workflow_dispatch:
|
5
|
+
inputs:
|
6
|
+
rubygems-otp-code:
|
7
|
+
description: RubyGems OTP code
|
8
|
+
required: true
|
9
|
+
|
10
|
+
permissions:
|
11
|
+
contents: write
|
12
|
+
|
13
|
+
jobs:
|
14
|
+
release-gem:
|
15
|
+
runs-on: ubuntu-latest
|
16
|
+
env:
|
17
|
+
GEM_HOST_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }}
|
18
|
+
GEM_HOST_OTP_CODE: ${{ github.event.inputs.rubygems-otp-code }}
|
19
|
+
steps:
|
20
|
+
- uses: actions/checkout@v2
|
21
|
+
with:
|
22
|
+
fetch-depth: 0 # bundle exec rake release で git tag を見るため、tagをfetchするようにしている
|
23
|
+
- uses: ruby/setup-ruby@v1
|
24
|
+
with:
|
25
|
+
ruby-version: 3.1.1
|
26
|
+
- name: Bundle install
|
27
|
+
run: bundle install
|
28
|
+
- name: Setup git config # bundle exec rake release でgit tagが打たれていない場合、タグを打ってpushしてくれるため用意している
|
29
|
+
run: |
|
30
|
+
git config --global user.email "taka0125@gmail.com"
|
31
|
+
git config --global user.name "Takahiro Ooishi"
|
32
|
+
- name: Release gem
|
33
|
+
run: bundle exec rake release
|
data/.rspec
CHANGED
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'uri'
|
2
|
+
|
3
|
+
module GoogleSpreadsheetFetcher
|
4
|
+
class SheetUrl
|
5
|
+
HOST = 'docs.google.com'.freeze
|
6
|
+
PATH_PATTERN = %r{spreadsheets/d/(?<spreadsheet_id>[^/]+)/edit}.freeze
|
7
|
+
|
8
|
+
attr_reader :spreadsheet_id, :sheet_id
|
9
|
+
|
10
|
+
private_class_method :new
|
11
|
+
|
12
|
+
def initialize(spreadsheet_id, sheet_id)
|
13
|
+
@spreadsheet_id = spreadsheet_id
|
14
|
+
@sheet_id = sheet_id
|
15
|
+
freeze
|
16
|
+
end
|
17
|
+
|
18
|
+
def url
|
19
|
+
"https://#{self.class::HOST}/spreadsheets/d/#{spreadsheet_id}/edit#gid=#{sheet_id}"
|
20
|
+
end
|
21
|
+
|
22
|
+
def ==(other)
|
23
|
+
return false unless other.class == self.class
|
24
|
+
|
25
|
+
other.hash == hash
|
26
|
+
end
|
27
|
+
|
28
|
+
alias eql? ==
|
29
|
+
|
30
|
+
def hash
|
31
|
+
[spreadsheet_id, sheet_id].join.hash
|
32
|
+
end
|
33
|
+
|
34
|
+
class << self
|
35
|
+
def parse!(url)
|
36
|
+
uri = URI.parse(url)
|
37
|
+
raise InvalidSheetUrl unless uri.host == HOST
|
38
|
+
|
39
|
+
path_matched_result = uri.path.match(PATH_PATTERN)
|
40
|
+
raise InvalidSheetUrl unless path_matched_result
|
41
|
+
|
42
|
+
spreadsheet_id = path_matched_result[:spreadsheet_id]
|
43
|
+
sheet_id = extract_sheet_id(uri.fragment)
|
44
|
+
|
45
|
+
new(spreadsheet_id, sheet_id)
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
def extract_sheet_id(fragment)
|
51
|
+
return 0 if fragment.blank?
|
52
|
+
|
53
|
+
results = Hash[*fragment.split('=')]
|
54
|
+
results.dig('gid')&.to_i || 0
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -1,9 +1,11 @@
|
|
1
|
+
require "active_support"
|
1
2
|
require "active_support/json"
|
2
3
|
require "active_support/core_ext"
|
3
4
|
require "google_spreadsheet_fetcher/version"
|
4
5
|
require "google_spreadsheet_fetcher/config"
|
5
6
|
require "google_spreadsheet_fetcher/error"
|
6
7
|
require "google_spreadsheet_fetcher/fetcher"
|
8
|
+
require "google_spreadsheet_fetcher/sheet_url"
|
7
9
|
require "google_spreadsheet_fetcher/bulk_fetcher"
|
8
10
|
require "google_spreadsheet_fetcher/sheets_service_builder"
|
9
11
|
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: google_spreadsheet_fetcher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Takahiro Ooishi
|
8
8
|
- Yuya Yokosuka
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2022-08-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: google-api-client
|
@@ -89,6 +89,8 @@ executables: []
|
|
89
89
|
extensions: []
|
90
90
|
extra_rdoc_files: []
|
91
91
|
files:
|
92
|
+
- ".github/workflows/main.yml"
|
93
|
+
- ".github/workflows/release.yml"
|
92
94
|
- ".gitignore"
|
93
95
|
- ".rspec"
|
94
96
|
- ".travis.yml"
|
@@ -103,12 +105,13 @@ files:
|
|
103
105
|
- lib/google_spreadsheet_fetcher/config.rb
|
104
106
|
- lib/google_spreadsheet_fetcher/error.rb
|
105
107
|
- lib/google_spreadsheet_fetcher/fetcher.rb
|
108
|
+
- lib/google_spreadsheet_fetcher/sheet_url.rb
|
106
109
|
- lib/google_spreadsheet_fetcher/sheets_service_builder.rb
|
107
110
|
- lib/google_spreadsheet_fetcher/version.rb
|
108
111
|
homepage: https://github.com/taka0125/google_spreadsheet_fetcher
|
109
112
|
licenses: []
|
110
113
|
metadata: {}
|
111
|
-
post_install_message:
|
114
|
+
post_install_message:
|
112
115
|
rdoc_options: []
|
113
116
|
require_paths:
|
114
117
|
- lib
|
@@ -123,8 +126,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
123
126
|
- !ruby/object:Gem::Version
|
124
127
|
version: '0'
|
125
128
|
requirements: []
|
126
|
-
rubygems_version: 3.
|
127
|
-
signing_key:
|
129
|
+
rubygems_version: 3.3.7
|
130
|
+
signing_key:
|
128
131
|
specification_version: 4
|
129
132
|
summary: Google Spreadsheet fetcher
|
130
133
|
test_files: []
|