revepast 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.travis.yml +14 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +18 -0
- data/LICENSE.txt +21 -0
- data/README.md +34 -0
- data/Rakefile +7 -0
- data/lib/revepast/parser/cargo_scan.rb +15 -0
- data/lib/revepast/parser/eft.rb +57 -0
- data/lib/revepast/parser/test.rb +21 -0
- data/lib/revepast/parser.rb +58 -0
- data/lib/revepast/version.rb +3 -0
- data/lib/revepast.rb +33 -0
- data/revepast.gemspec +30 -0
- metadata +60 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
ZjY2NWZhOTQ3ZmRiYWYyMDkyNTllZjRmNTU3ZWE2ZjhkYjgwOWU2Zg==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
NWFmZGFiN2VlZWRhNmNlZTIyZjM2MmQ5ZmNhZjg5ZDMwYjVhNjFlYg==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
M2MzM2IxMzFlYjA1MTE1ODdmYjMwODBhMTlmY2UyMDYxMmMwZTVmOGE3ZDY5
|
10
|
+
ZGM1NmNlYzgzODRmMmY4MWRlOTkyZTFlNTg0NjE3MzY5MTE1MzlmN2RiOTlk
|
11
|
+
M2Q2ZTk0MWFkMDhjNjE4YzQ2NjQ5MDAwZmQyNGNiOTRkMmQ1YjA=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
Mzc0MGVkNTcyOTRjNDcyNzBhYjlmMjVkY2FlNzcwNjA2OGQ4NWZiMWY3MWFm
|
14
|
+
OTE3MDU5MzMyYWQyZmQ5OTA5NTJmZWJmN2VjZTZiZGExNzE2MWZkMDhiNTM5
|
15
|
+
M2RiMTUwNDUwMTNlYWQxYzFjNmRkNWUwNTE5ZTJjYmYyNDlhY2Y=
|
data/.travis.yml
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
bundler_args: "--without development"
|
2
|
+
gemfile:
|
3
|
+
- Gemfile
|
4
|
+
language: ruby
|
5
|
+
rvm:
|
6
|
+
- 2.2.2
|
7
|
+
deploy:
|
8
|
+
provider: rubygems
|
9
|
+
api_key:
|
10
|
+
secure: mxAtVmz9APuDI6eYo445qpO2n+bl/M7jzVBln7k7iPSuLUhKt/pJZhFm/nf3GRq94wmssosSvdGcuEAGIOEeIixNxgei9zgaWJ7sZkZEXwefbX3KxW9EvupcADEbUebRfbkc9q2uj3+D2TRg0a9F8L3rP2Df3M34obBMQHWVpIkjKiXtN2ummA7zBHXAF7oj2bNRdoBLW4YNqWjCFqmqkv5tzqY/q+3R6h0/yyYpD91DLMpkLu35/X7kN0m+RnvELdlAtmKiQmLBG1mQh3y4BS94RBHyiciRXC7Ro9++rwJMzFYDEJQwcGOfwj9IKFZzZbATyUX9R5JBgyVJuZBu9qTJs0ktkw5qNqMjJiv/A+IzvUQ6ONMY+MPVIHO4PeHXYXYhUDljTdjbUw8OKmrhvrM/qN7tur+uA50ffzgJzFFBW7guapnn9KgonfWY8oeiNRHmawy61AumsVaDxKrw/k+DkmV+6SxUxCAmEqShdnUKRlyNN1Mv5uu0x8gXQMTrxrwzHcVzRUaaN3WSlTqBlZJQWO7uWLgUwi8tPtxLFN3tq6hadq6dcKTzySiELQ6O/W5a66+5BFXDmhJL65gFDjV8r6Uw/LVTRmSkp6YOeaGYA3Kxlp/4QGAPPeWirye5r/eLqmsLePN0Eg5L2fuKFijmMVbE6rBJzZHSMNCzwhw=
|
11
|
+
gem: revepast
|
12
|
+
on:
|
13
|
+
tags: true
|
14
|
+
repo: Mekaret/revepast
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
4
|
+
|
5
|
+
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
|
6
|
+
|
7
|
+
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
|
8
|
+
|
9
|
+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
|
10
|
+
|
11
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
12
|
+
|
13
|
+
This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
|
data/Gemfile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
gem 'bundler'
|
4
|
+
gem 'rake'
|
5
|
+
|
6
|
+
group :development do
|
7
|
+
gem 'pry'
|
8
|
+
gem 'awesome_print'
|
9
|
+
end
|
10
|
+
|
11
|
+
group :test do
|
12
|
+
gem 'coveralls'
|
13
|
+
gem 'rspec'
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
# Specify your gem's dependencies in revepast.gemspec
|
18
|
+
gemspec
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Mekaret Eriker
|
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,34 @@
|
|
1
|
+
[![Coverage Status](https://coveralls.io/repos/Mekaret/revepast/badge.svg?branch=master&service=github)](https://coveralls.io/github/Mekaret/revepast?branch=master)
|
2
|
+
[![Build Status](https://travis-ci.org/Mekaret/revepast.svg?branch=master)](https://travis-ci.org/Mekaret/revepast)
|
3
|
+
|
4
|
+
# Revepast
|
5
|
+
|
6
|
+
A ruby library to help parse various things that are copy/pastable from the Eve Online UI.
|
7
|
+
|
8
|
+
This is currently a **work in progress**.
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
Add this line to your application's Gemfile:
|
13
|
+
|
14
|
+
```ruby
|
15
|
+
gem 'revepast'
|
16
|
+
```
|
17
|
+
|
18
|
+
And then execute:
|
19
|
+
|
20
|
+
$ bundle
|
21
|
+
|
22
|
+
Or install it yourself as:
|
23
|
+
|
24
|
+
$ gem install revepast
|
25
|
+
|
26
|
+
|
27
|
+
## License
|
28
|
+
|
29
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
30
|
+
|
31
|
+
|
32
|
+
## CCP Copyright Notice
|
33
|
+
|
34
|
+
EVE Online and the EVE logo are the registered trademarks of CCP hf. All rights are reserved worldwide. All other trademarks are the property of their respective owners. EVE Online, the EVE logo, EVE and all associated logos and designs are the intellectual property of CCP hf. All artwork, screenshots, characters, vehicles, storylines, world facts or other recognizable features of the intellectual property relating to these trademarks are likewise the intellectual property of CCP hf. CCP hf. has granted permission to evepaste to use EVE Online and all associated logos and designs for promotional and information purposes on its website but does not endorse, and is not in any way affiliated with, evepaste. CCP is in no way responsible for the content on or functioning of this website, nor can it be liable for any damage arising from the use of this website.
|
data/Rakefile
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
module Revepast
|
2
|
+
module Parser
|
3
|
+
class EFT
|
4
|
+
autoload :Utils, 'revepast/parser'
|
5
|
+
include Revepast::Parser
|
6
|
+
|
7
|
+
attr_reader :result, :bad_lines
|
8
|
+
|
9
|
+
def initialize(str)
|
10
|
+
@Utils = Utils.new
|
11
|
+
@result = {}
|
12
|
+
@bad_lines = []
|
13
|
+
result = parse(@Utils.sanitize(str))
|
14
|
+
end
|
15
|
+
|
16
|
+
def parse(str)
|
17
|
+
ammo_pattern = /^([\S ]+), ?([\S ]+)$/
|
18
|
+
blacklist = ['[empty high slot]',
|
19
|
+
'[empty low slot]',
|
20
|
+
'[empty medium slot]',
|
21
|
+
'[empty rig slot]',
|
22
|
+
'[empty subsystem slot]']
|
23
|
+
|
24
|
+
if str.lines.first =~ /^(\[).*(\])$/
|
25
|
+
ship = str.lines.first.match(ammo_pattern)[1].tr('[]', '')
|
26
|
+
fit_name = str.lines.first.match(ammo_pattern)[2].tr('[]', '')
|
27
|
+
else
|
28
|
+
puts "Invalid EFT title line"
|
29
|
+
end
|
30
|
+
matches, bad_lines = @Utils.regex_match_lines(ammo_pattern, str.lines[1..-1])
|
31
|
+
matches2, bad_lines2 = @Utils.parse_listing(bad_lines)
|
32
|
+
|
33
|
+
@bad_lines = bad_lines2
|
34
|
+
|
35
|
+
module_w_ammo = Hash.new { |h, k| h[k] = 0 }
|
36
|
+
matches.each do |m|
|
37
|
+
module_w_ammo[m] += 1
|
38
|
+
end
|
39
|
+
|
40
|
+
modules = []
|
41
|
+
module_w_ammo.sort.each do |(name, ammo), quantity|
|
42
|
+
modules << { 'name'=> name.strip, 'ammo'=> ammo.strip, 'quantity'=> quantity}
|
43
|
+
modules
|
44
|
+
end
|
45
|
+
|
46
|
+
matches2.each do |item|
|
47
|
+
modules << item
|
48
|
+
end
|
49
|
+
|
50
|
+
@result = {'ship' => ship,
|
51
|
+
'name' => fit_name,
|
52
|
+
'modules' => modules.map { |i| i }
|
53
|
+
}
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# /usr/bin/ruby
|
2
|
+
|
3
|
+
input = {
|
4
|
+
"425mm AutoCannon II, Republic Fleet EMP M" => 3
|
5
|
+
}
|
6
|
+
|
7
|
+
expected_output = [
|
8
|
+
{
|
9
|
+
name: "425mm AutoCannon II",
|
10
|
+
ammo: "Republic Fleet EMP M",
|
11
|
+
quantity: 3
|
12
|
+
}
|
13
|
+
]
|
14
|
+
|
15
|
+
output = input.inject([]) do |memo, (key, quantity)|
|
16
|
+
name, ammo = key.split(",")
|
17
|
+
memo << { name: name.strip, ammo: ammo.strip, quantity: quantity }
|
18
|
+
p memo
|
19
|
+
end
|
20
|
+
|
21
|
+
raise "don't match" if output != expected_output
|
@@ -0,0 +1,58 @@
|
|
1
|
+
module Revepast
|
2
|
+
module Parser
|
3
|
+
class Utils
|
4
|
+
def sanitize(str)
|
5
|
+
return str.gsub /^$\n/, ''
|
6
|
+
end
|
7
|
+
|
8
|
+
def regex_match_lines(regex, lines)
|
9
|
+
matches = Array.new
|
10
|
+
bad_lines = Array.new
|
11
|
+
lines.each do |line|
|
12
|
+
if line.match(regex)
|
13
|
+
# p "--#{line.chomp}"
|
14
|
+
a = line.match(regex)
|
15
|
+
matches.push(a.captures)
|
16
|
+
# p matches
|
17
|
+
else
|
18
|
+
bad_lines.push(line.chomp)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
return matches, bad_lines
|
22
|
+
end
|
23
|
+
|
24
|
+
def parse_listing(lines)
|
25
|
+
# 10 x Cargo Scanner II | 10x Cargo Scanner II | 10 Cargo Scanner II
|
26
|
+
listing_re = /^([\d,'\.]+?) ?x? ([\S ]+)$/
|
27
|
+
# Cargo Scanner II x10 | Cargo Scanner II x 10 | Cargo Scanner II 10
|
28
|
+
listing_re2 = /^([\S ]+?) x? ?([\d,'\.]+)$/
|
29
|
+
# Cargo Scanner II
|
30
|
+
listing_re3 = /^([\S ]+)$/
|
31
|
+
|
32
|
+
matches, bad_lines = regex_match_lines(listing_re, lines)
|
33
|
+
matches2, bad_lines2 = regex_match_lines(listing_re2, bad_lines)
|
34
|
+
matches3, bad_lines3 = regex_match_lines(listing_re3, bad_lines2)
|
35
|
+
|
36
|
+
items = Hash.new { |h, k| h[k] = 0 }
|
37
|
+
matches.each do |name, count|
|
38
|
+
items[name.strip] += count.to_i
|
39
|
+
end
|
40
|
+
matches2.each do |name, count|
|
41
|
+
items[name.strip] += count.to_i
|
42
|
+
end
|
43
|
+
matches3.each do |res|
|
44
|
+
items[res[0].strip] += 1
|
45
|
+
end
|
46
|
+
results = []
|
47
|
+
items.each do |name, quantity|
|
48
|
+
results << {
|
49
|
+
'name' => name,
|
50
|
+
'quantity' => quantity
|
51
|
+
}
|
52
|
+
end
|
53
|
+
return results, bad_lines3
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
data/lib/revepast.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
require "revepast/version"
|
2
|
+
|
3
|
+
module Revepast
|
4
|
+
class Error < StandardError
|
5
|
+
end
|
6
|
+
|
7
|
+
module Parser
|
8
|
+
autoload :Parser, 'revepast/parser'
|
9
|
+
end
|
10
|
+
|
11
|
+
class Sort
|
12
|
+
autoload :EFT, 'revepast/parser/eft'
|
13
|
+
include Revepast::Parser
|
14
|
+
|
15
|
+
attr_reader :result, :bad_lines
|
16
|
+
|
17
|
+
def initialize(str)
|
18
|
+
eft_parse = EFT.new(str)
|
19
|
+
@result = eft_parse.result
|
20
|
+
@bad_lines = eft_parse.bad_lines
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
class Parse
|
25
|
+
attr_reader :result
|
26
|
+
def initialize (str)
|
27
|
+
@result = Revepast::Sort.new(str)
|
28
|
+
p result.result
|
29
|
+
p result.bad_lines
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
data/revepast.gemspec
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'revepast/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "revepast"
|
8
|
+
spec.version = Revepast::VERSION
|
9
|
+
spec.authors = ["Mekaret Eriker"]
|
10
|
+
spec.email = ["mekaret@revhosts.net"]
|
11
|
+
|
12
|
+
spec.summary = "A Ruby library to help parse various things that are copy/pastable from the Eve Online"
|
13
|
+
spec.description = "Ruby library to help parse various things that are copy/pastable from the Eve Online"
|
14
|
+
spec.homepage = ""
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
18
|
+
# delete this section to allow pushing this gem to any host.
|
19
|
+
if spec.respond_to?(:metadata)
|
20
|
+
spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
|
21
|
+
else
|
22
|
+
raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
23
|
+
end
|
24
|
+
|
25
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
26
|
+
spec.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
27
|
+
spec.bindir = "exe"
|
28
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
29
|
+
spec.require_paths = ["lib"]
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: revepast
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Mekaret Eriker
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-08-11 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Ruby library to help parse various things that are copy/pastable from
|
14
|
+
the Eve Online
|
15
|
+
email:
|
16
|
+
- mekaret@revhosts.net
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- .travis.yml
|
22
|
+
- CODE_OF_CONDUCT.md
|
23
|
+
- Gemfile
|
24
|
+
- LICENSE.txt
|
25
|
+
- README.md
|
26
|
+
- Rakefile
|
27
|
+
- lib/revepast.rb
|
28
|
+
- lib/revepast/parser.rb
|
29
|
+
- lib/revepast/parser/cargo_scan.rb
|
30
|
+
- lib/revepast/parser/eft.rb
|
31
|
+
- lib/revepast/parser/test.rb
|
32
|
+
- lib/revepast/version.rb
|
33
|
+
- revepast.gemspec
|
34
|
+
homepage: ''
|
35
|
+
licenses:
|
36
|
+
- MIT
|
37
|
+
metadata:
|
38
|
+
allowed_push_host: ! 'TODO: Set to ''http://mygemserver.com'''
|
39
|
+
post_install_message:
|
40
|
+
rdoc_options: []
|
41
|
+
require_paths:
|
42
|
+
- lib
|
43
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ! '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - ! '>='
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '0'
|
53
|
+
requirements: []
|
54
|
+
rubyforge_project:
|
55
|
+
rubygems_version: 2.4.5
|
56
|
+
signing_key:
|
57
|
+
specification_version: 4
|
58
|
+
summary: A Ruby library to help parse various things that are copy/pastable from the
|
59
|
+
Eve Online
|
60
|
+
test_files: []
|