drafting 0.3.1 → 0.4.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
- SHA1:
3
- metadata.gz: 61e04953e874ef520f0c4050d466663e9054668f
4
- data.tar.gz: 48933b218cd25ebb903c194bd781664dcdce72af
2
+ SHA256:
3
+ metadata.gz: 51d1c3d502674eec9428f13ab49b4bb409d167a29fa7b2394d201122c5f52d3b
4
+ data.tar.gz: 9484a9e2dd0a4105323d892f0df8c5a29e324cb54503e3bd9bd36f5b5c604db1
5
5
  SHA512:
6
- metadata.gz: a22afe0d44338e29007d41304a1a5e78cf1400a9a363a3de0f1a7834ef237dfcdac40f9bf31892f83c0ba3731fa380f44d6e89a4bf0f1fedee045b71e52bf1b6
7
- data.tar.gz: db8a828b28ccc88474b2ce9296a4adb2e968941310462fd88de3adb119fe438ce8614e1da2aa6033b6e02e2da700fa3f1d4827a16f42cfe494300b5b05377a7c
6
+ metadata.gz: 1ca6ad79074647ff654c65c32df1ae9e78e003e0cf477c43c2b91c6c3a03d9936160fec32953b4c26d5ce0234a1568149bf8d990f396c82f2bf21a876086b183
7
+ data.tar.gz: 8b59432d40b880c1ee74666f2e4c9be2cdd5b642323ad257fa9f3cb2fd189c67c2792a5ec9412d8eda00a6301faab2a2d04b6f1d662dfe9f8458b2c60e199f0d
data/.travis.yml CHANGED
@@ -2,9 +2,9 @@ language: ruby
2
2
  rvm:
3
3
  - 2.0.0
4
4
  - 2.1.10
5
- - 2.2.7
6
- - 2.3.4
7
- - 2.4.1
5
+ - 2.2.8
6
+ - 2.3.5
7
+ - 2.4.2
8
8
  gemfile:
9
9
  - gemfiles/rails_5_1.gemfile
10
10
  - gemfiles/rails_5_0.gemfile
@@ -20,7 +20,7 @@ matrix:
20
20
  gemfile: gemfiles/rails_5_0.gemfile
21
21
  - rvm: 2.1.10
22
22
  gemfile: gemfiles/rails_5_0.gemfile
23
- - rvm: 2.4.1
23
+ - rvm: 2.4.2
24
24
  gemfile: gemfiles/rails_4_1.gemfile
25
25
  before_install: gem update bundler
26
26
  sudo: false
data/README.md CHANGED
@@ -14,7 +14,7 @@ This Ruby gem enhances `ActiveRecord::Base` to save a draft version of the curre
14
14
  * A draft stores associations and virtual attributes, too
15
15
  * A draft is optionally linked to a given user, so every user can manage his own drafts (invisible for the other users)
16
16
  * A draft is optionally linked to a parent instance. This helps showing existing drafts in a context (e.g. message drafts for a given topic)
17
- * Only 80 lines of code
17
+ * Only 90 lines of code
18
18
 
19
19
  ## Requirements
20
20
 
@@ -61,6 +61,9 @@ message.save_draft(current_user)
61
61
  draft = Message.drafts(current_user).first
62
62
  message = draft.restore
63
63
  message.save!
64
+
65
+ drafts = Message.drafts(current_user)
66
+ messages = drafts.restore_all
64
67
  ```
65
68
 
66
69
  ### Linking to parent instance
data/Rakefile CHANGED
@@ -3,4 +3,4 @@ require "rspec/core/rake_task"
3
3
 
4
4
  RSpec::Core::RakeTask.new(:spec)
5
5
 
6
- task :default => :spec
6
+ task default: :spec
data/drafting.gemspec CHANGED
@@ -26,7 +26,7 @@ Gem::Specification.new do |spec|
26
26
  spec.add_development_dependency "rake"
27
27
  spec.add_development_dependency "rspec"
28
28
  spec.add_development_dependency "sqlite3"
29
- spec.add_development_dependency "factory_girl"
29
+ spec.add_development_dependency "factory_bot"
30
30
  spec.add_development_dependency "coveralls"
31
31
  spec.add_development_dependency "simplecov"
32
32
  spec.add_development_dependency "appraisal"
@@ -2,6 +2,6 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "activerecord", "~> 4.2.8"
5
+ gem "activerecord", "~> 4.2.9"
6
6
 
7
7
  gemspec path: "../"
@@ -2,6 +2,6 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "activerecord", "~> 5.0.2"
5
+ gem "activerecord", "~> 5.0.6"
6
6
 
7
7
  gemspec path: "../"
@@ -2,6 +2,6 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "activerecord", "~> 5.1.0"
5
+ gem "activerecord", "~> 5.1.4"
6
6
 
7
7
  gemspec path: "../"
@@ -15,11 +15,11 @@ module Drafting
15
15
  unless parent_class.method_defined? :drafts
16
16
  parent_class.class_eval do
17
17
  def drafts(user)
18
- Draft.where(:user => user, :parent => self)
18
+ Draft.where(user: user, parent: self)
19
19
  end
20
20
 
21
21
  def self.child_drafts(user)
22
- Draft.where(:user => user, :parent_type => self.base_class.name)
22
+ Draft.where(user: user, parent_type: self.base_class.name)
23
23
  end
24
24
  end
25
25
  end
@@ -13,7 +13,7 @@ module Drafting
13
13
  end
14
14
 
15
15
  def drafts(user)
16
- Draft.where(:user => user, :target_type => name)
16
+ Draft.where(user: user, target_type: name)
17
17
  end
18
18
  end
19
19
  end
@@ -1,10 +1,14 @@
1
1
  class Draft < ActiveRecord::Base
2
2
  belongs_to :user
3
- belongs_to :parent, :polymorphic => true
3
+ belongs_to :parent, polymorphic: true
4
4
 
5
5
  validates_presence_of :data, :target_type
6
6
 
7
7
  def restore
8
8
  target_type.constantize.from_draft(self)
9
9
  end
10
+
11
+ def self.restore_all
12
+ find_each.map(&:restore)
13
+ end
10
14
  end
@@ -1,3 +1,3 @@
1
1
  module Drafting
2
- VERSION = "0.3.1"
2
+ VERSION = "0.4.0"
3
3
  end
@@ -1,11 +1,11 @@
1
1
  class DraftingMigration < Drafting::MIGRATION_BASE_CLASS
2
2
  def self.up
3
3
  create_table :drafts do |t|
4
- t.string :target_type, :null => false
4
+ t.string :target_type, null: false
5
5
  t.references :user
6
- t.references :parent, :polymorphic => true, :index => true
7
- t.binary :data, :limit => 16777215, :null => false
8
- t.datetime :updated_at, :null => false
6
+ t.references :parent, polymorphic: true, index: true
7
+ t.binary :data, limit: 16777215, null: false
8
+ t.datetime :updated_at, null: false
9
9
  end
10
10
 
11
11
  add_index :drafts, [:user_id, :target_type]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: drafting
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Georg Ledermann
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-04-29 00:00:00.000000000 Z
11
+ date: 2017-11-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -81,7 +81,7 @@ dependencies:
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
- name: factory_girl
84
+ name: factory_bot
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - ">="
@@ -187,7 +187,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
187
187
  version: '0'
188
188
  requirements: []
189
189
  rubyforge_project:
190
- rubygems_version: 2.6.11
190
+ rubygems_version: 2.7.2
191
191
  signing_key:
192
192
  specification_version: 4
193
193
  summary: Save draft version of any ActiveRecord object