sprites 0.0.1.pre2 → 0.0.1.pre3
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/Rakefile +6 -2
- data/lib/sprites/cli.rb +2 -4
- data/lib/sprites/configuration.rb +1 -15
- data/lib/sprites/notifier.rb +0 -5
- data/lib/sprites/rails/railtie.rb +1 -18
- data/lib/sprites/rails/sprites.rake +23 -0
- data/lib/sprites/version.rb +1 -1
- data/spec/fixtures/rails_project1/Rakefile +4 -0
- data/spec/fixtures/rails_project1/config/environment.rb +0 -3
- data/spec/lib/sprites/configuration_spec.rb +14 -14
- data/spec/lib/sprites_spec.rb +2 -2
- metadata +5 -4
data/.gitignore
CHANGED
data/Rakefile
CHANGED
@@ -14,8 +14,6 @@ RSpec::Core::RakeTask.new(:coverage) do |t|
|
|
14
14
|
t.rcov_opts = ['--exclude', 'spec']
|
15
15
|
end
|
16
16
|
|
17
|
-
desc 'Default: run specs.'
|
18
|
-
task :default => :spec
|
19
17
|
|
20
18
|
namespace :spec do
|
21
19
|
desc 'Create spec'
|
@@ -38,3 +36,9 @@ EOS
|
|
38
36
|
puts spec_doc
|
39
37
|
end
|
40
38
|
end
|
39
|
+
|
40
|
+
desc "Run cucumber"
|
41
|
+
task(:cucumber) { sh 'cucumber' }
|
42
|
+
|
43
|
+
desc 'Default: run specs.'
|
44
|
+
task :default => [:spec, :cucumber]
|
data/lib/sprites/cli.rb
CHANGED
@@ -1,9 +1,8 @@
|
|
1
1
|
module Sprites
|
2
2
|
class Configuration
|
3
|
-
FIELDS = %w{
|
3
|
+
FIELDS = %w{sprites_path sprite_stylesheets_path sprite_pieces_path}
|
4
4
|
|
5
5
|
DEFAULT_CONFIGURATION = {
|
6
|
-
'backend' => :rmagick,
|
7
6
|
'sprites_path' => 'public/images/sprites',
|
8
7
|
'sprite_stylesheets_path' => 'public/stylesheets/sprites',
|
9
8
|
'sprite_pieces_path' => 'public/images/sprite_images'
|
@@ -39,19 +38,6 @@ module Sprites
|
|
39
38
|
EVAL
|
40
39
|
end
|
41
40
|
|
42
|
-
alias_method :backend_without_override, :backend
|
43
|
-
def backend_with_override(*args)
|
44
|
-
val, *_ = args
|
45
|
-
|
46
|
-
if val
|
47
|
-
backend_without_override(val)
|
48
|
-
return self
|
49
|
-
end
|
50
|
-
|
51
|
-
backend_without_override && backend_without_override.to_sym
|
52
|
-
end
|
53
|
-
alias_method :backend, :backend_with_override
|
54
|
-
|
55
41
|
def self.new_for_command_line_options(options)
|
56
42
|
config = new
|
57
43
|
options.each do |k, v|
|
data/lib/sprites/notifier.rb
CHANGED
@@ -4,24 +4,7 @@ require 'sprites'
|
|
4
4
|
module Sprites
|
5
5
|
class Railtie < Rails::Railtie
|
6
6
|
rake_tasks do
|
7
|
-
|
8
|
-
task :sprites => :environment do
|
9
|
-
assets_root = Rails.application.config.assets[:enabled] ? 'app/assets' : 'public'
|
10
|
-
|
11
|
-
::Sprites.configure do
|
12
|
-
sprites_path Rails.root.join(assets_root, 'images/sprites')
|
13
|
-
sprite_stylesheets_path Rails.root.join(assets_root, 'stylesheets/sprites')
|
14
|
-
sprite_pieces_path Rails.root.join(assets_root, 'images/sprite_images')
|
15
|
-
end unless ::Sprites.configuration.configured?
|
16
|
-
|
17
|
-
unless (def_file_path = Rails.root.join('config/sprites.rb')).exist?
|
18
|
-
raise CliApplication::DefinitionFileNotFound
|
19
|
-
end
|
20
|
-
|
21
|
-
load def_file_path
|
22
|
-
sprite_generator = ChunkyPngGenerator.new(::Sprites.configuration)
|
23
|
-
sprite_generator.generate(::Sprites.application.sprites)
|
24
|
-
end
|
7
|
+
load File.expand_path('../sprites.rake', __FILE__)
|
25
8
|
end
|
26
9
|
end
|
27
10
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'sprites'
|
2
|
+
|
3
|
+
include Rake::DSL if defined?(Rake::DSL)
|
4
|
+
include Sprites
|
5
|
+
|
6
|
+
desc "Generate sprites and stylesheets"
|
7
|
+
task :sprites => :environment do
|
8
|
+
assets_root = Rails.application.config.assets[:enabled] ? 'app/assets' : 'public'
|
9
|
+
|
10
|
+
::Sprites.configure do
|
11
|
+
sprites_path Rails.root.join(assets_root, 'images/sprites')
|
12
|
+
sprite_stylesheets_path Rails.root.join(assets_root, 'stylesheets/sprites')
|
13
|
+
sprite_pieces_path Rails.root.join(assets_root, 'images/sprite_images')
|
14
|
+
end unless ::Sprites.configuration.configured?
|
15
|
+
|
16
|
+
unless (def_file_path = Rails.root.join('config/sprites.rb')).exist?
|
17
|
+
raise CliApplication::DefinitionFileNotFound
|
18
|
+
end
|
19
|
+
|
20
|
+
load def_file_path
|
21
|
+
sprite_generator = ChunkyPngGenerator.new(::Sprites.configuration)
|
22
|
+
sprite_generator.generate(::Sprites.application.sprites)
|
23
|
+
end
|
data/lib/sprites/version.rb
CHANGED
@@ -6,20 +6,6 @@ describe Configuration do
|
|
6
6
|
Configuration.new
|
7
7
|
end
|
8
8
|
|
9
|
-
context "#backend" do
|
10
|
-
it 'should be rmagick by default' do
|
11
|
-
config.backend.should be(:rmagick)
|
12
|
-
end
|
13
|
-
|
14
|
-
it 'should set the backend' do
|
15
|
-
config.backend(:mini_magick).backend.should == :mini_magick
|
16
|
-
end
|
17
|
-
|
18
|
-
it 'should coerse backend into a symbol' do
|
19
|
-
config.backend('mini_magick').backend.should == :mini_magick
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
9
|
context '#sprites_path' do
|
24
10
|
it 'should return the default' do
|
25
11
|
config.sprites_path.should == 'public/images/sprites'
|
@@ -49,4 +35,18 @@ describe Configuration do
|
|
49
35
|
config.sprite_pieces_path('foo').sprite_pieces_path.should == 'foo'
|
50
36
|
end
|
51
37
|
end
|
38
|
+
|
39
|
+
context '#configured?' do
|
40
|
+
it 'should not be configured if no defaults have changed' do
|
41
|
+
Configuration.new.should_not be_configured
|
42
|
+
end
|
43
|
+
|
44
|
+
Configuration::FIELDS.each do |field|
|
45
|
+
it "should be configured if the #{field} has changed" do
|
46
|
+
config = Configuration.new
|
47
|
+
config.send(field, 'foo')
|
48
|
+
config.should be_configured
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
52
|
end
|
data/spec/lib/sprites_spec.rb
CHANGED
@@ -10,10 +10,10 @@ describe Sprites do
|
|
10
10
|
context 'self.configure' do
|
11
11
|
it 'should congfigure the application' do
|
12
12
|
Sprites.configure do
|
13
|
-
|
13
|
+
sprites_path 'public/sprites'
|
14
14
|
end
|
15
15
|
|
16
|
-
Sprites.configuration.
|
16
|
+
Sprites.configuration.sprites_path.should == 'public/sprites'
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sprites
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 1923831975
|
5
5
|
prerelease: 6
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
9
|
- 1
|
10
10
|
- pre
|
11
|
-
-
|
12
|
-
version: 0.0.1.
|
11
|
+
- 3
|
12
|
+
version: 0.0.1.pre3
|
13
13
|
platform: ruby
|
14
14
|
authors:
|
15
15
|
- Sam Woodard
|
@@ -17,7 +17,7 @@ autorequire:
|
|
17
17
|
bindir: bin
|
18
18
|
cert_chain: []
|
19
19
|
|
20
|
-
date: 2011-10-
|
20
|
+
date: 2011-10-29 00:00:00 -07:00
|
21
21
|
default_executable:
|
22
22
|
dependencies:
|
23
23
|
- !ruby/object:Gem::Dependency
|
@@ -176,6 +176,7 @@ files:
|
|
176
176
|
- lib/sprites/notifier.rb
|
177
177
|
- lib/sprites/rails.rb
|
178
178
|
- lib/sprites/rails/railtie.rb
|
179
|
+
- lib/sprites/rails/sprites.rake
|
179
180
|
- lib/sprites/sprite.rb
|
180
181
|
- lib/sprites/sprite_generators/chunky_png_generator.rb
|
181
182
|
- lib/sprites/sprite_piece.rb
|