wptools 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 1ddeb1b767f1426f863a2678bc9e6bf19bb2d2867d9146cc2c3a526acf8f8ee8
4
+ data.tar.gz: 655dd3b03427e70da5478e5b0380413729451c65590136987a1a0c2ae45a9912
5
+ SHA512:
6
+ metadata.gz: 4252d06263fcb85268930604f4b317a14ad9630203429becedff3100e8c206e6538f04e62d32728472b376ca04a63948a99b1809f391190f048b9bdacedc5227
7
+ data.tar.gz: 17bc9bb5d2ea5877372c11f864a3d79fd54f527396757b0182d301e77b29d8d3db1aae8f13079b5090a3270d798836b94d7bb4cd7e69bfd2ea2b683de53b0bcf
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ /out/
10
+ /vendor/
11
+ .DS_Store
12
+ /config/*
13
+ /data/*
14
+ !/config/config_sample.yml
15
+
16
+
17
+
18
+
data/.idea/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ # Default ignored files
2
+ /shelf/
3
+ /workspace.xml
4
+ # Editor-based HTTP Client requests
5
+ /httpRequests/
6
+ # Datasource local storage ignored files
7
+ /dataSources/
8
+ /dataSources.local.xml
data/.idea/modules.xml ADDED
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/wptools.iml" filepath="$PROJECT_DIR$/.idea/wptools.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
data/.idea/vcs.xml ADDED
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="" vcs="Git" />
5
+ </component>
6
+ </project>
data/.idea/wptools.iml ADDED
@@ -0,0 +1,270 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="RUBY_MODULE" version="4">
3
+ <component name="ModuleRunConfigurationManager">
4
+ <shared />
5
+ </component>
6
+ <component name="NewModuleRootManager">
7
+ <content url="file://$MODULE_DIR$">
8
+ <sourceFolder url="file://$MODULE_DIR$/features" isTestSource="true" />
9
+ <sourceFolder url="file://$MODULE_DIR$/spec" isTestSource="true" />
10
+ <sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
11
+ </content>
12
+ <orderEntry type="jdk" jdkName="rbenv: 3.1.4" jdkType="RUBY_SDK" />
13
+ <orderEntry type="sourceFolder" forTests="false" />
14
+ <orderEntry type="module-library">
15
+ <library name="activemodel (v7.1.3.2) [path][gem]" type="rubylib">
16
+ <properties>
17
+ <option name="version" value="4" />
18
+ </properties>
19
+ <CLASSES>
20
+ <root url="file://$MODULE_DIR$/vendor/bundle/ruby/3.1.0/gems/activemodel-7.1.3.2/lib" />
21
+ </CLASSES>
22
+ <JAVADOC />
23
+ <SOURCES>
24
+ <root url="file://$MODULE_DIR$/vendor/bundle/ruby/3.1.0/gems/activemodel-7.1.3.2/lib" />
25
+ </SOURCES>
26
+ </library>
27
+ </orderEntry>
28
+ <orderEntry type="module-library">
29
+ <library name="activerecord (v7.1.3.2) [path][gem]" type="rubylib">
30
+ <properties>
31
+ <option name="version" value="4" />
32
+ </properties>
33
+ <CLASSES>
34
+ <root url="file://$MODULE_DIR$/vendor/bundle/ruby/3.1.0/gems/activerecord-7.1.3.2/lib" />
35
+ <root url="file://$MODULE_DIR$/vendor/bundle/ruby/3.1.0/gems/activerecord-7.1.3.2/examples" />
36
+ </CLASSES>
37
+ <JAVADOC />
38
+ <SOURCES>
39
+ <root url="file://$MODULE_DIR$/vendor/bundle/ruby/3.1.0/gems/activerecord-7.1.3.2/lib" />
40
+ <root url="file://$MODULE_DIR$/vendor/bundle/ruby/3.1.0/gems/activerecord-7.1.3.2/examples" />
41
+ </SOURCES>
42
+ <excluded>
43
+ <root url="file://$MODULE_DIR$/vendor/bundle/ruby/3.1.0/gems/activerecord-7.1.3.2/examples" />
44
+ </excluded>
45
+ </library>
46
+ </orderEntry>
47
+ <orderEntry type="module-library">
48
+ <library name="activesupport (v7.1.3.2) [path][gem]" type="rubylib">
49
+ <properties>
50
+ <option name="version" value="4" />
51
+ </properties>
52
+ <CLASSES>
53
+ <root url="file://$MODULE_DIR$/vendor/bundle/ruby/3.1.0/gems/activesupport-7.1.3.2/lib" />
54
+ </CLASSES>
55
+ <JAVADOC />
56
+ <SOURCES>
57
+ <root url="file://$MODULE_DIR$/vendor/bundle/ruby/3.1.0/gems/activesupport-7.1.3.2/lib" />
58
+ </SOURCES>
59
+ </library>
60
+ </orderEntry>
61
+ <orderEntry type="module-library">
62
+ <library name="base64 (v0.2.0) [path][gem]" type="rubylib">
63
+ <properties>
64
+ <option name="version" value="4" />
65
+ </properties>
66
+ <CLASSES>
67
+ <root url="file://$MODULE_DIR$/vendor/bundle/ruby/3.1.0/gems/base64-0.2.0/lib" />
68
+ </CLASSES>
69
+ <JAVADOC />
70
+ <SOURCES>
71
+ <root url="file://$MODULE_DIR$/vendor/bundle/ruby/3.1.0/gems/base64-0.2.0/lib" />
72
+ </SOURCES>
73
+ </library>
74
+ </orderEntry>
75
+ <orderEntry type="module-library">
76
+ <library name="bigdecimal (v3.1.6) [path][gem]" type="rubylib">
77
+ <properties>
78
+ <option name="version" value="4" />
79
+ </properties>
80
+ <CLASSES>
81
+ <root url="file://$MODULE_DIR$/vendor/bundle/ruby/3.1.0/gems/bigdecimal-3.1.6/ext" />
82
+ <root url="file://$MODULE_DIR$/vendor/bundle/ruby/3.1.0/gems/bigdecimal-3.1.6/lib" />
83
+ <root url="file://$MODULE_DIR$/vendor/bundle/ruby/3.1.0/gems/bigdecimal-3.1.6/sample" />
84
+ </CLASSES>
85
+ <JAVADOC />
86
+ <SOURCES>
87
+ <root url="file://$MODULE_DIR$/vendor/bundle/ruby/3.1.0/gems/bigdecimal-3.1.6/ext" />
88
+ <root url="file://$MODULE_DIR$/vendor/bundle/ruby/3.1.0/gems/bigdecimal-3.1.6/lib" />
89
+ <root url="file://$MODULE_DIR$/vendor/bundle/ruby/3.1.0/gems/bigdecimal-3.1.6/sample" />
90
+ </SOURCES>
91
+ <excluded>
92
+ <root url="file://$MODULE_DIR$/vendor/bundle/ruby/3.1.0/gems/bigdecimal-3.1.6/ext" />
93
+ <root url="file://$MODULE_DIR$/vendor/bundle/ruby/3.1.0/gems/bigdecimal-3.1.6/sample" />
94
+ </excluded>
95
+ </library>
96
+ </orderEntry>
97
+ <orderEntry type="module-library">
98
+ <library name="concurrent-ruby (v1.2.3) [path][gem]" type="rubylib">
99
+ <properties>
100
+ <option name="version" value="4" />
101
+ </properties>
102
+ <CLASSES>
103
+ <root url="file://$MODULE_DIR$/vendor/bundle/ruby/3.1.0/gems/concurrent-ruby-1.2.3/ext" />
104
+ <root url="file://$MODULE_DIR$/vendor/bundle/ruby/3.1.0/gems/concurrent-ruby-1.2.3/lib" />
105
+ </CLASSES>
106
+ <JAVADOC />
107
+ <SOURCES>
108
+ <root url="file://$MODULE_DIR$/vendor/bundle/ruby/3.1.0/gems/concurrent-ruby-1.2.3/ext" />
109
+ <root url="file://$MODULE_DIR$/vendor/bundle/ruby/3.1.0/gems/concurrent-ruby-1.2.3/lib" />
110
+ </SOURCES>
111
+ <excluded>
112
+ <root url="file://$MODULE_DIR$/vendor/bundle/ruby/3.1.0/gems/concurrent-ruby-1.2.3/ext" />
113
+ </excluded>
114
+ </library>
115
+ </orderEntry>
116
+ <orderEntry type="module-library">
117
+ <library name="connection_pool (v2.4.1) [path][gem]" type="rubylib">
118
+ <properties>
119
+ <option name="version" value="4" />
120
+ </properties>
121
+ <CLASSES>
122
+ <root url="file://$MODULE_DIR$/vendor/bundle/ruby/3.1.0/gems/connection_pool-2.4.1/lib" />
123
+ </CLASSES>
124
+ <JAVADOC />
125
+ <SOURCES>
126
+ <root url="file://$MODULE_DIR$/vendor/bundle/ruby/3.1.0/gems/connection_pool-2.4.1/lib" />
127
+ </SOURCES>
128
+ </library>
129
+ </orderEntry>
130
+ <orderEntry type="module-library">
131
+ <library name="drb (v2.2.1) [path][gem]" type="rubylib">
132
+ <properties>
133
+ <option name="version" value="4" />
134
+ </properties>
135
+ <CLASSES>
136
+ <root url="file://$MODULE_DIR$/vendor/bundle/ruby/3.1.0/gems/drb-2.2.1/lib" />
137
+ </CLASSES>
138
+ <JAVADOC />
139
+ <SOURCES>
140
+ <root url="file://$MODULE_DIR$/vendor/bundle/ruby/3.1.0/gems/drb-2.2.1/lib" />
141
+ </SOURCES>
142
+ </library>
143
+ </orderEntry>
144
+ <orderEntry type="module-library">
145
+ <library name="i18n (v1.14.1) [path][gem]" type="rubylib">
146
+ <properties>
147
+ <option name="version" value="4" />
148
+ </properties>
149
+ <CLASSES>
150
+ <root url="file://$MODULE_DIR$/vendor/bundle/ruby/3.1.0/gems/i18n-1.14.1/lib" />
151
+ </CLASSES>
152
+ <JAVADOC />
153
+ <SOURCES>
154
+ <root url="file://$MODULE_DIR$/vendor/bundle/ruby/3.1.0/gems/i18n-1.14.1/lib" />
155
+ </SOURCES>
156
+ </library>
157
+ </orderEntry>
158
+ <orderEntry type="module-library">
159
+ <library name="minitest (v5.22.2) [path][gem]" type="rubylib">
160
+ <properties>
161
+ <option name="version" value="4" />
162
+ </properties>
163
+ <CLASSES>
164
+ <root url="file://$MODULE_DIR$/vendor/bundle/ruby/3.1.0/gems/minitest-5.22.2/lib" />
165
+ <root url="file://$MODULE_DIR$/vendor/bundle/ruby/3.1.0/gems/minitest-5.22.2/test" />
166
+ </CLASSES>
167
+ <JAVADOC />
168
+ <SOURCES>
169
+ <root url="file://$MODULE_DIR$/vendor/bundle/ruby/3.1.0/gems/minitest-5.22.2/lib" />
170
+ <root url="file://$MODULE_DIR$/vendor/bundle/ruby/3.1.0/gems/minitest-5.22.2/test" />
171
+ </SOURCES>
172
+ <excluded>
173
+ <root url="file://$MODULE_DIR$/vendor/bundle/ruby/3.1.0/gems/minitest-5.22.2/test" />
174
+ </excluded>
175
+ </library>
176
+ </orderEntry>
177
+ <orderEntry type="module-library">
178
+ <library name="mutex_m (v0.2.0) [path][gem]" type="rubylib">
179
+ <properties>
180
+ <option name="version" value="4" />
181
+ </properties>
182
+ <CLASSES>
183
+ <root url="file://$MODULE_DIR$/vendor/bundle/ruby/3.1.0/gems/mutex_m-0.2.0/lib" />
184
+ </CLASSES>
185
+ <JAVADOC />
186
+ <SOURCES>
187
+ <root url="file://$MODULE_DIR$/vendor/bundle/ruby/3.1.0/gems/mutex_m-0.2.0/lib" />
188
+ </SOURCES>
189
+ </library>
190
+ </orderEntry>
191
+ <orderEntry type="module-library">
192
+ <library name="mysql2 (v0.5.6) [path][gem]" type="rubylib">
193
+ <properties>
194
+ <option name="version" value="4" />
195
+ </properties>
196
+ <CLASSES>
197
+ <root url="file://$MODULE_DIR$/vendor/bundle/ruby/3.1.0/gems/mysql2-0.5.6/ext" />
198
+ <root url="file://$MODULE_DIR$/vendor/bundle/ruby/3.1.0/gems/mysql2-0.5.6/lib" />
199
+ <root url="file://$MODULE_DIR$/vendor/bundle/ruby/3.1.0/gems/mysql2-0.5.6/support" />
200
+ </CLASSES>
201
+ <JAVADOC />
202
+ <SOURCES>
203
+ <root url="file://$MODULE_DIR$/vendor/bundle/ruby/3.1.0/gems/mysql2-0.5.6/ext" />
204
+ <root url="file://$MODULE_DIR$/vendor/bundle/ruby/3.1.0/gems/mysql2-0.5.6/lib" />
205
+ <root url="file://$MODULE_DIR$/vendor/bundle/ruby/3.1.0/gems/mysql2-0.5.6/support" />
206
+ </SOURCES>
207
+ <excluded>
208
+ <root url="file://$MODULE_DIR$/vendor/bundle/ruby/3.1.0/gems/mysql2-0.5.6/ext" />
209
+ <root url="file://$MODULE_DIR$/vendor/bundle/ruby/3.1.0/gems/mysql2-0.5.6/support" />
210
+ </excluded>
211
+ </library>
212
+ </orderEntry>
213
+ <orderEntry type="module-library">
214
+ <library name="rake (v10.5.0) [path][gem]" type="rubylib">
215
+ <properties>
216
+ <option name="version" value="4" />
217
+ </properties>
218
+ <CLASSES>
219
+ <root url="file://$MODULE_DIR$/vendor/bundle/ruby/3.1.0/gems/rake-10.5.0/bin" />
220
+ <root url="file://$MODULE_DIR$/vendor/bundle/ruby/3.1.0/gems/rake-10.5.0/doc" />
221
+ <root url="file://$MODULE_DIR$/vendor/bundle/ruby/3.1.0/gems/rake-10.5.0/lib" />
222
+ <root url="file://$MODULE_DIR$/vendor/bundle/ruby/3.1.0/gems/rake-10.5.0/test" />
223
+ <root url="file://$MODULE_DIR$/vendor/bundle/ruby/3.1.0/gems/rake-10.5.0/rakelib" />
224
+ </CLASSES>
225
+ <JAVADOC />
226
+ <SOURCES>
227
+ <root url="file://$MODULE_DIR$/vendor/bundle/ruby/3.1.0/gems/rake-10.5.0/bin" />
228
+ <root url="file://$MODULE_DIR$/vendor/bundle/ruby/3.1.0/gems/rake-10.5.0/doc" />
229
+ <root url="file://$MODULE_DIR$/vendor/bundle/ruby/3.1.0/gems/rake-10.5.0/lib" />
230
+ <root url="file://$MODULE_DIR$/vendor/bundle/ruby/3.1.0/gems/rake-10.5.0/test" />
231
+ <root url="file://$MODULE_DIR$/vendor/bundle/ruby/3.1.0/gems/rake-10.5.0/rakelib" />
232
+ </SOURCES>
233
+ <excluded>
234
+ <root url="file://$MODULE_DIR$/vendor/bundle/ruby/3.1.0/gems/rake-10.5.0/bin" />
235
+ <root url="file://$MODULE_DIR$/vendor/bundle/ruby/3.1.0/gems/rake-10.5.0/doc" />
236
+ <root url="file://$MODULE_DIR$/vendor/bundle/ruby/3.1.0/gems/rake-10.5.0/test" />
237
+ <root url="file://$MODULE_DIR$/vendor/bundle/ruby/3.1.0/gems/rake-10.5.0/rakelib" />
238
+ </excluded>
239
+ </library>
240
+ </orderEntry>
241
+ <orderEntry type="module-library">
242
+ <library name="timeout (v0.4.1) [path][gem]" type="rubylib">
243
+ <properties>
244
+ <option name="version" value="4" />
245
+ </properties>
246
+ <CLASSES>
247
+ <root url="file://$MODULE_DIR$/vendor/bundle/ruby/3.1.0/gems/timeout-0.4.1/lib" />
248
+ </CLASSES>
249
+ <JAVADOC />
250
+ <SOURCES>
251
+ <root url="file://$MODULE_DIR$/vendor/bundle/ruby/3.1.0/gems/timeout-0.4.1/lib" />
252
+ </SOURCES>
253
+ </library>
254
+ </orderEntry>
255
+ <orderEntry type="module-library">
256
+ <library name="tzinfo (v2.0.6) [path][gem]" type="rubylib">
257
+ <properties>
258
+ <option name="version" value="4" />
259
+ </properties>
260
+ <CLASSES>
261
+ <root url="file://$MODULE_DIR$/vendor/bundle/ruby/3.1.0/gems/tzinfo-2.0.6/lib" />
262
+ </CLASSES>
263
+ <JAVADOC />
264
+ <SOURCES>
265
+ <root url="file://$MODULE_DIR$/vendor/bundle/ruby/3.1.0/gems/tzinfo-2.0.6/lib" />
266
+ </SOURCES>
267
+ </library>
268
+ </orderEntry>
269
+ </component>
270
+ </module>
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.6.5
7
+ before_install: gem install bundler -v 2.0.2
@@ -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 src@srcw.net. 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
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in wptools.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,52 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ wptools (0.1.0)
5
+ activerecord
6
+ mysql2
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ activemodel (7.1.3.2)
12
+ activesupport (= 7.1.3.2)
13
+ activerecord (7.1.3.2)
14
+ activemodel (= 7.1.3.2)
15
+ activesupport (= 7.1.3.2)
16
+ timeout (>= 0.4.0)
17
+ activesupport (7.1.3.2)
18
+ base64
19
+ bigdecimal
20
+ concurrent-ruby (~> 1.0, >= 1.0.2)
21
+ connection_pool (>= 2.2.5)
22
+ drb
23
+ i18n (>= 1.6, < 2)
24
+ minitest (>= 5.1)
25
+ mutex_m
26
+ tzinfo (~> 2.0)
27
+ base64 (0.2.0)
28
+ bigdecimal (3.1.6)
29
+ concurrent-ruby (1.2.3)
30
+ connection_pool (2.4.1)
31
+ drb (2.2.1)
32
+ i18n (1.14.1)
33
+ concurrent-ruby (~> 1.0)
34
+ minitest (5.22.2)
35
+ mutex_m (0.2.0)
36
+ mysql2 (0.5.6)
37
+ rake (10.5.0)
38
+ timeout (0.4.1)
39
+ tzinfo (2.0.6)
40
+ concurrent-ruby (~> 1.0)
41
+
42
+ PLATFORMS
43
+ ruby
44
+
45
+ DEPENDENCIES
46
+ bundler (~> 2.0)
47
+ minitest (~> 5.0)
48
+ rake (~> 10.0)
49
+ wptools!
50
+
51
+ BUNDLED WITH
52
+ 2.4.20
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 src
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,39 @@
1
+ wptools
2
+ ==============
3
+
4
+ WordPressのテーブルを扱うスクリプト
5
+
6
+ ## 実行環境
7
+
8
+ - macOS
9
+ - Ruby
10
+ - MySQL
11
+
12
+ ## インストール方法
13
+
14
+ 適当なフォルダに展開してbuild.shを実行。
15
+
16
+ ## 使用方法
17
+
18
+ ### 記事一覧の表示
19
+
20
+ - 以下のコマンドを実行
21
+ ```
22
+ ./test_wptools.sh -l # 起動スクリプトを使う場合
23
+ ```
24
+
25
+ ### バズった記事の表示
26
+
27
+ - DBから取得したページ一覧とGoogleAnalyticsのCSVデータを突き合わせる
28
+ - Googleアナリスティックスで「行動 > サイトコンテンツ > すべてのページ」を開く。
29
+ -期間を月単位で指定して表示する行数を5000に。CSV形式でエクスポートを実行。
30
+ - 以下のコマンドで実行
31
+ ```
32
+ ./test_wptools.sh -b data/Analytics_sablog_20200201-20200229.csv
33
+ ```
34
+ - 結果をGoogleスプレッドシートに貼り付け。貼り付けたあと右下のメニューから列を選択すればCSV形式になる。
35
+
36
+
37
+ ## ライセンス
38
+
39
+ [MIT](https://github.com/tcnksm/tool/blob/master/LICENCE)
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList["test/**/*_test.rb"]
8
+ end
9
+
10
+ task :default => :test
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "wptools"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/build.sh ADDED
@@ -0,0 +1,24 @@
1
+ #!/bin/sh
2
+ # rmagick for sierra
3
+ export PKG_CONFIG_PATH=/usr/local/opt/imagemagick@6/lib/pkgconfig
4
+ #export PATH=/usr/local/Cellar/imagemagick@6/6.9.7-5/bin:$PATH
5
+
6
+ if [ -d "/opt/local/lib" ]; then
7
+ bundle config --local build.mysql2 "--with-ldflags=-L/opt/local/lib"
8
+ else
9
+ bundle config --delete build.mysql2
10
+ fi
11
+
12
+ bundle_dir=./vendor/bundle
13
+ if [ -d "$bundle_dir" ] ; then
14
+ /bin/rm -rf "$bundle_dir"
15
+ bundle update
16
+ else
17
+ /bin/rm -rf "$bundle_dir"
18
+ bundle install --path "$bundle_dir"
19
+ fi
20
+
21
+
22
+
23
+
24
+
@@ -0,0 +1,5 @@
1
+ local:
2
+ dbuser: testuser
3
+ dbpasswd: testpasswd
4
+ dbname: testdb
5
+
data/exe/wptest ADDED
@@ -0,0 +1,3 @@
1
+ require "wptools"
2
+
3
+ STDOUT.sync = true
data/exe/wptools ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "wptools"
4
+
5
+ STDOUT.sync = true
6
+ Wptools::Command.run(ARGV)
7
+
@@ -0,0 +1,3 @@
1
+ module Wptools
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,53 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ require 'active_record'
4
+
5
+ module Wptools
6
+
7
+ ##### wp_posts: 投稿などを保存
8
+ # id: 投稿ID
9
+ # post_title: タイトル
10
+ # post_content: 本文
11
+ # post_status: 公開情報
12
+ # post_date: 公開日時(Timeクラス。2020-03-19 11:00:08 UTCと表示されるが実際は日本の時刻?)
13
+ # post_name: slug(テーブル全体でユニーク https://wordpress.stackexchange.com/questions/305371/how-to-add-two-same-slug-under-two-category)
14
+ class WpPost < ActiveRecord::Base
15
+ # has_many :wp_comments, foreign_key: :comment_post_ID
16
+ has_many :wp_term_relationships, foreign_key: :object_id
17
+ has_many :wp_term_taxonomies, through: :wp_term_relationships
18
+
19
+ scope :posts, -> { where(post_type: 'post') }
20
+ scope :published, -> { where(post_status: 'publish')}
21
+
22
+ STATUS_PUBLISHED = 'publish'
23
+ STATUS_FUTURE = 'future'
24
+ STATUS_DRAFT = 'draft'
25
+ STATUS_PENDING = 'pending'
26
+ STATUS_PRIVATE = 'private'
27
+ STATUS_TRASH = 'trash'
28
+ STATUS_AUTO_DRAFT = 'auto-draft'
29
+ STATUS_INHERIT = 'inherit'
30
+
31
+ def self.published_posts
32
+ where(post_type: 'post', post_status: STATUS_PUBLISHED)
33
+ end
34
+
35
+ def tags
36
+ wp_term_taxonomies.tags.map { |wp_term_taxonomy| wp_term_taxonomy.list }.flatten
37
+ end
38
+
39
+ def categories
40
+ wp_term_taxonomies.categories.map { |wp_term_taxonomy| wp_term_taxonomy.list }.flatten
41
+ end
42
+
43
+ def post_date_str
44
+ post_date.strftime("%Y/%m/%d %H:%M:%S")
45
+ end
46
+
47
+ def dispose
48
+ # 状態をtrashに変更
49
+ self.post_status = STATUS_TRASH
50
+ end
51
+ end
52
+ end
53
+
@@ -0,0 +1,9 @@
1
+ require 'active_record'
2
+
3
+ module Wptools
4
+ class WpTermRelationship < ActiveRecord::Base
5
+ belongs_to :wp_post, foreign_key: :object_id
6
+ belongs_to :wp_term_taxonomy, foreign_key: :term_taxonomy_id
7
+ end
8
+
9
+ end
@@ -0,0 +1,17 @@
1
+ require 'active_record'
2
+
3
+ module Wptools
4
+ class WpTermTaxnomy < ActiveRecord::Base
5
+ self.table_name = 'wp_term_taxonomy'
6
+ has_many :wp_terms, foreign_key: :term_id
7
+ has_many :wp_term_relationships, foreign_key: :term_taxonomy_id
8
+ has_many :wp_posts, through: :wp_term_relationships
9
+
10
+ scope :tags, -> { where(taxonomy: 'post_tag') }
11
+ scope :categories, -> { where(taxonomy: 'category') }
12
+
13
+ def list
14
+ wp_terms.map { |wp_term| { wp_term.slug => wp_term.name } }.flatten
15
+ end
16
+ end
17
+ end
data/lib/wptools.rb ADDED
@@ -0,0 +1,135 @@
1
+ # coding: utf-8
2
+ require "wptools/version"
3
+ require "wptools/wp_post"
4
+ require 'yaml'
5
+ require 'optparse'
6
+ require 'csv'
7
+ require 'erb'
8
+
9
+ module Wptools
10
+ class Error < StandardError; end
11
+ # Your code goes here...
12
+
13
+ class Config
14
+ def initialize(config)
15
+ @config = config
16
+ @dbname = config_value('local', 'dbname', true)
17
+ @dbuser = config_value('local', 'dbuser', true)
18
+ @dbpasswd = config_value('local', 'dbpasswd', true)
19
+ end
20
+ attr_reader :dbname, :dbuser, :dbpasswd
21
+ private
22
+ def config_value(section, key, require)
23
+ value = @config[section][key]
24
+ if require && (value.nil? || value.empty?)
25
+ raise RuntimeError, "#{section}:#{key}: is empty"
26
+ end
27
+ value
28
+ end
29
+ end
30
+
31
+ class DB
32
+ def self.prepare(spec)
33
+ ActiveRecord::Base.establish_connection spec
34
+ end
35
+ end
36
+
37
+ class Command
38
+ def self.load_yaml(filename)
39
+ content = File.read(filename)
40
+ content = ERB.new(content).result
41
+ YAML.load(content)
42
+ end
43
+
44
+ def self.run(argv)
45
+ STDOUT.sync = true
46
+ opts = {}
47
+ opt = OptionParser.new(argv)
48
+ opt.banner = "Usage: #{opt.program_name} [-h|--help] config.yml"
49
+ opt.separator('')
50
+ opt.separator "#{opt.program_name} Available Options"
51
+ opt.on_head('-h', '--help', 'Show this message') do |v|
52
+ puts opt.help
53
+ exit
54
+ end
55
+ opt.on('-v', '--verbose', 'Verbose message') {|v| opts[:v] = v}
56
+ opt.on('-n', '--dry-run', 'Message only') {|v| opts[:n] = v}
57
+ opt.on('-l NUM', '--list NUM', 'List posts') {|v| opts[:l] = v.to_i}
58
+ opt.on('-b DATAFILE', '--buzz DATAFILE', 'Buzz posts') {|v| opts[:b] = v }
59
+ opt.parse!(argv)
60
+ if argv.empty?
61
+ puts opt.help
62
+ exit
63
+ end
64
+ config_file = argv[0] || "~/.wptoolsrc"
65
+ config = Config.new(load_yaml(config_file))
66
+ command = Command.new(opts, config)
67
+ command.run
68
+ end
69
+
70
+ def initialize(opts, config)
71
+ @opts = opts
72
+ @config = config
73
+ spec = {adapter: 'mysql2', host: 'localhost', username: @config.dbuser, password: @config.dbpasswd, database: @config.dbname}
74
+ DB.prepare(spec)
75
+ end
76
+
77
+ def run
78
+ if @opts[:l]
79
+ list(@opts[:l])
80
+ elsif @opts[:b]
81
+ buzz(@opts[:b])
82
+ end
83
+ end
84
+
85
+ def list(num)
86
+ p num
87
+ WpPost.published_posts.order(post_date: "DESC").limit(num).each do | post|
88
+ print "#{post.id} #{post.post_type} #{post.post_date_str} #{post.post_title} #{post.post_name}\n"
89
+ end
90
+ end
91
+
92
+ def buzz(filename)
93
+ from_date, to_date, pvs = read_analytics(filename)
94
+ post_pvs = []
95
+ WpPost.published.where("post_date >= ? AND post_date <= ?", from_date, to_date).order(post_date: "DESC").each do |post|
96
+ pv = pvs[post.post_name] || 0
97
+ post_pvs << [post, pv]
98
+ end
99
+
100
+ yd = from_date.strftime("%Y/%m")
101
+ limit = 10
102
+ post_pvs.sort{|a, b| b[1] <=> a[1]}.each_with_index do |post_pvs, index|
103
+ break if index >= limit
104
+ post, pv = post_pvs
105
+ print "#{yd},#{index+1},\"#{post.post_title}\",#{pv}\n"
106
+ end
107
+ end
108
+
109
+ def read_analytics(filename)
110
+ p filename
111
+ # Google Analysticsから出力したページ毎のPVデータを読み込む
112
+ from_date = nil
113
+ to_date = nil
114
+ if filename =~ /(\d\d\d\d)(\d\d)(\d\d)-(\d\d\d\d)(\d\d)(\d\d)\.csv$/
115
+ from_date = Time.local($1.to_i, $2.to_i, $3.to_i)
116
+ to_date = Time.local($4.to_i, $5.to_i, $6.to_i)
117
+ end
118
+ if from_date.nil? || to_date.nil?
119
+ raise "Unknown file name #{filename}"
120
+ end
121
+ # slugごとにpv数を保存
122
+ pvs = {}
123
+ CSV.foreach(filename) do |raw|
124
+ if raw.size == 8
125
+ pagename = raw[0]
126
+ pv = raw[1].gsub(/,/, '').to_i
127
+ if pagename =~ /\/([^\/]+)\/$/
128
+ pvs[$1] = pv
129
+ end
130
+ end
131
+ end
132
+ return from_date, to_date, pvs
133
+ end
134
+ end
135
+ end
data/run_wptools.sh ADDED
@@ -0,0 +1,3 @@
1
+ #!/bin/sh
2
+ bundle exec ruby exe/wptools $*
3
+
data/wptools.gemspec ADDED
@@ -0,0 +1,40 @@
1
+ lib = File.expand_path("lib", __dir__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require "wptools/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "wptools"
7
+ spec.version = Wptools::VERSION
8
+ spec.authors = ["src"]
9
+ spec.email = ["src@srcw.net"]
10
+
11
+ spec.summary = %q{WordPress tools}
12
+ spec.description = %q{WordPress tools}
13
+ spec.homepage = "http://srcw.net/"
14
+ spec.license = "MIT"
15
+
16
+ # spec.metadata["allowed_push_host"] = ""
17
+
18
+ spec.metadata["homepage_uri"] = spec.homepage
19
+ spec.metadata["source_code_uri"] = spec.homepage
20
+ spec.metadata["changelog_uri"] = spec.homepage
21
+
22
+ # Specify which files should be added to the gem when it is released.
23
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
24
+ # spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
25
+ # `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
+ # end
27
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
28
+ f.match(%r{^(test|spec|features)/})
29
+ end
30
+
31
+ spec.bindir = "exe"
32
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
33
+ spec.require_paths = ["lib"]
34
+
35
+ spec.add_dependency 'activerecord'
36
+ spec.add_dependency 'mysql2'
37
+ spec.add_development_dependency "bundler", "~> 2.0"
38
+ spec.add_development_dependency "rake", "~> 10.0"
39
+ spec.add_development_dependency "minitest", "~> 5.0"
40
+ end
metadata ADDED
@@ -0,0 +1,143 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: wptools
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - src
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2024-03-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activerecord
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: mysql2
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
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: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '2.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '2.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: minitest
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '5.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '5.0'
83
+ description: WordPress tools
84
+ email:
85
+ - src@srcw.net
86
+ executables:
87
+ - wptest
88
+ - wptools
89
+ extensions: []
90
+ extra_rdoc_files: []
91
+ files:
92
+ - ".gitignore"
93
+ - ".idea/.gitignore"
94
+ - ".idea/modules.xml"
95
+ - ".idea/vcs.xml"
96
+ - ".idea/wptools.iml"
97
+ - ".travis.yml"
98
+ - CODE_OF_CONDUCT.md
99
+ - Gemfile
100
+ - Gemfile.lock
101
+ - LICENSE.txt
102
+ - README.md
103
+ - Rakefile
104
+ - bin/console
105
+ - bin/setup
106
+ - build.sh
107
+ - config/config_sample.yml
108
+ - exe/wptest
109
+ - exe/wptools
110
+ - lib/wptools.rb
111
+ - lib/wptools/version.rb
112
+ - lib/wptools/wp_post.rb
113
+ - lib/wptools/wp_term_relationship.rb
114
+ - lib/wptools/wp_term_taxnomy.rb
115
+ - run_wptools.sh
116
+ - wptools.gemspec
117
+ homepage: http://srcw.net/
118
+ licenses:
119
+ - MIT
120
+ metadata:
121
+ homepage_uri: http://srcw.net/
122
+ source_code_uri: http://srcw.net/
123
+ changelog_uri: http://srcw.net/
124
+ post_install_message:
125
+ rdoc_options: []
126
+ require_paths:
127
+ - lib
128
+ required_ruby_version: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - ">="
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
133
+ required_rubygems_version: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - ">="
136
+ - !ruby/object:Gem::Version
137
+ version: '0'
138
+ requirements: []
139
+ rubygems_version: 3.3.26
140
+ signing_key:
141
+ specification_version: 4
142
+ summary: WordPress tools
143
+ test_files: []