factorio_mods 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/.gitignore +8 -0
- data/.travis.yml +5 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +21 -0
- data/Rakefile +10 -0
- data/bin/factorio-manager +3 -0
- data/lib/factorio_mods.rb +10 -0
- data/lib/factorio_mods/api.rb +12 -0
- data/lib/factorio_mods/api/download.rb +128 -0
- data/lib/factorio_mods/api/matchmaking.rb +0 -0
- data/lib/factorio_mods/api/mod_portal.rb +44 -0
- data/lib/factorio_mods/api/web_authentication.rb +28 -0
- data/lib/factorio_mods/install.rb +124 -0
- data/lib/factorio_mods/mod.rb +168 -0
- data/lib/factorio_mods/os.rb +19 -0
- data/lib/factorio_mods/version.rb +3 -0
- data/ruby-factorio-mods.gemspec +29 -0
- metadata +161 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 0b6e78a56a99195736542aea3e90e34f45cf36e1ce7483b80bcc2afb09a7358c
|
4
|
+
data.tar.gz: a74c3c5718ea3f04ad2bf8b968fe933aac62e957ed6438e80956e8dfdf44ca81
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c710c579fe06a20fc19f63b0cc2c7df40277881e9fef525c9d932951725780173db36ba727d94c87f27385039d14e78a65b362a8dd7fb95d055a655bc6c8ed26
|
7
|
+
data.tar.gz: aaf71bd1572ef7d8e5dafe3e5e682042e1545985d89dfd97cce8495c7c9bb01692ab82e976e8ef4da9bf62e03d9931b36f08af0a4d4c9becb32a6a9924f482a0
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 Alexander Olofsson
|
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,21 @@
|
|
1
|
+
# Factorio management gem (focussed on use for modding)
|
2
|
+
|
3
|
+
|
4
|
+
## Installation
|
5
|
+
|
6
|
+
Install it with gem
|
7
|
+
|
8
|
+
$ gem install ruby-factorio-mods
|
9
|
+
|
10
|
+
## Usage
|
11
|
+
|
12
|
+
TODO: Implement thor-based CLI
|
13
|
+
|
14
|
+
|
15
|
+
## Contributing
|
16
|
+
|
17
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/ananace/ruby-factorio-mods
|
18
|
+
|
19
|
+
## License
|
20
|
+
|
21
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
|
3
|
+
module FactorioMods
|
4
|
+
module Api
|
5
|
+
autoload :Download, 'factorio_mods/api/download'
|
6
|
+
autoload :Matchmaking, 'factorio_mods/api/matchmaking'
|
7
|
+
autoload :ModPortal, 'factorio_mods/api/mod_portal'
|
8
|
+
autoload :WebAuthentication, 'factorio_mods/api/web_authentication'
|
9
|
+
|
10
|
+
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,128 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
|
3
|
+
module FactorioMods::Api
|
4
|
+
# Based on information from https://wiki.factorio.com/Download_API
|
5
|
+
class Download
|
6
|
+
BASE_URL = 'https://www.factorio.com'.freeze
|
7
|
+
|
8
|
+
Version = Struct.new(:api, :version, :build, :distro) do
|
9
|
+
def download(target)
|
10
|
+
api.download_to(version, target, build, distro)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.login(username_or_email, password)
|
15
|
+
uri = URI(BASE_URL + '/login')
|
16
|
+
http = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true)
|
17
|
+
|
18
|
+
req = Net::HTTP::Get.new uri
|
19
|
+
res = http.request(req)
|
20
|
+
|
21
|
+
csrf_token = Nokogiri::HTML(res.body)
|
22
|
+
.at_xpath('//input[@name="csrf_token"]/@value')
|
23
|
+
.value
|
24
|
+
|
25
|
+
cookie = res['set-cookie'].split('; ').first
|
26
|
+
|
27
|
+
req = Net::HTTP::Post.new uri
|
28
|
+
req.form_data = {
|
29
|
+
csrf_token: csrf_token,
|
30
|
+
username_or_email: username_or_email,
|
31
|
+
password: password
|
32
|
+
}
|
33
|
+
req['cookie'] = cookie
|
34
|
+
|
35
|
+
res = http.request(req)
|
36
|
+
raise 'Login failed' unless res.is_a?(Net::HTTPOK) || res.is_a?(Net::HTTPFound)
|
37
|
+
|
38
|
+
@session = res['set-cookie'].split('; ').first
|
39
|
+
|
40
|
+
true
|
41
|
+
ensure
|
42
|
+
http.finish if http
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.download(version, build = :alpha, distro = nil)
|
46
|
+
raise 'Needs to be logged in' unless @session
|
47
|
+
|
48
|
+
distro ||= if FactorioMods::OS.windows?
|
49
|
+
'win64-manual'
|
50
|
+
elsif FactorioMods::OS.linux?
|
51
|
+
'linux64'
|
52
|
+
elsif FactorioMods::OS.mac?
|
53
|
+
'osx'
|
54
|
+
end
|
55
|
+
|
56
|
+
raise 'Unknown build' unless %i[alpha demo headless].include? build
|
57
|
+
raise 'No distro specifed' unless distro
|
58
|
+
|
59
|
+
uri = URI(BASE_URL + "/get-download/#{version}/#{build}/#{distro}")
|
60
|
+
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
|
61
|
+
req = Net::HTTP::Get.new uri
|
62
|
+
req['cookie'] = @session
|
63
|
+
res = http.request(req)
|
64
|
+
|
65
|
+
if res.is_a? Net::HTTPFound
|
66
|
+
req = Net::HTTP::Get.new URI(res['location'])
|
67
|
+
req['referer'] = BASE_URL + '/download'
|
68
|
+
req['user-agent'] = 'Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0'
|
69
|
+
res = Net::HTTP.start(req.uri.hostname, req.uri.port, use_ssl: true) do |http2|
|
70
|
+
http2.request(req)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
res.value
|
76
|
+
res
|
77
|
+
end
|
78
|
+
|
79
|
+
def self.download_to(version, target = nil, build = :alpha, distro = nil)
|
80
|
+
dir = ''
|
81
|
+
if Dir.exist? target
|
82
|
+
dir = File.join target, ''
|
83
|
+
target = nil
|
84
|
+
end
|
85
|
+
|
86
|
+
data = download(version, build, distro) unless target
|
87
|
+
target ||= data['content-disposition'].split('=').last.strip
|
88
|
+
File.open(dir + target, 'wb') do |file|
|
89
|
+
data ||= download(version, build, distro)
|
90
|
+
file.write(data.body)
|
91
|
+
end
|
92
|
+
|
93
|
+
dir + target
|
94
|
+
end
|
95
|
+
|
96
|
+
def self.available_versions(build = :stable)
|
97
|
+
raise 'Needs to be logged in' unless @session
|
98
|
+
endpoints = {
|
99
|
+
stable: '/download',
|
100
|
+
experimental: '/download/experimental',
|
101
|
+
headless: '/download-headless'
|
102
|
+
}
|
103
|
+
raise 'Unknown build' unless endpoints.key? build
|
104
|
+
|
105
|
+
uri = URI(BASE_URL + endpoints[build])
|
106
|
+
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
|
107
|
+
req = Net::HTTP::Get.new uri
|
108
|
+
req['cookie'] = @session
|
109
|
+
http.request(req)
|
110
|
+
end
|
111
|
+
|
112
|
+
doc = Nokogiri::HTML(res.body)
|
113
|
+
|
114
|
+
doc.xpath('//body/div/ul//a/@href').map do |href|
|
115
|
+
uri = URI(BASE_URL + href.value)
|
116
|
+
components = uri.path.split('/').reject(&:empty?)
|
117
|
+
|
118
|
+
Version.new(
|
119
|
+
self,
|
120
|
+
components[1],
|
121
|
+
components[2].to_sym,
|
122
|
+
components[3],
|
123
|
+
uri
|
124
|
+
)
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
File without changes
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
module FactorioMods::Api
|
4
|
+
## Information taken from https://wiki.factorio.com/Mod_portal_API
|
5
|
+
class ModPortal
|
6
|
+
BASE_URL = 'https://mods.factorio.com'.freeze
|
7
|
+
|
8
|
+
def self.all_mods(data = {})
|
9
|
+
paginate = data.delete :paginate
|
10
|
+
|
11
|
+
uri = URI(BASE_URL + '/api/mods')
|
12
|
+
uri.query = data.map { |k, v| "#{k}=#{v}" }.join '&'
|
13
|
+
|
14
|
+
data = JSON.parse(Net::HTTP.get(uri), symbolize_names: true)
|
15
|
+
puts data
|
16
|
+
results = data.fetch(:results).map { |mod| FactorioMods::Mod.new mod }
|
17
|
+
while paginate && data[:pagination][:links][:next]
|
18
|
+
uri = URI(data[:pagination][:links][:next])
|
19
|
+
data = JSON.parse(Net::HTTP.get(uri), symbolize_names: true)
|
20
|
+
results.concat(data.fetch(:results).map { |mod| FactorioMods::Mod.new mod })
|
21
|
+
end
|
22
|
+
|
23
|
+
results
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.mod(name)
|
27
|
+
uri = URI(BASE_URL + '/api/mods/' + name)
|
28
|
+
FactorioMods::Mod.new JSON.parse(Net::HTTP.get(uri), symbolize_names: true)
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.mods(*names)
|
32
|
+
uri = URI(BASE_URL + '/api/mods')
|
33
|
+
uri.query = 'page_size=max&' + names.map { |mod| "namelist=#{mod}" }.join('&')
|
34
|
+
JSON.parse(Net::HTTP.get(uri), symbolize_names: true)
|
35
|
+
.fetch(:results)
|
36
|
+
.map { |mod| FactorioMods::Mod.new mod }
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.raw_mod(name)
|
40
|
+
uri = URI(BASE_URL + '/api/mods/' + name)
|
41
|
+
JSON.parse(Net::HTTP.get(uri), symbolize_names: true)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module FactorioMods::Api
|
2
|
+
## Information taken from https://wiki.factorio.com/Web_authentication_API
|
3
|
+
class WebAuthentication
|
4
|
+
BASE_URL = 'https://auth.factorio.com'.freeze
|
5
|
+
API_VERSION = 2
|
6
|
+
|
7
|
+
def self.username
|
8
|
+
@username
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.token
|
12
|
+
@token
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.login(username, password, version = API_VERSION, ownership = false)
|
16
|
+
resp = Net::HTTP.post_form(URI(BASE_URL + '/api-login'),
|
17
|
+
username: username,
|
18
|
+
password: password,
|
19
|
+
api_version: version,
|
20
|
+
require_game_ownership: ownership.to_s)
|
21
|
+
resp.value
|
22
|
+
data = JSON.parse(resp.body, symbolize_names: true)
|
23
|
+
|
24
|
+
@username = data[:username]
|
25
|
+
@token = data[:token]
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,124 @@
|
|
1
|
+
require 'inifile'
|
2
|
+
|
3
|
+
module FactorioMods
|
4
|
+
class Install
|
5
|
+
attr_reader :base_path, :version, :architecture, :is_steam
|
6
|
+
|
7
|
+
def self.discover
|
8
|
+
to_scan = if FactorioMods::OS.windows?
|
9
|
+
[
|
10
|
+
'C:\Program Files (x86)\Steam\steamapps\common\Factorio',
|
11
|
+
'C:\Program Files\Factorio'
|
12
|
+
]
|
13
|
+
elsif FactorioMods::OS.mac?
|
14
|
+
[
|
15
|
+
'~/Library/Application Support/Steam/steamapps/common/Factorio/factorio.app/Contents',
|
16
|
+
'/Applications/factorio.app/Contents'
|
17
|
+
]
|
18
|
+
elsif FactorioMods::OS.linux?
|
19
|
+
[
|
20
|
+
'~/.steam/steam/steamapps/common/Factorio',
|
21
|
+
'~/.factorio'
|
22
|
+
]
|
23
|
+
end
|
24
|
+
|
25
|
+
to_scan.map { |path| Install.new path }.select(&:valid?)
|
26
|
+
end
|
27
|
+
|
28
|
+
def initialize(path)
|
29
|
+
@base_path = File.expand_path path
|
30
|
+
return unless valid?
|
31
|
+
|
32
|
+
info = JSON.parse(File.read(File.join(mod_path('base'), 'info.json')),
|
33
|
+
symbolize_names: true)
|
34
|
+
|
35
|
+
@version = info[:version]
|
36
|
+
@is_steam = !(path.tr('\\', '/') =~ %r{/steamapps/common/}i).nil?
|
37
|
+
@architecture = Dir.entries(File.join(base_path, 'bin'))
|
38
|
+
.reject { |e| e.start_with? '.' }
|
39
|
+
.first
|
40
|
+
end
|
41
|
+
|
42
|
+
def binary
|
43
|
+
if OS.windows?
|
44
|
+
File.join bin_path, 'factorio.exe'
|
45
|
+
else
|
46
|
+
File.join bin_path, 'factorio'
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def read_path
|
51
|
+
@read_path ||= begin
|
52
|
+
if uses_system_paths
|
53
|
+
config = IniFile.load(File.join(system_path, 'config', 'config.ini'))
|
54
|
+
|
55
|
+
config['path']['read-data']
|
56
|
+
.gsub '__PATH__system-read-data__', system_path
|
57
|
+
else
|
58
|
+
base_path
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def write_path
|
64
|
+
@write_path ||= begin
|
65
|
+
if uses_system_paths
|
66
|
+
config = IniFile.load(File.join(system_path, 'config', 'config.ini'))
|
67
|
+
|
68
|
+
config['path']['write-data']
|
69
|
+
.gsub '__PATH__system-write-data__', system_path
|
70
|
+
else
|
71
|
+
base_path
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def bin_path
|
77
|
+
File.join base_path, 'bin', architecture
|
78
|
+
end
|
79
|
+
|
80
|
+
def data_path
|
81
|
+
File.join base_path, 'data'
|
82
|
+
end
|
83
|
+
|
84
|
+
def mods_path
|
85
|
+
File.join read_path, 'mods'
|
86
|
+
end
|
87
|
+
|
88
|
+
def mod_path(mod)
|
89
|
+
if %w[base core].include? mod.to_s
|
90
|
+
File.join data_path, mod
|
91
|
+
else
|
92
|
+
matching = Dir.entries(mods_path).select { |entry| entry.start_with?(mod) }
|
93
|
+
return nil unless matching.any?
|
94
|
+
raise 'More than one mod matches' if matching.count > 1
|
95
|
+
|
96
|
+
File.join(mods_path, matching.first)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
def valid?
|
101
|
+
Dir.exist?(base_path) &&
|
102
|
+
File.exist?(File.join(mod_path('base'), 'info.json'))
|
103
|
+
end
|
104
|
+
|
105
|
+
protected
|
106
|
+
|
107
|
+
def system_path
|
108
|
+
File.expand_path(if FactorioMods::OS.windows?
|
109
|
+
File.join '%appdata%', 'Factorio'
|
110
|
+
elsif FactorioMods::OS.mac?
|
111
|
+
File.join '~', 'Library', 'Application Support', 'factorio'
|
112
|
+
elsif FactorioMods::OS.linux?
|
113
|
+
File.join '~', '.factorio'
|
114
|
+
end)
|
115
|
+
end
|
116
|
+
|
117
|
+
def uses_system_paths
|
118
|
+
@uses_system_paths ||= begin
|
119
|
+
config = IniFile.load File.join(base_path, 'config-path.cfg')
|
120
|
+
config['global']['use-system-read-write-data-directories']
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
@@ -0,0 +1,168 @@
|
|
1
|
+
require 'time'
|
2
|
+
|
3
|
+
module FactorioMods
|
4
|
+
class Mod
|
5
|
+
class MediaFile
|
6
|
+
MediaUrl = Struct.new(:original, :thumb)
|
7
|
+
attr_accessor :id, :width, :height, :size
|
8
|
+
attr_reader :urls
|
9
|
+
|
10
|
+
def initialize(data = {})
|
11
|
+
data.each do |k, v|
|
12
|
+
send "#{k}=".to_sym, v if respond_to? "#{k}=".to_sym
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def urls=(data)
|
17
|
+
@urls = MediaUrl.new URI(data.fetch(:original)), URI(data.fetch(:thumb))
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
class Release
|
22
|
+
attr_accessor :downloads_count, :factorio_version, :file_name, :file_size,
|
23
|
+
:game_version, :id, :info_json, :sha1, :version
|
24
|
+
attr_reader :released_at
|
25
|
+
|
26
|
+
def initialize(data = {})
|
27
|
+
data.each do |k, v|
|
28
|
+
send "#{k}=".to_sym, v if respond_to? "#{k}=".to_sym
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def download
|
33
|
+
Net::HTTP.get(download_url)
|
34
|
+
end
|
35
|
+
|
36
|
+
def download_to(path)
|
37
|
+
dir = ''
|
38
|
+
if Dir.exist? path
|
39
|
+
dir = path
|
40
|
+
path = file_name
|
41
|
+
end
|
42
|
+
|
43
|
+
File.open(dir + path, 'wb') do |file|
|
44
|
+
Net::HTTP.get_response(download_url) do |resp|
|
45
|
+
resp.value
|
46
|
+
resp.read_body { |data| file.write(data) }
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
dir + path
|
51
|
+
end
|
52
|
+
|
53
|
+
def download_url
|
54
|
+
@download_url.dup.tap do |url|
|
55
|
+
a = FactorioMods::Api::WebAuthentication
|
56
|
+
url.query = "username=#{a.username}&token=#{a.token}" if a.token
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def download_url=(url)
|
61
|
+
@download_url = URI(FactorioMods::Api::ModPortal::BASE_URL + url)
|
62
|
+
end
|
63
|
+
|
64
|
+
def released_at=(time)
|
65
|
+
@released_at = Time.parse time
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
class Tag
|
70
|
+
attr_accessor :id, :name, :title, :description
|
71
|
+
attr_reader :type
|
72
|
+
|
73
|
+
def initialize(data = {})
|
74
|
+
data.each do |k, v|
|
75
|
+
send "#{k}=".to_sym, v if respond_to? "#{k}=".to_sym
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def type=(type)
|
80
|
+
@type = type.to_sym
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
attr_accessor :current_user_rating, :description, :description_html,
|
85
|
+
:downloads_count, :game_versions, :homepage,
|
86
|
+
:id, :license_name, :license_url, :name, :owner,
|
87
|
+
:ratings_count, :summary, :title, :visits_count
|
88
|
+
attr_reader :created_at, :github_path, :license_flags, :license_flags_raw,
|
89
|
+
:media_files, :releases, :tags, :updated_at
|
90
|
+
|
91
|
+
def initialize(data = {})
|
92
|
+
data.each do |k, v|
|
93
|
+
send "#{k}=".to_sym, v if respond_to? "#{k}=".to_sym
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def reload!
|
98
|
+
data = FactorioMods::Api::ModPortal.raw_mod(name)
|
99
|
+
data.each do |k, v|
|
100
|
+
send "#{k}=".to_sym, v if respond_to? "#{k}=".to_sym
|
101
|
+
end
|
102
|
+
true
|
103
|
+
end
|
104
|
+
|
105
|
+
def created_at=(date)
|
106
|
+
@created_at = Time.parse date
|
107
|
+
end
|
108
|
+
|
109
|
+
def first_media_file
|
110
|
+
return media_files.first if media_files
|
111
|
+
@first_media_file
|
112
|
+
end
|
113
|
+
|
114
|
+
def first_media_file=(file)
|
115
|
+
@first_media_file = MediaFile.new file
|
116
|
+
end
|
117
|
+
|
118
|
+
def latest_release
|
119
|
+
return releases.max { |r| r.released_at.to_i } if releases
|
120
|
+
@latest_release
|
121
|
+
end
|
122
|
+
|
123
|
+
def latest_release=(release)
|
124
|
+
@latest_release = Release.new release
|
125
|
+
end
|
126
|
+
|
127
|
+
def github_path=(path)
|
128
|
+
@github_path = URI('https://github.com/' + path)
|
129
|
+
end
|
130
|
+
|
131
|
+
def license_flags=(flags)
|
132
|
+
@license_flags_raw = flags
|
133
|
+
@license_flags = begin
|
134
|
+
ret = []
|
135
|
+
ret << :permit_commercial_use if flags & (1 << 0)
|
136
|
+
ret << :permit_modification if flags & (1 << 1)
|
137
|
+
ret << :permit_distribution if flags & (1 << 2)
|
138
|
+
ret << :permit_patent_use if flags & (1 << 3)
|
139
|
+
ret << :permit_private_use if flags & (1 << 4)
|
140
|
+
|
141
|
+
ret << :must_disclose_source if flags & (1 << 5)
|
142
|
+
ret << :must_license_notice if flags & (1 << 6)
|
143
|
+
ret << :must_same_license if flags & (1 << 7)
|
144
|
+
ret << :must_state_changes if flags & (1 << 8)
|
145
|
+
|
146
|
+
ret << :cant_hold_liable if flags & (1 << 9)
|
147
|
+
ret << :cant_use_trademark if flags & (1 << 10)
|
148
|
+
ret
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
def media_files=(files)
|
153
|
+
@media_files = files.map { |file| MediaFile.new file }
|
154
|
+
end
|
155
|
+
|
156
|
+
def releases=(releases)
|
157
|
+
@releases = releases.map { |release| Release.new release }
|
158
|
+
end
|
159
|
+
|
160
|
+
def tags=(tags)
|
161
|
+
@tags = tags.map { |tag| Tag.new tag }
|
162
|
+
end
|
163
|
+
|
164
|
+
def updated_at=(date)
|
165
|
+
@updated_at = Time.parse date
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module FactorioMods
|
2
|
+
module OS
|
3
|
+
def self.windows?
|
4
|
+
(/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.mac?
|
8
|
+
(/darwin/ =~ RUBY_PLATFORM) != nil
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.unix?
|
12
|
+
!OS.windows?
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.linux?
|
16
|
+
OS.unix? && !OS.mac?
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require File.join File.expand_path('lib', __dir__), 'factorio_mods/version'
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = 'factorio_mods'
|
5
|
+
spec.version = FactorioMods::VERSION
|
6
|
+
spec.authors = ['Alexander Olofsson']
|
7
|
+
spec.email = ['ace@haxalot.com']
|
8
|
+
|
9
|
+
spec.summary = %q{Write a short summary, because RubyGems requires one.}
|
10
|
+
spec.description = %q{Write a longer description or delete this line.}
|
11
|
+
spec.homepage = 'https://github.com/ananace/ruby-factorio-mods'
|
12
|
+
spec.license = 'MIT'
|
13
|
+
|
14
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
15
|
+
f.match(%r{^(test|spec|features)/})
|
16
|
+
end
|
17
|
+
spec.bindir = 'bin'
|
18
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
21
|
+
spec.add_dependency 'inifile'
|
22
|
+
spec.add_dependency 'logging', '~> 2'
|
23
|
+
spec.add_dependency 'nokogiri'
|
24
|
+
spec.add_dependency 'thor'
|
25
|
+
|
26
|
+
spec.add_development_dependency 'bundler'
|
27
|
+
spec.add_development_dependency 'minitest'
|
28
|
+
spec.add_development_dependency 'rake'
|
29
|
+
end
|
metadata
ADDED
@@ -0,0 +1,161 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: factorio_mods
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Alexander Olofsson
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-07-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: inifile
|
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: logging
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: nokogiri
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: thor
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: bundler
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: minitest
|
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'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rake
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
description: Write a longer description or delete this line.
|
112
|
+
email:
|
113
|
+
- ace@haxalot.com
|
114
|
+
executables:
|
115
|
+
- factorio-manager
|
116
|
+
extensions: []
|
117
|
+
extra_rdoc_files: []
|
118
|
+
files:
|
119
|
+
- ".gitignore"
|
120
|
+
- ".travis.yml"
|
121
|
+
- Gemfile
|
122
|
+
- LICENSE.txt
|
123
|
+
- README.md
|
124
|
+
- Rakefile
|
125
|
+
- bin/factorio-manager
|
126
|
+
- lib/factorio_mods.rb
|
127
|
+
- lib/factorio_mods/api.rb
|
128
|
+
- lib/factorio_mods/api/download.rb
|
129
|
+
- lib/factorio_mods/api/matchmaking.rb
|
130
|
+
- lib/factorio_mods/api/mod_portal.rb
|
131
|
+
- lib/factorio_mods/api/web_authentication.rb
|
132
|
+
- lib/factorio_mods/install.rb
|
133
|
+
- lib/factorio_mods/mod.rb
|
134
|
+
- lib/factorio_mods/os.rb
|
135
|
+
- lib/factorio_mods/version.rb
|
136
|
+
- ruby-factorio-mods.gemspec
|
137
|
+
homepage: https://github.com/ananace/ruby-factorio-mods
|
138
|
+
licenses:
|
139
|
+
- MIT
|
140
|
+
metadata: {}
|
141
|
+
post_install_message:
|
142
|
+
rdoc_options: []
|
143
|
+
require_paths:
|
144
|
+
- lib
|
145
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
146
|
+
requirements:
|
147
|
+
- - ">="
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: '0'
|
150
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
151
|
+
requirements:
|
152
|
+
- - ">="
|
153
|
+
- !ruby/object:Gem::Version
|
154
|
+
version: '0'
|
155
|
+
requirements: []
|
156
|
+
rubyforge_project:
|
157
|
+
rubygems_version: 2.7.6
|
158
|
+
signing_key:
|
159
|
+
specification_version: 4
|
160
|
+
summary: Write a short summary, because RubyGems requires one.
|
161
|
+
test_files: []
|