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 +4 -0
- data/Manifest.txt +2 -0
- data/Rakefile +17 -41
- data/lib/dm-is-list.rb +4 -5
- data/lib/dm-is-list/is/list.rb +21 -21
- data/lib/dm-is-list/is/version.rb +1 -1
- data/spec/integration/list_spec.rb +22 -1
- data/spec/spec.opts +0 -1
- data/spec/spec_helper.rb +13 -9
- data/tasks/install.rb +13 -0
- data/tasks/spec.rb +25 -0
- metadata +9 -16
data/History.txt
CHANGED
data/Manifest.txt
CHANGED
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 =
|
10
|
-
EMAIL =
|
11
|
-
GEM_NAME =
|
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 = [[
|
14
|
-
GEM_CLEAN = [
|
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
|
-
|
26
|
-
|
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
|
-
|
46
|
-
|
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.
|
4
|
+
gem 'dm-core', '~>0.9.8'
|
6
5
|
require 'dm-core'
|
7
6
|
|
8
|
-
gem 'dm-adjust', '~>0.9.
|
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
|
10
|
+
require Pathname(__FILE__).dirname.expand_path / 'dm-is-list' / 'is' / 'list'
|
12
11
|
|
13
12
|
DataMapper::Model.append_extensions DataMapper::Is::List
|
data/lib/dm-is-list/is/list.rb
CHANGED
@@ -28,28 +28,28 @@ module DataMapper
|
|
28
28
|
|
29
29
|
@list_options = options
|
30
30
|
|
31
|
-
before :
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
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
|
@@ -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)
|
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
data/spec/spec_helper.rb
CHANGED
@@ -1,22 +1,26 @@
|
|
1
|
+
require 'pathname'
|
1
2
|
require 'rubygems'
|
2
|
-
|
3
|
+
|
4
|
+
gem 'rspec', '~>1.1.11'
|
3
5
|
require 'spec'
|
4
|
-
|
5
|
-
|
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
|
19
|
-
warn "Could not load #{
|
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.
|
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-
|
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.
|
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.
|
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:
|