dm-enum 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (9) hide show
  1. data/.document +5 -0
  2. data/.rspec +1 -0
  3. data/Gemfile +15 -0
  4. data/LICENSE.txt +20 -0
  5. data/README.md +49 -0
  6. data/Rakefile +49 -0
  7. data/VERSION +1 -0
  8. data/spec/spec_helper.rb +39 -0
  9. metadata +134 -0
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile ADDED
@@ -0,0 +1,15 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem 'dm-core'
4
+
5
+ group :development, :test do
6
+ gem 'dm-migrations'
7
+ gem 'dm-sqlite-adapter'
8
+ end
9
+
10
+ group :development do
11
+ gem "rspec", "~> 2.3.0"
12
+ gem "bundler", "~> 1.0.0"
13
+ gem "jeweler", "~> 1.6.4"
14
+ gem 'pry'
15
+ end
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012 Potapov Sergey
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,49 @@
1
+ # dm-enums (Enumrated models for DataMapper)
2
+ by Potapov Sergey (aka Blake)
3
+
4
+ Inspired by [power\_enum](https://github.com/albertosaurus/enumerations_mixin)
5
+
6
+ ## Description
7
+
8
+ Allows you to cache enumeration models.
9
+
10
+ ## Usage
11
+
12
+ ```ruby
13
+
14
+ class Language
15
+ include DataMapper::Resource
16
+ include DataMapper::Enum
17
+
18
+ acts_as_enumerated :name_property => :code
19
+
20
+ property :code, String, :key => true
21
+ property :name, String
22
+ end
23
+
24
+ # should be called in order to cache values
25
+ Language.update_enums_cache!
26
+
27
+ Language.create(:code => "ru", :name => "Russian")
28
+ Language.create(:code => "en", :name => "English")
29
+
30
+ Language[:ru] # => #<Language @code="ru" @name="Russian">
31
+ Language["en"] # => #<Language @code="en" @name="English">
32
+
33
+ ```
34
+
35
+
36
+ ## Contributing to dm-enums
37
+
38
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
39
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
40
+ * Fork the project
41
+ * Start a feature/bugfix branch
42
+ * Commit and push until you are happy with your contribution
43
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
44
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
45
+
46
+ ## Copyright
47
+
48
+ Copyright (c) 2012 Potapov Sergey. See LICENSE.txt for
49
+ further details.
@@ -0,0 +1,49 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "dm-enum"
18
+ gem.homepage = "http://github.com/greyblake/dm-enum"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{Enumerated models for DataMapper}
21
+ gem.description = %Q{Enumerated models for DataMapper to cache enumerated values in memory}
22
+ gem.email = "blake131313@gmail.com"
23
+ gem.authors = ["Potapov Sergey"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rspec/core'
29
+ require 'rspec/core/rake_task'
30
+ RSpec::Core::RakeTask.new(:spec) do |spec|
31
+ spec.pattern = FileList['spec/**/*_spec.rb']
32
+ end
33
+
34
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
35
+ spec.pattern = 'spec/**/*_spec.rb'
36
+ spec.rcov = true
37
+ end
38
+
39
+ task :default => :spec
40
+
41
+ require 'rake/rdoctask'
42
+ Rake::RDocTask.new do |rdoc|
43
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
44
+
45
+ rdoc.rdoc_dir = 'rdoc'
46
+ rdoc.title = "dm-enum #{version}"
47
+ rdoc.rdoc_files.include('README*')
48
+ rdoc.rdoc_files.include('lib/**/*.rb')
49
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.0
@@ -0,0 +1,39 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+ require 'rspec'
4
+ require 'pry'
5
+
6
+ require 'dm-core'
7
+ require 'dm-migrations'
8
+ require 'dm-sqlite-adapter'
9
+
10
+ require 'dm-enum'
11
+
12
+
13
+ DataMapper.setup(:default, "sqlite3::memory:")
14
+
15
+
16
+ class Language
17
+ include DataMapper::Resource
18
+ include DataMapper::Enum
19
+ acts_as_enumerated :name_property => :code
20
+ property :code, String, :key => true
21
+ property :name, String
22
+ end
23
+
24
+ class Country
25
+ include DataMapper::Resource
26
+ include DataMapper::Enum
27
+ acts_as_enumerated
28
+ property :name, String, :key => true
29
+ end
30
+
31
+ class City
32
+ include DataMapper::Resource
33
+ include DataMapper::Enum
34
+ acts_as_enumerated
35
+ property :name, String, :key => true
36
+ end
37
+
38
+ DataMapper.finalize
39
+ DataMapper.auto_migrate!
metadata ADDED
@@ -0,0 +1,134 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dm-enum
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Potapov Sergey
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-03-02 00:00:00.000000000 +02:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: dm-core
17
+ requirement: &17199560 !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
22
+ version: '0'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: *17199560
26
+ - !ruby/object:Gem::Dependency
27
+ name: dm-migrations
28
+ requirement: &17198960 !ruby/object:Gem::Requirement
29
+ none: false
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: *17198960
37
+ - !ruby/object:Gem::Dependency
38
+ name: dm-sqlite-adapter
39
+ requirement: &17198300 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ! '>='
43
+ - !ruby/object:Gem::Version
44
+ version: '0'
45
+ type: :development
46
+ prerelease: false
47
+ version_requirements: *17198300
48
+ - !ruby/object:Gem::Dependency
49
+ name: rspec
50
+ requirement: &17197640 !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
53
+ - - ~>
54
+ - !ruby/object:Gem::Version
55
+ version: 2.3.0
56
+ type: :development
57
+ prerelease: false
58
+ version_requirements: *17197640
59
+ - !ruby/object:Gem::Dependency
60
+ name: bundler
61
+ requirement: &17196920 !ruby/object:Gem::Requirement
62
+ none: false
63
+ requirements:
64
+ - - ~>
65
+ - !ruby/object:Gem::Version
66
+ version: 1.0.0
67
+ type: :development
68
+ prerelease: false
69
+ version_requirements: *17196920
70
+ - !ruby/object:Gem::Dependency
71
+ name: jeweler
72
+ requirement: &17196080 !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: 1.6.4
78
+ type: :development
79
+ prerelease: false
80
+ version_requirements: *17196080
81
+ - !ruby/object:Gem::Dependency
82
+ name: pry
83
+ requirement: &17195360 !ruby/object:Gem::Requirement
84
+ none: false
85
+ requirements:
86
+ - - ! '>='
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ type: :development
90
+ prerelease: false
91
+ version_requirements: *17195360
92
+ description: Enumerated models for DataMapper to cache enumerated values in memory
93
+ email: blake131313@gmail.com
94
+ executables: []
95
+ extensions: []
96
+ extra_rdoc_files:
97
+ - LICENSE.txt
98
+ - README.md
99
+ files:
100
+ - .document
101
+ - .rspec
102
+ - Gemfile
103
+ - LICENSE.txt
104
+ - Rakefile
105
+ - VERSION
106
+ - spec/spec_helper.rb
107
+ - README.md
108
+ has_rdoc: true
109
+ homepage: http://github.com/greyblake/dm-enum
110
+ licenses:
111
+ - MIT
112
+ post_install_message:
113
+ rdoc_options: []
114
+ require_paths:
115
+ - lib
116
+ required_ruby_version: !ruby/object:Gem::Requirement
117
+ none: false
118
+ requirements:
119
+ - - ! '>='
120
+ - !ruby/object:Gem::Version
121
+ version: '0'
122
+ required_rubygems_version: !ruby/object:Gem::Requirement
123
+ none: false
124
+ requirements:
125
+ - - ! '>='
126
+ - !ruby/object:Gem::Version
127
+ version: '0'
128
+ requirements: []
129
+ rubyforge_project:
130
+ rubygems_version: 1.6.2
131
+ signing_key:
132
+ specification_version: 3
133
+ summary: Enumerated models for DataMapper
134
+ test_files: []