mongoid-glue 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +113 -0
- data/lib/mongoid-glue.rb +1 -0
- data/lib/mongoid-glue/terse_names.rb +25 -0
- data/lib/mongoid-glue/version.rb +3 -0
- data/mongoid-glue.gemspec +25 -0
- metadata +52 -0
data/Rakefile
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
require 'date'
|
4
|
+
|
5
|
+
#############################################################################
|
6
|
+
#
|
7
|
+
# Helper functions
|
8
|
+
#
|
9
|
+
#############################################################################
|
10
|
+
|
11
|
+
def name
|
12
|
+
@name ||= Dir['*.gemspec'].first.split('.').first
|
13
|
+
end
|
14
|
+
|
15
|
+
def version
|
16
|
+
line = File.read("lib/#{name}/version.rb")[/^\s*VERSION\s*=\s*.*/]
|
17
|
+
line.match(/.*VERSION\s*=\s*['"](.*)['"]/)[1]
|
18
|
+
end
|
19
|
+
|
20
|
+
def date
|
21
|
+
Date.today.to_s
|
22
|
+
end
|
23
|
+
|
24
|
+
def rubyforge_project
|
25
|
+
name
|
26
|
+
end
|
27
|
+
|
28
|
+
def gemspec_file
|
29
|
+
"#{name}.gemspec"
|
30
|
+
end
|
31
|
+
|
32
|
+
def gem_file
|
33
|
+
"#{name}-#{version}.gem"
|
34
|
+
end
|
35
|
+
|
36
|
+
def replace_header(head, header_name)
|
37
|
+
head.sub!(/(\.#{header_name}\s*= ').*'/) { "#{$1}#{send(header_name)}'"}
|
38
|
+
end
|
39
|
+
|
40
|
+
#############################################################################
|
41
|
+
#
|
42
|
+
# Custom tasks
|
43
|
+
#
|
44
|
+
#############################################################################
|
45
|
+
|
46
|
+
|
47
|
+
#############################################################################
|
48
|
+
#
|
49
|
+
# Packaging tasks
|
50
|
+
#
|
51
|
+
#############################################################################
|
52
|
+
|
53
|
+
desc "Create tag v#{version} and build and push #{gem_file} to Rubygems"
|
54
|
+
task :release => :build do
|
55
|
+
unless `git branch` =~ /^\* master$/
|
56
|
+
puts "You must be on the master branch to release!"
|
57
|
+
exit!
|
58
|
+
end
|
59
|
+
sh "git commit --allow-empty -a -m 'Release #{version}'"
|
60
|
+
sh "git tag v#{version}"
|
61
|
+
sh "git push origin master"
|
62
|
+
sh "git push origin v#{version}"
|
63
|
+
sh "gem push pkg/#{name}-#{version}.gem"
|
64
|
+
end
|
65
|
+
|
66
|
+
desc "Build #{gem_file} into the pkg directory"
|
67
|
+
task :build => :gemspec do
|
68
|
+
sh "mkdir -p pkg"
|
69
|
+
sh "gem build #{gemspec_file}"
|
70
|
+
sh "mv #{gem_file} pkg"
|
71
|
+
end
|
72
|
+
|
73
|
+
desc "Generate #{gemspec_file}"
|
74
|
+
task :gemspec => :validate do
|
75
|
+
# read spec file and split out manifest section
|
76
|
+
spec = File.read(gemspec_file)
|
77
|
+
head, manifest, tail = spec.split(" # = MANIFEST =\n")
|
78
|
+
|
79
|
+
# replace name version and date
|
80
|
+
replace_header(head, :name)
|
81
|
+
replace_header(head, :version)
|
82
|
+
replace_header(head, :date)
|
83
|
+
#comment this out if your rubyforge_project has a different name
|
84
|
+
#replace_header(head, :rubyforge_project)
|
85
|
+
|
86
|
+
# determine file list from git ls-files
|
87
|
+
files = `git ls-files`.
|
88
|
+
split("\n").
|
89
|
+
sort.
|
90
|
+
reject { |file| file =~ /^\./ }.
|
91
|
+
reject { |file| file =~ /^(rdoc|pkg)/ }.
|
92
|
+
map { |file| " #{file}" }.
|
93
|
+
join("\n")
|
94
|
+
|
95
|
+
# piece file back together and write
|
96
|
+
manifest = " s.files = %w[\n#{files}\n ]\n"
|
97
|
+
spec = [head, manifest, tail].join(" # = MANIFEST =\n")
|
98
|
+
File.open(gemspec_file, 'w') { |io| io.write(spec) }
|
99
|
+
puts "Updated #{gemspec_file}"
|
100
|
+
end
|
101
|
+
|
102
|
+
desc "Validate #{gemspec_file}"
|
103
|
+
task :validate do
|
104
|
+
libfiles = Dir['lib/*'] - ["lib/#{name}.rb", "lib/#{name}"]
|
105
|
+
unless libfiles.empty?
|
106
|
+
puts "Directory `lib` should only contain a `#{name}.rb` file and `#{name}` dir."
|
107
|
+
exit!
|
108
|
+
end
|
109
|
+
unless Dir['VERSION*'].empty?
|
110
|
+
puts "A `VERSION` file at root level violates Gem best practices."
|
111
|
+
exit!
|
112
|
+
end
|
113
|
+
end
|
data/lib/mongoid-glue.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'mongoid-glue/terse_names'
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module MongoidGlue
|
2
|
+
module TerseNames
|
3
|
+
def self.extended(base)
|
4
|
+
class_hierarchy = base.name.split('::')
|
5
|
+
base_class_name = class_hierarchy.pop
|
6
|
+
underscore_name = base_class_name.respond_to?(:underscore) ? base_class_name.underscore : base_class_name.downcase
|
7
|
+
|
8
|
+
if base.respond_to? :store_in
|
9
|
+
base.store_in(underscore_name.to_sym)
|
10
|
+
end
|
11
|
+
|
12
|
+
target = Kernel.const_get(class_hierarchy.shift)
|
13
|
+
|
14
|
+
while class_hierarchy.size > 0 do
|
15
|
+
target = target.const_get(class_hierarchy.shift)
|
16
|
+
end
|
17
|
+
|
18
|
+
target.instance_eval do
|
19
|
+
define_singleton_method(underscore_name.to_sym) do
|
20
|
+
base
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = 'mongoid-glue'
|
3
|
+
s.version = '1.0.0'
|
4
|
+
s.date = '2011-09-16'
|
5
|
+
s.platform = Gem::Platform::RUBY
|
6
|
+
s.authors = ['Lee Henson', 'Guy Boertje']
|
7
|
+
s.email = ['lee.m.henson@gmail.com', 'guyboertje@gmail.com']
|
8
|
+
s.homepage = "http://github.com/leemhenson/mongoid-glue"
|
9
|
+
s.summary = %q{Minor mongoid extensions}
|
10
|
+
s.description = %q{}
|
11
|
+
|
12
|
+
# = MANIFEST =
|
13
|
+
s.files = %w[
|
14
|
+
Rakefile
|
15
|
+
lib/mongoid-glue.rb
|
16
|
+
lib/mongoid-glue/terse_names.rb
|
17
|
+
lib/mongoid-glue/version.rb
|
18
|
+
mongoid-glue.gemspec
|
19
|
+
]
|
20
|
+
# = MANIFEST =
|
21
|
+
|
22
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
23
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
24
|
+
s.require_paths = ["lib"]
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mongoid-glue
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Lee Henson
|
9
|
+
- Guy Boertje
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2011-09-16 00:00:00.000000000 Z
|
14
|
+
dependencies: []
|
15
|
+
description: ''
|
16
|
+
email:
|
17
|
+
- lee.m.henson@gmail.com
|
18
|
+
- guyboertje@gmail.com
|
19
|
+
executables: []
|
20
|
+
extensions: []
|
21
|
+
extra_rdoc_files: []
|
22
|
+
files:
|
23
|
+
- Rakefile
|
24
|
+
- lib/mongoid-glue.rb
|
25
|
+
- lib/mongoid-glue/terse_names.rb
|
26
|
+
- lib/mongoid-glue/version.rb
|
27
|
+
- mongoid-glue.gemspec
|
28
|
+
homepage: http://github.com/leemhenson/mongoid-glue
|
29
|
+
licenses: []
|
30
|
+
post_install_message:
|
31
|
+
rdoc_options: []
|
32
|
+
require_paths:
|
33
|
+
- lib
|
34
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
35
|
+
none: false
|
36
|
+
requirements:
|
37
|
+
- - ! '>='
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
requirements: []
|
47
|
+
rubyforge_project:
|
48
|
+
rubygems_version: 1.8.10
|
49
|
+
signing_key:
|
50
|
+
specification_version: 3
|
51
|
+
summary: Minor mongoid extensions
|
52
|
+
test_files: []
|