dm-predefined 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,12 @@
1
+ === 0.2.0 / 2009-09-21
2
+
3
+ * Require Hoe >= 2.3.3.
4
+ * Require YARD >= 0.2.3.5.
5
+ * Require dm-core >= 0.10.0.
6
+ * Moved to YARD based documentation.
7
+ * Added YARD handlers for documenting +predefine+ method-calls.
8
+ * Renamed Predefined.predefined to Predefined.predefine.
9
+
1
10
  === 0.1.1 / 2009-01-17
2
11
 
3
12
  * Fixed specs to work with RSpec 1.1.12.
data/Manifest.txt CHANGED
@@ -5,9 +5,15 @@ README.txt
5
5
  Rakefile
6
6
  TODO.txt
7
7
  lib/dm-predefined.rb
8
+ lib/dm-predefined/exceptions/unknown_resource.rb
8
9
  lib/dm-predefined/predefined.rb
9
10
  lib/dm-predefined/version.rb
10
- lib/dm-predefined/exceptions/unknown_resource.rb
11
- spec/integration/helpers/test_model.rb
11
+ lib/dm-predefined/yard.rb
12
+ lib/dm-predefined/yard/handlers.rb
13
+ lib/dm-predefined/yard/handlers/ruby.rb
14
+ lib/dm-predefined/yard/handlers/ruby/predefine_handler.rb
15
+ lib/dm-predefined/yard/handlers/ruby/legacy.rb
16
+ lib/dm-predefined/yard/handlers/ruby/legacy/predefine_handler.rb
17
+ spec/integration/models/test_model.rb
12
18
  spec/integration/predefined_spec.rb
13
19
  spec/spec_helper.rb
data/README.txt CHANGED
@@ -24,8 +24,11 @@ A DataMapper plugin for adding predefined resources to Models.
24
24
  # URL to the licence
25
25
  property :url, String
26
26
 
27
- define :gpl2, :name => 'GPL-2', :url => 'http://www.gnu.org/copyleft/gpl.html'
28
- define :mit, :name => 'MIT'
27
+ predefine :gpl2,
28
+ :name => 'GPL-2',
29
+ :url => 'http://www.gnu.org/copyleft/gpl.html'
30
+
31
+ predefine :mit, :name => 'MIT'
29
32
 
30
33
  end
31
34
 
@@ -35,13 +38,17 @@ A DataMapper plugin for adding predefined resources to Models.
35
38
  Licence[:mit]
36
39
  # => #<Licence: id: 2, name: "MIT">
37
40
 
41
+ == REQUIREMENTS:
42
+
43
+ * {YARD}[http://yard.soen.ca/] >= 0.2.3.5
44
+
38
45
  == INSTALL:
39
46
 
40
47
  $ sudo gem install dm-predefined
41
48
 
42
49
  == LICENSE:
43
50
 
44
- Copyright (c) 2008 Hal Brodigan
51
+ Copyright (c) 2008-2009 Hal Brodigan
45
52
 
46
53
  Permission is hereby granted, free of charge, to any person obtaining
47
54
  a copy of this software and associated documentation files (the
data/Rakefile CHANGED
@@ -2,14 +2,24 @@
2
2
 
3
3
  require 'rubygems'
4
4
  require 'hoe'
5
+ require 'hoe/signing'
5
6
  require './tasks/spec.rb'
6
- require './lib/dm-predefined/version.rb'
7
+ require './tasks/yard.rb'
7
8
 
8
- Hoe.new('dm-predefined', DataMapper::Predefined::VERSION) do |p|
9
- p.rubyforge_name = 'dm-predefined'
10
- p.developer('Postmodern','postmodern.mod3@gmail.com')
11
- p.remote_rdoc_dir = ''
12
- p.extra_deps = [['dm-core', '>=0.9.8']]
9
+ Hoe.spec('dm-predefined') do
10
+ self.rubyforge_name = 'dm-predefined'
11
+ self.developer('Postmodern','postmodern.mod3@gmail.com')
12
+ self.remote_rdoc_dir = ''
13
+ self.extra_deps = [
14
+ ['yard', '>=0.2.3.5'],
15
+ ['dm-core', '>=0.10.0']
16
+ ]
17
+
18
+ self.extra_dev_deps = [
19
+ ['rspec', '>=1.2.8']
20
+ ]
21
+
22
+ self.spec_extras = {:has_rdoc => 'yard'}
13
23
  end
14
24
 
15
25
  # vim: syntax=Ruby
@@ -2,35 +2,64 @@ require 'dm-predefined/exceptions/unknown_resource'
2
2
 
3
3
  module DataMapper
4
4
  module Predefined
5
- ##
6
- # fired when your plugin gets included into Resource
5
+ #
6
+ # Fired when your plugin gets included into Resource.
7
7
  #
8
8
  def self.included(base)
9
9
  base.extend DataMapper::Predefined::ClassMethods
10
10
  end
11
11
 
12
12
  module ClassMethods
13
+ #
14
+ # Finds or auto-creates the pre-defined resource with the given name.
15
+ #
16
+ # @param [Symbol, String] name
17
+ # The name of the pre-defined resource.
18
+ #
19
+ # @return [Object]
20
+ # The pre-defined resource.
21
+ #
13
22
  def [](name)
14
23
  name = name.to_sym
15
- attributes = predefined_attributes[name]
24
+ attributes = self.predefined_attributes[name]
16
25
 
17
26
  unless attributes
18
27
  raise(UnknownResource,"the resource '#{name}' was not predefined",caller)
19
28
  end
20
29
 
21
- first_or_create(predefined_attributes[name.to_sym])
30
+ self.first_or_create(attributes)
22
31
  end
23
32
 
24
33
  protected
25
34
 
35
+ @@predefined_attributes = {}
36
+
37
+ #
38
+ # All pre-defined resources of the model.
39
+ #
40
+ # @return [Hash{Symbol => Hash}]
41
+ # The Hash of pre-defined resources and their attributes.
42
+ #
26
43
  def predefined_attributes
27
- @@predefined_attributes ||= {}
44
+ @@predefined_attributes
28
45
  end
29
46
 
30
- def define(name,attributes={})
47
+ #
48
+ # Defines a new pre-defined resource for the model.
49
+ #
50
+ # @param [Symbol, String] name
51
+ # The name of the pre-defined resource.
52
+ #
53
+ # @param [Hash] attributes
54
+ # The attributes for the pre-defined resource.
55
+ #
56
+ # @return [Hash]
57
+ # The attributes that will be assigned to the pre-defined resource.
58
+ #
59
+ def predefine(name,attributes={})
31
60
  name = name.to_s
32
61
 
33
- predefined_attributes[name.to_sym] = attributes
62
+ self.predefined_attributes[name.to_sym] = attributes
34
63
 
35
64
  class_eval %{
36
65
  class << self
@@ -1,5 +1,6 @@
1
1
  module DataMapper
2
2
  module Predefined
3
- VERSION = '0.1.1'
3
+ # The version of dm-predefined
4
+ VERSION = '0.2.0'
4
5
  end
5
6
  end
@@ -0,0 +1,26 @@
1
+ require 'yard'
2
+
3
+ module YARD
4
+ module Handlers
5
+ module Ruby
6
+ module Legacy
7
+ class PredefineHandler < Base
8
+
9
+ handles /\Apredefine\s/
10
+
11
+ def process
12
+ nobj = namespace
13
+ name = statement.tokens[2,1].to_s[1..-1]
14
+
15
+ register MethodObject.new(nobj, name, :class) do |o|
16
+ o.visibility = :public
17
+ o.source = statement.source
18
+ o.signature = "def #{nobj}.#{name}"
19
+ end
20
+ end
21
+
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1 @@
1
+ require 'dm-predefined/yard/handlers/ruby/legacy/predefine_handler'
@@ -0,0 +1,35 @@
1
+ require 'yard'
2
+
3
+ module YARD
4
+ module Handlers
5
+ module Ruby
6
+ class PredefineHandler < Base
7
+
8
+ handles method_call(:predefine)
9
+
10
+ def process
11
+ nobj = namespace
12
+ name = if statement.type == :predefine
13
+ statement.jump(:ident, :op, :kw, :const).source
14
+ elsif statement.call?
15
+ obj = statement.parameters(false).first
16
+
17
+ case obj.type
18
+ when :symbol_literal
19
+ obj.jump(:ident, :op, :kw, :const).source
20
+ when :string_literal
21
+ obj.jump(:string_content).source
22
+ end
23
+ end
24
+
25
+ register MethodObject.new(nobj, name, :class) do |o|
26
+ o.visibility = :public
27
+ o.source = statement.source
28
+ o.signature = "def #{nobj}.#{name}"
29
+ end
30
+ end
31
+
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,2 @@
1
+ require 'dm-predefined/yard/handlers/ruby/predefine_handler'
2
+ require 'dm-predefined/yard/handlers/ruby/legacy'
@@ -0,0 +1 @@
1
+ require 'dm-predefined/yard/handlers/ruby'
@@ -0,0 +1 @@
1
+ require 'dm-predefined/yard/handlers'
data/lib/dm-predefined.rb CHANGED
@@ -3,7 +3,7 @@ require 'rubygems'
3
3
  require 'pathname'
4
4
 
5
5
  # Add all external dependencies for the plugin here
6
- gem 'dm-core', '~>0.9.8'
6
+ gem 'dm-core', '~>0.10.0'
7
7
  require 'dm-core'
8
8
 
9
9
  # Require plugin-files
@@ -3,6 +3,9 @@ class TestModel
3
3
  include DataMapper::Resource
4
4
  include DataMapper::Predefined
5
5
 
6
+ # Primary key of the test model
7
+ property :id, Serial
8
+
6
9
  # Name property to test String values
7
10
  property :name, String
8
11
 
@@ -15,11 +18,11 @@ class TestModel
15
18
  # Body property to test Text values
16
19
  property :body, Text
17
20
 
18
- define :test1, :name => 'test1',
19
- :number => 1,
20
- :optional => 'yo',
21
- :body => %{This is a test.}
21
+ predefine :test1, :name => 'test1',
22
+ :number => 1,
23
+ :optional => 'yo',
24
+ :body => %{This is a test.}
22
25
 
23
- define :test2, :name => 'test2', :number => 2
26
+ predefine :test2, :name => 'test2', :number => 2
24
27
 
25
28
  end
@@ -1,5 +1,5 @@
1
1
  require 'spec_helper'
2
- require 'integration/helpers/test_model'
2
+ require 'integration/models/test_model'
3
3
 
4
4
  if (HAS_SQLITE3 || HAS_MYSQL || HAS_POSTGRES)
5
5
  describe DataMapper::Predefined do
data/spec/spec_helper.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require 'pathname'
2
2
  require 'rubygems'
3
3
 
4
- gem 'rspec', '~>1.1.11'
4
+ gem 'rspec', '~>1.2.6'
5
5
  require 'spec'
6
6
 
7
7
  require Pathname(__FILE__).dirname.expand_path.parent + 'lib/dm-predefined'
data.tar.gz.sig ADDED
Binary file
metadata CHANGED
@@ -1,17 +1,48 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dm-predefined
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Postmodern
8
8
  autorequire:
9
9
  bindir: bin
10
- cert_chain: []
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIDQDCCAiigAwIBAgIBADANBgkqhkiG9w0BAQUFADBGMRgwFgYDVQQDDA9wb3N0
14
+ bW9kZXJuLm1vZDMxFTATBgoJkiaJk/IsZAEZFgVnbWFpbDETMBEGCgmSJomT8ixk
15
+ ARkWA2NvbTAeFw0wOTA2MDMwNDU5MDNaFw0xMDA2MDMwNDU5MDNaMEYxGDAWBgNV
16
+ BAMMD3Bvc3Rtb2Rlcm4ubW9kMzEVMBMGCgmSJomT8ixkARkWBWdtYWlsMRMwEQYK
17
+ CZImiZPyLGQBGRYDY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA
18
+ 1wvANkTDHFgVih5XLjuTwTZjgBq1lBGybXJiH6Id1lY2JOMqM5FB1DDHVvvij94i
19
+ mJabN0zkzu6VKWC70y0IwOxY7CPokr0eFdK/D0y7mCq1P8QITv76i2YqAl0eYqIt
20
+ W+IhIkANQ7E6uMZIZcdnfadC6lPAtlKkqtd9crvRbFgr6e3kyflmohbRnTEJHoRd
21
+ 7SHHsybE6DSn7oTDs6XBTNrNIn5VfZA0z01eeos/+zBm1zKJOK2+/7xtLLDuDU9G
22
+ +Rd+ltUBbvxUrMNZmDG29pnmN2xTRH+Q8HxD2AxlvM5SRpK6OeZaHV7PaCCAVZ4L
23
+ T9BFl1sfMvRlABeGEkSyuQIDAQABozkwNzAJBgNVHRMEAjAAMAsGA1UdDwQEAwIE
24
+ sDAdBgNVHQ4EFgQUKwsd+PqEYmBvyaTyoL+uRuk+PhEwDQYJKoZIhvcNAQEFBQAD
25
+ ggEBAB4TvHsrlbcXcKg6gX5BIb9tI+zGkpzo0Z7jnxMEcNO7NGGwmzafDBI/xZYv
26
+ xkRH3/HXbGGYDOi6Q6gWt5GujSx0bOImDtYTJTH8jnzN92HzEK5WdScm1QpZKF1e
27
+ cezArMbxbSPaosxTCtG6LQTkE28lFQsmFZ5xzouugS4h5+LVJiVMmiP+l3EfkjFa
28
+ GOURU+rNEMPWo8MCWivGW7jes6BMzWHcW7DQ0scNVmIcCIgdyMmpscuAEOSeghy9
29
+ /fFs57Ey2OXBL55nDOyvN/ZQ2Vab05UH4t+GCxjAPeirzL/29FBtePT6VD44c38j
30
+ pDj+ws7QjtH/Qcrr1l9jfN0ehDs=
31
+ -----END CERTIFICATE-----
11
32
 
12
- date: 2009-01-17 00:00:00 -08:00
33
+ date: 2009-09-25 00:00:00 -07:00
13
34
  default_executable:
14
35
  dependencies:
36
+ - !ruby/object:Gem::Dependency
37
+ name: yard
38
+ type: :runtime
39
+ version_requirement:
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ version: 0.2.3.5
45
+ version:
15
46
  - !ruby/object:Gem::Dependency
16
47
  name: dm-core
17
48
  type: :runtime
@@ -20,7 +51,17 @@ dependencies:
20
51
  requirements:
21
52
  - - ">="
22
53
  - !ruby/object:Gem::Version
23
- version: 0.9.8
54
+ version: 0.10.0
55
+ version:
56
+ - !ruby/object:Gem::Dependency
57
+ name: rspec
58
+ type: :development
59
+ version_requirement:
60
+ version_requirements: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: 1.2.8
24
65
  version:
25
66
  - !ruby/object:Gem::Dependency
26
67
  name: hoe
@@ -30,7 +71,7 @@ dependencies:
30
71
  requirements:
31
72
  - - ">="
32
73
  - !ruby/object:Gem::Version
33
- version: 1.8.2
74
+ version: 2.3.3
34
75
  version:
35
76
  description: A DataMapper plugin for adding predefined resources to Models.
36
77
  email:
@@ -53,14 +94,22 @@ files:
53
94
  - Rakefile
54
95
  - TODO.txt
55
96
  - lib/dm-predefined.rb
97
+ - lib/dm-predefined/exceptions/unknown_resource.rb
56
98
  - lib/dm-predefined/predefined.rb
57
99
  - lib/dm-predefined/version.rb
58
- - lib/dm-predefined/exceptions/unknown_resource.rb
59
- - spec/integration/helpers/test_model.rb
100
+ - lib/dm-predefined/yard.rb
101
+ - lib/dm-predefined/yard/handlers.rb
102
+ - lib/dm-predefined/yard/handlers/ruby.rb
103
+ - lib/dm-predefined/yard/handlers/ruby/predefine_handler.rb
104
+ - lib/dm-predefined/yard/handlers/ruby/legacy.rb
105
+ - lib/dm-predefined/yard/handlers/ruby/legacy/predefine_handler.rb
106
+ - spec/integration/models/test_model.rb
60
107
  - spec/integration/predefined_spec.rb
61
108
  - spec/spec_helper.rb
62
- has_rdoc: true
109
+ has_rdoc: yard
63
110
  homepage: http://dm-predefined.rubyforge.org/
111
+ licenses: []
112
+
64
113
  post_install_message:
65
114
  rdoc_options:
66
115
  - --main
@@ -82,9 +131,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
82
131
  requirements: []
83
132
 
84
133
  rubyforge_project: dm-predefined
85
- rubygems_version: 1.3.1
134
+ rubygems_version: 1.3.5
86
135
  signing_key:
87
- specification_version: 2
136
+ specification_version: 3
88
137
  summary: A DataMapper plugin for adding predefined resources to Models.
89
138
  test_files: []
90
139
 
metadata.gz.sig ADDED
Binary file