dm-is-list 0.9.7 → 0.9.8

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1 +1,5 @@
1
+ === 0.9.8 / 2008-12-07
1
2
 
3
+ * 1 bug fix:
4
+
5
+ * Applied patch to fix bug with manual positioning [#672 state:resolved]
data/Manifest.txt CHANGED
@@ -10,3 +10,5 @@ lib/dm-is-list/is/version.rb
10
10
  spec/integration/list_spec.rb
11
11
  spec/spec.opts
12
12
  spec/spec_helper.rb
13
+ tasks/install.rb
14
+ tasks/spec.rb
data/Rakefile CHANGED
@@ -1,49 +1,25 @@
1
- require 'rubygems'
2
- require 'spec'
3
- require 'spec/rake/spectask'
4
1
  require 'pathname'
2
+ require 'rubygems'
3
+
4
+ ROOT = Pathname(__FILE__).dirname.expand_path
5
+ JRUBY = RUBY_PLATFORM =~ /java/
6
+ WINDOWS = Gem.win_platform?
7
+ SUDO = (WINDOWS || JRUBY) ? '' : ('sudo' unless ENV['SUDOLESS'])
5
8
 
6
- ROOT = Pathname(__FILE__).dirname.expand_path
7
9
  require ROOT + 'lib/dm-is-list/is/version'
8
10
 
9
- AUTHOR = "Sindre Aarsaether"
10
- EMAIL = "sindre [a] identu [d] no"
11
- GEM_NAME = "dm-is-list"
11
+ AUTHOR = 'Sindre Aarsaether'
12
+ EMAIL = 'sindre [a] identu [d] no'
13
+ GEM_NAME = 'dm-is-list'
12
14
  GEM_VERSION = DataMapper::Is::List::VERSION
13
- GEM_DEPENDENCIES = [["dm-core", GEM_VERSION], ["dm-adjust", GEM_VERSION]]
14
- GEM_CLEAN = ["log", "pkg"]
15
- GEM_EXTRAS = { :has_rdoc => true, :extra_rdoc_files => %w[ README.txt LICENSE TODO ] }
16
-
17
- PROJECT_NAME = "datamapper"
18
- PROJECT_URL = "http://github.com/sam/dm-more/tree/master/dm-is-list"
19
- PROJECT_DESCRIPTION = PROJECT_SUMMARY = "DataMapper plugin for creating and organizing lists"
20
-
21
- require ROOT.parent + 'tasks/hoe'
22
-
23
- task :default => [ :spec ]
15
+ GEM_DEPENDENCIES = [['dm-core', "~>#{GEM_VERSION}"], ['dm-adjust', "~>#{GEM_VERSION}"]]
16
+ GEM_CLEAN = %w[ log pkg coverage ]
17
+ GEM_EXTRAS = { :has_rdoc => true, :extra_rdoc_files => %w[ README.txt LICENSE TODO History.txt ] }
24
18
 
25
- WIN32 = (RUBY_PLATFORM =~ /win32|mingw|cygwin/) rescue nil
26
- SUDO = WIN32 ? '' : ('sudo' unless ENV['SUDOLESS'])
27
-
28
- desc "Install #{GEM_NAME} #{GEM_VERSION} (default ruby)"
29
- task :install => [ :package ] do
30
- sh "#{SUDO} gem install --local pkg/#{GEM_NAME}-#{GEM_VERSION} --no-update-sources", :verbose => false
31
- end
32
-
33
- desc "Uninstall #{GEM_NAME} #{GEM_VERSION} (default ruby)"
34
- task :uninstall => [ :clobber ] do
35
- sh "#{SUDO} gem uninstall #{GEM_NAME} -v#{GEM_VERSION} -I -x", :verbose => false
36
- end
37
-
38
- namespace :jruby do
39
- desc "Install #{GEM_NAME} #{GEM_VERSION} with JRuby"
40
- task :install => [ :package ] do
41
- sh %{#{SUDO} jruby -S gem install --local pkg/#{GEM_NAME}-#{GEM_VERSION} --no-update-sources}, :verbose => false
42
- end
43
- end
19
+ PROJECT_NAME = 'datamapper'
20
+ PROJECT_URL = "http://github.com/sam/dm-more/tree/master/#{GEM_NAME}"
21
+ PROJECT_DESCRIPTION = PROJECT_SUMMARY = 'DataMapper plugin for creating and organizing lists'
44
22
 
45
- desc 'Run specifications'
46
- Spec::Rake::SpecTask.new(:spec) do |t|
47
- t.spec_opts << '--options' << 'spec/spec.opts' if File.exists?('spec/spec.opts')
48
- t.spec_files = Pathname.glob((ROOT + 'spec/**/*_spec.rb').to_s)
23
+ [ ROOT, ROOT.parent ].each do |dir|
24
+ Pathname.glob(dir.join('tasks/**/*.rb').to_s).each { |f| require f }
49
25
  end
data/lib/dm-is-list.rb CHANGED
@@ -1,13 +1,12 @@
1
-
2
- require 'rubygems'
3
1
  require 'pathname'
2
+ require 'rubygems'
4
3
 
5
- gem 'dm-core', '~>0.9.7'
4
+ gem 'dm-core', '~>0.9.8'
6
5
  require 'dm-core'
7
6
 
8
- gem 'dm-adjust', '~>0.9.7'
7
+ #gem 'dm-adjust', '~>0.9.8'
9
8
  require 'dm-adjust'
10
9
 
11
- require Pathname(__FILE__).dirname.expand_path / 'dm-is-list' / 'is' / 'list.rb'
10
+ require Pathname(__FILE__).dirname.expand_path / 'dm-is-list' / 'is' / 'list'
12
11
 
13
12
  DataMapper::Model.append_extensions DataMapper::Is::List
@@ -28,28 +28,28 @@ module DataMapper
28
28
 
29
29
  @list_options = options
30
30
 
31
- before :save do
32
- if self.new_record?
33
- # a position has been set before save => open up and make room for item
34
- # no position has been set => move to bottom of my scope-list (or keep detached?)
35
- self.send(:move_without_saving, (self.position || :lowest))
36
- else
37
- # if the scope has changed, we need to detach our item from the old list
38
- if self.list_scope != self.original_list_scope
39
- newpos = self.position
40
-
41
- self.detach(self.original_list_scope) # removing from old list
42
- self.send(:move_without_saving, newpos || :lowest) # moving to pos or bottom of new list
43
-
44
- elsif self.attribute_dirty?(:position) && !self.moved
45
- self.send(:move_without_saving, self.position)
46
- else
47
- self.moved = false
48
- end
49
- # a (new) position has been set => move item to this position (only if position has been set manually)
50
- # the scope has changed => detach from old list, and possibly move into position
51
- # the scope and position has changed => detach from old, move to pos in new
31
+ before :create do
32
+ # a position has been set before save => open up and make room for item
33
+ # no position has been set => move to bottom of my scope-list (or keep detached?)
34
+ self.send(:move_without_saving, (self.position || :lowest))
35
+ end
36
+
37
+ before :update do
38
+ # if the scope has changed, we need to detach our item from the old list
39
+ if self.list_scope != self.original_list_scope
40
+ newpos = self.position
41
+ self.detach(self.original_list_scope) # removing from old list
42
+ self.send(:move_without_saving, newpos || :lowest) # moving to pos or bottom of new list
43
+ elsif self.attribute_dirty?(:position) && !self.moved
44
+ self.send(:move_without_saving, self.position)
52
45
  end
46
+
47
+ # on update, clean moved to prepare for the next change
48
+ self.moved = false
49
+
50
+ # a (new) position has been set => move item to this position (only if position has been set manually)
51
+ # the scope has changed => detach from old list, and possibly move into position
52
+ # the scope and position has changed => detach from old, move to pos in new
53
53
  end
54
54
 
55
55
  before :destroy do
@@ -1,7 +1,7 @@
1
1
  module DataMapper
2
2
  module Is
3
3
  module List
4
- VERSION = "0.9.7"
4
+ VERSION = '0.9.8'
5
5
  end
6
6
  end
7
7
  end
@@ -60,11 +60,32 @@ if HAS_SQLITE3 || HAS_MYSQL || HAS_POSTGRES
60
60
 
61
61
  it 'should rearrange items when setting position yourself' do
62
62
  repository(:default) do |repos|
63
- Todo.get(2).update_attributes(:position => 1)
63
+ todo = Todo.get(2)
64
+ todo.position = 1
65
+ todo.save
66
+
64
67
  Todo.get(2).position.should == 1
65
68
  Todo.get(1).position.should == 2
66
69
  end
67
70
  end
71
+
72
+ it 'should rearrange items when setting the position yourself multiple times' do
73
+ repository(:default) do |repos|
74
+ todo = Todo.get(2)
75
+ todo.position = 3
76
+ todo.save
77
+
78
+ Todo.get(2).position.should == 3
79
+ Todo.get(3).position.should == 2
80
+
81
+ todo = Todo.get(2)
82
+ todo.position = 2
83
+ todo.save
84
+
85
+ Todo.get(2).position.should == 2
86
+ Todo.get(3).position.should == 3
87
+ end
88
+ end
68
89
  end
69
90
 
70
91
  describe 'movement' do
data/spec/spec.opts CHANGED
@@ -1,2 +1 @@
1
- --format specdoc
2
1
  --colour
data/spec/spec_helper.rb CHANGED
@@ -1,22 +1,26 @@
1
+ require 'pathname'
1
2
  require 'rubygems'
2
- gem 'rspec', '>=1.1.3'
3
+
4
+ gem 'rspec', '~>1.1.11'
3
5
  require 'spec'
4
- require 'pathname'
5
- require Pathname(__FILE__).dirname.expand_path.parent + 'lib/dm-is-list'
6
+
7
+ ROOT = Pathname(__FILE__).dirname.parent.expand_path
8
+
9
+ # use local dm-adjust if running from dm-more directly
10
+ lib = ROOT.parent.join('dm-adjust', 'lib').expand_path
11
+ $LOAD_PATH.unshift(lib) if lib.directory?
12
+
13
+ require ROOT + 'lib/dm-is-list'
6
14
 
7
15
  def load_driver(name, default_uri)
8
16
  return false if ENV['ADAPTER'] != name.to_s
9
17
 
10
- lib = "do_#{name}"
11
-
12
18
  begin
13
- gem lib, '~>0.9.7'
14
- require lib
15
19
  DataMapper.setup(name, ENV["#{name.to_s.upcase}_SPEC_URI"] || default_uri)
16
20
  DataMapper::Repository.adapters[:default] = DataMapper::Repository.adapters[name]
17
21
  true
18
- rescue Gem::LoadError => e
19
- warn "Could not load #{lib}: #{e}"
22
+ rescue LoadError => e
23
+ warn "Could not load do_#{name}: #{e}"
20
24
  false
21
25
  end
22
26
  end
data/tasks/install.rb ADDED
@@ -0,0 +1,13 @@
1
+ def sudo_gem(cmd)
2
+ sh "#{SUDO} #{RUBY} -S gem #{cmd}", :verbose => false
3
+ end
4
+
5
+ desc "Install #{GEM_NAME} #{GEM_VERSION}"
6
+ task :install => [ :package ] do
7
+ sudo_gem "install --local pkg/#{GEM_NAME}-#{GEM_VERSION} --no-update-sources"
8
+ end
9
+
10
+ desc "Uninstall #{GEM_NAME} #{GEM_VERSION}"
11
+ task :uninstall => [ :clobber ] do
12
+ sudo_gem "uninstall #{GEM_NAME} -v#{GEM_VERSION} -Ix"
13
+ end
data/tasks/spec.rb ADDED
@@ -0,0 +1,25 @@
1
+ begin
2
+ gem 'rspec', '~>1.1.11'
3
+ require 'spec'
4
+ require 'spec/rake/spectask'
5
+
6
+ task :default => [ :spec ]
7
+
8
+ desc 'Run specifications'
9
+ Spec::Rake::SpecTask.new(:spec) do |t|
10
+ t.spec_opts << '--options' << 'spec/spec.opts' if File.exists?('spec/spec.opts')
11
+ t.spec_files = Pathname.glob((ROOT + 'spec/**/*_spec.rb').to_s)
12
+
13
+ begin
14
+ gem 'rcov', '~>0.8'
15
+ t.rcov = JRUBY ? false : (ENV.has_key?('NO_RCOV') ? ENV['NO_RCOV'] != 'true' : true)
16
+ t.rcov_opts << '--exclude' << 'spec'
17
+ t.rcov_opts << '--text-summary'
18
+ t.rcov_opts << '--sort' << 'coverage' << '--sort-reverse'
19
+ rescue LoadError
20
+ # rcov not installed
21
+ end
22
+ end
23
+ rescue LoadError
24
+ # rspec not installed
25
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dm-is-list
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.7
4
+ version: 0.9.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sindre Aarsaether
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-11-18 00:00:00 -08:00
12
+ date: 2008-12-07 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -18,9 +18,9 @@ dependencies:
18
18
  version_requirement:
19
19
  version_requirements: !ruby/object:Gem::Requirement
20
20
  requirements:
21
- - - "="
21
+ - - ~>
22
22
  - !ruby/object:Gem::Version
23
- version: 0.9.7
23
+ version: 0.9.8
24
24
  version:
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: dm-adjust
@@ -28,19 +28,9 @@ dependencies:
28
28
  version_requirement:
29
29
  version_requirements: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "="
31
+ - - ~>
32
32
  - !ruby/object:Gem::Version
33
- version: 0.9.7
34
- version:
35
- - !ruby/object:Gem::Dependency
36
- name: hoe
37
- type: :development
38
- version_requirement:
39
- version_requirements: !ruby/object:Gem::Requirement
40
- requirements:
41
- - - ">="
42
- - !ruby/object:Gem::Version
43
- version: 1.8.2
33
+ version: 0.9.8
44
34
  version:
45
35
  description: DataMapper plugin for creating and organizing lists
46
36
  email:
@@ -53,6 +43,7 @@ extra_rdoc_files:
53
43
  - README.txt
54
44
  - LICENSE
55
45
  - TODO
46
+ - History.txt
56
47
  files:
57
48
  - History.txt
58
49
  - LICENSE
@@ -66,6 +57,8 @@ files:
66
57
  - spec/integration/list_spec.rb
67
58
  - spec/spec.opts
68
59
  - spec/spec_helper.rb
60
+ - tasks/install.rb
61
+ - tasks/spec.rb
69
62
  has_rdoc: true
70
63
  homepage: http://github.com/sam/dm-more/tree/master/dm-is-list
71
64
  post_install_message: