archivable 0.0.3 → 1.0.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d44e5bc4b028fa7d6ac216051693c1ecf972d1eb
4
- data.tar.gz: 1e5453096684c7f2260a1098307018fae11e9f80
3
+ metadata.gz: 4fc7307d09a886e09d22380e036677cde86d644b
4
+ data.tar.gz: 96fea8d4bf70912f24cdb699ffd51af2d7541b11
5
5
  SHA512:
6
- metadata.gz: a779492544bbc49bc9fce1800c2b305a2dc1473ee7e54e398176bcb8d8a5c21cac51caa1933315d239c2632da93fefdd29ed29dc5eb9e430253d1b5327623d8a
7
- data.tar.gz: 72e4e0c6327ed264e14acc2e4ef4ef96a73bcd7ca186a1a114c0dec8db4182a61f3ccd498bd6d833f1baef89e3c08f3fcecac893f8e6ef1f7b490474a9d5c547
6
+ metadata.gz: 5ae7cebf05e9fda03dd208fddadd4b399d54392e33a742fcea648b83867367d4c0bc1d22142693166ed4593e127d329ec6f66bffa5277842627281d0caac2d91
7
+ data.tar.gz: 474d8a2c42be8be8a7b78cc547fc55fffdace91f486f8e8bcc01fb2de1443240cb41448e9862a4dbb0fd16e456a6dbabaf902c4ecf2933b88b4e57dcfcc2c5c5
@@ -1,9 +1,10 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 1.9.3
4
- - 2.0.0
5
- - 2.1.0
6
-
3
+ - 1.9
4
+ - 2.0
5
+ - 2.1
6
+ - 2.2
7
+
7
8
  notifications:
8
9
  email:
9
10
  - johnotander@gmail.com
@@ -1,4 +1,4 @@
1
- Copyright (c) 2014 John Otander
1
+ Copyright (c) 2014-2015 John Otander
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -2,27 +2,114 @@
2
2
 
3
3
  [![Build Status](https://travis-ci.org/johnotander/archivable.svg?branch=master)](https://travis-ci.org/johnotander/archivable)
4
4
 
5
- _Currently under development._
5
+ Archive your Rails models rather than delete them. This provides the archiving functionality app so you can do the following:
6
6
 
7
- Archive your Rails models rather than delete them.
7
+ ##### In your models:
8
+
9
+ ```ruby
10
+ user.archived? #=> false
11
+ user.archive! #=> true
12
+ user.archived? #=> true
13
+ user.unarchive! #=> true
14
+ user.archived? #=> false
15
+
16
+ # With scopes available:
17
+ User.archived
18
+ User.unarchived
19
+ ```
20
+
21
+ ##### In your views:
22
+
23
+ _This would typically be added to a view helper._
24
+
25
+ ```html+erb
26
+ <% if user.archived? %>
27
+ <%= link_to :Archive, archive_user_path(user) %>
28
+ <% else %>
29
+ <%= link_to :Unarchive, archive_user_path(user) %>
30
+ <% end %>
31
+ ```
8
32
 
9
33
  ## Installation
10
34
 
11
35
  Add this line to your application's Gemfile:
12
36
 
13
- gem 'archivable'
37
+ ```ruby
38
+ gem 'archivable'
39
+ ```
14
40
 
15
41
  And then execute:
16
42
 
17
- $ bundle
43
+ ```
44
+ $ bundle
45
+ ```
18
46
 
19
47
  Or install it yourself as:
20
48
 
21
- $ gem install archivable
49
+ ```
50
+ $ gem install archivable
51
+ ```
22
52
 
23
53
  ## Usage
24
54
 
25
- TODO: Write usage instructions here
55
+ ### Database Migration
56
+
57
+ First, you need to add the `archived` column to your model (which we we call `User` for this example):
58
+
59
+ ```
60
+ $ rails g migration add_archived_to_users archived:boolean
61
+ $ rake db:migrate
62
+ ```
63
+
64
+ ### Application Routes
65
+
66
+ In your routes file (`config/routes.rb`):
67
+
68
+ ```ruby
69
+ My::Application.routes.draw do
70
+ resources :users do
71
+ get archive, on: :member
72
+ get archived, on: :collection
73
+ end
74
+ end
75
+ ```
76
+
77
+ ### The Model
78
+
79
+ Next, you need to include the model concern to gain access to some handy methods.
80
+
81
+ ```ruby
82
+ class User < ActiveRecord::Base
83
+ include Archivable::Model
84
+
85
+ # ...
86
+ end
87
+ ```
88
+
89
+ ### The Controller
90
+
91
+ Lastly, you need to include the controller concern to handle the controller actions.
92
+
93
+ ```ruby
94
+ class UsersController < ApplicationController
95
+ include Archivable::Controller
96
+
97
+ def index
98
+ @users = User.where(archived: false)
99
+ end
100
+
101
+ # ...
102
+ end
103
+ ```
104
+
105
+ ### That's it.
106
+
107
+ Now, instead of a delete link, you can do the following:
108
+
109
+ ```html+erb
110
+ <%= link_to user.archived? ? :Unarchive : :Archive, archive_user_path(user) %>
111
+ <%= link_to 'See Archived Users', archived_users_path %>
112
+ ```
26
113
 
27
114
  ## Contributing
28
115
 
@@ -1,3 +1,3 @@
1
1
  module Archivable
2
- VERSION = '0.0.3'
2
+ VERSION = '1.0.0'
3
3
  end
@@ -12,7 +12,7 @@ describe Archivable::Controller do
12
12
 
13
13
  it 'should set the instance variable' do
14
14
  subject.archive
15
- subject.get_model_instance_variable.should eq(subject.fake)
15
+ expect.get_model_instance_variable).to eq(subject.fake)
16
16
  end
17
17
 
18
18
  context 'when successfully archived' do
@@ -6,10 +6,6 @@ require 'action_controller'
6
6
 
7
7
  require 'archivable'
8
8
 
9
- RSpec.configure do |config|
10
- config.color_enabled = true
11
- end
12
-
13
9
  class Fake
14
10
  attr_accessor :archived
15
11
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: archivable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Otander
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-25 00:00:00.000000000 Z
11
+ date: 2015-01-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -136,7 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
136
136
  version: '0'
137
137
  requirements: []
138
138
  rubyforge_project:
139
- rubygems_version: 2.2.2
139
+ rubygems_version: 2.4.5
140
140
  signing_key:
141
141
  specification_version: 4
142
142
  summary: Archive your Rails models rather than delete them.
@@ -144,4 +144,3 @@ test_files:
144
144
  - spec/archivable_controller_spec.rb
145
145
  - spec/archivable_model_spec.rb
146
146
  - spec/spec_helper.rb
147
- has_rdoc: