glue 0.29.0 → 0.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/ProjectInfo +17 -29
- data/README +2 -2
- data/doc/RELEASES +8 -0
- data/lib/glue.rb +5 -5
- data/lib/glue/autoreload.rb +2 -2
- data/lib/glue/builder.rb +17 -6
- data/lib/glue/builder/xml.rb +4 -13
- data/lib/glue/cache/drb.rb +2 -3
- data/lib/glue/cache/file.rb +3 -3
- data/lib/glue/configuration.rb +124 -40
- data/lib/glue/fixture.rb +2 -1
- data/lib/glue/localization.rb +2 -1
- data/lib/glue/property.rb +13 -9
- data/test/glue/tc_aspects.rb +4 -6
- data/test/glue/tc_configuration.rb +12 -3
- data/test/glue/tc_fixture.rb +56 -2
- data/test/glue/tc_flexob.rb +2 -1
- data/test/glue/tc_stores.rb +2 -1
- metadata +43 -57
- data/Rakefile +0 -222
- data/lib/glue/aspects.rb +0 -230
- data/lib/glue/expirable.rb +0 -39
- data/lib/glue/on_included.rb +0 -48
- data/lib/glue/paramix.rb +0 -233
data/lib/glue/fixture.rb
CHANGED
@@ -10,6 +10,7 @@ module Glue
|
|
10
10
|
# A collection of helper methods.
|
11
11
|
|
12
12
|
class Fixtures
|
13
|
+
|
13
14
|
# The directory where the fixtures are located.
|
14
15
|
|
15
16
|
setting :root_dir, :default => 'test/fixture', :doc => 'The directory where the fixtures are located'
|
@@ -71,7 +72,7 @@ class Fixture < Hash
|
|
71
72
|
end
|
72
73
|
|
73
74
|
def load(root_dir = Fixtures.root_dir)
|
74
|
-
raise("The fixture root
|
75
|
+
raise("The fixture root directory '#{root_dir}' doesn't exits") unless File.exist?(root_dir)
|
75
76
|
|
76
77
|
if path = "#{root_dir}/#{@name}.yml" and File.exist?(path)
|
77
78
|
parse_yaml(path)
|
data/lib/glue/localization.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'yaml'
|
2
2
|
|
3
|
-
require '
|
3
|
+
require 'facets/more/aspects'
|
4
4
|
|
5
5
|
module Glue
|
6
6
|
|
@@ -100,6 +100,7 @@ class Localization
|
|
100
100
|
@locales[key.to_s] = Locale.new(locale)
|
101
101
|
end
|
102
102
|
end
|
103
|
+
alias_method :locales=, :add
|
103
104
|
|
104
105
|
# Return the localization hash for the given
|
105
106
|
# locale.
|
data/lib/glue/property.rb
CHANGED
@@ -1,20 +1,26 @@
|
|
1
1
|
require 'facet/annotation'
|
2
2
|
require 'facet/inheritor'
|
3
3
|
require 'facet/dictionary'
|
4
|
+
require 'facets/core/module/on_included'
|
5
|
+
require 'facets/more/aspects'
|
4
6
|
|
5
|
-
require 'glue/on_included'
|
6
7
|
require 'glue/validation'
|
7
|
-
require 'glue/aspects'
|
8
8
|
require 'og/entity'
|
9
9
|
require 'og/relation/all'
|
10
10
|
|
11
11
|
# A convienience structure that holds property
|
12
|
-
# metadata.
|
12
|
+
# metadata. A property is a special type of class annotation.
|
13
|
+
# Typically used in Og managed classes (ie Entities), but it
|
14
|
+
# is *not* Og specific.
|
13
15
|
#--
|
14
16
|
# TODO: reimplement type checking.
|
17
|
+
# TODO: try to clean this up.
|
15
18
|
#++
|
16
19
|
|
17
20
|
class Property
|
21
|
+
|
22
|
+
# The hash used to store the property options.
|
23
|
+
|
18
24
|
attr_accessor :hash
|
19
25
|
|
20
26
|
def initialize(hash)
|
@@ -39,13 +45,11 @@ class Property
|
|
39
45
|
@hash[:symbol].to_s
|
40
46
|
end
|
41
47
|
alias_method :name, :to_s
|
42
|
-
end
|
43
48
|
|
44
|
-
# Property related utils and helpers.
|
49
|
+
# :section: Property related utils and helpers.
|
45
50
|
|
46
|
-
class Property
|
47
51
|
class << self
|
48
|
-
|
52
|
+
|
49
53
|
# Populate an object from a hash of values.
|
50
54
|
# This is a truly dangerous method.
|
51
55
|
#
|
@@ -260,7 +264,7 @@ class Module
|
|
260
264
|
}
|
261
265
|
end
|
262
266
|
end
|
263
|
-
|
267
|
+
|
264
268
|
Module.__add_prop_hook__(self)
|
265
269
|
end
|
266
270
|
}
|
@@ -275,7 +279,7 @@ class Module
|
|
275
279
|
def self.__add_prop_hook__(m)
|
276
280
|
m.send(:include, Og::EntityMixin) unless m.ancestors.include?(Og::EntityMixin)
|
277
281
|
m.send(:include, Glue::Validation) unless m.ancestors.include?(Glue::Validation)
|
278
|
-
m.send(:include,
|
282
|
+
m.send(:include, ::Aspects) unless m.ancestors.include?(::Aspects)
|
279
283
|
end
|
280
284
|
|
281
285
|
end
|
data/test/glue/tc_aspects.rb
CHANGED
@@ -1,9 +1,7 @@
|
|
1
1
|
$:.unshift File.join(File.dirname(__FILE__), '..', '..', 'lib')
|
2
2
|
|
3
3
|
require 'test/unit'
|
4
|
-
require '
|
5
|
-
|
6
|
-
include Glue
|
4
|
+
require 'facets/more/aspects'
|
7
5
|
|
8
6
|
class TestCaseAspects < Test::Unit::TestCase # :nodoc: all
|
9
7
|
|
@@ -24,14 +22,14 @@ class TestCaseAspects < Test::Unit::TestCase # :nodoc: all
|
|
24
22
|
end
|
25
23
|
|
26
24
|
module Tester
|
27
|
-
include
|
25
|
+
include ::Aspects
|
28
26
|
|
29
27
|
attr_accessor :ta
|
30
28
|
pre { |this| this.ta = 5 }
|
31
29
|
end
|
32
30
|
|
33
31
|
class Dummy
|
34
|
-
include
|
32
|
+
include ::Aspects
|
35
33
|
include Tester
|
36
34
|
|
37
35
|
attr_accessor :a, :b, :c
|
@@ -82,7 +80,7 @@ class TestCaseAspects < Test::Unit::TestCase # :nodoc: all
|
|
82
80
|
def test_all
|
83
81
|
Observer.wrap(Dummy, :hello)
|
84
82
|
Epilogue.new.wrap(Dummy, :hello)
|
85
|
-
|
83
|
+
::Aspects.wrap(Dummy, :hello)
|
86
84
|
|
87
85
|
d = Dummy.new
|
88
86
|
d.hello(3)
|
@@ -32,7 +32,9 @@ class TC_Configuration < Test::Unit::TestCase # :nodoc: all
|
|
32
32
|
# method is not needed if you only run this test (or in your
|
33
33
|
# real aplications of course).
|
34
34
|
|
35
|
-
|
35
|
+
# Running the next line breaks later tests when running the test suite.
|
36
|
+
|
37
|
+
# Configuration.clear_all_settings
|
36
38
|
|
37
39
|
Dummy.class_eval do
|
38
40
|
setting :root_dir, :default => '/home/gmosx', :doc => 'The root directory for the app'
|
@@ -49,8 +51,9 @@ class TC_Configuration < Test::Unit::TestCase # :nodoc: all
|
|
49
51
|
end
|
50
52
|
|
51
53
|
def test_all
|
52
|
-
|
53
|
-
assert_equal 4, Configuration.
|
54
|
+
# The following asserts are _not_ true when running the test suite.
|
55
|
+
# assert_equal 4, Configuration.settings.size
|
56
|
+
# assert_equal 4, Configuration.all.size
|
54
57
|
|
55
58
|
assert_equal 2, Configuration.settings(Dummy).size
|
56
59
|
assert_equal 1, Configuration.settings(Another).size
|
@@ -121,6 +124,12 @@ Dummy:
|
|
121
124
|
|
122
125
|
assert_equal 99, Internal.radius
|
123
126
|
assert_equal 99, TC_Configuration::Internal.radius
|
127
|
+
|
128
|
+
# Intuitive setting
|
129
|
+
|
130
|
+
Configuration.Dummy.root_dir = 'wow'
|
131
|
+
assert_equal 'wow', Dummy.root_dir
|
132
|
+
assert_equal 'wow', Configuration.Dummy.root_dir.value
|
124
133
|
end
|
125
134
|
|
126
135
|
end
|
data/test/glue/tc_fixture.rb
CHANGED
@@ -3,7 +3,51 @@ $:.unshift File.join(File.dirname(__FILE__), 'lib')
|
|
3
3
|
require 'test/unit'
|
4
4
|
require 'glue/fixture'
|
5
5
|
|
6
|
-
|
6
|
+
RootDir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'fixture'))
|
7
|
+
|
8
|
+
class TestFixtureExplicitRootDir < Test::Unit::TestCase # :nodoc: all
|
9
|
+
include Glue
|
10
|
+
|
11
|
+
class User
|
12
|
+
attr_accessor :name
|
13
|
+
attr_accessor :age
|
14
|
+
end
|
15
|
+
|
16
|
+
class Article
|
17
|
+
attr_accessor :title
|
18
|
+
attr_accessor :body
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_all
|
22
|
+
users = Fixture.new(User, :root_dir => RootDir)
|
23
|
+
|
24
|
+
assert_equal 3, users.size
|
25
|
+
george = users['george']
|
26
|
+
assert_equal 30, george.age
|
27
|
+
assert_equal 'Renos', users['renos'].name
|
28
|
+
|
29
|
+
articles = Fixture.new(Article, :root_dir => RootDir)
|
30
|
+
|
31
|
+
assert_equal 9, articles.size
|
32
|
+
assert_equal 'This is cool', articles['article_1'].title
|
33
|
+
assert_equal 'Another', articles['article_2'].title
|
34
|
+
assert_equal 'I love this', articles['Test'].title
|
35
|
+
|
36
|
+
assert_equal 'title 3', articles['Auto3'].title
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_global
|
40
|
+
"This is not supported with explicit root directory setting"
|
41
|
+
=begin
|
42
|
+
assert_raises(RuntimeError, "This test will fail when running via rake") do
|
43
|
+
Fixtures.load User, Article
|
44
|
+
end # Fixtures.load _only_ uses Fixtures.root_dir setting.
|
45
|
+
=end
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
class TestFixtureRootDirSetting < Test::Unit::TestCase # :nodoc: all
|
7
51
|
include Glue
|
8
52
|
|
9
53
|
class User
|
@@ -16,6 +60,16 @@ class TestFixture < Test::Unit::TestCase # :nodoc: all
|
|
16
60
|
attr_accessor :body
|
17
61
|
end
|
18
62
|
|
63
|
+
def setup
|
64
|
+
@old_rootdir = Fixtures.root_dir
|
65
|
+
Fixtures.root_dir = RootDir
|
66
|
+
end
|
67
|
+
|
68
|
+
def teardown
|
69
|
+
Fixtures.root_dir = @old_rootdir
|
70
|
+
@old_rootdir = nil
|
71
|
+
end
|
72
|
+
|
19
73
|
def test_all
|
20
74
|
users = Fixture.new(User)
|
21
75
|
|
@@ -35,7 +89,7 @@ class TestFixture < Test::Unit::TestCase # :nodoc: all
|
|
35
89
|
end
|
36
90
|
|
37
91
|
def test_global
|
38
|
-
Fixtures.load User, Article
|
92
|
+
Fixtures.load User, Article
|
39
93
|
assert_equal 3, Fixtures.user.size
|
40
94
|
assert_equal 'This is cool', Fixtures.article['article_1'].title
|
41
95
|
end
|
data/test/glue/tc_flexob.rb
CHANGED
data/test/glue/tc_stores.rb
CHANGED
@@ -5,9 +5,10 @@ require 'test/unit'
|
|
5
5
|
require 'glue/cache/memory'
|
6
6
|
|
7
7
|
class TC_CachingStores < Test::Unit::TestCase # :nodoc: all
|
8
|
+
include Glue
|
8
9
|
|
9
10
|
def test_memory
|
10
|
-
s =
|
11
|
+
s = MemoryCache.new
|
11
12
|
s.write('test', 'hello', { :none => 1})
|
12
13
|
s.read('test')
|
13
14
|
end
|
metadata
CHANGED
@@ -3,13 +3,13 @@ rubygems_version: 0.8.11
|
|
3
3
|
specification_version: 1
|
4
4
|
name: glue
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.
|
7
|
-
date: 2006-
|
6
|
+
version: 0.30.0
|
7
|
+
date: 2006-05-05 00:00:00 +03:00
|
8
8
|
summary: Utility methods and classes for Nitro.
|
9
9
|
require_paths:
|
10
10
|
- lib
|
11
11
|
email: gm@navel.gr
|
12
|
-
homepage: http://www.
|
12
|
+
homepage: http://www.nitroproject.org
|
13
13
|
rubyforge_project: nitro
|
14
14
|
description:
|
15
15
|
autorequire:
|
@@ -22,90 +22,85 @@ required_ruby_version: !ruby/object:Gem::Version::Requirement
|
|
22
22
|
- !ruby/object:Gem::Version
|
23
23
|
version: 0.0.0
|
24
24
|
version:
|
25
|
-
platform:
|
25
|
+
platform:
|
26
26
|
signing_key:
|
27
27
|
cert_chain:
|
28
28
|
authors:
|
29
29
|
- George Moschovitis
|
30
30
|
files:
|
31
|
+
- ProjectInfo
|
32
|
+
- INSTALL
|
33
|
+
- README
|
31
34
|
- doc
|
32
35
|
- lib
|
33
36
|
- test
|
34
|
-
- ProjectInfo
|
35
|
-
- Rakefile
|
36
|
-
- README
|
37
37
|
- setup.rb
|
38
|
-
- INSTALL
|
39
38
|
- doc/CHANGELOG.1
|
40
|
-
- doc/RELEASES
|
41
|
-
- doc/LICENSE
|
42
39
|
- doc/AUTHORS
|
40
|
+
- doc/LICENSE
|
41
|
+
- doc/RELEASES
|
43
42
|
- lib/glue
|
44
43
|
- lib/html
|
45
44
|
- lib/glue.rb
|
45
|
+
- lib/glue/attribute.rb
|
46
46
|
- lib/glue/builder
|
47
|
+
- lib/glue/html.rb
|
47
48
|
- lib/glue/mailer
|
49
|
+
- lib/glue/builder.rb
|
50
|
+
- lib/glue/fixture.rb
|
51
|
+
- lib/glue/configuration.rb
|
52
|
+
- lib/glue/flexob.rb
|
53
|
+
- lib/glue/cache
|
54
|
+
- lib/glue/logger.rb
|
48
55
|
- lib/glue/localization.rb
|
49
|
-
- lib/glue/
|
50
|
-
- lib/glue/uri.rb
|
51
|
-
- lib/glue/template.rb
|
52
|
-
- lib/glue/settings.rb
|
53
|
-
- lib/glue/sanitize.rb
|
56
|
+
- lib/glue/mail.rb
|
54
57
|
- lib/glue/property.rb
|
55
|
-
- lib/glue/on_included.rb
|
56
|
-
- lib/glue/cache
|
57
|
-
- lib/glue/html.rb
|
58
58
|
- lib/glue/mailer.rb
|
59
|
-
- lib/glue/mail.rb
|
60
|
-
- lib/glue/logger.rb
|
61
|
-
- lib/glue/attribute.rb
|
62
|
-
- lib/glue/flexob.rb
|
63
|
-
- lib/glue/fixture.rb
|
64
|
-
- lib/glue/builder.rb
|
65
|
-
- lib/glue/configuration.rb
|
66
|
-
- lib/glue/expirable.rb
|
67
59
|
- lib/glue/cache.rb
|
68
|
-
- lib/glue/
|
60
|
+
- lib/glue/sanitize.rb
|
61
|
+
- lib/glue/settings.rb
|
62
|
+
- lib/glue/template.rb
|
63
|
+
- lib/glue/uri.rb
|
64
|
+
- lib/glue/validation.rb
|
69
65
|
- lib/glue/markup.rb
|
70
|
-
- lib/glue/paramix.rb
|
71
66
|
- lib/glue/accumulate.rb
|
72
67
|
- lib/glue/autoreload.rb
|
73
68
|
- lib/glue/builder/xml.rb
|
74
|
-
- lib/glue/mailer/outgoing.rb
|
75
69
|
- lib/glue/mailer/incoming.rb
|
70
|
+
- lib/glue/mailer/outgoing.rb
|
76
71
|
- lib/glue/cache/file.rb
|
77
|
-
- lib/glue/cache/
|
72
|
+
- lib/glue/cache/drb.rb
|
78
73
|
- lib/glue/cache/memcached.rb
|
79
74
|
- lib/glue/cache/memory.rb
|
80
|
-
- lib/glue/cache/
|
81
|
-
- lib/html/tokenizer.rb
|
82
|
-
- lib/html/version.rb
|
75
|
+
- lib/glue/cache/og.rb
|
83
76
|
- lib/html/document.rb
|
84
77
|
- lib/html/node.rb
|
78
|
+
- lib/html/tokenizer.rb
|
79
|
+
- lib/html/version.rb
|
85
80
|
- test/fixture
|
86
81
|
- test/glue
|
87
82
|
- test/public
|
83
|
+
- test/fixture/article.csv
|
88
84
|
- test/fixture/article.yml
|
89
85
|
- test/fixture/user.yml
|
90
|
-
- test/fixture/article.csv
|
91
86
|
- test/glue/builder
|
92
|
-
- test/glue/
|
87
|
+
- test/glue/tc_attribute.rb
|
88
|
+
- test/glue/tc_aspects.rb
|
93
89
|
- test/glue/tc_validation.rb
|
94
|
-
- test/glue/
|
95
|
-
- test/glue/
|
96
|
-
- test/glue/
|
97
|
-
- test/glue/
|
98
|
-
- test/glue/tc_property_mixins.rb
|
99
|
-
- test/glue/tc_mail.rb
|
90
|
+
- test/glue/tc_builder.rb
|
91
|
+
- test/glue/tc_fixture.rb
|
92
|
+
- test/glue/tc_configuration.rb
|
93
|
+
- test/glue/tc_flexob.rb
|
100
94
|
- test/glue/tc_logger.rb
|
101
95
|
- test/glue/tc_localization.rb
|
102
|
-
- test/glue/
|
103
|
-
- test/glue/
|
104
|
-
- test/glue/
|
105
|
-
- test/glue/
|
106
|
-
- test/glue/
|
107
|
-
- test/glue/tc_aspects.rb
|
96
|
+
- test/glue/tc_mail.rb
|
97
|
+
- test/glue/tc_property.rb
|
98
|
+
- test/glue/tc_template.rb
|
99
|
+
- test/glue/tc_property_mixins.rb
|
100
|
+
- test/glue/tc_uri.rb
|
108
101
|
- test/glue/tc_stores.rb
|
102
|
+
- test/glue/tc_property_type_checking.rb
|
103
|
+
- test/glue/tc_accumulate.rb
|
109
104
|
- test/glue/builder/tc_xml.rb
|
110
105
|
- test/public/dummy_mailer
|
111
106
|
- test/public/dummy_mailer/registration.xhtml
|
@@ -129,14 +124,5 @@ dependencies:
|
|
129
124
|
requirements:
|
130
125
|
- - "="
|
131
126
|
- !ruby/object:Gem::Version
|
132
|
-
version: 1.
|
133
|
-
version:
|
134
|
-
- !ruby/object:Gem::Dependency
|
135
|
-
name: cmdparse
|
136
|
-
version_requirement:
|
137
|
-
version_requirements: !ruby/object:Gem::Version::Requirement
|
138
|
-
requirements:
|
139
|
-
- - "="
|
140
|
-
- !ruby/object:Gem::Version
|
141
|
-
version: 2.0.0
|
127
|
+
version: 1.3.3
|
142
128
|
version:
|
data/Rakefile
DELETED
@@ -1,222 +0,0 @@
|
|
1
|
-
require 'rake/rdoctask'
|
2
|
-
require 'rake/testtask'
|
3
|
-
require 'rake/gempackagetask'
|
4
|
-
|
5
|
-
# Initialize some variables.
|
6
|
-
|
7
|
-
readme = File.read('README')
|
8
|
-
Release = (readme[/^= (.+) README$/, 1] || 'unknown').downcase.tr(" ", "-")
|
9
|
-
Name = Release[/\D+/].sub(/\-+$/, '') || 'unknown'
|
10
|
-
Version = Release[/[\d.]+/] || 'unknown'
|
11
|
-
|
12
|
-
AuthorName, AuthorMail = 'George Moschovitis', 'gm@navel.gr'
|
13
|
-
RubyVersion = '1.8.2'
|
14
|
-
|
15
|
-
# Description = (readme[/README\s+(.+?)\n\n/m, 1] || "unknown").gsub(/\s+/, " ")
|
16
|
-
# Summary = Description[/^.+?>/] || "unknown"
|
17
|
-
|
18
|
-
# DocFiles = %w(README NEWS TODO COPYING GPL)
|
19
|
-
# RDocFiles = DocFiles - %w(GPL)
|
20
|
-
RDocOpts = ["--inline-source", "--line-numbers","--title", Name ]
|
21
|
-
# AdditionalFiles = DocFiles + %w(setup.rb)
|
22
|
-
VersionFile = MainFile = File.join("lib", Name + '.rb')
|
23
|
-
|
24
|
-
RubyForgeProject = 'nitro'
|
25
|
-
RubyForgeUser = 'gmosx'
|
26
|
-
Homepage = "http://www.nitrohq.com/"
|
27
|
-
|
28
|
-
task :default => :package
|
29
|
-
|
30
|
-
# Run all tests.
|
31
|
-
|
32
|
-
Rake::TestTask.new do |t|
|
33
|
-
cwd = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
34
|
-
t.libs << 'test'
|
35
|
-
%w[glue nitro og].each do |dir|
|
36
|
-
t.libs << File.join(cwd, dir, 'lib')
|
37
|
-
end
|
38
|
-
t.test_files = FileList['test/**/tc*.rb']
|
39
|
-
t.verbose = true
|
40
|
-
end
|
41
|
-
|
42
|
-
# Generate RDoc documentation.
|
43
|
-
|
44
|
-
Rake::RDocTask.new do |rd|
|
45
|
-
rd.main = 'README'
|
46
|
-
rd.rdoc_dir = 'rdoc'
|
47
|
-
rd.rdoc_files.include('README', 'INSTALL', 'lib/**/*.rb')
|
48
|
-
rd.options << '--all --inline-source'
|
49
|
-
end
|
50
|
-
|
51
|
-
# Build gem.
|
52
|
-
|
53
|
-
spec = Gem::Specification.new do |s|
|
54
|
-
s.name = 'glue'
|
55
|
-
if File.read('lib/glue.rb') =~ /Version\s+=\s+'(\d+\.\d+\.\d+)'/
|
56
|
-
s.version = $1
|
57
|
-
else
|
58
|
-
raise 'No version found'
|
59
|
-
end
|
60
|
-
s.summary = 'Glue utilities'
|
61
|
-
s.description = 'A collection of utilities and useful classes'
|
62
|
-
# s.add_dependency 'facets', '= 0.8.2'
|
63
|
-
# s.add_dependency 'cmdparse', '= 2.0.0'
|
64
|
-
|
65
|
-
s.required_ruby_version = '>= 1.8.2'
|
66
|
-
|
67
|
-
s.files = FileList[
|
68
|
-
'[A-Z]*', 'setup.rb', '{doc,lib,test,vendor}/**/*'
|
69
|
-
].exclude("_darcs").exclude("_darcs/**/*").exclude('**/*.log').to_a
|
70
|
-
|
71
|
-
s.require_path = 'lib'
|
72
|
-
s.autorequire = 'glue'
|
73
|
-
|
74
|
-
s.has_rdoc = true
|
75
|
-
s.extra_rdoc_files = FileList['[A-Z]*'].to_a
|
76
|
-
s.rdoc_options << '--main' << 'README' << '--title' << 'Glue Documentation'
|
77
|
-
s.rdoc_options << '--all' << '--inline-source'
|
78
|
-
|
79
|
-
s.test_files = []
|
80
|
-
|
81
|
-
s.bindir = 'bin'
|
82
|
-
|
83
|
-
s.author = 'George Moschovitis'
|
84
|
-
s.email = 'gm@navel.gr'
|
85
|
-
s.homepage = 'http://www.nitrohq.com'
|
86
|
-
s.rubyforge_project = 'nitro'
|
87
|
-
end
|
88
|
-
|
89
|
-
Rake::GemPackageTask.new(spec) do |pkg|
|
90
|
-
pkg.package_dir = 'dist'
|
91
|
-
pkg.need_zip = true
|
92
|
-
pkg.need_tar = true
|
93
|
-
end
|
94
|
-
|
95
|
-
# Manual install (not recommended).
|
96
|
-
|
97
|
-
task :install do
|
98
|
-
ruby 'install.rb'
|
99
|
-
end
|
100
|
-
|
101
|
-
# Release files to Rubyforge.
|
102
|
-
# The code for this task provided by Florian Gross.
|
103
|
-
|
104
|
-
desc "Publish the release files to RubyForge."
|
105
|
-
task :publish => [:package] do
|
106
|
-
files = ['gem', 'tgz', 'zip'].map { |ext| "dist/#{Release}.#{ext}" }
|
107
|
-
|
108
|
-
if RubyForgeProject then
|
109
|
-
require 'net/http'
|
110
|
-
require 'open-uri'
|
111
|
-
|
112
|
-
changes = ''
|
113
|
-
if File.exist?('doc/RELEASES') then
|
114
|
-
changes_re = /^== \s+ Version \s+ #{Regexp.quote(Version)} \s*
|
115
|
-
(.+?) (?:==|\Z)/mx
|
116
|
-
changes = File.read('doc/RELEASES')[changes_re, 1] || ''
|
117
|
-
end
|
118
|
-
|
119
|
-
project_uri = "http://rubyforge.org/projects/#{RubyForgeProject}/"
|
120
|
-
project_data = open(project_uri) { |data| data.read }
|
121
|
-
group_id = project_data[/[?&]group_id=(\d+)/, 1]
|
122
|
-
raise "Couldn't get group id" unless group_id
|
123
|
-
|
124
|
-
print "#{RubyForgeUser}@rubyforge.org's password: "
|
125
|
-
password = STDIN.gets.chomp
|
126
|
-
|
127
|
-
login_response = Net::HTTP.start('rubyforge.org', 80) do |http|
|
128
|
-
data = [
|
129
|
-
"login=1",
|
130
|
-
"form_loginname=#{RubyForgeUser}",
|
131
|
-
"form_pw=#{password}"
|
132
|
-
].join("&")
|
133
|
-
http.post('/account/login.php', data)
|
134
|
-
end
|
135
|
-
|
136
|
-
cookie = login_response['set-cookie']
|
137
|
-
raise 'Login failed' unless cookie
|
138
|
-
headers = { 'Cookie' => cookie }
|
139
|
-
|
140
|
-
release_uri = "http://rubyforge.org/frs/admin/?group_id=#{group_id}"
|
141
|
-
release_data = open(release_uri, headers) { |data| data.read }
|
142
|
-
package_id = release_data[/[?&]package_id=(\d+)/, 1]
|
143
|
-
raise "Couldn't get package id" unless package_id
|
144
|
-
|
145
|
-
first_file = true
|
146
|
-
release_id = ""
|
147
|
-
|
148
|
-
files.each do |filename|
|
149
|
-
basename = File.basename(filename)
|
150
|
-
file_ext = File.extname(filename)
|
151
|
-
file_data = File.open(filename, "rb") { |file| file.read }
|
152
|
-
|
153
|
-
puts "Releasing #{basename}..."
|
154
|
-
|
155
|
-
release_response = Net::HTTP.start('rubyforge.org', 80) do |http|
|
156
|
-
release_date = Time.now.strftime('%Y-%m-%d %H:%M')
|
157
|
-
type_map = {
|
158
|
-
'.zip' => '3000',
|
159
|
-
'.tgz' => '3110',
|
160
|
-
'.gz' => '3110',
|
161
|
-
'.gem' => '1400',
|
162
|
-
'.md5sum' => '8100'
|
163
|
-
}; type_map.default = '9999'
|
164
|
-
type = type_map[file_ext]
|
165
|
-
boundary = 'rubyqMY6QN9bp6e4kS21H4y0zxcvoor'
|
166
|
-
|
167
|
-
query_hash = if first_file then
|
168
|
-
{
|
169
|
-
'group_id' => group_id,
|
170
|
-
'package_id' => package_id,
|
171
|
-
'release_name' => Release,
|
172
|
-
'release_date' => release_date,
|
173
|
-
'type_id' => type,
|
174
|
-
'processor_id' => '8000', # Any
|
175
|
-
'release_notes' => '',
|
176
|
-
'release_changes' => changes,
|
177
|
-
'preformatted' => '1',
|
178
|
-
'submit' => '1'
|
179
|
-
}
|
180
|
-
else
|
181
|
-
{
|
182
|
-
'group_id' => group_id,
|
183
|
-
'release_id' => release_id,
|
184
|
-
'package_id' => package_id,
|
185
|
-
'step2' => '1',
|
186
|
-
'type_id' => type,
|
187
|
-
'processor_id' => '8000', # Any
|
188
|
-
'submit' => 'Add This File'
|
189
|
-
}
|
190
|
-
end
|
191
|
-
|
192
|
-
query = '?' + query_hash.map do |(name, value)|
|
193
|
-
[name, URI.encode(value)].join('=')
|
194
|
-
end.join('&')
|
195
|
-
|
196
|
-
data = [
|
197
|
-
"--" + boundary,
|
198
|
-
"Content-Disposition: form-data; name=\"userfile\"; filename=\"#{basename}\"",
|
199
|
-
"Content-Type: application/octet-stream",
|
200
|
-
"Content-Transfer-Encoding: binary",
|
201
|
-
"", file_data, ""
|
202
|
-
].join("\x0D\x0A")
|
203
|
-
|
204
|
-
release_headers = headers.merge(
|
205
|
-
'Content-Type' => "multipart/form-data; boundary=#{boundary}"
|
206
|
-
)
|
207
|
-
|
208
|
-
target = first_file ? '/frs/admin/qrs.php' : '/frs/admin/editrelease.php'
|
209
|
-
http.post(target + query, data, release_headers)
|
210
|
-
end
|
211
|
-
|
212
|
-
if first_file then
|
213
|
-
release_id = release_response.body[/release_id=(\d+)/, 1]
|
214
|
-
raise("Couldn't get release id") unless release_id
|
215
|
-
end
|
216
|
-
|
217
|
-
first_file = false
|
218
|
-
end
|
219
|
-
end
|
220
|
-
end
|
221
|
-
|
222
|
-
# * George Moschovitis <gm@navel.gr>
|