wikiscript 0.0.1
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 +7 -0
- data/HISTORY.md +3 -0
- data/Manifest.txt +7 -0
- data/README.md +23 -0
- data/Rakefile +30 -0
- data/lib/wikiscript/client.rb +62 -0
- data/lib/wikiscript/version.rb +4 -0
- data/lib/wikiscript.rb +36 -0
- metadata +97 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4fd62d114d9a91fc66c7ab7ff876c483b8f56492
|
4
|
+
data.tar.gz: 3035ff53b83b8cb4d110b1be3046adb6adb89f46
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a580bfa164a812dded6a2d267fde47dfdf413bb2f587e9ce72d7b68af8af483be3ecd4e8d9036b3c4a54c11d41228c2808eba2d2076cffffb1ae766ba90b9e9b
|
7
|
+
data.tar.gz: 8cd5d6104a444cf9ce2edf904275d2a14fdd9c423806c1ccebc2dd7ee0b59d7cd866c96ec609ddb5fde208f06a02961df521135de37f739745869b5dc816a239
|
data/HISTORY.md
ADDED
data/Manifest.txt
ADDED
data/README.md
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# wikiscript - scripts for wikipedia (get wikitext for page etc.)
|
2
|
+
|
3
|
+
* home :: [github.com/wikiscript/wikiscript.ruby](https://github.com/wikiscript/wikiscript.ruby)
|
4
|
+
* bugs :: [github.com/wikiscript/wikiscript.ruby/issues](https://github.com/wikiscript/wikiscript.ruby/issues)
|
5
|
+
* gem :: [rubygems.org/gems/wikiscript](https://rubygems.org/gems/wikiscript)
|
6
|
+
* rdoc :: [rubydoc.info/gems/wikiscript](http://rubydoc.info/gems/wikiscript)
|
7
|
+
|
8
|
+
|
9
|
+
## Usage
|
10
|
+
|
11
|
+
TBD
|
12
|
+
|
13
|
+
## Install
|
14
|
+
|
15
|
+
Just install the gem:
|
16
|
+
|
17
|
+
$ gem install wikiscript
|
18
|
+
|
19
|
+
|
20
|
+
## License
|
21
|
+
|
22
|
+
The `wikiscript` scripts are dedicated to the public domain.
|
23
|
+
Use it as you please with no restrictions whatsoever.
|
data/Rakefile
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'hoe'
|
2
|
+
require './lib/wikiscript/version.rb'
|
3
|
+
|
4
|
+
Hoe.spec 'wikiscript' do
|
5
|
+
|
6
|
+
self.version = Wikiscript::VERSION
|
7
|
+
|
8
|
+
self.summary = 'wikiscript - scripts for wikipedia (get wikitext for page etc.)'
|
9
|
+
self.description = summary
|
10
|
+
|
11
|
+
self.urls = ['https://github.com/wikiscript/wikiscript.ruby']
|
12
|
+
|
13
|
+
self.author = 'Gerald Bauer'
|
14
|
+
self.email = 'opensport@googlegroups.com'
|
15
|
+
|
16
|
+
# switch extension to .markdown for gihub formatting
|
17
|
+
self.readme_file = 'README.md'
|
18
|
+
self.history_file = 'HISTORY.md'
|
19
|
+
|
20
|
+
self.extra_deps = [
|
21
|
+
['logutils' ]
|
22
|
+
]
|
23
|
+
|
24
|
+
self.licenses = ['Public Domain']
|
25
|
+
|
26
|
+
self.spec_extras = {
|
27
|
+
:required_ruby_version => '>= 1.9.2'
|
28
|
+
}
|
29
|
+
|
30
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
|
2
|
+
module Wikiscript
|
3
|
+
|
4
|
+
class Client
|
5
|
+
|
6
|
+
include LogUtils::Logging
|
7
|
+
|
8
|
+
SITE_BASE = 'http://en.wikipedia.org/w/index.php'
|
9
|
+
|
10
|
+
### API_BASE = 'http://en.wikipedia.org/w/api.php'
|
11
|
+
|
12
|
+
def initialize( opts={} )
|
13
|
+
@opts = opts
|
14
|
+
end
|
15
|
+
|
16
|
+
def text( title )
|
17
|
+
## todo/fix: urlencode title ???
|
18
|
+
get( "?action=raw&title=#{title}" )
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
### fix: reuse code from fetcher gem!!!!
|
23
|
+
## do NOT duplicate!!! also cleanup jogo gem!!!!
|
24
|
+
|
25
|
+
def get( params )
|
26
|
+
uri = URI.parse( "#{SITE_BASE}?#{params}" )
|
27
|
+
|
28
|
+
|
29
|
+
# new code: honor proxy env variable HTTP_PROXY
|
30
|
+
proxy = ENV['HTTP_PROXY']
|
31
|
+
proxy = ENV['http_proxy'] if proxy.nil? # try possible lower/case env variable (for *nix systems) is this necessary??
|
32
|
+
|
33
|
+
if proxy
|
34
|
+
proxy = URI.parse( proxy )
|
35
|
+
logger.debug "using net http proxy: proxy.host=#{proxy.host}, proxy.port=#{proxy.port}"
|
36
|
+
if proxy.user && proxy.password
|
37
|
+
logger.debug " using credentials: proxy.user=#{proxy.user}, proxy.password=****"
|
38
|
+
else
|
39
|
+
logger.debug " using no credentials"
|
40
|
+
end
|
41
|
+
else
|
42
|
+
logger.debug "using direct net http access; no proxy configured"
|
43
|
+
proxy = OpenStruct.new # all fields return nil (e.g. proxy.host, etc.)
|
44
|
+
end
|
45
|
+
|
46
|
+
http_proxy = Net::HTTP::Proxy( proxy.host, proxy.port, proxy.user, proxy.password )
|
47
|
+
|
48
|
+
http = http_proxy.new( uri.host, uri.port )
|
49
|
+
response = http.request( Net::HTTP::Get.new( uri.request_uri ))
|
50
|
+
|
51
|
+
if response.code == '200'
|
52
|
+
t = response.body
|
53
|
+
## pp t
|
54
|
+
t
|
55
|
+
else
|
56
|
+
logger.error "fetch HTTP - #{response.code} #{response.message}"
|
57
|
+
nil
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
end # class Client
|
62
|
+
end # Wikiscript
|
data/lib/wikiscript.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
## stdlibs
|
2
|
+
|
3
|
+
require 'net/http'
|
4
|
+
require 'uri'
|
5
|
+
require 'json'
|
6
|
+
require 'pp'
|
7
|
+
require 'ostruct'
|
8
|
+
|
9
|
+
|
10
|
+
## 3rd party gems/libs
|
11
|
+
## require 'props'
|
12
|
+
|
13
|
+
require 'logutils'
|
14
|
+
|
15
|
+
|
16
|
+
# our own code
|
17
|
+
|
18
|
+
require 'wikiscript/version' # let it always go first
|
19
|
+
require 'wikiscript/client'
|
20
|
+
|
21
|
+
|
22
|
+
module Wikiscript
|
23
|
+
|
24
|
+
def self.banner
|
25
|
+
"wikiscript/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.root
|
29
|
+
"#{File.expand_path( File.dirname(File.dirname(__FILE__)) )}"
|
30
|
+
end
|
31
|
+
|
32
|
+
end # module Wikiscript
|
33
|
+
|
34
|
+
|
35
|
+
|
36
|
+
puts Wikiscript.banner
|
metadata
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: wikiscript
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Gerald Bauer
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-07-03 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: logutils
|
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: rdoc
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '4.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '4.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: hoe
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.10'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.10'
|
55
|
+
description: wikiscript - scripts for wikipedia (get wikitext for page etc.)
|
56
|
+
email: opensport@googlegroups.com
|
57
|
+
executables: []
|
58
|
+
extensions: []
|
59
|
+
extra_rdoc_files:
|
60
|
+
- HISTORY.md
|
61
|
+
- Manifest.txt
|
62
|
+
- README.md
|
63
|
+
files:
|
64
|
+
- HISTORY.md
|
65
|
+
- Manifest.txt
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- lib/wikiscript.rb
|
69
|
+
- lib/wikiscript/client.rb
|
70
|
+
- lib/wikiscript/version.rb
|
71
|
+
homepage: https://github.com/wikiscript/wikiscript.ruby
|
72
|
+
licenses:
|
73
|
+
- Public Domain
|
74
|
+
metadata: {}
|
75
|
+
post_install_message:
|
76
|
+
rdoc_options:
|
77
|
+
- --main
|
78
|
+
- README.md
|
79
|
+
require_paths:
|
80
|
+
- lib
|
81
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: 1.9.2
|
86
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ! '>='
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
requirements: []
|
92
|
+
rubyforge_project:
|
93
|
+
rubygems_version: 2.1.10
|
94
|
+
signing_key:
|
95
|
+
specification_version: 4
|
96
|
+
summary: wikiscript - scripts for wikipedia (get wikitext for page etc.)
|
97
|
+
test_files: []
|