shameless 0.4.0 → 0.5.0

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: 0ff6ea520714793fdb051f127d2e4cbbf931fb29
4
- data.tar.gz: 41128cd58c21dd895fc7323777693e2a06ac3843
3
+ metadata.gz: 839607ae8ec8ee9e759f37a6f2a6c69264fca086
4
+ data.tar.gz: 498b1d442dc13719c2a67a5a3176f0bf160baa32
5
5
  SHA512:
6
- metadata.gz: 23ecbebf884feae9a8beb027c3e3b1c6f567b29f897e5b71902190c01f42628de9b504368b59890d5f5d06ad52c73096b6f01260ffba56860dfb4ef0c6b8ab9f
7
- data.tar.gz: 5185109b6ab8aadef0f441d0ae6b56892d19910973dcd11456c66c8c93bd257dd58b501d7c890d3595520db155aec186331e7935e1342a093c770a507a4af2fd
6
+ metadata.gz: f2f01520df26451f4b64fa4b70bcbe24d169565d105955a715f88245680e032b8aa8065f8c03354440a07e6e7d385473ad7e45f30e5017529b266a2cea1d5579
7
+ data.tar.gz: 06d827ed97efc129c88ec1d0ded8f0d271a990b84580129b436957f38e5ed3638f2d6761551670afd292ac9fb5c2d3dc217f97dcd3800513dfdc0b625391183e
data/.travis.yml CHANGED
@@ -1,5 +1,3 @@
1
- sudo: false
2
1
  language: ruby
3
2
  rvm:
4
- - 2.3.1
5
- before_install: gem install bundler -v 1.12.5
3
+ - 2.3.2
data/CHANGELOG.md CHANGED
@@ -1,4 +1,7 @@
1
- ### Unreleased
1
+ ### 0.5.0 (2016-12-01)
2
+
3
+ * Add `Model#as_json` and `Cell#as_json`
4
+ * Remember cell ID after save
2
5
 
3
6
  ### 0.4.0 (2016-11-21)
4
7
 
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Shameless
2
2
 
3
+ [![Build Status](https://travis-ci.org/hoteltonight/shameless.svg?branch=master)](https://travis-ci.org/hoteltonight/shameless)
4
+
3
5
  Shameless is an implementation of a schemaless, distributed, append-only store built on top of MySQL and the Sequel gem. It was extracted from a battle-tested codebase of our main application at HotelTonight. Since it's using Sequel for database access, it could work on any database, e.g. postgres, although we've only used it with MySQL.
4
6
 
5
7
  ## Background
@@ -18,6 +18,7 @@ module Shameless
18
18
  def initialize(model, name, values = nil)
19
19
  @model = model
20
20
  @name = name
21
+ reload
21
22
  initialize_from_values(values)
22
23
  end
23
24
 
@@ -36,7 +37,7 @@ module Shameless
36
37
  @created_at = (@created_at.to_f * 1000).to_i if @model.class.store.configuration.legacy_created_at_is_bigint
37
38
  @ref_key ||= -1
38
39
  @ref_key += 1
39
- @model.put_cell(cell_values)
40
+ @id = @model.put_cell(cell_values(true))
40
41
  end
41
42
 
42
43
  def update(values)
@@ -69,7 +70,7 @@ module Shameless
69
70
  end
70
71
 
71
72
  def reload
72
- @body = @ref_key = @created_at = nil
73
+ @id = @body = @ref_key = @created_at = nil
73
74
  end
74
75
 
75
76
  def fetch(key, default)
@@ -85,15 +86,19 @@ module Shameless
85
86
  @model.uuid
86
87
  end
87
88
 
89
+ def as_json(*)
90
+ cell_values(false).merge(id: id)
91
+ end
92
+
88
93
  private
89
94
 
90
- def cell_values
95
+ def cell_values(serialize_body)
91
96
  {
92
97
  uuid: uuid,
93
98
  column_name: @name,
94
99
  ref_key: ref_key,
95
100
  created_at: created_at,
96
- body: serialized_body
101
+ body: serialize_body ? serialized_body : body
97
102
  }
98
103
  end
99
104
 
@@ -36,8 +36,8 @@ module Shameless
36
36
  else
37
37
  uuid = SecureRandom.uuid
38
38
 
39
- new(uuid, values).tap do |model|
40
- model.save
39
+ new(uuid, values).tap do |m|
40
+ m.save
41
41
 
42
42
  index_values = values.merge(uuid: uuid)
43
43
  @indices.each {|i| i.put(index_values) }
@@ -152,6 +152,10 @@ module Shameless
152
152
  base.present?
153
153
  end
154
154
 
155
+ def as_json(*)
156
+ base.as_json
157
+ end
158
+
155
159
  def reload
156
160
  cells.each(&:reload)
157
161
  end
@@ -80,7 +80,7 @@ module Shameless
80
80
 
81
81
  def connect(url)
82
82
  Sequel.connect(url, @configuration.connection_options || Sequel::OPTS).tap do |db|
83
- db.extension *@configuration.database_extensions
83
+ db.extension(*@configuration.database_extensions)
84
84
  end
85
85
  end
86
86
 
@@ -1,3 +1,3 @@
1
1
  module Shameless
2
- VERSION = "0.4.0"
2
+ VERSION = "0.5.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shameless
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Olek Janiszewski
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-11-21 00:00:00.000000000 Z
11
+ date: 2016-12-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: msgpack
@@ -140,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
140
140
  version: '0'
141
141
  requirements: []
142
142
  rubyforge_project:
143
- rubygems_version: 2.5.1
143
+ rubygems_version: 2.5.2
144
144
  signing_key:
145
145
  specification_version: 4
146
146
  summary: Scalable distributed append-only data store