wikian 0.2.2 → 0.2.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 66726501f7fd096888803fc73c97612ef35b26e3246c54c4f9fbb7ea887c9d78
4
- data.tar.gz: 9cda60a1184cb39a79cec8a93cb36fba2cde382bb7d1d69ca7d1beb79f36dc4e
3
+ metadata.gz: 6044c74a22baf5f757da1f68bc65f0758da46a41ee3567b19b0a61688d3b7034
4
+ data.tar.gz: 415490e2958ed48196c97ddbca6f3a86afff1c7ee535c9d1a1ed39bf3313bce8
5
5
  SHA512:
6
- metadata.gz: 5370603bfe66ffe85be969cbb5eadcd4f96dedcc59c594effb81f76c1b7538ba9588f822e7ef50c52c04a46e54217e086d93cd64cda742607018d1e5c9d81dc9
7
- data.tar.gz: b9039ccf6311700d85ce6b80f62a8a9238e08ba3727a684e82764ace39778975bff5f543932e91b84749f1e094e89cef68a671d24607026fab75300366d3a85c
6
+ metadata.gz: 3155eb0bc4f6a2a1648eb186072bda807b4af64ef79d9034e0c597900a5b2a9ed7b6d498a469545596673b37a0323360d59eef8f043b2710fcea462bf3ec7b55
7
+ data.tar.gz: cc705511bc328eeb488180ce7940f64eaa2e82f0b8302cbc26cb93e38aeff15b7f6ccd20b3f08d8ea5ec2dd2ab0eedeb9ca4297f01bae0b18a05995e5ec56f3e
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- wikian (0.2.2)
4
+ wikian (0.2.3)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -70,24 +70,28 @@ $ wi post -s 2 Wikipedia:Sandbox.en.wikipedia.org.wiki
70
70
  Article uploaded
71
71
  ```
72
72
 
73
- To search for a pattern in Wikipedia:
73
+ To search for a term in Wikipedia:
74
74
 
75
75
  ```
76
- $ wi search -t
77
- Creating template wiki.yml
78
-
79
- $ wi s
76
+ $ wi s Mr. Fixit
80
77
  Writing to Mr. Fixit.json
81
78
  ```
82
79
 
83
80
  To get your last 10 Wikipedia contributions:
84
81
 
85
82
  ```
86
- $ wi c -t
87
- Creating template wiki.yml
88
-
89
83
  $ wi c
90
84
  Writing to User:Example_User.contributions.en.wikipedia.org.json
91
85
  ```
92
86
 
87
+ To tune the request parameters create a config file with any of these:
88
+ ```
89
+ $ wi g -t
90
+
91
+ $ wi c -t
92
+
93
+ $ wi s -t
94
+ ```
95
+
96
+
93
97
  Vim users should try [mediawiki.vim](https://en.wikipedia.org/wiki/Help:Text_editor_support#Vim) which adds syntax highlighting and abbreviations for wikitext files.
@@ -113,6 +113,9 @@ class Wikian
113
113
  # append wikitext to section 2 of the article
114
114
  wi post -a -s 2 Wikipedia:Sandbox.en.wikipedia.org.wiki
115
115
 
116
+ # search for multiple terms in Wikipedia
117
+ wi search term 1:term 2:term 3
118
+
116
119
  # heavy use of the API may require cache validation
117
120
  wi post -c 1234:someMessage spider-Man.wiki
118
121
 
@@ -131,7 +131,7 @@ class Wikian
131
131
  timestamp
132
132
  else
133
133
  FileUtils.mkdir_p(Wikian.meta_dir)
134
- metadata = {'meta' => {'title' => {'timestamp' => File.mtime(input_file).utc.iso8601}}}
134
+ metadata = {'meta' => {params['title'] => {'timestamp' => File.mtime(input_file).utc.iso8601}}}
135
135
  File.write(Wikian.meta_file, YAML.dump(metadata))
136
136
  end
137
137
  wikitext = File.read(input_file)
@@ -1,14 +1,18 @@
1
1
  class Wikian
2
2
  class WikianGetError < StandardError; end
3
- class ArgumentRequiredError < WikianGetError; end
3
+ class MissingSearchTermError < WikianGetError; end
4
4
 
5
5
  class Search < Subcommand
6
6
  def initialize(args)
7
7
  super
8
8
 
9
- @output_file = config['api']['srsearch'].first
9
+ srsearch = non_opt_args.join(' ')
10
10
 
11
- @params.merge!('format' => Wikian::RESPONSE_FORMAT)
11
+ raise MissingSearchTermError if srsearch.empty?
12
+
13
+ @params.merge!('srsearch' => srsearch, 'format' => Wikian::RESPONSE_FORMAT)
14
+
15
+ @output_file = srsearch
12
16
 
13
17
  @query = @params.to_query
14
18
 
@@ -30,8 +34,9 @@ class Wikian
30
34
  - query
31
35
  list:
32
36
  - search
33
- srsearch: # text to search for. You can use multiple
34
- - Mr. Fixit
37
+ #srsearch: # text to search for. You can use multiple
38
+ # - Mr. Fixit
39
+ # - Term 2
35
40
  eos
36
41
  end
37
42
  end
@@ -43,6 +43,11 @@ class Wikian
43
43
  exit
44
44
  end
45
45
 
46
+ # return args that dont start with '-'
47
+ def non_opt_args
48
+ args.reject {|p| p[0] == '-'}
49
+ end
50
+
46
51
  # HTTP response file name. Its extension depends on the 'content-type' header
47
52
  def response_file
48
53
  output_file + '.' + res.meta['content-type'].split('/').last.sub(/;.*/,'')
@@ -1,3 +1,3 @@
1
1
  class Wikian
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wikian
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - sergioro
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-09-15 00:00:00.000000000 Z
11
+ date: 2020-09-16 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Get and update Wikipedia articles
14
14
  email: