tangshi 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE.txt +21 -0
- data/README.md +36 -0
- data/lib/db/tangshi.sqlite +0 -0
- data/lib/tangshi/version.rb +3 -0
- data/lib/tangshi.rb +20 -0
- metadata +63 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 02894910edcef87b25e559f9af7d116942e52632
|
4
|
+
data.tar.gz: 377d5d832cb8f7dd9a4de0c32bbdce989665f1c5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 79a179a77cb44e4aa1c3808a15ab0790080c2114d12a0cd9ded3802913dcb41cd2162fec4d979b18e1f347aab66885e8092c68c4c537c4bfc3d636e2bc035e9b
|
7
|
+
data.tar.gz: 3ce49505c7f51af135191872793a1081b2b4b94b68831c5b017990df33ad6cb6b5dbd49adfd82f38ec0fcc2655e5948a005ff88bdf5bfb123859145a06511cd0
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 adamshen
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# Tangshi
|
2
|
+
|
3
|
+
唐诗的数据库,ORM用的AD
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
$ gem install tangshi
|
8
|
+
|
9
|
+
## Usage
|
10
|
+
|
11
|
+
两个表poets和poetries
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
Tangshi::Poet.column_names
|
15
|
+
=> ["id", "name", "created_at", "updated_at"]
|
16
|
+
|
17
|
+
Tangshi::Poetry.column_names
|
18
|
+
=> ["id", "poet_id", "content", "title", "created_at", "updated_at"]
|
19
|
+
|
20
|
+
Tangshi::Poet.find_by_name("李商隐").poetries.length
|
21
|
+
=> 555
|
22
|
+
|
23
|
+
Tangshi::Poetry.search_sentence("心有灵犀")
|
24
|
+
=> [#<Tangshi::Poetry:0x007fa431f1cb38
|
25
|
+
id: 25788,
|
26
|
+
poet_id: 166,
|
27
|
+
content: "昨夜星辰昨夜风,画楼西畔桂堂东。身无彩凤双飞翼,心有灵犀一点通。隔座送钩春酒暖,分曹射覆蜡灯红。嗟余听鼓应官去,走马兰台类断蓬。闻道阊门萼绿华,昔年相望抵天涯。岂知一夜秦楼客,偷看吴王苑内花。",
|
28
|
+
title: "无题二首",
|
29
|
+
created_at: 2014-06-02 12:22:16 UTC,
|
30
|
+
updated_at: 2014-06-02 12:22:16 UTC>]
|
31
|
+
```
|
32
|
+
|
33
|
+
## License
|
34
|
+
|
35
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
36
|
+
|
Binary file
|
data/lib/tangshi.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require "tangshi/version"
|
2
|
+
require "active_record"
|
3
|
+
require "pry"
|
4
|
+
|
5
|
+
module Tangshi
|
6
|
+
class Poet < ActiveRecord::Base
|
7
|
+
establish_connection :adapter => "sqlite3", :database => File.expand_path('../db/tangshi.sqlite', __FILE__)
|
8
|
+
|
9
|
+
has_many :poetries
|
10
|
+
end
|
11
|
+
class Poetry < ActiveRecord::Base
|
12
|
+
establish_connection :adapter => "sqlite3", :database =>File.expand_path('../db/tangshi.sqlite', __FILE__)
|
13
|
+
|
14
|
+
belongs_to :poet
|
15
|
+
|
16
|
+
def self.search_sentence(string)
|
17
|
+
where("content like '%#{string}%'")
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: tangshi
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- adamshen
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-04-13 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activerecord
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
description: using active_record as orm
|
28
|
+
email:
|
29
|
+
- adam_ruby@126.com
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- LICENSE.txt
|
35
|
+
- README.md
|
36
|
+
- lib/db/tangshi.sqlite
|
37
|
+
- lib/tangshi.rb
|
38
|
+
- lib/tangshi/version.rb
|
39
|
+
homepage: https://github.com/adamshen/tangshi
|
40
|
+
licenses:
|
41
|
+
- MIT
|
42
|
+
metadata: {}
|
43
|
+
post_install_message:
|
44
|
+
rdoc_options: []
|
45
|
+
require_paths:
|
46
|
+
- lib
|
47
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
48
|
+
requirements:
|
49
|
+
- - ">="
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: '0'
|
52
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '0'
|
57
|
+
requirements: []
|
58
|
+
rubyforge_project:
|
59
|
+
rubygems_version: 2.5.1
|
60
|
+
signing_key:
|
61
|
+
specification_version: 4
|
62
|
+
summary: database of tang poems
|
63
|
+
test_files: []
|