munchsrb 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.circleci/config.yml +84 -0
- data/.gitignore +16 -0
- data/.rspec +3 -0
- data/.rubocop.yml +36 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Dangerfile +11 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +70 -0
- data/Rakefile +8 -0
- data/bin/console +15 -0
- data/bin/gather +8 -0
- data/bin/setup +8 -0
- data/lib/munchsrb.rb +23 -0
- data/lib/munchsrb/exporter/google_client.rb +33 -0
- data/lib/munchsrb/exporter/sheet.rb +35 -0
- data/lib/munchsrb/gather/config.rb +60 -0
- data/lib/munchsrb/gather/page_object/pages.rb +36 -0
- data/lib/munchsrb/gather/scenario.rb +35 -0
- data/lib/munchsrb/gather/starter.rb +24 -0
- data/lib/munchsrb/version.rb +5 -0
- data/munchsrb.gemspec +47 -0
- data/renovate.json +39 -0
- metadata +347 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 49c62e3d7633d0a9a77f6217d8c4d251d19e135c750167b11879c9924e55561b
|
4
|
+
data.tar.gz: 13bf0cfd952b83960570dfd1fa40359ab841c476fddec00127025f49652a12a6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 88ebd81bca3556161625688e9571529d5c6ba506dc1ffce8163366f459e4d7693fb850e48a280882dd7c84633b0aaadd38c67d3e3ef6ce612670cf1d2ea4cd8b
|
7
|
+
data.tar.gz: c8317e6f025ade0016ec9bdf818a180c736961a0ec8f9272221589644859bea0fc0696468d93f0648675140278aaf9b77c7a513ce9034daa4e38fa8c8862bc28
|
@@ -0,0 +1,84 @@
|
|
1
|
+
defaults: &defaults
|
2
|
+
working_directory: ~/repo
|
3
|
+
environment:
|
4
|
+
- CIRCLE_ARTIFACTS: "/tmp/test-results"
|
5
|
+
- BUNDLER_VERSION: 2.0.1
|
6
|
+
executors:
|
7
|
+
default_container:
|
8
|
+
docker:
|
9
|
+
- image: circleci/ruby:2.6.3-node-browsers
|
10
|
+
commands:
|
11
|
+
restore-and-save-cache:
|
12
|
+
steps:
|
13
|
+
- restore_cache:
|
14
|
+
keys:
|
15
|
+
- v1-dependencies-{{ checksum "munchsrb.gemspec" }}
|
16
|
+
- v1-dependencies-
|
17
|
+
- run:
|
18
|
+
name: Configure Bundler
|
19
|
+
command: gem install bundler
|
20
|
+
- run:
|
21
|
+
name: install dependencies
|
22
|
+
command: |
|
23
|
+
bundle install --jobs=4 --quiet --retry=3 --path vendor/bundle
|
24
|
+
- save_cache:
|
25
|
+
paths:
|
26
|
+
- ./vendor/bundle
|
27
|
+
key: v1-dependencies-{{ checksum "munchsrb.gemspec" }}
|
28
|
+
- persist_to_workspace:
|
29
|
+
root: .
|
30
|
+
paths:
|
31
|
+
- .
|
32
|
+
version: 2.1
|
33
|
+
jobs:
|
34
|
+
prepare:
|
35
|
+
<<: *defaults
|
36
|
+
parallelism: 1
|
37
|
+
executor: default_container
|
38
|
+
steps:
|
39
|
+
- checkout
|
40
|
+
- restore-and-save-cache
|
41
|
+
rspec:
|
42
|
+
<<: *defaults
|
43
|
+
executor: default_container
|
44
|
+
steps:
|
45
|
+
- attach_workspace:
|
46
|
+
at: .
|
47
|
+
- restore-and-save-cache
|
48
|
+
- run:
|
49
|
+
name: Run tests
|
50
|
+
command: |
|
51
|
+
mkdir ${CIRCLE_ARTIFACTS}
|
52
|
+
TEST_FILES="$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)"
|
53
|
+
bundle exec rspec --format progress \
|
54
|
+
--format RspecJunitFormatter \
|
55
|
+
--out $CIRCLE_ARTIFACTS/rspec.xml \
|
56
|
+
$TEST_FILES
|
57
|
+
after_success:
|
58
|
+
- command: bash <(curl -fs https://codecov.io/bash) -t ${CODECOV_TOKEN}
|
59
|
+
- store_test_results:
|
60
|
+
path: ${CIRCLE_ARTIFACTS}
|
61
|
+
- store_artifacts:
|
62
|
+
path: ${CIRCLE_ARTIFACTS}
|
63
|
+
destination: test-results
|
64
|
+
danger:
|
65
|
+
<<: *defaults
|
66
|
+
executor: default_container
|
67
|
+
steps:
|
68
|
+
- attach_workspace:
|
69
|
+
at: .
|
70
|
+
- restore-and-save-cache
|
71
|
+
- run:
|
72
|
+
name: Run danger
|
73
|
+
command: |
|
74
|
+
bundle exec danger --fail-on-errors=true
|
75
|
+
workflows:
|
76
|
+
integration:
|
77
|
+
jobs:
|
78
|
+
- prepare
|
79
|
+
- rspec:
|
80
|
+
requires:
|
81
|
+
- prepare
|
82
|
+
- danger:
|
83
|
+
requires:
|
84
|
+
- prepare
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
require:
|
2
|
+
- rubocop-rspec
|
3
|
+
|
4
|
+
AllCops:
|
5
|
+
DisplayCopNames: true
|
6
|
+
TargetRubyVersion: 2.6
|
7
|
+
Exclude:
|
8
|
+
- 'tmp/**/*'
|
9
|
+
- 'vendor/**/*'
|
10
|
+
- !ruby/regexp /old_and_unused\.rb$/
|
11
|
+
|
12
|
+
Metrics/BlockLength:
|
13
|
+
Enabled: false
|
14
|
+
|
15
|
+
Metrics/LineLength:
|
16
|
+
Max: 120
|
17
|
+
Exclude:
|
18
|
+
- 'spec/**/*'
|
19
|
+
|
20
|
+
Metrics/MethodLength:
|
21
|
+
Max: 15
|
22
|
+
|
23
|
+
RSpec/MultipleExpectations:
|
24
|
+
Enabled: false
|
25
|
+
|
26
|
+
RSpec/ExampleLength:
|
27
|
+
Enabled: false
|
28
|
+
|
29
|
+
Style/DoubleNegation:
|
30
|
+
Enabled: false
|
31
|
+
|
32
|
+
RSpec/NamedSubject:
|
33
|
+
Enabled: false
|
34
|
+
|
35
|
+
RSpec/MessageChain:
|
36
|
+
Enabled: false
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at pavegy@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Dangerfile
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 Ryota Ikezawa
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
Munchsrb
|
2
|
+
========
|
3
|
+
|
4
|
+
[![MIT License](http://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)][license]
|
5
|
+
[![Renovate](https://badges.renovateapi.com/github/paveg/munchsrb)][renovate]
|
6
|
+
[![CircleCI](https://circleci.com/gh/paveg/munchsrb.svg?style=svg&circle-token=d9adfa363e47070777441c9f94f9401b070a2a36)][circleci]
|
7
|
+
[![codecov](https://codecov.io/gh/paveg/munchsrb/branch/master/graph/badge.svg)][codecov]
|
8
|
+
|
9
|
+
[license]: https://github.com/paveg/munchsrb/blob/master/LICENSE
|
10
|
+
[renovate]: https://github.com/renovatebot/renovate
|
11
|
+
[circleci]: https://circleci.com/gh/paveg/munchsrb
|
12
|
+
[codecov]: https://codecov.io/gh/paveg/munchsrb
|
13
|
+
|
14
|
+
Munchsrb is rubygem for those who love Munch's Burger!
|
15
|
+
|
16
|
+
## Installation
|
17
|
+
|
18
|
+
Add this line to your application's Gemfile:
|
19
|
+
|
20
|
+
```ruby
|
21
|
+
gem 'munchsrb'
|
22
|
+
```
|
23
|
+
|
24
|
+
And then execute:
|
25
|
+
|
26
|
+
$ bundle
|
27
|
+
|
28
|
+
Or install it yourself as:
|
29
|
+
|
30
|
+
$ gem install munchsrb
|
31
|
+
|
32
|
+
## Usage
|
33
|
+
|
34
|
+
# Please, set your google client key and spread sheet key.
|
35
|
+
$ bin/gather
|
36
|
+
|
37
|
+
### Environment
|
38
|
+
|
39
|
+
|key|value|
|
40
|
+
|:---:|:---:|
|
41
|
+
| `GOOGLE_CLIENT` | your google client id |
|
42
|
+
| `GOOGLE_CLIENT_SECRET` | your google client secret |
|
43
|
+
| `GOOGLE_REFRESH_TOKEN` | your google refresh token |
|
44
|
+
| `GOOGLE_SPREAD_SHEET_KEY` | your destination Google Spread Sheet Key |
|
45
|
+
|
46
|
+
## Development
|
47
|
+
|
48
|
+
After checking out the repo, run `bin/setup` to install dependencies.
|
49
|
+
|
50
|
+
Then, run `bundle exec rake spec` to run the tests.
|
51
|
+
|
52
|
+
You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
53
|
+
|
54
|
+
To install this gem onto your local machine, run `bundle exec rake install`.
|
55
|
+
|
56
|
+
To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
57
|
+
|
58
|
+
## Contributing
|
59
|
+
|
60
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/paveg/munchsrb.
|
61
|
+
|
62
|
+
This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
63
|
+
|
64
|
+
## License
|
65
|
+
|
66
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
67
|
+
|
68
|
+
## Code of Conduct
|
69
|
+
|
70
|
+
Everyone interacting in the Munchsrb project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/munchsrb/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'munchsrb'
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require 'pry'
|
15
|
+
Pry.start
|
data/bin/gather
ADDED
data/bin/setup
ADDED
data/lib/munchsrb.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'munchsrb/version'
|
4
|
+
require 'capybara'
|
5
|
+
require 'capybara/rspec'
|
6
|
+
require 'nokogiri'
|
7
|
+
require 'site_prism'
|
8
|
+
require 'google_drive'
|
9
|
+
require 'selenium-webdriver'
|
10
|
+
require 'munchsrb/gather/config'
|
11
|
+
require 'munchsrb/gather/starter'
|
12
|
+
require 'munchsrb/gather/page_object/pages'
|
13
|
+
require 'munchsrb/exporter/google_client'
|
14
|
+
require 'munchsrb/exporter/sheet'
|
15
|
+
|
16
|
+
# Munchsrb Top level module Munchsrb
|
17
|
+
module Munchsrb
|
18
|
+
class Error < StandardError
|
19
|
+
end
|
20
|
+
# GatherError is occurred in gathering.
|
21
|
+
class GatherError < StandardError
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'google_drive'
|
4
|
+
|
5
|
+
module Munchsrb
|
6
|
+
module Exporter
|
7
|
+
# Munchsrb::Exporter::GoogleClient is shared client to access google apis.
|
8
|
+
class GoogleClient
|
9
|
+
SCOPES = [
|
10
|
+
'https://www.googleapis.com/auth/drive',
|
11
|
+
'https://spreadsheets.google.com/feeds/'
|
12
|
+
].freeze
|
13
|
+
|
14
|
+
class << self
|
15
|
+
def session
|
16
|
+
GoogleDrive::Session.from_credentials(credentials)
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def credentials
|
22
|
+
::Google::Auth::UserRefreshCredentials.new(
|
23
|
+
client_id: ENV['GOOGLE_CLIENT'],
|
24
|
+
client_secret: ENV['GOOGLE_CLIENT_SECRET'],
|
25
|
+
refresh_token: ENV['GOOGLE_REFRESH_TOKEN'],
|
26
|
+
scope: SCOPES,
|
27
|
+
redirect_uri: 'urn:ietf:wg:oauth:2.0:oob'
|
28
|
+
)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Munchsrb
|
4
|
+
module Exporter
|
5
|
+
# Munchsrb::Exporter::Sheet exports content to Google Spread Sheet.
|
6
|
+
class Sheet
|
7
|
+
HEADER = %w[メニュー名 金額].freeze
|
8
|
+
ROW_START_INDEX = 1
|
9
|
+
COLUMN_START_INDEX = 1
|
10
|
+
|
11
|
+
def initialize(key = nil)
|
12
|
+
session = Munchsrb::Exporter::GoogleClient.session
|
13
|
+
@worksheet = session.spreadsheet_by_key(ENV.fetch('GOOGLE_SPREAD_SHEET_KEY', key)).worksheets[0]
|
14
|
+
end
|
15
|
+
|
16
|
+
def export(details)
|
17
|
+
contents = []
|
18
|
+
contents << HEADER
|
19
|
+
details.each { |detail| contents << [detail[:name], detail[:price]] }
|
20
|
+
save(contents)
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def save(contents)
|
26
|
+
contents.each.with_index(ROW_START_INDEX) do |content, row_index|
|
27
|
+
content.each.with_index(COLUMN_START_INDEX) do |c, column_index|
|
28
|
+
@worksheet[row_index, column_index] = c
|
29
|
+
end
|
30
|
+
end
|
31
|
+
@worksheet.save
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Munchsrb
|
4
|
+
# Munchsrb::Gather
|
5
|
+
module Gather
|
6
|
+
DEFAULT_MAX_WAIT_TIME = 2
|
7
|
+
class << self
|
8
|
+
attr_reader :driver
|
9
|
+
|
10
|
+
def init
|
11
|
+
Capybara.register_driver :chrome do |app|
|
12
|
+
prepare(app)
|
13
|
+
end
|
14
|
+
|
15
|
+
Capybara.configure do |config|
|
16
|
+
config.run_server = false
|
17
|
+
config.default_driver = :chrome
|
18
|
+
config.javascript_driver = :chrome
|
19
|
+
config.default_max_wait_time = DEFAULT_MAX_WAIT_TIME
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def prepare(app)
|
26
|
+
@driver = Capybara::Selenium::Driver.new(
|
27
|
+
app,
|
28
|
+
browser: :chrome,
|
29
|
+
desired_capabilities: Selenium::WebDriver::Remote::Capabilities.chrome(options)
|
30
|
+
)
|
31
|
+
end
|
32
|
+
|
33
|
+
def options
|
34
|
+
{
|
35
|
+
chrome_options: {
|
36
|
+
args: arguments,
|
37
|
+
prefs: preferences
|
38
|
+
}
|
39
|
+
}
|
40
|
+
end
|
41
|
+
|
42
|
+
def arguments
|
43
|
+
[
|
44
|
+
'--no-sandbox',
|
45
|
+
'--verbose',
|
46
|
+
'--window-size=1280,800',
|
47
|
+
'--disable-save-password-bubble',
|
48
|
+
'--lang=ja',
|
49
|
+
'--disable-gpu',
|
50
|
+
'incognito',
|
51
|
+
'--headless'
|
52
|
+
]
|
53
|
+
end
|
54
|
+
|
55
|
+
def preferences
|
56
|
+
{ credentials_enable_service: false, password_manager_enabled: false }
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'site_prism'
|
4
|
+
require 'unicode'
|
5
|
+
|
6
|
+
module Munchsrb
|
7
|
+
module Gather
|
8
|
+
module PageObject
|
9
|
+
# IndexPage is index page of Munch's Burger.
|
10
|
+
class IndexPage < SitePrism::Page
|
11
|
+
set_url 'https://munchs.jp/index.html'
|
12
|
+
|
13
|
+
element :menu_link, 'a[href="menu.html"]'
|
14
|
+
end
|
15
|
+
# Item is Item section on Menu page of Munch's Burger.
|
16
|
+
class Item < SitePrism::Section
|
17
|
+
element :name, 'h4'
|
18
|
+
element :price, 'p'
|
19
|
+
end
|
20
|
+
# MenuPage is Menu page of Munch's Burger.
|
21
|
+
class MenuPage < SitePrism::Page
|
22
|
+
set_url 'https://munchs.jsp/menu.html'
|
23
|
+
|
24
|
+
sections :menu_items, Item, 'section.menu-all div.menu-item'
|
25
|
+
|
26
|
+
def details
|
27
|
+
menu_items.map do |item|
|
28
|
+
name = Unicode.nfkc(item.name.text.split("\n").last)
|
29
|
+
price = item.price.text.delete(',').match(/¥(?<price>\d+)/)[:price].to_i
|
30
|
+
{ name: name, price: price }
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Munchsrb
|
4
|
+
module Gather
|
5
|
+
# Munchsrb::Gather::Scenario written story page scraping.
|
6
|
+
class Scenario
|
7
|
+
attr_reader :details
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
@page = open
|
11
|
+
@driver = Munchsrb::Gather.driver
|
12
|
+
@details = nil
|
13
|
+
end
|
14
|
+
|
15
|
+
def execute
|
16
|
+
@page.menu_link.click # open menu page
|
17
|
+
Munchsrb::Gather::PageObject::MenuPage.new.tap do |page|
|
18
|
+
@details = page.details
|
19
|
+
end
|
20
|
+
ensure
|
21
|
+
quit
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def open
|
27
|
+
Munchsrb::Gather::PageObject::IndexPage.new.tap(&:load)
|
28
|
+
end
|
29
|
+
|
30
|
+
def quit
|
31
|
+
@driver.quit
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'munchsrb/gather/scenario'
|
4
|
+
|
5
|
+
module Munchsrb
|
6
|
+
module Gather
|
7
|
+
# Starter starts gather information of Munch's Burger.
|
8
|
+
class Starter
|
9
|
+
attr_reader :scenario
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
Munchsrb::Gather.init
|
13
|
+
@scenario = ::Munchsrb::Gather::Scenario.new
|
14
|
+
end
|
15
|
+
|
16
|
+
def run
|
17
|
+
scenario.execute
|
18
|
+
@scenario.details
|
19
|
+
rescue Munchsrb::GatherError => e
|
20
|
+
print("Gather Error occurred! #{e.message}\n")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/munchsrb.gemspec
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require 'munchsrb/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = 'munchsrb'
|
9
|
+
spec.version = Munchsrb::VERSION
|
10
|
+
spec.authors = ['Ryota Ikezawa']
|
11
|
+
spec.email = ['pavegy@gmail.com']
|
12
|
+
|
13
|
+
spec.summary = "Munch's Burger Gather."
|
14
|
+
spec.description = "Munch's Burger Scraper Gem."
|
15
|
+
spec.homepage = 'https://github.com/paveg/munchsrb'
|
16
|
+
spec.license = 'MIT'
|
17
|
+
|
18
|
+
# Specify which files should be added to the gem when it is released.
|
19
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
20
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
21
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
22
|
+
end
|
23
|
+
spec.bindir = 'exe'
|
24
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
25
|
+
spec.require_paths = ['lib']
|
26
|
+
|
27
|
+
spec.add_development_dependency 'bundler', '~> 2.0'
|
28
|
+
spec.add_development_dependency 'codecov'
|
29
|
+
spec.add_development_dependency 'danger'
|
30
|
+
spec.add_development_dependency 'danger-junit'
|
31
|
+
spec.add_development_dependency 'danger-rubocop'
|
32
|
+
spec.add_development_dependency 'pry-byebug'
|
33
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
34
|
+
spec.add_development_dependency 'rspec', '~> 3.8'
|
35
|
+
spec.add_development_dependency 'rspec_junit_formatter'
|
36
|
+
spec.add_development_dependency 'rubocop', '~> 0.70'
|
37
|
+
spec.add_development_dependency 'rubocop-performance'
|
38
|
+
spec.add_development_dependency 'rubocop-rspec'
|
39
|
+
spec.add_development_dependency 'simplecov'
|
40
|
+
spec.add_dependency 'capybara'
|
41
|
+
spec.add_dependency 'google-api-client'
|
42
|
+
spec.add_dependency 'google_drive'
|
43
|
+
spec.add_dependency 'nokogiri'
|
44
|
+
spec.add_dependency 'selenium-webdriver', '~> 3.142'
|
45
|
+
spec.add_dependency 'site_prism', '~> 3.2'
|
46
|
+
spec.add_dependency 'unicode'
|
47
|
+
end
|
data/renovate.json
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
{
|
2
|
+
"enabled": true,
|
3
|
+
"extends": [
|
4
|
+
"config:base"
|
5
|
+
],
|
6
|
+
"timezone": "Asia/Tokyo",
|
7
|
+
"schedule": "before 9am every weekday",
|
8
|
+
"prConcurrentLimit": 5,
|
9
|
+
"separateMultipleMajor": true,
|
10
|
+
"major": {
|
11
|
+
"automerge": false,
|
12
|
+
"labels": [
|
13
|
+
"renovate",
|
14
|
+
"major"
|
15
|
+
]
|
16
|
+
},
|
17
|
+
"minor": {
|
18
|
+
"automerge": false,
|
19
|
+
"labels": [
|
20
|
+
"renovate",
|
21
|
+
"minor"
|
22
|
+
]
|
23
|
+
},
|
24
|
+
"patch": {
|
25
|
+
"groupName": "all patch dependencies",
|
26
|
+
"automerge": true,
|
27
|
+
"labels": [
|
28
|
+
"renovate",
|
29
|
+
"patch"
|
30
|
+
]
|
31
|
+
},
|
32
|
+
"pin": {
|
33
|
+
"automerge": false,
|
34
|
+
"labels": [
|
35
|
+
"renovate",
|
36
|
+
"pin"
|
37
|
+
]
|
38
|
+
}
|
39
|
+
}
|
metadata
ADDED
@@ -0,0 +1,347 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: munchsrb
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ryota Ikezawa
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-05-25 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: codecov
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: danger
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: danger-junit
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: danger-rubocop
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: pry-byebug
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rake
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '10.0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '10.0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rspec
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '3.8'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '3.8'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: rspec_junit_formatter
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: rubocop
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - "~>"
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0.70'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - "~>"
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0.70'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: rubocop-performance
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ">="
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: rubocop-rspec
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - ">="
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - ">="
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
181
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
name: simplecov
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - ">="
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '0'
|
188
|
+
type: :development
|
189
|
+
prerelease: false
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - ">="
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: '0'
|
195
|
+
- !ruby/object:Gem::Dependency
|
196
|
+
name: capybara
|
197
|
+
requirement: !ruby/object:Gem::Requirement
|
198
|
+
requirements:
|
199
|
+
- - ">="
|
200
|
+
- !ruby/object:Gem::Version
|
201
|
+
version: '0'
|
202
|
+
type: :runtime
|
203
|
+
prerelease: false
|
204
|
+
version_requirements: !ruby/object:Gem::Requirement
|
205
|
+
requirements:
|
206
|
+
- - ">="
|
207
|
+
- !ruby/object:Gem::Version
|
208
|
+
version: '0'
|
209
|
+
- !ruby/object:Gem::Dependency
|
210
|
+
name: google-api-client
|
211
|
+
requirement: !ruby/object:Gem::Requirement
|
212
|
+
requirements:
|
213
|
+
- - ">="
|
214
|
+
- !ruby/object:Gem::Version
|
215
|
+
version: '0'
|
216
|
+
type: :runtime
|
217
|
+
prerelease: false
|
218
|
+
version_requirements: !ruby/object:Gem::Requirement
|
219
|
+
requirements:
|
220
|
+
- - ">="
|
221
|
+
- !ruby/object:Gem::Version
|
222
|
+
version: '0'
|
223
|
+
- !ruby/object:Gem::Dependency
|
224
|
+
name: google_drive
|
225
|
+
requirement: !ruby/object:Gem::Requirement
|
226
|
+
requirements:
|
227
|
+
- - ">="
|
228
|
+
- !ruby/object:Gem::Version
|
229
|
+
version: '0'
|
230
|
+
type: :runtime
|
231
|
+
prerelease: false
|
232
|
+
version_requirements: !ruby/object:Gem::Requirement
|
233
|
+
requirements:
|
234
|
+
- - ">="
|
235
|
+
- !ruby/object:Gem::Version
|
236
|
+
version: '0'
|
237
|
+
- !ruby/object:Gem::Dependency
|
238
|
+
name: nokogiri
|
239
|
+
requirement: !ruby/object:Gem::Requirement
|
240
|
+
requirements:
|
241
|
+
- - ">="
|
242
|
+
- !ruby/object:Gem::Version
|
243
|
+
version: '0'
|
244
|
+
type: :runtime
|
245
|
+
prerelease: false
|
246
|
+
version_requirements: !ruby/object:Gem::Requirement
|
247
|
+
requirements:
|
248
|
+
- - ">="
|
249
|
+
- !ruby/object:Gem::Version
|
250
|
+
version: '0'
|
251
|
+
- !ruby/object:Gem::Dependency
|
252
|
+
name: selenium-webdriver
|
253
|
+
requirement: !ruby/object:Gem::Requirement
|
254
|
+
requirements:
|
255
|
+
- - "~>"
|
256
|
+
- !ruby/object:Gem::Version
|
257
|
+
version: '3.142'
|
258
|
+
type: :runtime
|
259
|
+
prerelease: false
|
260
|
+
version_requirements: !ruby/object:Gem::Requirement
|
261
|
+
requirements:
|
262
|
+
- - "~>"
|
263
|
+
- !ruby/object:Gem::Version
|
264
|
+
version: '3.142'
|
265
|
+
- !ruby/object:Gem::Dependency
|
266
|
+
name: site_prism
|
267
|
+
requirement: !ruby/object:Gem::Requirement
|
268
|
+
requirements:
|
269
|
+
- - "~>"
|
270
|
+
- !ruby/object:Gem::Version
|
271
|
+
version: '3.2'
|
272
|
+
type: :runtime
|
273
|
+
prerelease: false
|
274
|
+
version_requirements: !ruby/object:Gem::Requirement
|
275
|
+
requirements:
|
276
|
+
- - "~>"
|
277
|
+
- !ruby/object:Gem::Version
|
278
|
+
version: '3.2'
|
279
|
+
- !ruby/object:Gem::Dependency
|
280
|
+
name: unicode
|
281
|
+
requirement: !ruby/object:Gem::Requirement
|
282
|
+
requirements:
|
283
|
+
- - ">="
|
284
|
+
- !ruby/object:Gem::Version
|
285
|
+
version: '0'
|
286
|
+
type: :runtime
|
287
|
+
prerelease: false
|
288
|
+
version_requirements: !ruby/object:Gem::Requirement
|
289
|
+
requirements:
|
290
|
+
- - ">="
|
291
|
+
- !ruby/object:Gem::Version
|
292
|
+
version: '0'
|
293
|
+
description: Munch's Burger Scraper Gem.
|
294
|
+
email:
|
295
|
+
- pavegy@gmail.com
|
296
|
+
executables: []
|
297
|
+
extensions: []
|
298
|
+
extra_rdoc_files: []
|
299
|
+
files:
|
300
|
+
- ".circleci/config.yml"
|
301
|
+
- ".gitignore"
|
302
|
+
- ".rspec"
|
303
|
+
- ".rubocop.yml"
|
304
|
+
- CODE_OF_CONDUCT.md
|
305
|
+
- Dangerfile
|
306
|
+
- Gemfile
|
307
|
+
- LICENSE.txt
|
308
|
+
- README.md
|
309
|
+
- Rakefile
|
310
|
+
- bin/console
|
311
|
+
- bin/gather
|
312
|
+
- bin/setup
|
313
|
+
- lib/munchsrb.rb
|
314
|
+
- lib/munchsrb/exporter/google_client.rb
|
315
|
+
- lib/munchsrb/exporter/sheet.rb
|
316
|
+
- lib/munchsrb/gather/config.rb
|
317
|
+
- lib/munchsrb/gather/page_object/pages.rb
|
318
|
+
- lib/munchsrb/gather/scenario.rb
|
319
|
+
- lib/munchsrb/gather/starter.rb
|
320
|
+
- lib/munchsrb/version.rb
|
321
|
+
- munchsrb.gemspec
|
322
|
+
- renovate.json
|
323
|
+
homepage: https://github.com/paveg/munchsrb
|
324
|
+
licenses:
|
325
|
+
- MIT
|
326
|
+
metadata: {}
|
327
|
+
post_install_message:
|
328
|
+
rdoc_options: []
|
329
|
+
require_paths:
|
330
|
+
- lib
|
331
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
332
|
+
requirements:
|
333
|
+
- - ">="
|
334
|
+
- !ruby/object:Gem::Version
|
335
|
+
version: '0'
|
336
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
337
|
+
requirements:
|
338
|
+
- - ">="
|
339
|
+
- !ruby/object:Gem::Version
|
340
|
+
version: '0'
|
341
|
+
requirements: []
|
342
|
+
rubyforge_project:
|
343
|
+
rubygems_version: 2.7.6
|
344
|
+
signing_key:
|
345
|
+
specification_version: 4
|
346
|
+
summary: Munch's Burger Gather.
|
347
|
+
test_files: []
|