narou_agent 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/narou_agent.rb +4 -4
- data/lib/narou_agent/actions/create_part.rb +9 -2
- data/lib/narou_agent/actions/update_part.rb +15 -7
- data/lib/narou_agent/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 56fd3d8fd44edffb590ebaba8bfe2071ecd1e55295819e741fde05fbf00dbdb7
|
|
4
|
+
data.tar.gz: 74199069044c56d567a855eb4550f37b132d2a1e0c7ac9ddde39a071074e6220
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: adc52215e6ec5e24900f2e00a979433ad4cfadfa2c0d0509226281c4980a2f28c9229c4643e18447606cd640f771f8cdd23a0fe3a537df923418de9fd1564e93
|
|
7
|
+
data.tar.gz: d493a87d7c0536b2840aa24c1582ac43b1fcdf60511946da7d29a35f22b0c2b388fd9ae579eda5dddc23f012706521c0e5babf5faec8d862c7a9d694b1ba224c
|
data/lib/narou_agent.rb
CHANGED
|
@@ -32,14 +32,14 @@ class NarouAgent
|
|
|
32
32
|
@logged_in = true
|
|
33
33
|
end
|
|
34
34
|
|
|
35
|
-
def create_part(ncode:, subtitle:, body:, wait_duration: DEFAULT_WAIT_DURATION)
|
|
35
|
+
def create_part(ncode:, subtitle:, body:, date: nil, wait_duration: DEFAULT_WAIT_DURATION)
|
|
36
36
|
raise NotLoggedInError unless logged_in?
|
|
37
|
-
Actions::CreatePart.new(self).run(ncode, subtitle, body, wait_duration)
|
|
37
|
+
Actions::CreatePart.new(self).run(ncode, subtitle, body, date, wait_duration)
|
|
38
38
|
end
|
|
39
39
|
|
|
40
|
-
def update_part(ncode:, part_id:, subtitle:, body:)
|
|
40
|
+
def update_part(ncode:, part_id:, subtitle:, body:, date: nil)
|
|
41
41
|
raise NotLoggedInError unless logged_in?
|
|
42
|
-
Actions::UpdatePart.new(self).run(ncode, part_id, subtitle, body)
|
|
42
|
+
Actions::UpdatePart.new(self).run(ncode, part_id, subtitle, body, date)
|
|
43
43
|
end
|
|
44
44
|
|
|
45
45
|
def delete_part(ncode:, part_id:)
|
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
class NarouAgent
|
|
2
2
|
module Actions
|
|
3
3
|
class CreatePart < Action
|
|
4
|
-
def run(ncode, subtitle, body, wait_duration)
|
|
4
|
+
def run(ncode, subtitle, body, date = nil, wait_duration = NarouAgent::DEFAULT_WAIT_DURATION)
|
|
5
5
|
driver.get(new_part_url(ncode))
|
|
6
6
|
|
|
7
7
|
driver.find_element(name: 'novel').send_keys(body)
|
|
8
8
|
driver.find_element(name: 'subtitle').send_keys(subtitle)
|
|
9
9
|
|
|
10
|
+
if !date.nil? && date > Time.now
|
|
11
|
+
driver.script <<~JAVASCRIPT
|
|
12
|
+
$('.hasDatepicker').datepicker('setDate', new Date('#{date.strftime('%F')}'));
|
|
13
|
+
JAVASCRIPT
|
|
14
|
+
Selenium::WebDriver::Support::Select.new(driver.find_element(:name, 'hour')).select_by(:value, date.hour.to_s)
|
|
15
|
+
end
|
|
16
|
+
|
|
10
17
|
driver.find_element(css: '#ziwainput[value="次話投稿[確認]"]').click
|
|
11
18
|
driver.find_element(css: '#ziwainput[value="次話投稿[実行]"]').click
|
|
12
19
|
|
|
@@ -15,7 +22,7 @@ class NarouAgent
|
|
|
15
22
|
sleep wait_duration
|
|
16
23
|
|
|
17
24
|
driver.navigate.to(novel_url(ncode))
|
|
18
|
-
driver.find_element(link: subtitle)
|
|
25
|
+
driver.find_element(link: subtitle)['href']
|
|
19
26
|
rescue Selenium::WebDriver::Error::WebDriverError => e
|
|
20
27
|
raise ActionFailedError.new(e)
|
|
21
28
|
end
|
|
@@ -1,16 +1,24 @@
|
|
|
1
1
|
class NarouAgent
|
|
2
2
|
module Actions
|
|
3
3
|
class UpdatePart < Action
|
|
4
|
-
def run(ncode, part_id, subtitle, body)
|
|
4
|
+
def run(ncode, part_id, subtitle, body, date = nil)
|
|
5
5
|
driver.get(edit_part_url(ncode, part_id))
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
driver.find_element(name: 'subtitle').tap do |subtitle_input|
|
|
8
|
+
subtitle_input.clear
|
|
9
|
+
subtitle_input.send_keys(subtitle)
|
|
10
|
+
end
|
|
11
|
+
driver.find_element(name: 'novel').tap do |novel_textarea|
|
|
12
|
+
novel_textarea.clear
|
|
13
|
+
novel_textarea.send_keys(body)
|
|
14
|
+
end
|
|
10
15
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
16
|
+
if !date.nil? && date > Time.now
|
|
17
|
+
driver.script <<~JAVASCRIPT
|
|
18
|
+
$('.hasDatepicker').datepicker('setDate', new Date('#{date.strftime('%F')}'));
|
|
19
|
+
JAVASCRIPT
|
|
20
|
+
Selenium::WebDriver::Support::Select.new(driver.find_element(:name, 'hour')).select_by(:value, date.hour.to_s)
|
|
21
|
+
end
|
|
14
22
|
|
|
15
23
|
driver.find_element(css: '#novelmanage[value="編集[確認]"]').click
|
|
16
24
|
driver.find_element(css: '#novelmanage[value="編集[実行]"]').click
|
data/lib/narou_agent/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: narou_agent
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Fuji Nakahara
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2018-
|
|
11
|
+
date: 2018-12-09 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: selenium-webdriver
|