narou_agent 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.env.sample +4 -0
- data/.gitignore +56 -0
- data/.rspec +3 -0
- data/.rubocop.yml +6 -0
- data/.travis.yml +23 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +63 -0
- data/Rakefile +6 -0
- data/bin/console +10 -0
- data/bin/setup +8 -0
- data/lib/narou_agent/action.rb +16 -0
- data/lib/narou_agent/actions/create_part.rb +24 -0
- data/lib/narou_agent/actions/delete_part.rb +16 -0
- data/lib/narou_agent/actions/login.rb +19 -0
- data/lib/narou_agent/actions/update_part.rb +26 -0
- data/lib/narou_agent/error.rb +5 -0
- data/lib/narou_agent/url_helper.rb +46 -0
- data/lib/narou_agent/version.rb +3 -0
- data/lib/narou_agent.rb +49 -0
- data/narou_agent.gemspec +33 -0
- metadata +164 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 0f8e69706dc126e7d1bae1add3d0a6c7a22cf1add1d4a26177da01599afd7b9f
|
4
|
+
data.tar.gz: 47e78831364dfad9c80e2de7c48f69035e1aeebdb163307ec858d1b5b81b7a60
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a4279e3459c85b4e407a4bfddfcd8322d8ba2ff755510b53524186ea6ac0cf68e109a326cf56e2809548d3947812eaa5d54b3ee7cc014a8f3671d4b04f2b8b3e
|
7
|
+
data.tar.gz: 9d3f1dd07e4f864b34d6c3c56a35793f7ce602024721499f68a34f03c54335767d35428b3b795a10dea8bbb4f49b07fb9db7ba8480bac4de3dc85b38b1280401
|
data/.env.sample
ADDED
data/.gitignore
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
### https://raw.github.com/github/gitignore/9da1b5d8ce4e009ff627c4fe49a4488b2a3f60d4/Ruby.gitignore
|
2
|
+
|
3
|
+
*.gem
|
4
|
+
*.rbc
|
5
|
+
/.config
|
6
|
+
/coverage/
|
7
|
+
/InstalledFiles
|
8
|
+
/pkg/
|
9
|
+
/spec/reports/
|
10
|
+
/spec/examples.txt
|
11
|
+
/test/tmp/
|
12
|
+
/test/version_tmp/
|
13
|
+
/tmp/
|
14
|
+
|
15
|
+
# Used by dotenv library to load environment variables.
|
16
|
+
.env
|
17
|
+
|
18
|
+
## Specific to RubyMotion:
|
19
|
+
.dat*
|
20
|
+
.repl_history
|
21
|
+
build/
|
22
|
+
*.bridgesupport
|
23
|
+
build-iPhoneOS/
|
24
|
+
build-iPhoneSimulator/
|
25
|
+
|
26
|
+
## Specific to RubyMotion (use of CocoaPods):
|
27
|
+
#
|
28
|
+
# We recommend against adding the Pods directory to your .gitignore. However
|
29
|
+
# you should judge for yourself, the pros and cons are mentioned at:
|
30
|
+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
31
|
+
#
|
32
|
+
# vendor/Pods/
|
33
|
+
|
34
|
+
## Documentation cache and generated files:
|
35
|
+
/.yardoc/
|
36
|
+
/_yardoc/
|
37
|
+
/doc/
|
38
|
+
/rdoc/
|
39
|
+
|
40
|
+
## Environment normalization:
|
41
|
+
/.bundle/
|
42
|
+
/vendor/bundle
|
43
|
+
/lib/bundler/man/
|
44
|
+
|
45
|
+
# for a library or gem, you might want to ignore these files since the code is
|
46
|
+
# intended to run in multiple environments; otherwise, check them in:
|
47
|
+
Gemfile.lock
|
48
|
+
.ruby-version
|
49
|
+
.ruby-gemset
|
50
|
+
|
51
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
52
|
+
.rvmrc
|
53
|
+
|
54
|
+
# rspec failure tracking
|
55
|
+
.rspec_status
|
56
|
+
|
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/.travis.yml
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
sudo: required
|
2
|
+
language: ruby
|
3
|
+
rvm:
|
4
|
+
- 2.5
|
5
|
+
addons:
|
6
|
+
chrome: stable
|
7
|
+
env:
|
8
|
+
global:
|
9
|
+
- NCODE=N8472FC
|
10
|
+
- PART_ID=11170710
|
11
|
+
- secure: wVi0jY4gK6bK9v6UbcE9BTBjnYaQVVHQC4SXjT05O7Zstt6rdMesg22yR5RgHvjxjD+yfGiPW50kSkcKIpdQ4D8Zm6u5d5BqyasJfmvQd7Hww7jhx+KChAWMyos2nOlvr4noXNcpllNhedaU9aEXADijxOpCCm1NvjW7GBWOOjkdsgBJcqU2z48NtpbazW+J6/ZiVT+Hsi+weIvIbmZ8TUHSFRmHEncz0TyzzmDbio+Lobuksh8pMoHDs157FfpT0picKXMsQRUcB/nTisnoLzSBzHiT9ttPYXqET0dEDbM+e5VhPjaXQEHQKtiJDeJxsGVpHpo+DYMt4Q3KrqO6il3hKJ3JQK31fzAh8LN1JbmDxIWn1zqyX5YolWyrxYVOv/HByBGyp+4w4WPUw3sspX9BL27fwYEE0qqYmtOvE/Z22GOfUHXIVjyNuGzrBGP13IAPlmxqHZGIYX5TYgZTSc13v3nKXzsMm9onjzcwGgbPmsNSKGl+/mC5gdNVgwG6PRz+zhU5v5X8ENJhFfrUozE4q6J6sVSXSJWdzQ0S6XfE02pwT0pwX65mVpLpa1G8xVAxxPFDPg9+hHjXlYncKL0r7WytKVZ9EJo7WtRjvRH7EEC3DOGnG6iDZFOi0mO/YOWWOdK4GmVh+Xldt82fzfuhMqC0mL07HYm69nyYpLc=
|
12
|
+
cache: bundler
|
13
|
+
before_install:
|
14
|
+
- gem install bundler -v 1.17.1
|
15
|
+
install:
|
16
|
+
- bundle install --jobs=3 --retry=3
|
17
|
+
# https://github.com/SeleniumHQ/selenium/blob/master/scripts/travis/install.sh#L4-L6
|
18
|
+
- export CHROMEDRIVER_VERSION=`curl -s http://chromedriver.storage.googleapis.com/LATEST_RELEASE`
|
19
|
+
- curl -L -O "http://chromedriver.storage.googleapis.com/${CHROMEDRIVER_VERSION}/chromedriver_linux64.zip"
|
20
|
+
- unzip chromedriver_linux64.zip && chmod +x chromedriver && sudo mv chromedriver /usr/local/bin
|
21
|
+
branches:
|
22
|
+
only:
|
23
|
+
- master
|
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 fujinakahara2032@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/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 Fuji Nakahara
|
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,63 @@
|
|
1
|
+
# NarouAgent
|
2
|
+
|
3
|
+
Selenium script for [小説家になろう](https://syosetu.com/) novel management.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'narou_agent'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install narou_agent
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
require 'narou_agent'
|
25
|
+
|
26
|
+
agent = NarouAgent.new(driver: Selenium::WebDriver.for(:chrome))
|
27
|
+
|
28
|
+
# ログイン
|
29
|
+
agent.login!(id: YOUR_ID, password: YOUR_PASSWORD)
|
30
|
+
|
31
|
+
# 連載小説のNコード
|
32
|
+
ncode = 'N8472FC'
|
33
|
+
|
34
|
+
# 次話投稿
|
35
|
+
part_url = agent.create_part(ncode: ncode, subtitle: 'サブタイトル', body: '本文')
|
36
|
+
|
37
|
+
# URL から part_id を抽出
|
38
|
+
part_id = NarouAgent::UrlHelper.extract_part_id(part_url)
|
39
|
+
|
40
|
+
# 編集
|
41
|
+
agent.update_part(ncode: ncode, part_id: part_id, subtitle: '新しいサブタイトル', body: '新しい本文')
|
42
|
+
|
43
|
+
# 削除
|
44
|
+
agent.delete_part(ncode: ncode, part_id: part_id)
|
45
|
+
```
|
46
|
+
|
47
|
+
## Development
|
48
|
+
|
49
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
50
|
+
|
51
|
+
To install this gem onto your local machine, run `bundle exec rake install`. 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).
|
52
|
+
|
53
|
+
## Contributing
|
54
|
+
|
55
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/fuji-nakahara/narou_agent. 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.
|
56
|
+
|
57
|
+
## License
|
58
|
+
|
59
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
60
|
+
|
61
|
+
## Code of Conduct
|
62
|
+
|
63
|
+
Everyone interacting in the NarouAgent project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/fuji-nakahara/narou_agent/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
data/bin/setup
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
class NarouAgent
|
2
|
+
module Actions
|
3
|
+
class CreatePart < Action
|
4
|
+
def run(ncode, subtitle, body, wait_duration)
|
5
|
+
driver.get(new_part_url(ncode))
|
6
|
+
|
7
|
+
driver.find_element(name: 'novel').send_keys(body)
|
8
|
+
driver.find_element(name: 'subtitle').send_keys(subtitle)
|
9
|
+
|
10
|
+
driver.find_element(css: '#ziwainput[value="次話投稿[確認]"]').click
|
11
|
+
driver.find_element(css: '#ziwainput[value="次話投稿[実行]"]').click
|
12
|
+
|
13
|
+
driver.find_element(xpath: '//h2[text()="次話投稿[完了]"]')
|
14
|
+
|
15
|
+
sleep wait_duration
|
16
|
+
|
17
|
+
driver.navigate.to(novel_url(ncode))
|
18
|
+
driver.find_element(link: subtitle).attribute('href')
|
19
|
+
rescue Selenium::WebDriver::Error::WebDriverError => e
|
20
|
+
raise ActionFailedError.new(e)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class NarouAgent
|
2
|
+
module Actions
|
3
|
+
class DeletePart < Action
|
4
|
+
def run(ncode, part_id)
|
5
|
+
driver.get(delete_part_url(ncode, part_id))
|
6
|
+
|
7
|
+
driver.find_element(css: 'input[value="削除[実行]"]').click
|
8
|
+
|
9
|
+
driver.find_element(xpath: '//h2[text()="投稿済み連載小説部分削除[完了]"]')
|
10
|
+
true
|
11
|
+
rescue Selenium::WebDriver::Error::WebDriverError => e
|
12
|
+
raise ActionFailedError.new(e)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class NarouAgent
|
2
|
+
module Actions
|
3
|
+
class Login < Action
|
4
|
+
def run(id, password)
|
5
|
+
driver.get(login_url)
|
6
|
+
|
7
|
+
driver.find_element(name: 'narouid').send_keys(id)
|
8
|
+
driver.find_element(name: 'pass').send_keys(password)
|
9
|
+
|
10
|
+
driver.find_element(id: 'mainsubmit').click
|
11
|
+
|
12
|
+
# Confirm logging in succeeded
|
13
|
+
driver.find_element(id: 'userid')
|
14
|
+
rescue Selenium::WebDriver::Error::WebDriverError => e
|
15
|
+
raise ActionFailedError.new(e)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
class NarouAgent
|
2
|
+
module Actions
|
3
|
+
class UpdatePart < Action
|
4
|
+
def run(ncode, part_id, subtitle, body)
|
5
|
+
driver.get(edit_part_url(ncode, part_id))
|
6
|
+
|
7
|
+
subtitle_input = driver.find_element(name: 'subtitle')
|
8
|
+
subtitle_input.clear
|
9
|
+
subtitle_input.send_keys(subtitle)
|
10
|
+
|
11
|
+
novel_textarea = driver.find_element(name: 'novel')
|
12
|
+
novel_textarea.clear
|
13
|
+
novel_textarea.send_keys(body)
|
14
|
+
|
15
|
+
driver.find_element(css: '#novelmanage[value="編集[確認]"]').click
|
16
|
+
driver.find_element(css: '#novelmanage[value="編集[実行]"]').click
|
17
|
+
|
18
|
+
driver.find_element(xpath: '//h2[text()="投稿済み小説編集[完了]"]')
|
19
|
+
|
20
|
+
part_url(ncode, part_id)
|
21
|
+
rescue Selenium::WebDriver::Error::WebDriverError => e
|
22
|
+
raise ActionFailedError.new(e)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
class NarouAgent
|
2
|
+
module UrlHelper
|
3
|
+
NCODE_PATTERN = /\AN(?<digits>\d{4})(?<alphabets>[A-Z]*)\z/
|
4
|
+
|
5
|
+
class << self
|
6
|
+
# See http://syosetu.com/bbstopic/top/topicid/2733/
|
7
|
+
def ncode_to_i(ncode)
|
8
|
+
match = ncode.upcase.match(NCODE_PATTERN)
|
9
|
+
alphabets = ('A'..'Z').to_a
|
10
|
+
match[:digits].to_i + match[:alphabets].chars.reverse.each_with_index.inject(0) do |sum, (alphabet, i)|
|
11
|
+
sum += 9999 * alphabets.index(alphabet) * (alphabets.size ** i)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def extract_part_id(url)
|
16
|
+
url[%r{noveldataid/(\d+)}, 1]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def login_url
|
23
|
+
"#{base_url}/login/input/"
|
24
|
+
end
|
25
|
+
|
26
|
+
def novel_url(ncode)
|
27
|
+
"#{base_url}/usernovelmanage/top/ncode/#{UrlHelper.ncode_to_i(ncode)}/"
|
28
|
+
end
|
29
|
+
|
30
|
+
def part_url(ncode, id)
|
31
|
+
"#{base_url}/usernoveldatamanage/top/ncode/#{UrlHelper.ncode_to_i(ncode)}/noveldataid/#{id}/"
|
32
|
+
end
|
33
|
+
|
34
|
+
def new_part_url(ncode)
|
35
|
+
"#{base_url}/usernovelmanage/ziwainput/ncode/#{UrlHelper.ncode_to_i(ncode)}}/"
|
36
|
+
end
|
37
|
+
|
38
|
+
def edit_part_url(ncode, id)
|
39
|
+
"#{base_url}/usernoveldatamanage/updateinput/ncode/#{UrlHelper.ncode_to_i(ncode)}/noveldataid/#{id}/"
|
40
|
+
end
|
41
|
+
|
42
|
+
def delete_part_url(ncode, id)
|
43
|
+
"#{base_url}/usernoveldatamanage/deleteconfirm/ncode/#{UrlHelper.ncode_to_i(ncode)}/noveldataid/#{id}/"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
data/lib/narou_agent.rb
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'selenium-webdriver'
|
2
|
+
|
3
|
+
require_relative 'narou_agent/url_helper'
|
4
|
+
require_relative 'narou_agent/action'
|
5
|
+
require_relative 'narou_agent/error'
|
6
|
+
require_relative 'narou_agent/version'
|
7
|
+
|
8
|
+
require_relative 'narou_agent/actions/login'
|
9
|
+
require_relative 'narou_agent/actions/create_part'
|
10
|
+
require_relative 'narou_agent/actions/update_part'
|
11
|
+
require_relative 'narou_agent/actions/delete_part'
|
12
|
+
|
13
|
+
class NarouAgent
|
14
|
+
BASE_URL = 'https://syosetu.com'
|
15
|
+
|
16
|
+
DEFAULT_WAIT_DURATION = 30
|
17
|
+
|
18
|
+
attr_reader :base_url, :driver
|
19
|
+
|
20
|
+
def initialize(base_url: BASE_URL, driver: Selenium::WebDriver.for(:chrome))
|
21
|
+
@base_url = base_url
|
22
|
+
@driver = driver
|
23
|
+
@logged_in = false
|
24
|
+
end
|
25
|
+
|
26
|
+
def logged_in?
|
27
|
+
@logged_in
|
28
|
+
end
|
29
|
+
|
30
|
+
def login!(id:, password:)
|
31
|
+
Actions::Login.new(self).run(id, password)
|
32
|
+
@logged_in = true
|
33
|
+
end
|
34
|
+
|
35
|
+
def create_part(ncode:, subtitle:, body:, wait_duration: DEFAULT_WAIT_DURATION)
|
36
|
+
raise NotLoggedInError unless logged_in?
|
37
|
+
Actions::CreatePart.new(self).run(ncode, subtitle, body, wait_duration)
|
38
|
+
end
|
39
|
+
|
40
|
+
def update_part(ncode:, part_id:, subtitle:, body:)
|
41
|
+
raise NotLoggedInError unless logged_in?
|
42
|
+
Actions::UpdatePart.new(self).run(ncode, part_id, subtitle, body)
|
43
|
+
end
|
44
|
+
|
45
|
+
def delete_part(ncode:, part_id:)
|
46
|
+
raise NotLoggedInError unless logged_in?
|
47
|
+
Actions::DeletePart.new(self).run(ncode, part_id)
|
48
|
+
end
|
49
|
+
end
|
data/narou_agent.gemspec
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'narou_agent/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'narou_agent'
|
8
|
+
spec.version = NarouAgent::VERSION
|
9
|
+
spec.authors = ['Fuji Nakahara']
|
10
|
+
spec.email = ['fujinakahara2032@gmail.com']
|
11
|
+
|
12
|
+
spec.summary = 'Selenium script for Narou novel management'
|
13
|
+
spec.homepage = 'https://github.com/fuji-nakahara/narou_agent'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
# Specify which files should be added to the gem when it is released.
|
17
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
18
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
19
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
20
|
+
end
|
21
|
+
spec.bindir = 'exe'
|
22
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
|
+
spec.require_paths = ['lib']
|
24
|
+
|
25
|
+
spec.add_dependency 'selenium-webdriver', '~> 3.0'
|
26
|
+
|
27
|
+
spec.add_development_dependency 'bundler', '~> 1.17'
|
28
|
+
spec.add_development_dependency 'dotenv', '~> 2.5'
|
29
|
+
spec.add_development_dependency 'meowcop', '~> 1.17'
|
30
|
+
spec.add_development_dependency 'pry', '>= 0.12'
|
31
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
32
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
33
|
+
end
|
metadata
ADDED
@@ -0,0 +1,164 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: narou_agent
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Fuji Nakahara
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-11-11 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: selenium-webdriver
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.17'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.17'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: dotenv
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.5'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.5'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: meowcop
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.17'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.17'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: pry
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0.12'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0.12'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rake
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '10.0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '10.0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rspec
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '3.0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '3.0'
|
111
|
+
description:
|
112
|
+
email:
|
113
|
+
- fujinakahara2032@gmail.com
|
114
|
+
executables: []
|
115
|
+
extensions: []
|
116
|
+
extra_rdoc_files: []
|
117
|
+
files:
|
118
|
+
- ".env.sample"
|
119
|
+
- ".gitignore"
|
120
|
+
- ".rspec"
|
121
|
+
- ".rubocop.yml"
|
122
|
+
- ".travis.yml"
|
123
|
+
- CODE_OF_CONDUCT.md
|
124
|
+
- Gemfile
|
125
|
+
- LICENSE.txt
|
126
|
+
- README.md
|
127
|
+
- Rakefile
|
128
|
+
- bin/console
|
129
|
+
- bin/setup
|
130
|
+
- lib/narou_agent.rb
|
131
|
+
- lib/narou_agent/action.rb
|
132
|
+
- lib/narou_agent/actions/create_part.rb
|
133
|
+
- lib/narou_agent/actions/delete_part.rb
|
134
|
+
- lib/narou_agent/actions/login.rb
|
135
|
+
- lib/narou_agent/actions/update_part.rb
|
136
|
+
- lib/narou_agent/error.rb
|
137
|
+
- lib/narou_agent/url_helper.rb
|
138
|
+
- lib/narou_agent/version.rb
|
139
|
+
- narou_agent.gemspec
|
140
|
+
homepage: https://github.com/fuji-nakahara/narou_agent
|
141
|
+
licenses:
|
142
|
+
- MIT
|
143
|
+
metadata: {}
|
144
|
+
post_install_message:
|
145
|
+
rdoc_options: []
|
146
|
+
require_paths:
|
147
|
+
- lib
|
148
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
154
|
+
requirements:
|
155
|
+
- - ">="
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: '0'
|
158
|
+
requirements: []
|
159
|
+
rubyforge_project:
|
160
|
+
rubygems_version: 2.7.6
|
161
|
+
signing_key:
|
162
|
+
specification_version: 4
|
163
|
+
summary: Selenium script for Narou novel management
|
164
|
+
test_files: []
|