memento 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,6 @@
1
+ *.sw?
2
+ .DS_Store
3
+ coverage
4
+ rdoc
5
+ pkg
6
+ .rvmrc
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in valvat.gemspec
4
+ gemspec
5
+
6
+ group :development do
7
+ gem 'rake'
8
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,62 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ memento (0.3.3)
5
+ actionpack (>= 3.0.0)
6
+ activerecord (>= 3.0.0)
7
+
8
+ GEM
9
+ remote: http://rubygems.org/
10
+ specs:
11
+ abstract (1.0.0)
12
+ actionpack (3.0.9)
13
+ activemodel (= 3.0.9)
14
+ activesupport (= 3.0.9)
15
+ builder (~> 2.1.2)
16
+ erubis (~> 2.6.6)
17
+ i18n (~> 0.5.0)
18
+ rack (~> 1.2.1)
19
+ rack-mount (~> 0.6.14)
20
+ rack-test (~> 0.5.7)
21
+ tzinfo (~> 0.3.23)
22
+ activemodel (3.0.9)
23
+ activesupport (= 3.0.9)
24
+ builder (~> 2.1.2)
25
+ i18n (~> 0.5.0)
26
+ activerecord (3.0.9)
27
+ activemodel (= 3.0.9)
28
+ activesupport (= 3.0.9)
29
+ arel (~> 2.0.10)
30
+ tzinfo (~> 0.3.23)
31
+ activesupport (3.0.9)
32
+ arel (2.0.10)
33
+ builder (2.1.2)
34
+ diff-lcs (1.1.2)
35
+ erubis (2.6.6)
36
+ abstract (>= 1.0.0)
37
+ i18n (0.5.0)
38
+ rack (1.2.3)
39
+ rack-mount (0.6.14)
40
+ rack (>= 1.0.0)
41
+ rack-test (0.5.7)
42
+ rack (>= 1.0)
43
+ rake (0.9.2)
44
+ rspec (2.6.0)
45
+ rspec-core (~> 2.6.0)
46
+ rspec-expectations (~> 2.6.0)
47
+ rspec-mocks (~> 2.6.0)
48
+ rspec-core (2.6.4)
49
+ rspec-expectations (2.6.0)
50
+ diff-lcs (~> 1.1.2)
51
+ rspec-mocks (2.6.0)
52
+ sqlite3 (1.3.3)
53
+ tzinfo (0.3.29)
54
+
55
+ PLATFORMS
56
+ ruby
57
+
58
+ DEPENDENCIES
59
+ memento!
60
+ rake
61
+ rspec (>= 2.4.0)
62
+ sqlite3 (>= 1.3.3)
data/Rakefile CHANGED
@@ -1,31 +1,9 @@
1
- require 'rubygems'
2
- require 'rake'
3
- require "rspec/core/rake_task"
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
4
3
 
5
- RSpec::Core::RakeTask.new(:spec) do |spec|
6
- spec.pattern = 'spec/**/*_spec.rb'
7
- end
4
+ require 'rspec/core/rake_task'
8
5
 
9
- RSpec::Core::RakeTask.new(:rcov) do |spec|
10
- spec.pattern = 'spec/**/*_spec.rb'
11
- spec.rcov = true
12
- end
6
+ RSpec::Core::RakeTask.new(:spec)
13
7
 
14
8
  task :default => :spec
15
9
 
16
- begin
17
- require 'jeweler'
18
- Jeweler::Tasks.new do |gem|
19
- gem.name = "memento"
20
- gem.summary = %Q{Undo for Rails/ActiveRecord - covers destroy, update and create}
21
- gem.email = "sebastian@yo.lk"
22
- gem.homepage = "http://github.com/yolk/memento"
23
- gem.authors = ["Yolk Sebastian Munz & Julia Soergel GbR"]
24
-
25
- # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
26
- end
27
- Jeweler::GemcutterTasks.new
28
- rescue LoadError
29
- puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
30
- end
31
-
@@ -35,7 +35,7 @@ class Memento::Action::Update < Memento::Action::Base
35
35
  values = values.map{|v| v.is_a?(Time) ? v.to_s(:db) : v }
36
36
  current_value = record.send(:"#{attribute}")
37
37
  current_value = current_value.utc.to_s(:db) if current_value.is_a?(Time)
38
- values.include?(current_value)
38
+ values.include?(current_value) || (current_value.is_a?(String) && values.include?(current_value.gsub(/\r\n/, "\n")))
39
39
  end || record_data.size.zero?
40
40
  end
41
41
 
@@ -0,0 +1,3 @@
1
+ class Memento
2
+ VERSION = "0.3.3"
3
+ end
data/memento.gemspec CHANGED
@@ -1,65 +1,26 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
1
  # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "memento/version"
5
4
 
6
5
  Gem::Specification.new do |s|
7
- s.name = %q{memento}
8
- s.version = "0.3.2"
9
-
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
6
+ s.name = "memento"
7
+ s.version = Memento::VERSION
8
+ s.platform = Gem::Platform::RUBY
11
9
  s.authors = ["Yolk Sebastian Munz & Julia Soergel GbR"]
12
- s.date = %q{2011-07-12}
13
10
  s.email = %q{sebastian@yo.lk}
14
- s.extra_rdoc_files = [
15
- "LICENSE",
16
- "README.rdoc",
17
- "TODO"
18
- ]
19
- s.files = [
20
- "LICENSE",
21
- "README.rdoc",
22
- "Rakefile",
23
- "TODO",
24
- "VERSION.yml",
25
- "generators/memento_migration/memento_migration_generator.rb",
26
- "generators/memento_migration/templates/migration.rb",
27
- "init.rb",
28
- "lib/memento.rb",
29
- "lib/memento/action.rb",
30
- "lib/memento/action/create.rb",
31
- "lib/memento/action/destroy.rb",
32
- "lib/memento/action/update.rb",
33
- "lib/memento/action_controller_methods.rb",
34
- "lib/memento/active_record_methods.rb",
35
- "lib/memento/result.rb",
36
- "lib/memento/session.rb",
37
- "lib/memento/state.rb",
38
- "memento.gemspec",
39
- "spec/memento/action/create_spec.rb",
40
- "spec/memento/action/destroy_spec.rb",
41
- "spec/memento/action/update_spec.rb",
42
- "spec/memento/action_controller_methods_spec.rb",
43
- "spec/memento/active_record_methods_spec.rb",
44
- "spec/memento/result_spec.rb",
45
- "spec/memento/session_spec.rb",
46
- "spec/memento/state_spec.rb",
47
- "spec/memento_spec.rb",
48
- "spec/spec_helper.rb"
49
- ]
50
11
  s.homepage = %q{http://github.com/yolk/memento}
51
- s.require_paths = ["lib"]
52
- s.rubygems_version = %q{1.3.7}
53
12
  s.summary = %q{Undo for Rails/ActiveRecord - covers destroy, update and create}
13
+ s.description = %q{Undo for Rails/ActiveRecord - covers destroy, update and create}
14
+
15
+ s.files = `git ls-files`.split("\n")
16
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
+ s.require_paths = ["lib"]
19
+
20
+ s.add_dependency 'activerecord', '>= 3.0.0'
21
+ s.add_dependency 'actionpack', '>= 3.0.0'
54
22
 
55
- if s.respond_to? :specification_version then
56
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
57
- s.specification_version = 3
58
-
59
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
60
- else
61
- end
62
- else
63
- end
23
+ s.add_development_dependency 'rspec', '>= 2.4.0'
24
+ s.add_development_dependency 'sqlite3', '>= 1.3.3'
64
25
  end
65
26
 
@@ -89,7 +89,7 @@ describe Memento::Action::Update do
89
89
  describe "with mergeable recorded changes" do
90
90
  before do
91
91
  Memento.instance.memento(@user) do
92
- @project.update_attributes({:notes => "Bla!"})
92
+ @project.update_attributes({:notes => "Bla\nBla!"})
93
93
  end
94
94
  Memento::State.last.update_attribute(:created_at, 1.minute.from_now)
95
95
  @result = Memento::Session.first.undo.first
@@ -105,7 +105,7 @@ describe Memento::Action::Update do
105
105
  @object.name.should eql("P1")
106
106
  @object.customer.should be_nil
107
107
  @object.closed_at.to_s.should eql(@time1.to_s)
108
- @object.notes.should eql("Bla!")
108
+ @object.notes.should eql("Bla\nBla!")
109
109
  end
110
110
 
111
111
  describe "when second state is undone" do
@@ -94,7 +94,7 @@ describe Memento::Session do
94
94
  end
95
95
  end
96
96
 
97
- it "should undo states in order of creation (newest first)" do
97
+ it "should undo states in reverse order of creation (newest first)" do
98
98
  @session.undo.map(&:state).map(&:id).should eql([@state2.id, @state1.id])
99
99
  end
100
100
  end
data/spec/spec_helper.rb CHANGED
@@ -1,4 +1,3 @@
1
- require 'rubygems'
2
1
  require 'active_support'
3
2
  require 'active_record'
4
3
  require 'action_controller'
@@ -22,7 +21,7 @@ def setup_db
22
21
  create_table :projects do |t|
23
22
  t.column :name, :string
24
23
  t.column :closed_at, :datetime
25
- t.column :notes, :string
24
+ t.column :notes, :text
26
25
  t.references :customer
27
26
  t.integer :ignore_this
28
27
  t.timestamps
metadata CHANGED
@@ -1,39 +1,73 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: memento
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 3
8
- - 2
9
- version: 0.3.2
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.3
5
+ prerelease:
10
6
  platform: ruby
11
- authors:
7
+ authors:
12
8
  - Yolk Sebastian Munz & Julia Soergel GbR
13
9
  autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
-
17
- date: 2011-07-12 00:00:00 +02:00
18
- default_executable:
19
- dependencies: []
20
-
21
- description:
12
+ date: 2011-09-13 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: activerecord
16
+ requirement: &2151919320 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 3.0.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *2151919320
25
+ - !ruby/object:Gem::Dependency
26
+ name: actionpack
27
+ requirement: &2151918240 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: 3.0.0
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *2151918240
36
+ - !ruby/object:Gem::Dependency
37
+ name: rspec
38
+ requirement: &2151916880 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: 2.4.0
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *2151916880
47
+ - !ruby/object:Gem::Dependency
48
+ name: sqlite3
49
+ requirement: &2151915560 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: 1.3.3
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *2151915560
58
+ description: Undo for Rails/ActiveRecord - covers destroy, update and create
22
59
  email: sebastian@yo.lk
23
60
  executables: []
24
-
25
61
  extensions: []
26
-
27
- extra_rdoc_files:
28
- - LICENSE
29
- - README.rdoc
30
- - TODO
31
- files:
62
+ extra_rdoc_files: []
63
+ files:
64
+ - .gitignore
65
+ - Gemfile
66
+ - Gemfile.lock
32
67
  - LICENSE
33
68
  - README.rdoc
34
69
  - Rakefile
35
70
  - TODO
36
- - VERSION.yml
37
71
  - generators/memento_migration/memento_migration_generator.rb
38
72
  - generators/memento_migration/templates/migration.rb
39
73
  - init.rb
@@ -47,6 +81,7 @@ files:
47
81
  - lib/memento/result.rb
48
82
  - lib/memento/session.rb
49
83
  - lib/memento/state.rb
84
+ - lib/memento/version.rb
50
85
  - memento.gemspec
51
86
  - spec/memento/action/create_spec.rb
52
87
  - spec/memento/action/destroy_spec.rb
@@ -58,37 +93,44 @@ files:
58
93
  - spec/memento/state_spec.rb
59
94
  - spec/memento_spec.rb
60
95
  - spec/spec_helper.rb
61
- has_rdoc: true
62
96
  homepage: http://github.com/yolk/memento
63
97
  licenses: []
64
-
65
98
  post_install_message:
66
99
  rdoc_options: []
67
-
68
- require_paths:
100
+ require_paths:
69
101
  - lib
70
- required_ruby_version: !ruby/object:Gem::Requirement
102
+ required_ruby_version: !ruby/object:Gem::Requirement
71
103
  none: false
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- segments:
104
+ requirements:
105
+ - - ! '>='
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ segments:
76
109
  - 0
77
- version: "0"
78
- required_rubygems_version: !ruby/object:Gem::Requirement
110
+ hash: -3434226907778954075
111
+ required_rubygems_version: !ruby/object:Gem::Requirement
79
112
  none: false
80
- requirements:
81
- - - ">="
82
- - !ruby/object:Gem::Version
83
- segments:
113
+ requirements:
114
+ - - ! '>='
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ segments:
84
118
  - 0
85
- version: "0"
119
+ hash: -3434226907778954075
86
120
  requirements: []
87
-
88
121
  rubyforge_project:
89
- rubygems_version: 1.3.7
122
+ rubygems_version: 1.8.10
90
123
  signing_key:
91
124
  specification_version: 3
92
125
  summary: Undo for Rails/ActiveRecord - covers destroy, update and create
93
- test_files: []
94
-
126
+ test_files:
127
+ - spec/memento/action/create_spec.rb
128
+ - spec/memento/action/destroy_spec.rb
129
+ - spec/memento/action/update_spec.rb
130
+ - spec/memento/action_controller_methods_spec.rb
131
+ - spec/memento/active_record_methods_spec.rb
132
+ - spec/memento/result_spec.rb
133
+ - spec/memento/session_spec.rb
134
+ - spec/memento/state_spec.rb
135
+ - spec/memento_spec.rb
136
+ - spec/spec_helper.rb
data/VERSION.yml DELETED
@@ -1,5 +0,0 @@
1
- ---
2
- :major: 0
3
- :minor: 3
4
- :patch: 2
5
- :build: