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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 708c389bc20b556951cf0316255899a11a64d495
4
- data.tar.gz: 57dd89f064bbb2914c8d0eb0b1488339fd1587d1
3
+ metadata.gz: c2e4a80fc0fe7de57bf7f44e1509c5c47ec58bc2
4
+ data.tar.gz: 6afdce580bfe2fac0ba159a21ba3153d9cb6f193
5
5
  SHA512:
6
- metadata.gz: 949de3b23500a28f0a54e6b90730ce4d78053aba404d247aff818e83c4909cd920e5171e11599af569f8fb2c6222c111cb94f67cdf7f765c645876047598b06e
7
- data.tar.gz: 5e74383b2089e242fe4ec0d97640f7b1423606ba4678648a7cb95103efc1efcdf2f72b5af876a8e1425478dc81884f954d95745a0864d67b327425fa6722b18b
6
+ metadata.gz: 11a714a7c8de5a974a0de9de20087205ae9aa8df10150aef1c03c818bf58792a4ab81664bf9339e7d99b0a1201f3ebb659d07074c0db9282b4b2ede43223cef8
7
+ data.tar.gz: 120723a5fc7f25f964cf1968eb988731520941b456c3f2abe4afe2db087ac0cabd18ccbffa125b93062058f17caeaa73b32aba028c8fe9940601acb9f0f8dd34
data/.gitignore CHANGED
@@ -19,4 +19,5 @@ tmp
19
19
  *.so
20
20
  *.o
21
21
  *.a
22
+ *.swp
22
23
  mkmf.log
@@ -0,0 +1,6 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.0.0
5
+ - 2.1.0
6
+ - 2.1.2
data/Gemfile CHANGED
@@ -2,3 +2,7 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in zeamays.gemspec
4
4
  gemspec
5
+ group :development, :test do
6
+ gem 'guard'
7
+ gem 'guard-rspec'
8
+ end
@@ -0,0 +1,8 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ guard 'rspec' do
5
+ watch(%r{^spec/.+_spec\.rb$})
6
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
7
+ watch('spec/spec_helper.rb') { "spec" }
8
+ end
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
- TODO: Write usage instructions here
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
@@ -1,5 +1,7 @@
1
1
  require "zeamays/version"
2
+ require "zeamays/cob"
3
+ require "zeamays/corn"
4
+ require "zeamays/fridge"
2
5
 
3
6
  module Zeamays
4
- # Your code goes here...
5
7
  end
@@ -1,4 +1,13 @@
1
+ require 'zeamays/cob/gene'
2
+ require 'zeamays/cob/growth'
3
+ require 'zeamays/cob/freezing'
4
+ require 'zeamays/cob/defreezing'
5
+
1
6
  module Zeamays
2
7
  class Cob
8
+ extend Gene
9
+ include Growth
10
+ include Freezing
11
+ extend Defreezing
3
12
  end
4
13
  end
@@ -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
@@ -3,6 +3,15 @@
3
3
  module Zeamays
4
4
  class Cob
5
5
  module Gene
6
+ @gene = []
7
+
8
+ def gene_sequencing(*pattern)
9
+ @gene = pattern
10
+ end
11
+
12
+ def gene_sequence
13
+ @gene
14
+ end
6
15
  end
7
16
  end
8
17
  end
@@ -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
@@ -0,0 +1,11 @@
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
@@ -0,0 +1,9 @@
1
+ module Zeamays
2
+ class Fridge
3
+ def self.stick(cob, path)
4
+ File.open(path, "wb") { |file|
5
+ f.write cob.freeze
6
+ }
7
+ end
8
+ end
9
+ end
@@ -1,3 +1,3 @@
1
1
  module Zeamays
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -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
@@ -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.1
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/serialize.rb
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
@@ -1,4 +0,0 @@
1
- module Zeamays
2
- module Serialize
3
- end
4
- end