yinx_sql 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/yinx_sql.rb +4 -13
- data/lib/yinx_sql/batch.rb +12 -19
- data/lib/yinx_sql/note.rb +7 -1
- data/lib/yinx_sql/version.rb +1 -1
- data/yinx_sql.gemspec +1 -1
- metadata +6 -8
- data/lib/yinx_sql/book.rb +0 -11
- data/lib/yinx_sql/stack.rb +0 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1fc35c9b4ca3237fff11f3c1ec25ab076dd77f50
|
4
|
+
data.tar.gz: 5ea8718c80eda6e7c9d102d0cf4ae101fd247748
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f6a0e458109bf921e989de7e603099839c17e0b702115cbb9fea2e05f09a7a4ce32e3b3887a3deb9abe6acdfc6ee0944f82e748518ce786a74fed13bc5050534
|
7
|
+
data.tar.gz: a2d16bc5730fc93ec0655537f72b8d5c2517ba80bf131b0547bd005b16184718aea556f3f5a0172d3aec46bcb7a66e8573ba5d126c5e4a83f7f6e8217fc2a86e
|
data/lib/yinx_sql.rb
CHANGED
@@ -22,22 +22,13 @@ module Yinx
|
|
22
22
|
t.belongs_to :batch
|
23
23
|
end
|
24
24
|
|
25
|
-
create_table :stacks do |t|
|
26
|
-
t.string :name
|
27
|
-
t.belongs_to :batch
|
28
|
-
end
|
29
|
-
|
30
|
-
create_table :books do |t|
|
31
|
-
t.string :name
|
32
|
-
t.belongs_to :stack
|
33
|
-
t.belongs_to :batch
|
34
|
-
end
|
35
|
-
|
36
25
|
create_table :notes do |t|
|
37
26
|
t.string :title
|
27
|
+
t.string :book
|
28
|
+
t.string :stack
|
38
29
|
t.integer :content_length
|
39
30
|
t.timestamps
|
40
|
-
t.belongs_to :
|
31
|
+
t.belongs_to :batch
|
41
32
|
end
|
42
33
|
|
43
34
|
create_table :notes_tags do |t|
|
@@ -47,7 +38,7 @@ module Yinx
|
|
47
38
|
end
|
48
39
|
|
49
40
|
def down
|
50
|
-
[:notes_tags, :notes, :
|
41
|
+
[:notes_tags, :notes, :tags, :batches].each do |t|
|
51
42
|
drop_table t
|
52
43
|
end
|
53
44
|
end
|
data/lib/yinx_sql/batch.rb
CHANGED
@@ -1,6 +1,4 @@
|
|
1
1
|
require 'yinx'
|
2
|
-
require 'yinx_sql/stack'
|
3
|
-
require 'yinx_sql/book'
|
4
2
|
require 'yinx_sql/note'
|
5
3
|
require 'yinx_sql/tag'
|
6
4
|
|
@@ -8,25 +6,11 @@ module Yinx
|
|
8
6
|
module SQL
|
9
7
|
class Batch < ActiveRecord::Base
|
10
8
|
has_many :tags, dependent: :destroy
|
11
|
-
has_many :
|
12
|
-
has_many :books, dependent: :destroy
|
9
|
+
has_many :notes, dependent: :destroy
|
13
10
|
|
14
11
|
def self.insert notes
|
15
12
|
batch = Batch.new
|
16
13
|
|
17
|
-
stacks = Hash.new do |h, name|
|
18
|
-
stack = Stack.new name: name
|
19
|
-
batch.stacks << stack
|
20
|
-
h[name] = stack
|
21
|
-
end
|
22
|
-
|
23
|
-
books = Hash.new do |h, stack_book|
|
24
|
-
b = Book.new(name: stack_book[1])
|
25
|
-
batch.books << b
|
26
|
-
stacks[stack_book[0]].books << b
|
27
|
-
h[stack_book] = b
|
28
|
-
end
|
29
|
-
|
30
14
|
tags = Hash.new do |h, name|
|
31
15
|
tag = Tag.new name: name
|
32
16
|
batch.tags << tag
|
@@ -35,12 +19,13 @@ module Yinx
|
|
35
19
|
|
36
20
|
notes.each do |note|
|
37
21
|
n = Note.new(title: note.title,
|
22
|
+
book: note.book,
|
23
|
+
stack: note.stack,
|
38
24
|
content_length: note.contentLength,
|
39
25
|
created_at: note.created_at,
|
40
26
|
updated_at: note.updated_at)
|
41
27
|
|
42
|
-
|
43
|
-
book.notes << n
|
28
|
+
batch.notes << n
|
44
29
|
|
45
30
|
note.tags.each do |tag_name|
|
46
31
|
tag = tags[tag_name]
|
@@ -51,6 +36,14 @@ module Yinx
|
|
51
36
|
batch.save
|
52
37
|
end
|
53
38
|
|
39
|
+
def books
|
40
|
+
notes.map(&:stack_book).uniq
|
41
|
+
end
|
42
|
+
|
43
|
+
def stacks
|
44
|
+
notes.map{|note| note.stack.nil? ? 'NO_STACK' : note.stack}.uniq
|
45
|
+
end
|
46
|
+
|
54
47
|
end
|
55
48
|
end
|
56
49
|
end
|
data/lib/yinx_sql/note.rb
CHANGED
data/lib/yinx_sql/version.rb
CHANGED
data/yinx_sql.gemspec
CHANGED
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.add_development_dependency "rake", "~> 10.0"
|
25
25
|
spec.add_development_dependency "minitest", "~> 5.0"
|
26
26
|
|
27
|
-
spec.add_dependency "yinx", "0.1.
|
27
|
+
spec.add_dependency "yinx", "~> 0.1.5"
|
28
28
|
spec.add_dependency "activerecord", "~> 5.0.0"
|
29
29
|
spec.add_dependency "pg", "~> 0.19.0"
|
30
30
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yinx_sql
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ken
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-02-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -56,16 +56,16 @@ dependencies:
|
|
56
56
|
name: yinx
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0.1.
|
61
|
+
version: 0.1.5
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 0.1.
|
68
|
+
version: 0.1.5
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: activerecord
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -111,10 +111,8 @@ files:
|
|
111
111
|
- bin/setup
|
112
112
|
- lib/yinx_sql.rb
|
113
113
|
- lib/yinx_sql/batch.rb
|
114
|
-
- lib/yinx_sql/book.rb
|
115
114
|
- lib/yinx_sql/json_batch.rb
|
116
115
|
- lib/yinx_sql/note.rb
|
117
|
-
- lib/yinx_sql/stack.rb
|
118
116
|
- lib/yinx_sql/tag.rb
|
119
117
|
- lib/yinx_sql/version.rb
|
120
118
|
- yinx_sql.gemspec
|
data/lib/yinx_sql/book.rb
DELETED