pupu 0.2 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -3,6 +3,7 @@
3
3
  .DS_Store
4
4
  .cache
5
5
  .yardoc
6
+ .rvmrc
6
7
 
7
8
  script/*
8
9
  gems/*
data/Gemfile CHANGED
@@ -1,9 +1,8 @@
1
- # configuration
2
- bundle_path "gems"
3
- bin_path "script"
4
- disable_rubygems
1
+ source 'http://rubygems.org'
5
2
 
6
3
  # gems
7
4
  gem "nake"
8
5
  gem "media-path"
9
- gem "rspec", only: "test"
6
+
7
+ gem "rspec", "~> 2.6.0", group: :test
8
+ gem "fakefs", "~> 0.3.2", group: :test
@@ -0,0 +1,26 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ diff-lcs (1.1.2)
5
+ fakefs (0.3.2)
6
+ media-path (0.1.3)
7
+ nake (0.0.8)
8
+ term-ansicolor
9
+ rspec (2.6.0)
10
+ rspec-core (~> 2.6.0)
11
+ rspec-expectations (~> 2.6.0)
12
+ rspec-mocks (~> 2.6.0)
13
+ rspec-core (2.6.4)
14
+ rspec-expectations (2.6.0)
15
+ diff-lcs (~> 1.1.2)
16
+ rspec-mocks (2.6.0)
17
+ term-ansicolor (1.0.5)
18
+
19
+ PLATFORMS
20
+ ruby
21
+
22
+ DEPENDENCIES
23
+ fakefs (~> 0.3.2)
24
+ media-path
25
+ nake
26
+ rspec (~> 2.6.0)
@@ -5,8 +5,8 @@
5
5
  # Make sure the secret is at least 30 characters and all random,
6
6
  # no regular words or you'll be exposed to dictionary attacks.
7
7
  ActionController::Base.session = {
8
- :key => '_rails_session',
9
- :secret => '6bd040269fe358f0a2bc3bccd9972b9096e31a59b68902d877b3599e026fe290912d57792b67b04e6dab3eda3f67471dc03d229466495c6fc583d3fb263dcea2'
8
+ key: '_rails_session',
9
+ secret: '6bd040269fe358f0a2bc3bccd9972b9096e31a59b68902d877b3599e026fe290912d57792b67b04e6dab3eda3f67471dc03d229466495c6fc583d3fb263dcea2'
10
10
  }
11
11
 
12
12
  # Use the database for sessions instead of the cookie-based default,
@@ -13,7 +13,7 @@ ActionController::Routing::Routes.draw do |map|
13
13
  # map.resources :products
14
14
 
15
15
  # Sample resource route with options:
16
- # map.resources :products, :member => { :short => :get, :toggle => :post }, :collection => { :sold => :get }
16
+ # map.resources :products, member: { short: :get, toggle: :post }, collection: { sold: :get }
17
17
 
18
18
  # Sample resource route with sub-resources:
19
19
  # map.resources :products, :has_many => [ :comments, :sales ], :has_one => :seller
@@ -21,7 +21,7 @@ ActionController::Routing::Routes.draw do |map|
21
21
  # Sample resource route with more complex sub-resources
22
22
  # map.resources :products do |products|
23
23
  # products.resources :comments
24
- # products.resources :sales, :collection => { :recent => :get }
24
+ # products.resources :sales, collection: { recent: :get }
25
25
  # end
26
26
 
27
27
  # Sample resource route within a namespace:
@@ -3,5 +3,5 @@
3
3
  #
4
4
  # Examples:
5
5
  #
6
- # cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
7
- # Major.create(:name => 'Daley', :city => cities.first)
6
+ # cities = City.create([{name: 'Chicago'}, {name: 'Copenhagen'}])
7
+ # Major.create(name: 'Daley', city: cities.first)
@@ -102,19 +102,8 @@ module Pupu
102
102
  end
103
103
 
104
104
  def proceed_files(repo, url)
105
- js_initializer = "initializers/#{repo}.js"
106
- css_initializer = "initializers/#{repo}.css"
107
- if File.exist?(js_initializer) && (not File.exist?("#{::Pupu.media_root}/javascripts/initializers/#{repo}.js"))
108
- puts "Creating JS initializer"
109
- FileUtils.mkdir_p("#{::Pupu.media_root}/javascripts/initializers")
110
- FileUtils.mv js_initializer, "#{::Pupu.media_root}/javascripts/initializers/#{repo}.js"
111
- end
112
- if File.exist?(css_initializer) && (not File.exist?("#{::Pupu.media_root}/stylesheets/initializers/#{repo}.css"))
113
- puts "Creating CSS initializer"
114
- FileUtils.mkdir_p("#{::Pupu.media_root}/stylesheets/initializers")
115
- FileUtils.mv css_initializer, "#{::Pupu.media_root}/stylesheets/initializers/#{repo}.css"
116
- end
117
105
  @pupu = Pupu[repo]
106
+ @pupu.copy_initializers
118
107
  self.save_metadata(@pupu, url)
119
108
  FileUtils.rm_r(".git") if ::Pupu.strategy.eql?(:copy)
120
109
  rescue Exception => exception
@@ -14,6 +14,7 @@ module Pupu
14
14
  end
15
15
 
16
16
  def self.root=(path)
17
+ raise PupuRootNotFound unless File.directory?(path)
17
18
  @@root = path
18
19
  end
19
20
 
@@ -136,7 +137,7 @@ module Pupu
136
137
  end
137
138
 
138
139
  def image(basename)
139
- file("javascripts/#{image}")
140
+ file("images/#{basename}")
140
141
  end
141
142
 
142
143
  def uninstall
@@ -152,9 +153,38 @@ module Pupu
152
153
  when :all
153
154
  [self.initializer(:javascript), self.initializer(:stylesheet)]
154
155
  when :javascript
155
- file("#{@path}.js", "#{::Pupu.media_root}/javascripts/initializers") rescue nil # TODO: fix media
156
+ begin
157
+ file("#{@path}.js", "#{root}/initializers")
158
+ rescue AssetNotFound
159
+ file("#{@path}.js", "#{::Pupu.media_root}/javascripts/initializers")
160
+ rescue
161
+ nil
162
+ end
156
163
  when :stylesheet
157
- file("#{@path}.css", "#{::Pupu.media_root}/stylesheets/initializers") rescue nil # TODO: fix media
164
+ begin
165
+ file("#{@path}.css", "#{root}/initializers")
166
+ rescue AssetNotFound
167
+ file("#{@path}.css", "#{::Pupu.media_root}/stylesheets/initializers")
168
+ rescue
169
+ nil
170
+ end
171
+ else
172
+ raise Exception, "#{type.to_s} is not know type of initializer"
173
+ end
174
+ end
175
+
176
+ def copy_initializers
177
+ js_initializer = initializer(:javascript)
178
+ css_initializer = initializer(:stylesheet)
179
+
180
+ if js_initializer && (not File.exist?("#{::Pupu.media_root}/javascripts/initializers/#{File.basename(js_initializer.to_s)}"))
181
+ FileUtils.mkdir_p("#{::Pupu.media_root}/javascripts/initializers")
182
+ FileUtils.mv js_initializer.to_s, "#{::Pupu.media_root}/javascripts/initializers/#{File.basename(js_initializer.to_s)}"
183
+ end
184
+
185
+ if css_initializer && (not File.exist?("#{::Pupu.media_root}/stylesheets/initializers/#{File.basename(css_initializer.to_s)}"))
186
+ FileUtils.mkdir_p("#{::Pupu.media_root}/stylesheets/initializers")
187
+ FileUtils.mv css_initializer.to_s, "#{::Pupu.media_root}/stylesheets/initializers/#{File.basename(css_initializer.to_s)}"
158
188
  end
159
189
  end
160
190
 
@@ -165,6 +195,8 @@ module Pupu
165
195
  def file(path, root = self.root)
166
196
  root = MediaPath.new(root) if root.is_a?(String)
167
197
  root.join(path)
198
+ rescue Errno::ENOENT
199
+ raise AssetNotFound, "#{soft_file(path, root)}"
168
200
  end
169
201
  end
170
202
  end
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Pupu
4
- VERSION = "0.2"
4
+ VERSION = "0.2.1"
5
5
  end
@@ -11,7 +11,6 @@ Gem::Specification.new do |s|
11
11
  s.homepage = "http://github.com/botanicus/pupu"
12
12
  s.summary = "Framework-agnostic package system for media files"
13
13
  s.description = "Pupu is a plugin system for media like mootools plugins, icon sets etc. It knows dependencies and it has CLI interface, so it's really easy to bundle such pupus into your app."
14
- s.cert_chain = nil
15
14
  s.email = Base64.decode64("c3Rhc3RueUAxMDFpZGVhcy5jeg==\n")
16
15
 
17
16
  # files
@@ -21,9 +20,6 @@ Gem::Specification.new do |s|
21
20
  s.default_executable = "pupu"
22
21
  s.require_paths = ["lib"]
23
22
 
24
- # Ruby version
25
- s.required_ruby_version = ::Gem::Requirement.new("~> 1.9.1")
26
-
27
23
  # runtime dependencies
28
24
  s.add_dependency "media-path"
29
25
 
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+ require "fakefs/spec_helpers"
2
3
 
3
4
  require_relative "../spec_helper"
4
5
 
@@ -28,6 +29,13 @@ describe Pupu::Pupu do
28
29
  lambda { Pupu.root = "#{PROJECT_ROOT}/root/prefix/pupu" }.should raise_error(Pupu::PupuRootNotFound)
29
30
  end
30
31
  end
32
+
33
+ describe "#file" do
34
+ it "should return path" do
35
+ @pupu = Pupu::Pupu[:autocompleter]
36
+ @pupu.file("autocompleter.js", @pupu.root + "/initializers").to_s.should eql("#{@pupu.root}/initializers/autocompleter.js")
37
+ end
38
+ end
31
39
 
32
40
  describe "#initializers(type)" do
33
41
  before(:each) do
@@ -35,52 +43,62 @@ describe Pupu::Pupu do
35
43
  end
36
44
 
37
45
  it "should return pathname to pupu" do
38
- @pupu.initializer.should eql("#{PROJECT_ROOT}/root/pupu/autocompleter/initializer.js") # TODO: pole s 2 pathname
46
+ @pupu.initializer.map{|path| path.to_s}.should eql(["#{Pupu.media_root}/pupu/autocompleter/initializers/autocompleter.js","#{Pupu.media_root}/pupu/autocompleter/initializers/autocompleter.css"])
39
47
  end
40
48
 
41
49
  it "should return pathname to pupu" do
42
- @pupu.initializer(:script).should eql("#{PROJECT_ROOT}/root/pupu/autocompleter/initializer.js")
50
+ @pupu.initializer(:javascript).to_s.should eql("#{Pupu.media_root}/pupu/autocompleter/initializers/autocompleter.js")
43
51
  end
44
52
 
45
53
  it "should return pathname to pupu" do
46
- @pupu.initializer(:stylesheet).should eql("#{PROJECT_ROOT}/root/pupu/autocompleter/initializer.css")
54
+ @pupu.initializer(:stylesheet).to_s.should eql("#{Pupu.media_root}/pupu/autocompleter/initializers/autocompleter.css")
47
55
  end
48
56
 
49
- it "should return pathname to pupu" do
57
+ it "should raise error for non-existing initializer type" do
50
58
  lambda { @pupu.initializer(:nonexisting) }.should raise_error()
51
59
  end
52
60
 
53
- it "should return nil if image do not exists" do
54
- lambda { @pupu.image("missing.gif") }.should raise_error(AssetNotFound) # TODO
61
+ it "should raise AssetNotFound if image do not exists" do
62
+ lambda { @pupu.image("missing.gif") }.should raise_error(Pupu::AssetNotFound)
55
63
  end
56
64
  end
57
65
 
58
66
  # initializer.js will be copied into root/javascripts/initializers/[pupu-name].js
59
67
  describe "#copy_initializers" do
68
+ include FakeFS::SpecHelpers
69
+
60
70
  before(:each) do
71
+ FakeFS::FileSystem.clone("#{PROJECT_ROOT}")
61
72
  @pupu = Pupu::Pupu[:autocompleter]
62
73
  end
63
74
 
64
- it "should return pathname to pupu" do
65
- @pupu.initializer.should eql("#{PROJECT_ROOT}/root/pupu/autocompleter/initializer.js")
75
+ it "should copy initializers to ROOT/initializers" do
76
+ File.should_not exist("#{Pupu.media_root}/javascripts/initializers/autocompleter.js")
77
+ File.should_not exist("#{Pupu.media_root}/stylesheets/initializers/autocompleter.css")
78
+ @pupu.copy_initializers
79
+ File.should exist("#{Pupu.media_root}/javascripts/initializers/autocompleter.js")
80
+ File.should exist("#{Pupu.media_root}/stylesheets/initializers/autocompleter.css")
66
81
  end
67
82
 
68
- it "should return nil if image do not exists" do
69
- lambda { @pupu.image("missing.gif") }.should raise_error(AssetNotFound) # TODO
83
+ it "should cause #initializer to return path to copied file" do
84
+ @pupu.initializer(:javascript).to_s.should eql("#{Pupu.media_root}/pupu/autocompleter/initializers/autocompleter.js")
85
+ @pupu.copy_initializers
86
+ @pupu.initializer(:javascript).to_s.should eql("#{Pupu.media_root}/javascripts/initializers/autocompleter.js")
70
87
  end
71
88
  end
72
89
 
73
90
  describe "#uninstall" do
74
- before(:each) do
75
- #@pupu = Pupu::Pupu[:autocompleter]
76
- end
91
+ include FakeFS::SpecHelpers
77
92
 
78
- it "should return path to image" do
79
- @pupu.uninstall # TODO
93
+ before(:each) do
94
+ FakeFS::FileSystem.clone("#{PROJECT_ROOT}")
95
+ @pupu = Pupu::Pupu[:autocompleter]
80
96
  end
81
97
 
82
- it "should return nil if image do not exists" do
83
- lambda { @pupu.image("missing.gif") }.should raise_error(AssetNotFound) # TODO
98
+ it "should remove plugins directory" do
99
+ File.should exist(@pupu.root.to_s)
100
+ @pupu.uninstall
101
+ File.should_not exist(@pupu.root.to_s)
84
102
  end
85
103
  end
86
104
 
@@ -90,11 +108,11 @@ describe Pupu::Pupu do
90
108
  end
91
109
 
92
110
  it "should return path to image" do
93
- @pupu.image("spinner.gif").should eql("/pupu/autocompleter/images/spinner.gif")
111
+ @pupu.image("spinner.gif").to_s.should eql("#{Pupu.media_root}/pupu/autocompleter/images/spinner.gif")
94
112
  end
95
113
 
96
114
  it "should return nil if image do not exists" do
97
- lambda { @pupu.image("missing.gif") }.should raise_error(AssetNotFound)
115
+ lambda { @pupu.image("missing.gif") }.should raise_error(Pupu::AssetNotFound)
98
116
  end
99
117
  end
100
118
 
@@ -104,11 +122,11 @@ describe Pupu::Pupu do
104
122
  end
105
123
 
106
124
  it "should return path to javascript" do
107
- @pupu.javascript("autocompleter").should eql("/pupu/autocompleter/lib/autocompleter.js")
125
+ @pupu.javascript("autocompleter").to_s.should eql("#{Pupu.media_root}/pupu/autocompleter/javascripts/autocompleter.js")
108
126
  end
109
127
 
110
128
  it "should return nil if javascript do not exists" do
111
- lambda { @pupu.javascript("missing") }.should raise_error(AssetNotFound)
129
+ lambda { @pupu.javascript("missing") }.should raise_error(Pupu::AssetNotFound)
112
130
  end
113
131
  end
114
132
 
@@ -118,11 +136,11 @@ describe Pupu::Pupu do
118
136
  end
119
137
 
120
138
  it "should return path to image" do
121
- @pupu.stylesheet("autocompleter").should eql("/pupu/autocompleter/autocompleter.css")
139
+ @pupu.stylesheet("autocompleter").to_s.should eql("#{Pupu.media_root}/pupu/autocompleter/stylesheets/autocompleter.css")
122
140
  end
123
141
 
124
142
  it "should return nil if stylesheet do not exists" do
125
- lambda { @pupu.stylesheet("missing") }.should raise_error(AssetNotFound)
143
+ lambda { @pupu.stylesheet("missing") }.should raise_error(Pupu::AssetNotFound)
126
144
  end
127
145
  end
128
146
  end
metadata CHANGED
@@ -1,51 +1,62 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: pupu
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.1
4
5
  prerelease:
5
- version: "0.2"
6
6
  platform: ruby
7
- authors:
8
- - "Jakub \xC5\xA0\xC5\xA5astn\xC3\xBD aka Botanicus"
7
+ authors:
8
+ - Jakub Šťastný aka Botanicus
9
9
  autorequire:
10
10
  bindir: bin
11
- cert_chain:
12
- date: 2011-05-25 00:00:00 +02:00
13
- default_executable: pupu
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
11
+ cert_chain: []
12
+ date: 2013-04-26 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
16
15
  name: media-path
17
- prerelease: false
18
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
19
17
  none: false
20
- requirements:
21
- - - ">="
22
- - !ruby/object:Gem::Version
23
- version: "0"
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
24
22
  type: :runtime
25
- version_requirements: *id001
26
- - !ruby/object:Gem::Dependency
27
- name: simple-templater
28
23
  prerelease: false
29
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: simple-templater
32
+ requirement: !ruby/object:Gem::Requirement
30
33
  none: false
31
- requirements:
32
- - - ">="
33
- - !ruby/object:Gem::Version
34
- version: "0"
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
35
38
  type: :development
36
- version_requirements: *id002
37
- description: Pupu is a plugin system for media like mootools plugins, icon sets etc. It knows dependencies and it has CLI interface, so it's really easy to bundle such pupus into your app.
38
- email: stastny@101ideas.cz
39
- executables:
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ description: Pupu is a plugin system for media like mootools plugins, icon sets etc.
47
+ It knows dependencies and it has CLI interface, so it's really easy to bundle such
48
+ pupus into your app.
49
+ email: !binary |-
50
+ c3Rhc3RueUAxMDFpZGVhcy5jeg==
51
+ executables:
40
52
  - pupu
41
53
  extensions: []
42
-
43
54
  extra_rdoc_files: []
44
-
45
- files:
55
+ files:
46
56
  - .gitignore
47
57
  - CHANGELOG
48
58
  - Gemfile
59
+ - Gemfile.lock
49
60
  - LICENSE
50
61
  - README.textile
51
62
  - TODO.txt
@@ -354,6 +365,7 @@ files:
354
365
  - spec/data/public/pupu/autocompleter/TODO
355
366
  - spec/data/public/pupu/autocompleter/config.rb
356
367
  - spec/data/public/pupu/autocompleter/images/spinner.gif
368
+ - spec/data/public/pupu/autocompleter/initializers/autocompleter.css
357
369
  - spec/data/public/pupu/autocompleter/initializers/autocompleter.js
358
370
  - spec/data/public/pupu/autocompleter/javascripts/autocompleter.js
359
371
  - spec/data/public/pupu/autocompleter/javascripts/autocompleter.local.js
@@ -396,33 +408,28 @@ files:
396
408
  - stubs/pupu/postprocess.rb
397
409
  - stubs/pupu/setup.rb
398
410
  - tasks.rb
399
- has_rdoc: true
400
411
  homepage: http://github.com/botanicus/pupu
401
412
  licenses: []
402
-
403
- post_install_message: "[\e[32mVersion 0.1\e[0m] Ace adapter.\n"
413
+ post_install_message:
404
414
  rdoc_options: []
405
-
406
- require_paths:
415
+ require_paths:
407
416
  - lib
408
- required_ruby_version: !ruby/object:Gem::Requirement
417
+ required_ruby_version: !ruby/object:Gem::Requirement
409
418
  none: false
410
- requirements:
411
- - - ~>
412
- - !ruby/object:Gem::Version
413
- version: 1.9.1
414
- required_rubygems_version: !ruby/object:Gem::Requirement
419
+ requirements:
420
+ - - ! '>='
421
+ - !ruby/object:Gem::Version
422
+ version: '0'
423
+ required_rubygems_version: !ruby/object:Gem::Requirement
415
424
  none: false
416
- requirements:
417
- - - ">="
418
- - !ruby/object:Gem::Version
419
- version: "0"
425
+ requirements:
426
+ - - ! '>='
427
+ - !ruby/object:Gem::Version
428
+ version: '0'
420
429
  requirements: []
421
-
422
430
  rubyforge_project: pupu
423
- rubygems_version: 1.5.3
431
+ rubygems_version: 1.8.23
424
432
  signing_key:
425
433
  specification_version: 3
426
434
  summary: Framework-agnostic package system for media files
427
435
  test_files: []
428
-