zeamays 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 63c64b1abe873452b3a50f93df15acc7c37201e9
4
- data.tar.gz: 31593cf69e4c7a3b281d890319752f5ca7dd1696
3
+ metadata.gz: 8a97403a14887bb25163d86332669c1b3d13c2af
4
+ data.tar.gz: 14d6996da00292657523488cc36d923ced25551b
5
5
  SHA512:
6
- metadata.gz: 300eeb8608f053cfc6275ee0b944859fbbb0ceeb42fa26c217c69ae717a8964c475a1d566efb9380481b982d041fc0dba6ad231ce9a03a740031aa1d7b24d83b
7
- data.tar.gz: 364538df09fae0b35285de80254e4b2ae50b85eb46ddd6a50e823e7587a37cbb52aa103e7c8b242cc3063d8446ea3baff7be33a17f7d052869cd564b61a0e8d6
6
+ metadata.gz: 802cc378549b24299c768c331b413cfd7b5095d2d514d9875f5b4ac960fd99ab78022f7b1563f599e16fef7db2f909706b439d31aeb56fb161ca7625cd6b70b9
7
+ data.tar.gz: efedb9afb96a072416212ae8859d8d1ace8d7ddcba82cebe0b0a9353f3b2524bf726bc2d92a99a0248418e829397f7ff38322d4dc60d518d73939ead486647bf
data/README.md CHANGED
@@ -2,7 +2,9 @@
2
2
 
3
3
  [![Build Status](https://travis-ci.org/myun2ext/zeamays.svg?branch=master)](https://travis-ci.org/myun2ext/zeamays)
4
4
 
5
- Minimum Database gem for Ruby (notSQL)
5
+ **Zeamays** is **Simple Persistation Any Data** for Ruby.
6
+
7
+ https://rubygems.org/gems/zeamays
6
8
 
7
9
  ## Installation
8
10
 
@@ -1,6 +1,5 @@
1
1
  require "zeamays/version"
2
2
  require "zeamays/cob"
3
- require "zeamays/corn"
4
3
  require "zeamays/fridge"
5
4
 
6
5
  module Zeamays
@@ -1,7 +1,7 @@
1
1
  module Zeamays
2
2
  class Cob
3
3
  module Defreezing
4
- def unpack(packed_string)
4
+ def deserialized(packed_string)
5
5
  unpacked_list = []
6
6
 
7
7
  left_string = packed_string
@@ -15,11 +15,13 @@ module Zeamays
15
15
 
16
16
  def defreeze(freezed)
17
17
  cob = Cob.new
18
- unpack(freezed).each do |row|
18
+ deserialized(freezed).each do |row|
19
19
  cob.grow!(row)
20
20
  end
21
21
  cob
22
22
  end
23
+ alias unpack defreeze
24
+ alias depack defreeze
23
25
 
24
26
  private
25
27
  def tail_pattern
@@ -6,13 +6,8 @@ module Zeamays
6
6
  row.pack(self.class.package_pattern)
7
7
  }.join("")
8
8
  end
9
-
10
- def freeze
11
- pack
12
- end
13
- def freezed
14
- pack
15
- end
9
+ alias freeze pack
10
+ alias freezed pack
16
11
 
17
12
  module ClassMethods
18
13
  def package_pattern
@@ -1,9 +1,15 @@
1
1
  module Zeamays
2
2
  class Fridge
3
- def self.stick(cob, path)
4
- File.open(path, "wb") { |file|
5
- f.write cob.freeze
3
+ def self.stick(path, freezed)
4
+ File.open(path, "wb") { |f|
5
+ f.write(freezed)
6
6
  }
7
7
  end
8
+
9
+ def self.take(path)
10
+ #File.open(path, "rb") { |f|
11
+ #}
12
+ readed = File.binread(path)
13
+ end
8
14
  end
9
15
  end
@@ -1,3 +1,3 @@
1
1
  module Zeamays
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
@@ -1,14 +1,13 @@
1
1
  require "zeamays"
2
2
 
3
3
  describe "Zeamays Model example" do
4
- let(:example_cob_class) {
4
+ before do
5
5
  class YellowSweet < Zeamays::Cob
6
6
  gene_sequencing :i8, :i16, :integer, :string
7
7
  end
8
- YellowSweet
9
- }
8
+ end
10
9
 
11
- let(:cob) { example_cob_class.new }
10
+ let(:cob) { YellowSweet.new }
12
11
  let(:record1) { [30, 2000, 500000, "test"] }
13
12
  let(:record2) { [80, 1000, 200000, "Example!!! "] }
14
13
  before do
@@ -16,14 +15,35 @@ describe "Zeamays Model example" do
16
15
  cob.grow(record2)
17
16
  end
18
17
 
19
- let(:packaged) { cob.pack }
20
- let(:unpackaged) { example_cob_class.unpack(packaged) }
21
- it { expect(unpackaged).to eq [record1, record2] }
18
+ let(:packed) { cob.pack }
19
+ let(:unpacked) { YellowSweet.unpack(packed) }
20
+
21
+ describe "pack and unpack" do
22
+ it { expect(unpacked[0]).to eq record1 }
23
+ it { expect(unpacked[1]).to eq record2 }
24
+ end
25
+
26
+ describe "Fridging" do
27
+ before do
28
+ FileUtils.makedirs("./tmp")
29
+ fridging
30
+ end
31
+ after do
32
+ #FileUtils.remove_dir("./tmp")
33
+ end
34
+
35
+ let(:fridging_path) { "./tmp/yellow_sweet.zmd" }
36
+ let(:fridging) do
37
+ Zeamays::Fridge.stick(fridging_path, cob.freezed)
38
+ end
39
+ let(:defridged) do
40
+ Zeamays::Fridge.take(fridging_path)
41
+ end
42
+ let(:defreezed_cob) do
43
+ YellowSweet.defreeze(defridged)
44
+ end
22
45
 
23
- describe "#defreeze" do
24
- let(:freezed) { cob.freezed }
25
- let(:defreezed) { example_cob_class.defreeze(freezed) }
26
- it { expect(defreezed[0]).to eq record1 }
27
- it { expect(defreezed[1]).to eq record2 }
46
+ it { expect(defreezed_cob[0]).to eq record1 }
47
+ it { expect(defreezed_cob[1]).to eq record2 }
28
48
  end
29
49
  end
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
8
8
  spec.version = Zeamays::VERSION
9
9
  spec.authors = ["myun2"]
10
10
  spec.email = ["myun2@nwhite.info"]
11
- spec.summary = %q{Minimum Database gem for Ruby (notSQL)}
12
- spec.description = %q{Minimum Database gem for Ruby (notSQL)}
11
+ spec.summary = %q{Simple Persistation Any Data for Ruby.}
12
+ spec.description = %q{Simple Persistation Any Data for Ruby.}
13
13
  spec.homepage = "https://github.com/myun2ext/zeamays"
14
14
  spec.license = "MIT"
15
15
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zeamays
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - myun2
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-11 00:00:00.000000000 Z
11
+ date: 2014-07-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,7 +52,7 @@ dependencies:
52
52
  - - '>='
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
- description: Minimum Database gem for Ruby (notSQL)
55
+ description: Simple Persistation Any Data for Ruby.
56
56
  email:
57
57
  - myun2@nwhite.info
58
58
  executables: []
@@ -72,21 +72,9 @@ files:
72
72
  - lib/zeamays/cob/freezing.rb
73
73
  - lib/zeamays/cob/gene.rb
74
74
  - lib/zeamays/cob/growth.rb
75
- - lib/zeamays/corn.rb
76
- - lib/zeamays/corn/fruiter.rb
77
- - lib/zeamays/corn/fruiter/byte.rb
78
- - lib/zeamays/corn/fruiter/integer16.rb
79
- - lib/zeamays/corn/fruiter/integer32.rb
80
- - lib/zeamays/corn/fruiter/string.rb
81
- - lib/zeamays/corn/granule.rb
82
- - lib/zeamays/corn/mass.rb
83
- - lib/zeamays/corn/string.rb
84
75
  - lib/zeamays/fridge.rb
85
76
  - lib/zeamays/version.rb
86
77
  - spec/model_test/zeamays_mode_example_spec.rb
87
- - spec/zeamays/corn/fruiter/integer16_spec.rb
88
- - spec/zeamays/corn/fruiter/integer32_spec.rb
89
- - spec/zeamays/corn/fruiter_spec.rb
90
78
  - spec/zeamays_spec.rb
91
79
  - zeamays.gemspec
92
80
  homepage: https://github.com/myun2ext/zeamays
@@ -112,10 +100,7 @@ rubyforge_project:
112
100
  rubygems_version: 2.1.11
113
101
  signing_key:
114
102
  specification_version: 4
115
- summary: Minimum Database gem for Ruby (notSQL)
103
+ summary: Simple Persistation Any Data for Ruby.
116
104
  test_files:
117
105
  - spec/model_test/zeamays_mode_example_spec.rb
118
- - spec/zeamays/corn/fruiter/integer16_spec.rb
119
- - spec/zeamays/corn/fruiter/integer32_spec.rb
120
- - spec/zeamays/corn/fruiter_spec.rb
121
106
  - spec/zeamays_spec.rb
@@ -1,4 +0,0 @@
1
- module Zeamays
2
- class Corn
3
- end
4
- end
@@ -1,8 +0,0 @@
1
- module Zeamays
2
- class Corn
3
- class Fruiter
4
- def self.fruit(*corn_or_masses)
5
- end
6
- end
7
- end
8
- end
@@ -1,11 +0,0 @@
1
- module Zeamays
2
- class Corn
3
- class Fruiter
4
- module Byte
5
- def self.fruit_byte(u8)
6
- [u8].pack("C")
7
- end
8
- end
9
- end
10
- end
11
- end
@@ -1,11 +0,0 @@
1
- module Zeamays
2
- class Corn
3
- class Fruiter
4
- module Integer16
5
- def self.fruit_i16(value)
6
- [value].pack("n")
7
- end
8
- end
9
- end
10
- end
11
- end
@@ -1,11 +0,0 @@
1
- module Zeamays
2
- class Corn
3
- class Fruiter
4
- module Integer32
5
- def self.fruit_i32(value)
6
- [value].pack("N")
7
- end
8
- end
9
- end
10
- end
11
- end
@@ -1,22 +0,0 @@
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
@@ -1,11 +0,0 @@
1
- module Zeamays
2
- class Corn
3
- class Granule
4
- @value = nil
5
-
6
- def initialize(value)
7
- @value = value
8
- end
9
- end
10
- end
11
- end
@@ -1,11 +0,0 @@
1
- module Zeamays
2
- class Corn
3
- class Mass
4
- @value = nil
5
-
6
- def initialize(value)
7
- @value = value
8
- end
9
- end
10
- end
11
- end
@@ -1,11 +0,0 @@
1
- module Zeamays
2
- class Corn
3
- class String
4
- @s = ""
5
-
6
- def initialize(s)
7
- @s = s
8
- end
9
- end
10
- end
11
- end
@@ -1,13 +0,0 @@
1
- require 'zeamays/corn/fruiter/integer16'
2
-
3
- describe Zeamays::Corn::Fruiter::Integer16 do
4
- let(:packing) { Zeamays::Corn::Fruiter::Integer16.fruit_i16(target_value) }
5
-
6
- context "normally" do
7
- let(:target_value) { 50000 }
8
- subject { packing.unpack("n").first }
9
- it { should eq target_value }
10
- end
11
-
12
- pending "Not Integer16 type"
13
- end
@@ -1,13 +0,0 @@
1
- require 'zeamays/corn/fruiter/integer32'
2
-
3
- describe Zeamays::Corn::Fruiter::Integer32 do
4
- let(:packing) { Zeamays::Corn::Fruiter::Integer32.fruit_i32(target_value) }
5
-
6
- context "normally" do
7
- let(:target_value) { 4000000000 }
8
- subject { packing.unpack("N").first }
9
- it { should eq target_value }
10
- end
11
-
12
- pending "Not Integer32 type"
13
- end
@@ -1,22 +0,0 @@
1
- require 'zeamays/corn/fruiter'
2
- require 'zeamays/corn/fruiter/byte'
3
-
4
- describe Zeamays::Corn::Fruiter do
5
- context "Byte" do
6
- let(:packing) { Zeamays::Corn::Fruiter::Byte.fruit_byte(target_value) }
7
-
8
- context "normally" do
9
- let(:target_value) { 30 }
10
- subject { packing.unpack("C").first }
11
- it { should eq target_value }
12
- end
13
-
14
- context "over byte size" do
15
- let(:target_value) { 300 }
16
- subject { packing.unpack("C").first }
17
- it { should eq (300 - 256) }
18
- end
19
-
20
- pending "Not byte type"
21
- end
22
- end