static_fm 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +11 -1
- data/Rakefile +6 -1
- data/VERSION +1 -1
- data/config/static.yml +7 -5
- data/lib/static_fm/asset.rb +10 -10
- data/lib/static_fm/installer.rb +2 -1
- data/lib/static_fm/tasks.rb +0 -25
- data/lib/static_fm.rb +0 -1
- data/spec/spec_helper.rb +9 -1
- data/spec/static_fm/asset_spec.rb +13 -6
- data/spec/static_fm/network_spec.rb +29 -0
- data/static_fm.gemspec +3 -4
- metadata +4 -5
- data/lib/static_fm/updater.rb +0 -22
- data/spec/static_fm/integration_spec.rb +0 -18
data/README.markdown
CHANGED
@@ -2,12 +2,22 @@
|
|
2
2
|
|
3
3
|
A static file manager: install and upgrade vendor assets (Javascript|CSS).
|
4
4
|
|
5
|
-
##
|
5
|
+
## About
|
6
6
|
|
7
7
|
This project is still under heavy development
|
8
8
|
|
9
|
+
## Development
|
10
|
+
|
11
|
+
rake # Runs non-network specs
|
12
|
+
rake network # Runs all specs, will hit network to test all downloads
|
13
|
+
ASSET=backbone rake network # Runs all non-network specs + network check for backbone asset
|
14
|
+
|
9
15
|
## Contributing to static_fm
|
10
16
|
|
17
|
+
To add a new library to static_fm, fork the project, add an entry to static.yml on a feature branch and submit a pull request.
|
18
|
+
|
19
|
+
## Best practices
|
20
|
+
|
11
21
|
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
12
22
|
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
13
23
|
* Fork the project
|
data/Rakefile
CHANGED
@@ -33,7 +33,7 @@ Jeweler::RubygemsDotOrgTasks.new
|
|
33
33
|
require 'rspec/core'
|
34
34
|
require 'rspec/core/rake_task'
|
35
35
|
RSpec::Core::RakeTask.new(:spec) do |spec|
|
36
|
-
spec.pattern = FileList['spec/**/*_spec.rb']
|
36
|
+
spec.pattern = FileList['spec/**/*_spec.rb'].exclude('spec/**/network_spec.rb')
|
37
37
|
end
|
38
38
|
|
39
39
|
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
@@ -41,6 +41,11 @@ RSpec::Core::RakeTask.new(:rcov) do |spec|
|
|
41
41
|
spec.rcov = true
|
42
42
|
end
|
43
43
|
|
44
|
+
RSpec::Core::RakeTask.new(:network) do |spec|
|
45
|
+
# includes network_spec which requires network access to perform and check downloads
|
46
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
47
|
+
end
|
48
|
+
|
44
49
|
task :default => :spec
|
45
50
|
|
46
51
|
# require 'rake/task'
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.2
|
data/config/static.yml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
"underscore":
|
2
2
|
url: "https://github.com/documentcloud/underscore/raw/{version}/underscore.js"
|
3
3
|
description: "javascript's utility belt"
|
4
|
-
|
4
|
+
compressed_url: "http://cdnjs.cloudflare.com/ajax/libs/underscore.js/{version}/underscore-min.js"
|
5
5
|
version: "1.1.7"
|
6
6
|
|
7
7
|
"raphael":
|
@@ -133,7 +133,7 @@
|
|
133
133
|
|
134
134
|
"backbone":
|
135
135
|
url: "https://github.com/documentcloud/backbone/raw/{version}/backbone.js"
|
136
|
-
|
136
|
+
compressed_url: "http://cdnjs.cloudflare.com/ajax/libs/backbone.js/{version}/backbone-min.js"
|
137
137
|
description: "Backbone supplies structure to Javascript Apps by providing models, views, collections, and events"
|
138
138
|
version: "0.5.3"
|
139
139
|
|
@@ -153,9 +153,10 @@
|
|
153
153
|
version: "4.0"
|
154
154
|
|
155
155
|
"modernizr":
|
156
|
-
url: "
|
156
|
+
url: "http://www.modernizr.com/downloads/modernizr-{version}.js"
|
157
|
+
file_name: "modernizr.js"
|
157
158
|
description: "Feature detection to test browsers against upcoming features"
|
158
|
-
version: "
|
159
|
+
version: "2.0.6"
|
159
160
|
|
160
161
|
"mustache.js":
|
161
162
|
url: "https://raw.github.com/janl/mustache.js/{version}/mustache.js"
|
@@ -165,4 +166,5 @@
|
|
165
166
|
"jasmine-jquery.js":
|
166
167
|
url: "https://github.com/downloads/velesin/jasmine-jquery/jasmine-jquery-{version}.js"
|
167
168
|
description: "jQuery matchers and fixture loader for Jasmine framework"
|
168
|
-
version: "1.3.1"
|
169
|
+
version: "1.3.1"
|
170
|
+
file_name: "jasmine-jquery.js"
|
data/lib/static_fm/asset.rb
CHANGED
@@ -42,15 +42,19 @@ module StaticFM
|
|
42
42
|
end
|
43
43
|
|
44
44
|
|
45
|
-
attr_accessor :name, :url, :version, :compressed,
|
45
|
+
attr_accessor :name, :url, :version, :compressed,
|
46
|
+
:compressed_url, :description, :file_name, :dependencies
|
46
47
|
|
47
48
|
def initialize(name, attributes = {})
|
48
49
|
@name = name
|
49
50
|
attributes.each_pair do |attribute, value|
|
50
51
|
self.send("#{attribute}=", value)
|
51
52
|
end
|
53
|
+
end
|
52
54
|
|
53
|
-
|
55
|
+
def url_with_options(options = {})
|
56
|
+
calculated_url = options[:compress] ? compressed_url : url
|
57
|
+
update_url_with_version(calculated_url, @version)
|
54
58
|
end
|
55
59
|
|
56
60
|
def host
|
@@ -69,12 +73,8 @@ module StaticFM
|
|
69
73
|
@file_name.nil? ? basename : @file_name
|
70
74
|
end
|
71
75
|
|
72
|
-
def compressed_path
|
73
|
-
@compressed && path.gsub(basename, @compressed)
|
74
|
-
end
|
75
|
-
|
76
76
|
def compressed_url
|
77
|
-
@compressed && @url.gsub(basename, @compressed)
|
77
|
+
@compressed_url || (@compressed && @url.gsub(basename, @compressed))
|
78
78
|
end
|
79
79
|
|
80
80
|
def display_name
|
@@ -84,11 +84,11 @@ module StaticFM
|
|
84
84
|
protected
|
85
85
|
|
86
86
|
def parsed_uri
|
87
|
-
@parsed_uri ||= URI.parse(@url)
|
87
|
+
@parsed_uri ||= URI.parse(update_url_with_version(@url, @version))
|
88
88
|
end
|
89
89
|
|
90
|
-
def update_url_with_version
|
91
|
-
|
90
|
+
def update_url_with_version(url, version = nil)
|
91
|
+
version.nil? ? url : url.gsub(/\{version\}/, version)
|
92
92
|
end
|
93
93
|
end
|
94
94
|
|
data/lib/static_fm/installer.rb
CHANGED
data/lib/static_fm/tasks.rb
CHANGED
@@ -4,29 +4,4 @@ namespace :static do
|
|
4
4
|
puts "static <library>"
|
5
5
|
end
|
6
6
|
|
7
|
-
namespace :install do
|
8
|
-
|
9
|
-
desc 'Update backbone'
|
10
|
-
task :backbone do
|
11
|
-
dir = File.dirname(File.expand_path(__FILE__))
|
12
|
-
StaticFM::Updater.update! do |u|
|
13
|
-
u.url = "http://documentcloud.github.com/backbone"
|
14
|
-
u.dir = File.join("public", "javascripts")
|
15
|
-
u.files << "backbone.js"
|
16
|
-
u.files << "backbone-min.js"
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
desc 'Update underscore'
|
21
|
-
task :underscore do
|
22
|
-
StaticFM::Updater.update!.update! do |u|
|
23
|
-
u.url = "http://documentcloud.github.com/underscore"
|
24
|
-
u.dir = Rails.root.join("public", "javascripts", "vendor")
|
25
|
-
u.files << "underscore.js"
|
26
|
-
u.files << "underscore-min.js"
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
end
|
31
|
-
|
32
7
|
end
|
data/lib/static_fm.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -11,4 +11,12 @@ RSpec.configure do |config|
|
|
11
11
|
|
12
12
|
end
|
13
13
|
|
14
|
-
StaticFM::Logger.silence!
|
14
|
+
StaticFM::Logger.silence!
|
15
|
+
|
16
|
+
at_exit do
|
17
|
+
# Run 'rake network' to test downloads
|
18
|
+
# Run DOWNLOAD=preserve rake network to test downloads and keep directory for inspection
|
19
|
+
if !!ENV['DOWNLOAD'] == "preserve" && File.directory?('./spec/downloads')
|
20
|
+
system "rm ./spec/downloads/*"
|
21
|
+
end
|
22
|
+
end
|
@@ -45,18 +45,25 @@ describe StaticFM::Asset do
|
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
|
-
describe "
|
49
|
-
|
50
|
-
@asset
|
51
|
-
|
48
|
+
describe "url_with_options" do
|
49
|
+
before(:each) do
|
50
|
+
@asset = StaticFM::Asset.new("backbone", {
|
51
|
+
:url => "http://www.example.com/path/to/{version}/backbone.js",
|
52
|
+
:version => "0.1"
|
53
|
+
})
|
52
54
|
end
|
53
55
|
|
54
|
-
it "should return
|
55
|
-
@asset.
|
56
|
+
it "should return url with gsubbed version if no special options" do
|
57
|
+
@asset.url_with_options.should == "http://www.example.com/path/to/0.1/backbone.js"
|
56
58
|
end
|
57
59
|
end
|
58
60
|
|
59
61
|
describe "compressed_url" do
|
62
|
+
it "should return explicitly defined url" do
|
63
|
+
@asset.compressed_url = "http://www.example.com/path/to/backbone-min.js"
|
64
|
+
@asset.compressed_url.should == "http://www.example.com/path/to/backbone-min.js"
|
65
|
+
end
|
66
|
+
|
60
67
|
it "should replace basename with compressed" do
|
61
68
|
@asset.compressed = "backbone-min.js"
|
62
69
|
@asset.compressed_url.should == "http://www.example.com/path/to/backbone-min.js"
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
describe "StaticFM integration" do
|
4
|
+
|
5
|
+
def file_should_contain_desired_code(file_name, code)
|
6
|
+
File.readlines(file_name).any? { |line| !!line.match(/#{Regexp.escape(code).downcase}/i) }
|
7
|
+
end
|
8
|
+
|
9
|
+
def file_should_contain_bytes(file_name)
|
10
|
+
File.size(file_name).should > 128
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "downloads" do
|
14
|
+
it "should download assets in static.yml" do
|
15
|
+
config = StaticFM::Asset.config
|
16
|
+
assets = ENV['ASSET'].nil? ? config : {ENV['ASSET'] => config[ENV['ASSET']]}
|
17
|
+
assets.each_pair do |asset_name, attributes|
|
18
|
+
asset = StaticFM::Asset.find(asset_name)
|
19
|
+
destination = "./spec/downloads"
|
20
|
+
installer = StaticFM::Installer.new(asset, destination)
|
21
|
+
installer.download
|
22
|
+
|
23
|
+
File.exist?(installer.file_name).should be_true
|
24
|
+
file_should_contain_bytes(installer.file_name)
|
25
|
+
file_should_contain_desired_code(installer.file_name, asset.name)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/static_fm.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{static_fm}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Ross Kaffenberger"]
|
12
|
-
s.date = %q{2011-09-
|
12
|
+
s.date = %q{2011-09-09}
|
13
13
|
s.description = %q{It's time consuming to look up the URLs to your favorite javascript libraries and css
|
14
14
|
frameworks every time you start a new project or need to upgrade to a new version. Static
|
15
15
|
FM provides recipes and tasks to speed up the process so you can start using the latest now.
|
@@ -37,12 +37,11 @@ FM provides recipes and tasks to speed up the process so you can start using the
|
|
37
37
|
"lib/static_fm/installer.rb",
|
38
38
|
"lib/static_fm/tasks.rb",
|
39
39
|
"lib/static_fm/tasks/static_fm.rake",
|
40
|
-
"lib/static_fm/updater.rb",
|
41
40
|
"spec/spec_helper.rb",
|
42
41
|
"spec/static_fm/asset_spec.rb",
|
43
42
|
"spec/static_fm/command_line_spec.rb",
|
44
43
|
"spec/static_fm/installer_spec.rb",
|
45
|
-
"spec/static_fm/
|
44
|
+
"spec/static_fm/network_spec.rb",
|
46
45
|
"spec/static_fm_spec.rb",
|
47
46
|
"static_fm.gemspec"
|
48
47
|
]
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: static_fm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.2
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Ross Kaffenberger
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-09-
|
13
|
+
date: 2011-09-09 00:00:00 -04:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -165,12 +165,11 @@ files:
|
|
165
165
|
- lib/static_fm/installer.rb
|
166
166
|
- lib/static_fm/tasks.rb
|
167
167
|
- lib/static_fm/tasks/static_fm.rake
|
168
|
-
- lib/static_fm/updater.rb
|
169
168
|
- spec/spec_helper.rb
|
170
169
|
- spec/static_fm/asset_spec.rb
|
171
170
|
- spec/static_fm/command_line_spec.rb
|
172
171
|
- spec/static_fm/installer_spec.rb
|
173
|
-
- spec/static_fm/
|
172
|
+
- spec/static_fm/network_spec.rb
|
174
173
|
- spec/static_fm_spec.rb
|
175
174
|
- static_fm.gemspec
|
176
175
|
has_rdoc: true
|
@@ -187,7 +186,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
187
186
|
requirements:
|
188
187
|
- - ">="
|
189
188
|
- !ruby/object:Gem::Version
|
190
|
-
hash:
|
189
|
+
hash: 2596875027417535980
|
191
190
|
segments:
|
192
191
|
- 0
|
193
192
|
version: "0"
|
data/lib/static_fm/updater.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
module StaticFM
|
2
|
-
class Updater
|
3
|
-
|
4
|
-
def self.update!
|
5
|
-
installer = new
|
6
|
-
yield installer
|
7
|
-
installer.update!
|
8
|
-
end
|
9
|
-
|
10
|
-
attr_accessor :url, :dir, :files
|
11
|
-
|
12
|
-
def files
|
13
|
-
@files ||= []
|
14
|
-
end
|
15
|
-
|
16
|
-
def update!
|
17
|
-
@files.each do |file|
|
18
|
-
system `wget #{File.join(@url, file)} -O#{File.join(@dir, file)}`
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
-
|
3
|
-
describe "StaticFM integration" do
|
4
|
-
|
5
|
-
describe "downloads" do
|
6
|
-
it "should download assets in static.yml" do
|
7
|
-
pending
|
8
|
-
StaticFM::Asset.config.each_pair do |asset_name, attributes|
|
9
|
-
asset = StaticFM::Asset.find(asset_name)
|
10
|
-
destination = "./spec/downloads/#{asset.basename}"
|
11
|
-
StaticFM::Installer.new(asset, destination).download
|
12
|
-
File.exist?(destination).should be_true
|
13
|
-
File.size(destination).should > 128
|
14
|
-
File.readlines(destination).should include(/backbone/i)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|