lays 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +7 -0
- data/lays.gemspec +24 -0
- data/lib/lays/version.rb +3 -0
- data/lib/lays.rb +30 -0
- data/test/test_helper.rb +1 -0
- data/test/text_layers_test.rb +83 -0
- metadata +98 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d5439b43079d73905d206be9b4d37bd0a7293440
|
4
|
+
data.tar.gz: 98e168c8c39e42363294888dd34911095b7f3de4
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: cd236c35af9b791cfe1dd69379bc5b7d55ba0583c886f458b466ab044b87a3a434292f694d73a2b5656815ee7b1a429d56dcf4704fc2c6487e9eb28dc3bbb563
|
7
|
+
data.tar.gz: 38f48527e7db5e9556a58f553bfba342f5ef67c2d226747de0f46bf8479a2d95e0285a42df9452834fea78842ba628add52cebfb3f68c5d68cd5d66880489cb1
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Federico Iachetti
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Lays
|
2
|
+
|
3
|
+
Layered text frames for TRecs
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'lays'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install lays
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it ( https://github.com/[my-github-username]/lays/fork )
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/lays.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'lays/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "lays"
|
8
|
+
spec.version = Lays::VERSION
|
9
|
+
spec.authors = ["Federico Iachetti"]
|
10
|
+
spec.email = ["iachetti.federico@gmail.com"]
|
11
|
+
spec.summary = %q{Layered text frames for TRecs.}
|
12
|
+
spec.description = %q{Layered text frames for TRecs.}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "cutest"
|
24
|
+
end
|
data/lib/lays/version.rb
ADDED
data/lib/lays.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
require "lays/version"
|
2
|
+
|
3
|
+
module Lays
|
4
|
+
|
5
|
+
def []=(layer, content)
|
6
|
+
layers[layer] = content
|
7
|
+
@result = nil
|
8
|
+
end
|
9
|
+
|
10
|
+
def [](layer)
|
11
|
+
layers[layer]
|
12
|
+
end
|
13
|
+
|
14
|
+
def layers
|
15
|
+
@layer ||= {}
|
16
|
+
end
|
17
|
+
|
18
|
+
def to_s
|
19
|
+
@result ||= []
|
20
|
+
layers.sort {|a, b| a[0] <=> b[0] }.each do |_, content|
|
21
|
+
content.split("\n").each_with_index.map do |line, i|
|
22
|
+
line.each_char.each_with_index do |c, j|
|
23
|
+
@result[i] ||= []
|
24
|
+
@result[i][j] = c unless c == nil || c == " "
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
@result.map {|a|a.join}.join("\n")
|
29
|
+
end
|
30
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require File.expand_path("../../lib/lays", __FILE__)
|
@@ -0,0 +1,83 @@
|
|
1
|
+
require_relative "./test_helper"
|
2
|
+
|
3
|
+
Frame = Struct.new(:content) do
|
4
|
+
include Lays
|
5
|
+
def initialize(**attrs)
|
6
|
+
attrs.each do |attr, val|
|
7
|
+
self.send("#{attr}=", val)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
test "one layer, one line" do
|
13
|
+
frame = Frame.new
|
14
|
+
frame[1] = "hello"
|
15
|
+
assert_equal frame.to_s, "hello"
|
16
|
+
end
|
17
|
+
|
18
|
+
test "one layer, multiple lines" do
|
19
|
+
frame = Frame.new
|
20
|
+
frame[1] = "hello\none\ntwo"
|
21
|
+
assert_equal frame.to_s, "hello\none\ntwo"
|
22
|
+
end
|
23
|
+
|
24
|
+
test "two layers, one line, same size" do
|
25
|
+
frame = Frame.new
|
26
|
+
frame[1] = "one"
|
27
|
+
frame[2] = "two"
|
28
|
+
assert_equal frame.to_s, "two"
|
29
|
+
end
|
30
|
+
|
31
|
+
test "two layers, one line, same size, switched" do
|
32
|
+
frame = Frame.new
|
33
|
+
frame[2] = "two"
|
34
|
+
frame[1] = "one"
|
35
|
+
assert_equal frame.to_s, "two"
|
36
|
+
end
|
37
|
+
|
38
|
+
test "two layers, one line, different size" do
|
39
|
+
frame = Frame.new
|
40
|
+
frame[1] = "123"
|
41
|
+
frame[2] = "abcdef"
|
42
|
+
assert_equal frame.to_s, "abcdef"
|
43
|
+
end
|
44
|
+
|
45
|
+
test "two layers, one line, different size" do
|
46
|
+
frame = Frame.new
|
47
|
+
frame[2] = "123"
|
48
|
+
frame[1] = "abcdef"
|
49
|
+
assert_equal frame.to_s, "123def"
|
50
|
+
end
|
51
|
+
|
52
|
+
test "two layers, two lines" do
|
53
|
+
frame = Frame.new
|
54
|
+
frame[2] = "222\n2"
|
55
|
+
frame[1] = "11\n111"
|
56
|
+
assert_equal frame.to_s, "222\n211"
|
57
|
+
end
|
58
|
+
|
59
|
+
test "three layers, three lines" do
|
60
|
+
frame = Frame.new
|
61
|
+
frame[3] = <<THREE
|
62
|
+
3 3
|
63
|
+
3
|
64
|
+
333
|
65
|
+
THREE
|
66
|
+
frame[2] = <<TWO
|
67
|
+
22
|
68
|
+
222 2
|
69
|
+
222
|
70
|
+
TWO
|
71
|
+
frame[1] = <<ONE
|
72
|
+
1111111
|
73
|
+
111111
|
74
|
+
11111
|
75
|
+
ONE
|
76
|
+
|
77
|
+
res = <<RES.chomp
|
78
|
+
3231111
|
79
|
+
232121
|
80
|
+
33321
|
81
|
+
RES
|
82
|
+
assert_equal frame.to_s, res
|
83
|
+
end
|
metadata
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: lays
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Federico Iachetti
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-09-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: cutest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: Layered text frames for TRecs.
|
56
|
+
email:
|
57
|
+
- iachetti.federico@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- Gemfile
|
64
|
+
- LICENSE.txt
|
65
|
+
- README.md
|
66
|
+
- Rakefile
|
67
|
+
- lays.gemspec
|
68
|
+
- lib/lays.rb
|
69
|
+
- lib/lays/version.rb
|
70
|
+
- test/test_helper.rb
|
71
|
+
- test/text_layers_test.rb
|
72
|
+
homepage: ''
|
73
|
+
licenses:
|
74
|
+
- MIT
|
75
|
+
metadata: {}
|
76
|
+
post_install_message:
|
77
|
+
rdoc_options: []
|
78
|
+
require_paths:
|
79
|
+
- lib
|
80
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
requirements: []
|
91
|
+
rubyforge_project:
|
92
|
+
rubygems_version: 2.2.2
|
93
|
+
signing_key:
|
94
|
+
specification_version: 4
|
95
|
+
summary: Layered text frames for TRecs.
|
96
|
+
test_files:
|
97
|
+
- test/test_helper.rb
|
98
|
+
- test/text_layers_test.rb
|