factorio-mod 0.2.1 → 0.2.2
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/.coco.yml +3 -3
- data/.gitlab-ci.yml +16 -0
- data/Gemfile.lock +31 -13
- data/README.md +3 -0
- data/factorio-mod.gemspec +1 -1
- data/lib/factorio/mod.rb +1 -1
- data/lib/factorio/mod/{get_on_read.rb → cache.rb} +3 -3
- data/lib/factorio/mod/mod.rb +28 -27
- data/lib/factorio/mod/version.rb +1 -1
- metadata +18 -4
- data/.travis.yml +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eab89026d714d5fe2035918a550368313b0d4f03214e0df9bfa87c9689891b51
|
4
|
+
data.tar.gz: 8bdf056b0f5b5435ac4d4207c06172e835d4c1767c9464af988dfaec2a6c90bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 19ba0055879c601bda30be33d49064ee947e84d37da76a75ee480fb285f85f61b5da82b0d1ad2d755633c1e263902af6bba735de443a6ec1e62de9f8a6525936
|
7
|
+
data.tar.gz: e8fd3a9596712a8d580eeb38046d995bd66db2a400f9b80bd4356e33a2f8182cc6a01a562c969d1fc6033ff6532506a298d5229670497157ab955937525a8712
|
data/.coco.yml
CHANGED
data/.gitlab-ci.yml
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
variables:
|
2
|
+
FORCE_LOGIN_ENV: 'true'
|
3
|
+
|
4
|
+
before_script:
|
5
|
+
- ruby -v
|
6
|
+
- which ruby
|
7
|
+
- gem install bundler --no-ri --no-rdoc
|
8
|
+
- bundle install --jobs $(nproc) "${FLAGS[@]}"
|
9
|
+
|
10
|
+
rspec:
|
11
|
+
script:
|
12
|
+
- bundle exec rspec
|
13
|
+
|
14
|
+
rubocop:
|
15
|
+
script:
|
16
|
+
- bundle exec rubocop
|
data/Gemfile.lock
CHANGED
@@ -1,32 +1,49 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
factorio-mod (0.2.
|
4
|
+
factorio-mod (0.2.2)
|
5
5
|
nokogiri (~> 1.8)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
+
ast (2.4.0)
|
10
11
|
bump (0.6.1)
|
11
12
|
coco (0.15.0)
|
12
13
|
diff-lcs (1.3)
|
14
|
+
jaro_winkler (1.5.1)
|
13
15
|
mini_portile2 (2.3.0)
|
14
16
|
nokogiri (1.8.4)
|
15
17
|
mini_portile2 (~> 2.3.0)
|
18
|
+
parallel (1.12.1)
|
19
|
+
parser (2.5.1.2)
|
20
|
+
ast (~> 2.4.0)
|
21
|
+
powerpack (0.1.2)
|
22
|
+
rainbow (3.0.0)
|
16
23
|
rake (10.5.0)
|
17
|
-
rspec (3.
|
18
|
-
rspec-core (~> 3.
|
19
|
-
rspec-expectations (~> 3.
|
20
|
-
rspec-mocks (~> 3.
|
21
|
-
rspec-core (3.
|
22
|
-
rspec-support (~> 3.
|
23
|
-
rspec-expectations (3.
|
24
|
+
rspec (3.8.0)
|
25
|
+
rspec-core (~> 3.8.0)
|
26
|
+
rspec-expectations (~> 3.8.0)
|
27
|
+
rspec-mocks (~> 3.8.0)
|
28
|
+
rspec-core (3.8.0)
|
29
|
+
rspec-support (~> 3.8.0)
|
30
|
+
rspec-expectations (3.8.1)
|
24
31
|
diff-lcs (>= 1.2.0, < 2.0)
|
25
|
-
rspec-support (~> 3.
|
26
|
-
rspec-mocks (3.
|
32
|
+
rspec-support (~> 3.8.0)
|
33
|
+
rspec-mocks (3.8.0)
|
27
34
|
diff-lcs (>= 1.2.0, < 2.0)
|
28
|
-
rspec-support (~> 3.
|
29
|
-
rspec-support (3.
|
35
|
+
rspec-support (~> 3.8.0)
|
36
|
+
rspec-support (3.8.0)
|
37
|
+
rubocop (0.58.2)
|
38
|
+
jaro_winkler (~> 1.5.1)
|
39
|
+
parallel (~> 1.10)
|
40
|
+
parser (>= 2.5, != 2.5.1.1)
|
41
|
+
powerpack (~> 0.1)
|
42
|
+
rainbow (>= 2.2.2, < 4.0)
|
43
|
+
ruby-progressbar (~> 1.7)
|
44
|
+
unicode-display_width (~> 1.0, >= 1.0.1)
|
45
|
+
ruby-progressbar (1.10.0)
|
46
|
+
unicode-display_width (1.4.0)
|
30
47
|
|
31
48
|
PLATFORMS
|
32
49
|
ruby
|
@@ -38,6 +55,7 @@ DEPENDENCIES
|
|
38
55
|
factorio-mod!
|
39
56
|
rake (~> 10.0)
|
40
57
|
rspec (~> 3.0)
|
58
|
+
rubocop
|
41
59
|
|
42
60
|
BUNDLED WITH
|
43
|
-
1.16.
|
61
|
+
1.16.4
|
data/README.md
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# Factorio::Mod
|
2
2
|
|
3
|
+
[](https://gitlab.com/71e6fd52/factorio-mod/commits/master)
|
4
|
+
[](https://gitlab.com/71e6fd52/factorio-mod/commits/master)
|
5
|
+
|
3
6
|
## Installation
|
4
7
|
|
5
8
|
Add this line to your application's Gemfile:
|
data/factorio-mod.gemspec
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
|
2
1
|
lib = File.expand_path('lib', __dir__)
|
3
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
3
|
require 'factorio/mod/version'
|
@@ -28,6 +27,7 @@ Gem::Specification.new do |spec|
|
|
28
27
|
|
29
28
|
spec.add_development_dependency 'bump'
|
30
29
|
spec.add_development_dependency 'coco'
|
30
|
+
spec.add_development_dependency 'rubocop'
|
31
31
|
|
32
32
|
spec.add_dependency 'nokogiri', '~> 1.8'
|
33
33
|
end
|
data/lib/factorio/mod.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module Factorio
|
2
|
-
#
|
3
|
-
class
|
2
|
+
# cache mod info
|
3
|
+
class Cache
|
4
4
|
attr_reader :gotten
|
5
5
|
|
6
6
|
def initialize(uri, cookie = '')
|
@@ -34,7 +34,7 @@ module Factorio
|
|
34
34
|
symbol = symbol.to_sym
|
35
35
|
return instance_variable_get "@#{symbol}" if @gotten[symbol]
|
36
36
|
instance_variable_set "@#{symbol}", Nokogiri::HTML(
|
37
|
-
open(uri, 'Cookie' => @cookie)
|
37
|
+
URI.open(uri, 'Cookie' => @cookie)
|
38
38
|
)
|
39
39
|
@gotten[symbol] = true
|
40
40
|
instance_variable_get "@#{symbol}"
|
data/lib/factorio/mod/mod.rb
CHANGED
@@ -20,7 +20,16 @@ module Factorio
|
|
20
20
|
# @param cookie [String] logged in cookie
|
21
21
|
def initialize(name, cookie = '')
|
22
22
|
@name = name
|
23
|
-
@mod =
|
23
|
+
@mod = Cache.new "#{MOD_URI}/mod/#{ERB::Util.url_encode @name}", cookie
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def data_table(key = '')
|
29
|
+
table = @mod.mod.xpath("//div[@class='mod-page-data-table']")
|
30
|
+
return table if key == ''
|
31
|
+
xpath = "//td[../td[@class='data-name'][.='#{key}:']]"
|
32
|
+
table.xpath xpath
|
24
33
|
end
|
25
34
|
|
26
35
|
# @return [String, String] csrf_token and cookie
|
@@ -32,6 +41,24 @@ module Factorio
|
|
32
41
|
end
|
33
42
|
private_class_method :csrf_and_cookie
|
34
43
|
|
44
|
+
public
|
45
|
+
|
46
|
+
# rubocop:disable MethodLength
|
47
|
+
def self.bind_td_to_th(table_head, line)
|
48
|
+
line.css('td').each_with_index.each_with_object({}) \
|
49
|
+
do |(item, index), obj|
|
50
|
+
key = table_head[index]
|
51
|
+
if key == 'Download'
|
52
|
+
href = item.xpath('a/@href').to_s
|
53
|
+
raise NotLoginError if href =~ %r{^/login}
|
54
|
+
obj[:uri] = MOD_URI + href
|
55
|
+
else
|
56
|
+
obj[TABLE_HEAD_TO_GOOD_NAME[key]] = item.text
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
# rubocop:enable MethodLength
|
61
|
+
|
35
62
|
# Get logged in cookie
|
36
63
|
# @param username [String]
|
37
64
|
# @param password [String]
|
@@ -60,14 +87,6 @@ module Factorio
|
|
60
87
|
@mod.any.css('.mod-card-summary').text
|
61
88
|
end
|
62
89
|
|
63
|
-
def data_table(key = '')
|
64
|
-
table = @mod.mod.xpath("//div[@class='mod-page-data-table']")
|
65
|
-
return table if key == ''
|
66
|
-
xpath = "//td[../td[@class='data-name'][.='#{key}:']]"
|
67
|
-
table.xpath xpath
|
68
|
-
end
|
69
|
-
private :data_table
|
70
|
-
|
71
90
|
# Get github uri
|
72
91
|
# @return [String] github uri
|
73
92
|
def github
|
@@ -128,23 +147,5 @@ module Factorio
|
|
128
147
|
Mod.bind_td_to_th head, line
|
129
148
|
end
|
130
149
|
end
|
131
|
-
|
132
|
-
private_class_method
|
133
|
-
|
134
|
-
# rubocop:disable MethodLength
|
135
|
-
def self.bind_td_to_th(table_head, line)
|
136
|
-
line.css('td').each_with_index.each_with_object({}) \
|
137
|
-
do |(item, index), obj|
|
138
|
-
key = table_head[index]
|
139
|
-
if key == 'Download'
|
140
|
-
href = item.xpath('a/@href').to_s
|
141
|
-
raise NotLoginError if href =~ %r{^/login}
|
142
|
-
obj[:uri] = MOD_URI + href
|
143
|
-
else
|
144
|
-
obj[TABLE_HEAD_TO_GOOD_NAME[key]] = item.text
|
145
|
-
end
|
146
|
-
end
|
147
|
-
end
|
148
|
-
# rubocop:enable MethodLength
|
149
150
|
end
|
150
151
|
end
|
data/lib/factorio/mod/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: factorio-mod
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- 71e6fd52
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-09-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rubocop
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: nokogiri
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -103,8 +117,8 @@ extra_rdoc_files: []
|
|
103
117
|
files:
|
104
118
|
- ".coco.yml"
|
105
119
|
- ".gitignore"
|
120
|
+
- ".gitlab-ci.yml"
|
106
121
|
- ".rspec"
|
107
|
-
- ".travis.yml"
|
108
122
|
- Gemfile
|
109
123
|
- Gemfile.lock
|
110
124
|
- LICENSE
|
@@ -114,8 +128,8 @@ files:
|
|
114
128
|
- bin/setup
|
115
129
|
- factorio-mod.gemspec
|
116
130
|
- lib/factorio/mod.rb
|
131
|
+
- lib/factorio/mod/cache.rb
|
117
132
|
- lib/factorio/mod/exception.rb
|
118
|
-
- lib/factorio/mod/get_on_read.rb
|
119
133
|
- lib/factorio/mod/mod.rb
|
120
134
|
- lib/factorio/mod/version.rb
|
121
135
|
homepage: https://gitlab.com/71e6fd52/factorio-mod
|