montage 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +7 -4
- data/VERSION +1 -1
- data/lib/montage/core_ext.rb +3 -5
- data/lib/montage/sprite.rb +8 -3
- data/lib/montage/sprite_definition.rb +3 -4
- data/montage.gemspec +13 -8
- data/spec/lib/command_runner.rb +1 -1
- data/spec/lib/have_public_method_defined.rb +1 -1
- data/spec/lib/shared_project_specs.rb +1 -1
- data/spec/lib/shared_sprite_specs.rb +1 -1
- data/spec/montage/commands/generate_spec.rb +24 -0
- data/spec/montage/project_spec.rb +2 -2
- data/spec/montage/spec/have_public_method_defined_spec.rb +5 -5
- data/spec/montage/sprite_definition_spec.rb +10 -5
- data/spec/spec_helper.rb +4 -5
- data/tasks/spec.rake +4 -7
- metadata +69 -15
- data/spec/spec.opts +0 -4
data/Rakefile
CHANGED
@@ -24,10 +24,13 @@ begin
|
|
24
24
|
gem.add_dependency 'highline', '>= 1.5'
|
25
25
|
|
26
26
|
# Development dependencies.
|
27
|
-
gem.add_development_dependency 'rspec',
|
28
|
-
gem.add_development_dependency '
|
29
|
-
gem.add_development_dependency '
|
30
|
-
|
27
|
+
gem.add_development_dependency 'rspec-core', '>= 2.0.0.beta.12'
|
28
|
+
gem.add_development_dependency 'rspec-expectations', '>= 2.0.0.beta.12'
|
29
|
+
gem.add_development_dependency 'rspec-mocks', '>= 2.0.0.beta.12'
|
30
|
+
|
31
|
+
gem.add_development_dependency 'open4', '>= 1.0'
|
32
|
+
gem.add_development_dependency 'haml', '>= 3.0.0.beta.1'
|
33
|
+
gem.add_development_dependency 'yard', '>= 0.5'
|
31
34
|
end
|
32
35
|
|
33
36
|
Jeweler::GemcutterTasks.new
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.4.0
|
data/lib/montage/core_ext.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# Some simple string extensions to make things easier.
|
1
2
|
class String
|
2
3
|
|
3
4
|
# Replace sequences of whitespace (including newlines) with either
|
@@ -8,13 +9,10 @@ class String
|
|
8
9
|
# FROM users
|
9
10
|
# QUERY => "SELECT name FROM users"
|
10
11
|
#
|
11
|
-
# @param [TrueClass, FalseClass] spaced (default=true)
|
12
|
-
# Determines whether returned string has whitespace collapsed or removed
|
13
|
-
#
|
14
12
|
# @return [String] Receiver with whitespace (including newlines) replaced
|
15
13
|
#
|
16
|
-
def compress_lines
|
17
|
-
split($/).map { |line| line.strip }.join(
|
14
|
+
def compress_lines
|
15
|
+
split($/).map { |line| line.strip }.join(' ')
|
18
16
|
end
|
19
17
|
|
20
18
|
# Removes leading whitespace from each line, such as might be added when
|
data/lib/montage/sprite.rb
CHANGED
@@ -91,10 +91,15 @@ module Montage
|
|
91
91
|
MESSAGE
|
92
92
|
end
|
93
93
|
|
94
|
-
list =
|
94
|
+
list = Magick::ImageList.new
|
95
|
+
|
96
|
+
@sources.each do |source|
|
95
97
|
list << source.image
|
96
|
-
|
97
|
-
|
98
|
+
|
99
|
+
if @padding and @padding > 0
|
100
|
+
list << Magick::Image.new(1, @padding) do
|
101
|
+
self.background_color = '#FFF0'
|
102
|
+
end
|
98
103
|
end
|
99
104
|
end
|
100
105
|
|
@@ -48,10 +48,9 @@ module Montage
|
|
48
48
|
option; please use only one.
|
49
49
|
ERROR
|
50
50
|
elsif not has_name_segment? and not @options.has_key?(:name)
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
ERROR
|
51
|
+
# Infer the sprite name from the filename.
|
52
|
+
@options[:name] =
|
53
|
+
File.basename(@options[:to], File.extname(@options[:to]))
|
55
54
|
elsif has_name_segment? and not @options[:to] =~ /:name/
|
56
55
|
raise Montage::MissingName, <<-ERROR.compress_lines
|
57
56
|
Sprite `#{path}' requires :name in the "to" option.
|
data/montage.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{montage}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.4.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Anthony Williams"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-07-14}
|
13
13
|
s.default_executable = %q{montage}
|
14
14
|
s.description = %q{Even Rocky had a montage.}
|
15
15
|
s.email = %q{hi@antw.me}
|
@@ -68,7 +68,6 @@ Gem::Specification.new do |s|
|
|
68
68
|
"spec/montage/sprite_definition_spec.rb",
|
69
69
|
"spec/montage/sprite_spec.rb",
|
70
70
|
"spec/rcov.opts",
|
71
|
-
"spec/spec.opts",
|
72
71
|
"spec/spec_helper.rb",
|
73
72
|
"tasks/spec.rake",
|
74
73
|
"tasks/yard.rake"
|
@@ -77,7 +76,7 @@ Gem::Specification.new do |s|
|
|
77
76
|
s.homepage = %q{http://github.com/antw/montage}
|
78
77
|
s.rdoc_options = ["--charset=UTF-8"]
|
79
78
|
s.require_paths = ["lib"]
|
80
|
-
s.rubygems_version = %q{1.3.
|
79
|
+
s.rubygems_version = %q{1.3.7}
|
81
80
|
s.summary = %q{Montage}
|
82
81
|
s.test_files = [
|
83
82
|
"spec/lib/command_runner.rb",
|
@@ -101,17 +100,21 @@ Gem::Specification.new do |s|
|
|
101
100
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
102
101
|
s.specification_version = 3
|
103
102
|
|
104
|
-
if Gem::Version.new(Gem::
|
103
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
105
104
|
s.add_runtime_dependency(%q<rmagick>, [">= 2.12"])
|
106
105
|
s.add_runtime_dependency(%q<highline>, [">= 1.5"])
|
107
|
-
s.add_development_dependency(%q<rspec>, [">=
|
106
|
+
s.add_development_dependency(%q<rspec-core>, [">= 2.0.0.beta.12"])
|
107
|
+
s.add_development_dependency(%q<rspec-expectations>, [">= 2.0.0.beta.12"])
|
108
|
+
s.add_development_dependency(%q<rspec-mocks>, [">= 2.0.0.beta.12"])
|
108
109
|
s.add_development_dependency(%q<open4>, [">= 1.0"])
|
109
110
|
s.add_development_dependency(%q<haml>, [">= 3.0.0.beta.1"])
|
110
111
|
s.add_development_dependency(%q<yard>, [">= 0.5"])
|
111
112
|
else
|
112
113
|
s.add_dependency(%q<rmagick>, [">= 2.12"])
|
113
114
|
s.add_dependency(%q<highline>, [">= 1.5"])
|
114
|
-
s.add_dependency(%q<rspec>, [">=
|
115
|
+
s.add_dependency(%q<rspec-core>, [">= 2.0.0.beta.12"])
|
116
|
+
s.add_dependency(%q<rspec-expectations>, [">= 2.0.0.beta.12"])
|
117
|
+
s.add_dependency(%q<rspec-mocks>, [">= 2.0.0.beta.12"])
|
115
118
|
s.add_dependency(%q<open4>, [">= 1.0"])
|
116
119
|
s.add_dependency(%q<haml>, [">= 3.0.0.beta.1"])
|
117
120
|
s.add_dependency(%q<yard>, [">= 0.5"])
|
@@ -119,7 +122,9 @@ Gem::Specification.new do |s|
|
|
119
122
|
else
|
120
123
|
s.add_dependency(%q<rmagick>, [">= 2.12"])
|
121
124
|
s.add_dependency(%q<highline>, [">= 1.5"])
|
122
|
-
s.add_dependency(%q<rspec>, [">=
|
125
|
+
s.add_dependency(%q<rspec-core>, [">= 2.0.0.beta.12"])
|
126
|
+
s.add_dependency(%q<rspec-expectations>, [">= 2.0.0.beta.12"])
|
127
|
+
s.add_dependency(%q<rspec-mocks>, [">= 2.0.0.beta.12"])
|
123
128
|
s.add_dependency(%q<open4>, [">= 1.0"])
|
124
129
|
s.add_dependency(%q<haml>, [">= 3.0.0.beta.1"])
|
125
130
|
s.add_dependency(%q<yard>, [">= 0.5"])
|
data/spec/lib/command_runner.rb
CHANGED
@@ -76,6 +76,30 @@ end
|
|
76
76
|
|
77
77
|
# ----------------------------------------------------------------------------
|
78
78
|
|
79
|
+
context 'Generating a single sprite with zero padding' do
|
80
|
+
before(:all) do
|
81
|
+
@runner = Montage::Spec::CommandRunner.new('montage')
|
82
|
+
@runner.write_config <<-CONFIG
|
83
|
+
---
|
84
|
+
config.padding: 0
|
85
|
+
|
86
|
+
"public/images/sprites/:name/*.{png,jpg,jpeg,gif}":
|
87
|
+
to: "public/images/:name.png"
|
88
|
+
|
89
|
+
CONFIG
|
90
|
+
@runner.write_source('sprite_one/one')
|
91
|
+
@runner.write_source('sprite_one/two')
|
92
|
+
@runner.run!
|
93
|
+
end
|
94
|
+
|
95
|
+
it { @runner.should be_success }
|
96
|
+
it { @runner.stdout.should =~ /Generating "sprite_one": Done/ }
|
97
|
+
it { @runner.path_to_sprite('sprite_one').should be_file }
|
98
|
+
it { @runner.dimensions_of('sprite_one').should == [50, 40] }
|
99
|
+
end
|
100
|
+
|
101
|
+
# ----------------------------------------------------------------------------
|
102
|
+
|
79
103
|
context 'Trying to generate sprites in a non-project directory' do
|
80
104
|
before(:all) do
|
81
105
|
@runner = Montage::Spec::CommandRunner.new('montage').run!
|
@@ -130,14 +130,14 @@ describe Montage::Project do
|
|
130
130
|
|
131
131
|
it 'should raise an error' do
|
132
132
|
running = lambda { Montage::Project.find(@helper.project_dir) }
|
133
|
-
running.should
|
133
|
+
running.should raise_error(Montage::MissingProject)
|
134
134
|
end
|
135
135
|
end # when given an empty directory
|
136
136
|
|
137
137
|
describe 'when given an invalid path' do
|
138
138
|
it 'should raise an error' do
|
139
139
|
running = lambda { Montage::Project.find('__invalid__') }
|
140
|
-
running.should
|
140
|
+
running.should raise_error(Montage::MissingProject)
|
141
141
|
end
|
142
142
|
end # when given an invalid path
|
143
143
|
end
|
@@ -2,30 +2,30 @@ require File.expand_path('../../../spec_helper', __FILE__)
|
|
2
2
|
|
3
3
|
describe 'have_public_method_defined matcher' do
|
4
4
|
before(:all) do
|
5
|
-
@exception =
|
5
|
+
@exception = RSpec::Expectations::ExpectationNotMetError
|
6
6
|
end
|
7
7
|
|
8
8
|
describe 'with should' do
|
9
9
|
it 'should pass when the method is defined' do
|
10
10
|
running = lambda { String.should have_public_method_defined(:length) }
|
11
|
-
running.should_not
|
11
|
+
running.should_not raise_error(@exception)
|
12
12
|
end
|
13
13
|
|
14
14
|
it 'should fail when the method is not defined' do
|
15
15
|
running = lambda { String.should have_public_method_defined(:__invalid__) }
|
16
|
-
running.should
|
16
|
+
running.should raise_error(@exception)
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
20
|
describe 'with should_not' do
|
21
21
|
it 'should fail when the method is defined' do
|
22
22
|
running = lambda { String.should_not have_public_method_defined(:length) }
|
23
|
-
running.should
|
23
|
+
running.should raise_error(@exception)
|
24
24
|
end
|
25
25
|
|
26
26
|
it 'should pass when the method is not defined' do
|
27
27
|
running = lambda { String.should_not have_public_method_defined(:__invalid__) }
|
28
|
-
running.should_not
|
28
|
+
running.should_not raise_error(@exception)
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
@@ -338,12 +338,17 @@ describe Montage::SpriteDefinition do
|
|
338
338
|
|
339
339
|
# --------------------------------------------------------------------------
|
340
340
|
|
341
|
-
context 'with a
|
342
|
-
it 'should
|
343
|
-
|
344
|
-
@helper.project, '/__invalid__/*', "to" => "_") }
|
341
|
+
context 'with a full file name, and no :name capture or option' do
|
342
|
+
it 'should infer the sprite name from the filename' do
|
343
|
+
@helper.touch('src/source')
|
345
344
|
|
346
|
-
|
345
|
+
definition = Montage::SpriteDefinition.new(
|
346
|
+
@helper.project, 'src/*', 'to' => 'lurrr.png')
|
347
|
+
|
348
|
+
@return = definition.to_sprites
|
349
|
+
|
350
|
+
@return.length.should == 1
|
351
|
+
@return[0].name.should == 'lurrr'
|
347
352
|
end
|
348
353
|
end
|
349
354
|
|
data/spec/spec_helper.rb
CHANGED
@@ -4,16 +4,15 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
|
4
4
|
require 'tmpdir'
|
5
5
|
|
6
6
|
require 'rubygems'
|
7
|
-
require '
|
8
|
-
require '
|
7
|
+
require 'rspec/core'
|
8
|
+
require 'rspec/autorun'
|
9
9
|
|
10
10
|
require 'montage'
|
11
11
|
require 'sass'
|
12
12
|
|
13
13
|
# Spec libraries.
|
14
|
-
|
15
|
-
spec_libs.each { |file| require file }
|
14
|
+
Dir["#{File.dirname(__FILE__)}/lib/**/*.rb"].each { |f| require f }
|
16
15
|
|
17
|
-
|
16
|
+
RSpec.configure do |config|
|
18
17
|
config.after(:suite) { Montage::Spec::ProjectHelper.cleanup! }
|
19
18
|
end
|
data/tasks/spec.rake
CHANGED
@@ -1,13 +1,10 @@
|
|
1
1
|
begin
|
2
|
-
require 'spec/rake/spectask'
|
3
2
|
|
4
|
-
|
5
|
-
spec.pattern = 'spec/**/*_spec.rb'
|
6
|
-
spec.libs << 'lib' << 'spec'
|
7
|
-
spec.spec_opts << '--options' << 'spec/spec.opts'
|
8
|
-
end
|
3
|
+
require 'rspec/core/rake_task'
|
9
4
|
|
10
|
-
|
5
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
6
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
7
|
+
end
|
11
8
|
|
12
9
|
rescue LoadError
|
13
10
|
task :spec do
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: montage
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 15
|
4
5
|
prerelease: false
|
5
6
|
segments:
|
6
7
|
- 0
|
7
|
-
-
|
8
|
+
- 4
|
8
9
|
- 0
|
9
|
-
version: 0.
|
10
|
+
version: 0.4.0
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Anthony Williams
|
@@ -14,16 +15,18 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2010-
|
18
|
+
date: 2010-07-14 00:00:00 +01:00
|
18
19
|
default_executable: montage
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
21
22
|
name: rmagick
|
22
23
|
prerelease: false
|
23
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
24
26
|
requirements:
|
25
27
|
- - ">="
|
26
28
|
- !ruby/object:Gem::Version
|
29
|
+
hash: 27
|
27
30
|
segments:
|
28
31
|
- 2
|
29
32
|
- 12
|
@@ -34,9 +37,11 @@ dependencies:
|
|
34
37
|
name: highline
|
35
38
|
prerelease: false
|
36
39
|
requirement: &id002 !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
37
41
|
requirements:
|
38
42
|
- - ">="
|
39
43
|
- !ruby/object:Gem::Version
|
44
|
+
hash: 5
|
40
45
|
segments:
|
41
46
|
- 1
|
42
47
|
- 5
|
@@ -44,39 +49,83 @@ dependencies:
|
|
44
49
|
type: :runtime
|
45
50
|
version_requirements: *id002
|
46
51
|
- !ruby/object:Gem::Dependency
|
47
|
-
name: rspec
|
52
|
+
name: rspec-core
|
48
53
|
prerelease: false
|
49
54
|
requirement: &id003 !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
50
56
|
requirements:
|
51
57
|
- - ">="
|
52
58
|
- !ruby/object:Gem::Version
|
59
|
+
hash: 62196475
|
53
60
|
segments:
|
54
|
-
-
|
55
|
-
- 3
|
61
|
+
- 2
|
56
62
|
- 0
|
57
|
-
|
63
|
+
- 0
|
64
|
+
- beta
|
65
|
+
- 12
|
66
|
+
version: 2.0.0.beta.12
|
58
67
|
type: :development
|
59
68
|
version_requirements: *id003
|
60
69
|
- !ruby/object:Gem::Dependency
|
61
|
-
name:
|
70
|
+
name: rspec-expectations
|
62
71
|
prerelease: false
|
63
72
|
requirement: &id004 !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
hash: 62196475
|
78
|
+
segments:
|
79
|
+
- 2
|
80
|
+
- 0
|
81
|
+
- 0
|
82
|
+
- beta
|
83
|
+
- 12
|
84
|
+
version: 2.0.0.beta.12
|
85
|
+
type: :development
|
86
|
+
version_requirements: *id004
|
87
|
+
- !ruby/object:Gem::Dependency
|
88
|
+
name: rspec-mocks
|
89
|
+
prerelease: false
|
90
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
91
|
+
none: false
|
64
92
|
requirements:
|
65
93
|
- - ">="
|
66
94
|
- !ruby/object:Gem::Version
|
95
|
+
hash: 62196475
|
96
|
+
segments:
|
97
|
+
- 2
|
98
|
+
- 0
|
99
|
+
- 0
|
100
|
+
- beta
|
101
|
+
- 12
|
102
|
+
version: 2.0.0.beta.12
|
103
|
+
type: :development
|
104
|
+
version_requirements: *id005
|
105
|
+
- !ruby/object:Gem::Dependency
|
106
|
+
name: open4
|
107
|
+
prerelease: false
|
108
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
109
|
+
none: false
|
110
|
+
requirements:
|
111
|
+
- - ">="
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
hash: 15
|
67
114
|
segments:
|
68
115
|
- 1
|
69
116
|
- 0
|
70
117
|
version: "1.0"
|
71
118
|
type: :development
|
72
|
-
version_requirements: *
|
119
|
+
version_requirements: *id006
|
73
120
|
- !ruby/object:Gem::Dependency
|
74
121
|
name: haml
|
75
122
|
prerelease: false
|
76
|
-
requirement: &
|
123
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
124
|
+
none: false
|
77
125
|
requirements:
|
78
126
|
- - ">="
|
79
127
|
- !ruby/object:Gem::Version
|
128
|
+
hash: 62196417
|
80
129
|
segments:
|
81
130
|
- 3
|
82
131
|
- 0
|
@@ -85,20 +134,22 @@ dependencies:
|
|
85
134
|
- 1
|
86
135
|
version: 3.0.0.beta.1
|
87
136
|
type: :development
|
88
|
-
version_requirements: *
|
137
|
+
version_requirements: *id007
|
89
138
|
- !ruby/object:Gem::Dependency
|
90
139
|
name: yard
|
91
140
|
prerelease: false
|
92
|
-
requirement: &
|
141
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
142
|
+
none: false
|
93
143
|
requirements:
|
94
144
|
- - ">="
|
95
145
|
- !ruby/object:Gem::Version
|
146
|
+
hash: 1
|
96
147
|
segments:
|
97
148
|
- 0
|
98
149
|
- 5
|
99
150
|
version: "0.5"
|
100
151
|
type: :development
|
101
|
-
version_requirements: *
|
152
|
+
version_requirements: *id008
|
102
153
|
description: Even Rocky had a montage.
|
103
154
|
email: hi@antw.me
|
104
155
|
executables:
|
@@ -158,7 +209,6 @@ files:
|
|
158
209
|
- spec/montage/sprite_definition_spec.rb
|
159
210
|
- spec/montage/sprite_spec.rb
|
160
211
|
- spec/rcov.opts
|
161
|
-
- spec/spec.opts
|
162
212
|
- spec/spec_helper.rb
|
163
213
|
- tasks/spec.rake
|
164
214
|
- tasks/yard.rake
|
@@ -172,23 +222,27 @@ rdoc_options:
|
|
172
222
|
require_paths:
|
173
223
|
- lib
|
174
224
|
required_ruby_version: !ruby/object:Gem::Requirement
|
225
|
+
none: false
|
175
226
|
requirements:
|
176
227
|
- - ">="
|
177
228
|
- !ruby/object:Gem::Version
|
229
|
+
hash: 3
|
178
230
|
segments:
|
179
231
|
- 0
|
180
232
|
version: "0"
|
181
233
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
234
|
+
none: false
|
182
235
|
requirements:
|
183
236
|
- - ">="
|
184
237
|
- !ruby/object:Gem::Version
|
238
|
+
hash: 3
|
185
239
|
segments:
|
186
240
|
- 0
|
187
241
|
version: "0"
|
188
242
|
requirements: []
|
189
243
|
|
190
244
|
rubyforge_project:
|
191
|
-
rubygems_version: 1.3.
|
245
|
+
rubygems_version: 1.3.7
|
192
246
|
signing_key:
|
193
247
|
specification_version: 3
|
194
248
|
summary: Montage
|
data/spec/spec.opts
DELETED