asset_manager 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
@@ -0,0 +1,17 @@
1
+ $:.push File.expand_path("../lib", __FILE__)
2
+ require 'asset_manager'
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = "asset_manager"
6
+ s.version = AssetManager::VERSION
7
+ s.authors = ["Andrew Horsman"]
8
+ s.email = ["self@andrewhorsman.net"]
9
+ s.homepage = "http://github.con/basicxman/asset_manager"
10
+ s.summary = "Quick Gemfile-like tool for managing assets."
11
+ s.description = "Tool to manage static assets like JS, CSS and images."
12
+
13
+ s.files = `git ls-files`.split("\n")
14
+ #s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
15
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
16
+ s.require_paths = ["lib"]
17
+ end
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'asset_manager'
4
+
5
+ source_file = ARGV.first || "Assetfile"
6
+ AssetManager::Runner.new(source_file)
@@ -0,0 +1,8 @@
1
+ module AssetManager
2
+ VERSION = "0.1.0"
3
+
4
+ FETCHERS = [:git]
5
+ require 'asset_manager/fetch/git'
6
+ require 'asset_manager/manager'
7
+ require 'asset_manager/runner'
8
+ end
@@ -0,0 +1,29 @@
1
+ module AssetManager
2
+
3
+ module Fetch
4
+
5
+ def self.is_git?(source)
6
+ if source[-4..-1] == ".git"
7
+ true
8
+ elsif source[0..5] == "git://"
9
+ true
10
+ elsif !source.match("github.com").nil?
11
+ true
12
+ else
13
+ false
14
+ end
15
+ end
16
+
17
+ def self.git(source)
18
+ target = "./.assets/#{source.split("/").last}"
19
+ if File.exists? target
20
+ `cd #{target} && git pull`
21
+ else
22
+ `git clone #{source} #{target}`
23
+ end
24
+ target
25
+ end
26
+
27
+ end
28
+
29
+ end
@@ -0,0 +1,48 @@
1
+ require 'FileUtils'
2
+
3
+ module AssetManager
4
+
5
+ class Manager
6
+
7
+ def source(location, &block)
8
+ AssetManager::FETCHERS.each do |f|
9
+ if AssetManager::Fetch.send("is_#{f.to_s}?", location)
10
+ @repo = AssetManager::Fetch.send(f, location)
11
+ break
12
+ end
13
+ end
14
+
15
+ instance_eval(&block)
16
+ end
17
+
18
+ def asset(source, target)
19
+ location = "#{@repo}/#{source}"
20
+ target_location = get_location(source, target)
21
+ FileUtils.cp(location, target_location)
22
+ rescue Exception => e
23
+ File.open("./.assets/run.log", "a") do |file|
24
+ file.puts e
25
+ end
26
+ puts "An error occurred running asset #{location}, logged to .assets/run.log."
27
+ end
28
+
29
+ def get_location(source, target)
30
+ filename = source.split("/").last
31
+ if target.is_a? Symbol
32
+ "#{location_by_type(target)}/#{filename}"
33
+ else
34
+ target
35
+ end
36
+ end
37
+
38
+ def location_by_type(type)
39
+ case type
40
+ when :stylesheet then "app/assets/stylesheets"
41
+ when :javascript then "app/assets/javascript"
42
+ when :image then "app/assets/images"
43
+ end
44
+ end
45
+
46
+ end
47
+
48
+ end
@@ -0,0 +1,13 @@
1
+ module AssetManager
2
+
3
+ class Runner
4
+
5
+ def initialize(source_file)
6
+ a = AssetManager::Manager.new
7
+ f = File.read(source_file)
8
+ a.instance_eval(f)
9
+ end
10
+
11
+ end
12
+
13
+ end
metadata ADDED
@@ -0,0 +1,63 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: asset_manager
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.1.0
6
+ platform: ruby
7
+ authors:
8
+ - Andrew Horsman
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-06-10 00:00:00 -04:00
14
+ default_executable:
15
+ dependencies: []
16
+
17
+ description: Tool to manage static assets like JS, CSS and images.
18
+ email:
19
+ - self@andrewhorsman.net
20
+ executables:
21
+ - assets
22
+ extensions: []
23
+
24
+ extra_rdoc_files: []
25
+
26
+ files:
27
+ - .gitignore
28
+ - asset_manager.gemspec
29
+ - bin/assets
30
+ - lib/asset_manager.rb
31
+ - lib/asset_manager/fetch/git.rb
32
+ - lib/asset_manager/manager.rb
33
+ - lib/asset_manager/runner.rb
34
+ has_rdoc: true
35
+ homepage: http://github.con/basicxman/asset_manager
36
+ licenses: []
37
+
38
+ post_install_message:
39
+ rdoc_options: []
40
+
41
+ require_paths:
42
+ - lib
43
+ required_ruby_version: !ruby/object:Gem::Requirement
44
+ none: false
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: "0"
49
+ required_rubygems_version: !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: "0"
55
+ requirements: []
56
+
57
+ rubyforge_project:
58
+ rubygems_version: 1.5.0
59
+ signing_key:
60
+ specification_version: 3
61
+ summary: Quick Gemfile-like tool for managing assets.
62
+ test_files: []
63
+