zeamays 0.0.1 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +6 -0
- data/Gemfile +4 -0
- data/Guardfile +8 -0
- data/README.md +29 -1
- data/Rakefile +9 -0
- data/lib/zeamays.rb +3 -1
- data/lib/zeamays/cob.rb +9 -0
- data/lib/zeamays/cob/defreezing.rb +22 -0
- data/lib/zeamays/cob/freezing.rb +29 -0
- data/lib/zeamays/cob/gene.rb +9 -0
- data/lib/zeamays/cob/growth.rb +23 -0
- data/lib/zeamays/corn/fruiter/string.rb +22 -0
- data/lib/zeamays/corn/string.rb +11 -0
- data/lib/zeamays/fridge.rb +9 -0
- data/lib/zeamays/version.rb +1 -1
- data/spec/model_test/zeamays_mode_example_spec.rb +22 -0
- data/zeamays.gemspec +1 -1
- metadata +12 -3
- data/lib/zeamays/serialize.rb +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c2e4a80fc0fe7de57bf7f44e1509c5c47ec58bc2
|
4
|
+
data.tar.gz: 6afdce580bfe2fac0ba159a21ba3153d9cb6f193
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 11a714a7c8de5a974a0de9de20087205ae9aa8df10150aef1c03c818bf58792a4ab81664bf9339e7d99b0a1201f3ebb659d07074c0db9282b4b2ede43223cef8
|
7
|
+
data.tar.gz: 120723a5fc7f25f964cf1968eb988731520941b456c3f2abe4afe2db087ac0cabd18ccbffa125b93062058f17caeaa73b32aba028c8fe9940601acb9f0f8dd34
|
data/.gitignore
CHANGED
data/.travis.yml
ADDED
data/Gemfile
CHANGED
data/Guardfile
ADDED
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# Zeamays
|
2
2
|
|
3
|
+
[![Build Status](https://travis-ci.org/myun2ext/zeamays.svg?branch=master)](https://travis-ci.org/myun2ext/zeamays)
|
4
|
+
|
3
5
|
Minimum Database gem for Ruby (notSQL)
|
4
6
|
|
5
7
|
## Installation
|
@@ -18,7 +20,33 @@ Or install it yourself as:
|
|
18
20
|
|
19
21
|
## Usage
|
20
22
|
|
21
|
-
|
23
|
+
Declare Modeling for
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
class ExampleCobClass < Zeamays::Cob
|
27
|
+
gene_sequencing :i8, :i16, :integer, :string
|
28
|
+
end
|
29
|
+
```
|
30
|
+
|
31
|
+
columns declare use for `gene_sequencing` **class method**.
|
32
|
+
|
33
|
+
Symbol use for Column type.
|
34
|
+
|
35
|
+
* `:i8`: 1byte Integer (8bits)
|
36
|
+
* `:i16`: 2byte Integer (16bits)
|
37
|
+
* `:i32` or `:integer`: 4byte Integer (32bits)
|
38
|
+
* `:string`: String type (Any length usable)
|
39
|
+
|
40
|
+
## Add new Record
|
41
|
+
|
42
|
+
Use for `grow` or `grow!` method(`grow` method is alias for `grow!`).
|
43
|
+
|
44
|
+
for example
|
45
|
+
|
46
|
+
```ruby
|
47
|
+
yellow_sweet = ExampleCobClass.new
|
48
|
+
yellow_sweet.grow 30, 2000, 500000, "test"
|
49
|
+
```
|
22
50
|
|
23
51
|
## Contributing
|
24
52
|
|
data/Rakefile
CHANGED
@@ -1,2 +1,11 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
2
|
|
3
|
+
task default: [:spec]
|
4
|
+
begin
|
5
|
+
require 'rspec/core/rake_task'
|
6
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
7
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
8
|
+
spec.rspec_opts = %w(--format documentation --color)
|
9
|
+
end
|
10
|
+
rescue LoadError => e
|
11
|
+
end
|
data/lib/zeamays.rb
CHANGED
data/lib/zeamays/cob.rb
CHANGED
@@ -0,0 +1,22 @@
|
|
1
|
+
module Zeamays
|
2
|
+
class Cob
|
3
|
+
module Defreezing
|
4
|
+
def unpack(packed_string)
|
5
|
+
unpacked_list = []
|
6
|
+
|
7
|
+
left_string = packed_string
|
8
|
+
while left_string.size != 0 do
|
9
|
+
unpacked = left_string.unpack(package_pattern + tail_pattern)
|
10
|
+
left_string = unpacked.pop
|
11
|
+
unpacked_list << unpacked
|
12
|
+
end
|
13
|
+
unpacked_list
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
def tail_pattern
|
18
|
+
'a*'
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Zeamays
|
2
|
+
class Cob
|
3
|
+
module Freezing
|
4
|
+
def pack
|
5
|
+
@rows.collect { |row|
|
6
|
+
row.pack(self.class.package_pattern)
|
7
|
+
}.join("")
|
8
|
+
end
|
9
|
+
|
10
|
+
module ClassMethods
|
11
|
+
def package_pattern
|
12
|
+
gene_sequence.map { |type|
|
13
|
+
case type
|
14
|
+
when :i8 then 'C'
|
15
|
+
when :i16 then 'n'
|
16
|
+
when :i32 then 'N'
|
17
|
+
when :integer then 'N'
|
18
|
+
when :string then 'Z*'
|
19
|
+
end
|
20
|
+
}.join("")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.included(me)
|
25
|
+
me.extend ClassMethods
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/lib/zeamays/cob/gene.rb
CHANGED
@@ -0,0 +1,23 @@
|
|
1
|
+
module Zeamays
|
2
|
+
class Cob
|
3
|
+
module Growth
|
4
|
+
@rows = []
|
5
|
+
|
6
|
+
def initialize(rows = [])
|
7
|
+
@rows = rows
|
8
|
+
end
|
9
|
+
|
10
|
+
def grow!(*row)
|
11
|
+
# Expanding single item Array
|
12
|
+
if row.is_a? Array and row.length == 1 and row[0].is_a? Array
|
13
|
+
row = row[0]
|
14
|
+
end
|
15
|
+
@rows << row
|
16
|
+
end
|
17
|
+
|
18
|
+
def grow(*row)
|
19
|
+
grow!(*row)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Zeamays
|
2
|
+
class Corn
|
3
|
+
class Fruiter
|
4
|
+
module String
|
5
|
+
def self.fruit_short_string(s)
|
6
|
+
bytesize = s.bytesize
|
7
|
+
[bytesize].pack("C") + s
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.fruit_medium_string(s)
|
11
|
+
bytesize = s.bytesize
|
12
|
+
[bytesize].pack("n") + s
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.fruit_large_string(s)
|
16
|
+
bytesize = s.bytesize
|
17
|
+
[bytesize].pack("N") + s
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/zeamays/version.rb
CHANGED
@@ -0,0 +1,22 @@
|
|
1
|
+
require "zeamays"
|
2
|
+
|
3
|
+
describe "Zeamays Model example" do
|
4
|
+
let(:example_cob_class) {
|
5
|
+
class ExampleCobClass < Zeamays::Cob
|
6
|
+
gene_sequencing :i8, :i16, :integer, :string
|
7
|
+
end
|
8
|
+
ExampleCobClass
|
9
|
+
}
|
10
|
+
|
11
|
+
let(:cob) { example_cob_class.new }
|
12
|
+
let(:record1) { [30, 2000, 500000, "test"] }
|
13
|
+
let(:record2) { [80, 1000, 200000, "Example!!! "] }
|
14
|
+
before do
|
15
|
+
cob.grow(record1)
|
16
|
+
cob.grow(record2)
|
17
|
+
end
|
18
|
+
|
19
|
+
let(:packaged) { cob.pack }
|
20
|
+
let(:unpackaged) { example_cob_class.unpack(packaged) }
|
21
|
+
it { unpackaged.should eq [record1, record2] }
|
22
|
+
end
|
data/zeamays.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.email = ["myun2@nwhite.info"]
|
11
11
|
spec.summary = %q{Minimum Database gem for Ruby (notSQL)}
|
12
12
|
spec.description = %q{Minimum Database gem for Ruby (notSQL)}
|
13
|
-
spec.homepage = ""
|
13
|
+
spec.homepage = "https://github.com/myun2ext/zeamays"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0")
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zeamays
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- myun2
|
@@ -60,28 +60,36 @@ extensions: []
|
|
60
60
|
extra_rdoc_files: []
|
61
61
|
files:
|
62
62
|
- .gitignore
|
63
|
+
- .travis.yml
|
63
64
|
- Gemfile
|
65
|
+
- Guardfile
|
64
66
|
- LICENSE.txt
|
65
67
|
- README.md
|
66
68
|
- Rakefile
|
67
69
|
- lib/zeamays.rb
|
68
70
|
- lib/zeamays/cob.rb
|
71
|
+
- lib/zeamays/cob/defreezing.rb
|
72
|
+
- lib/zeamays/cob/freezing.rb
|
69
73
|
- lib/zeamays/cob/gene.rb
|
74
|
+
- lib/zeamays/cob/growth.rb
|
70
75
|
- lib/zeamays/corn.rb
|
71
76
|
- lib/zeamays/corn/fruiter.rb
|
72
77
|
- lib/zeamays/corn/fruiter/byte.rb
|
73
78
|
- lib/zeamays/corn/fruiter/integer16.rb
|
74
79
|
- lib/zeamays/corn/fruiter/integer32.rb
|
80
|
+
- lib/zeamays/corn/fruiter/string.rb
|
75
81
|
- lib/zeamays/corn/granule.rb
|
76
82
|
- lib/zeamays/corn/mass.rb
|
77
|
-
- lib/zeamays/
|
83
|
+
- lib/zeamays/corn/string.rb
|
84
|
+
- lib/zeamays/fridge.rb
|
78
85
|
- lib/zeamays/version.rb
|
86
|
+
- spec/model_test/zeamays_mode_example_spec.rb
|
79
87
|
- spec/zeamays/corn/fruiter/integer16_spec.rb
|
80
88
|
- spec/zeamays/corn/fruiter/integer32_spec.rb
|
81
89
|
- spec/zeamays/corn/fruiter_spec.rb
|
82
90
|
- spec/zeamays_spec.rb
|
83
91
|
- zeamays.gemspec
|
84
|
-
homepage:
|
92
|
+
homepage: https://github.com/myun2ext/zeamays
|
85
93
|
licenses:
|
86
94
|
- MIT
|
87
95
|
metadata: {}
|
@@ -106,6 +114,7 @@ signing_key:
|
|
106
114
|
specification_version: 4
|
107
115
|
summary: Minimum Database gem for Ruby (notSQL)
|
108
116
|
test_files:
|
117
|
+
- spec/model_test/zeamays_mode_example_spec.rb
|
109
118
|
- spec/zeamays/corn/fruiter/integer16_spec.rb
|
110
119
|
- spec/zeamays/corn/fruiter/integer32_spec.rb
|
111
120
|
- spec/zeamays/corn/fruiter_spec.rb
|
data/lib/zeamays/serialize.rb
DELETED