brainopia-assets 0.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ .DS_Store
2
+ pkg
data/Rakefile ADDED
@@ -0,0 +1,13 @@
1
+ begin
2
+ require 'jeweler'
3
+ Jeweler::Tasks.new do |gemspec|
4
+ gemspec.name = "assets"
5
+ gemspec.summary = "Library to manage css and js assets in any rack-based framework"
6
+ gemspec.email = "ravwar@gmail.com"
7
+ gemspec.homepage = "http://github.com/brainopia/assets"
8
+ gemspec.authors = ["Ravil Bayramgalin"]
9
+ end
10
+ Jeweler::GemcutterTasks.new
11
+ rescue LoadError
12
+ puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
13
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.9.1
data/assets.gemspec ADDED
@@ -0,0 +1,40 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{assets}
8
+ s.version = "0.9.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Ravil Bayramgalin"]
12
+ s.date = %q{2009-09-13}
13
+ s.email = %q{ravwar@gmail.com}
14
+ s.files = [
15
+ ".gitignore",
16
+ "Rakefile",
17
+ "VERSION",
18
+ "assets.gemspec",
19
+ "lib/assets.rb",
20
+ "lib/assets/base.rb",
21
+ "lib/assets/compressor.jar",
22
+ "lib/assets/javascript.rb",
23
+ "lib/assets/stylesheet.rb"
24
+ ]
25
+ s.homepage = %q{http://github.com/brainopia/assets}
26
+ s.rdoc_options = ["--charset=UTF-8"]
27
+ s.require_paths = ["lib"]
28
+ s.rubygems_version = %q{1.3.5}
29
+ s.summary = %q{Library to manage css and js assets in any rack-based framework}
30
+
31
+ if s.respond_to? :specification_version then
32
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
33
+ s.specification_version = 3
34
+
35
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
36
+ else
37
+ end
38
+ else
39
+ end
40
+ end
@@ -0,0 +1,62 @@
1
+ module Base
2
+ if Object.const_defined?('RACK_ENV') && RACK_ENV == 'production'
3
+ def bundle
4
+ include_links + tag_for_file('application_compressed')
5
+ end
6
+ else
7
+ def bundle
8
+ include_links + include_files
9
+ end
10
+ end
11
+
12
+ def compress
13
+ raise 'You need java to compress assets' if `which java`.empty?
14
+
15
+ compressor = "#{File.dirname(__FILE__)}/compressor.jar"
16
+ file = system_path('application_compressed')
17
+
18
+ File.open file, 'w+' do |it|
19
+ it.puts files.map {|it| File.read system_path(it) }.join("\n")
20
+ end
21
+
22
+ `java -jar #{compressor} --charset utf-8 -o #{file} #{file}`
23
+ end
24
+
25
+ protected
26
+
27
+ def sources
28
+ raise 'Abstract method'
29
+ end
30
+
31
+ def tag(url)
32
+ raise 'Abstract method'
33
+ end
34
+
35
+ def url_path(asset_name)
36
+ raise 'Abstract method'
37
+ end
38
+
39
+ def links
40
+ sources.select {|it| it[/^http/] }
41
+ end
42
+
43
+ def include_links
44
+ links.map {|it| tag it }.join
45
+ end
46
+
47
+ def files
48
+ sources - links
49
+ end
50
+
51
+ def tag_for_file(asset_name)
52
+ tag url_path(asset_name)
53
+ end
54
+
55
+ def include_files
56
+ files.map {|it| tag_for_file it }.join
57
+ end
58
+
59
+ def system_path(asset_name)
60
+ 'public' + url_path(asset_name)
61
+ end
62
+ end
Binary file
@@ -0,0 +1,15 @@
1
+ module Javascript
2
+ extend Base
3
+
4
+ def self.sources
5
+ Assets.config['js']
6
+ end
7
+
8
+ def self.tag(url)
9
+ "<script src='#{url}' type='text/javascript'></script>"
10
+ end
11
+
12
+ def self.url_path(asset_name)
13
+ "/javascripts/#{asset_name}.js"
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ module Stylesheet
2
+ extend Base
3
+
4
+ def self.sources
5
+ Assets.config['css']
6
+ end
7
+
8
+ def self.tag(url)
9
+ "<link href='#{url}' rel='stylesheet' type='text/css' />"
10
+ end
11
+
12
+ def self.url_path(asset_name)
13
+ "/stylesheets/#{asset_name}.css"
14
+ end
15
+ end
data/lib/assets.rb ADDED
@@ -0,0 +1,22 @@
1
+ require 'yaml'
2
+ require 'assets/base'
3
+ require 'assets/javascripts'
4
+ require 'assets/stylesheets'
5
+
6
+ module Assets
7
+ def self.config
8
+ @config or raise 'You need to define config for assets'
9
+ end
10
+
11
+ def self.config=(file)
12
+ @config = YAML.load_file file
13
+ end
14
+
15
+ def self.js
16
+ Javascript
17
+ end
18
+
19
+ def self.css
20
+ Stylesheet
21
+ end
22
+ end
metadata ADDED
@@ -0,0 +1,62 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: brainopia-assets
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.9.1
5
+ platform: ruby
6
+ authors:
7
+ - Ravil Bayramgalin
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-09-13 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description:
17
+ email: ravwar@gmail.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files: []
23
+
24
+ files:
25
+ - .gitignore
26
+ - Rakefile
27
+ - VERSION
28
+ - assets.gemspec
29
+ - lib/assets.rb
30
+ - lib/assets/base.rb
31
+ - lib/assets/compressor.jar
32
+ - lib/assets/javascript.rb
33
+ - lib/assets/stylesheet.rb
34
+ has_rdoc: false
35
+ homepage: http://github.com/brainopia/assets
36
+ licenses:
37
+ post_install_message:
38
+ rdoc_options:
39
+ - --charset=UTF-8
40
+ require_paths:
41
+ - lib
42
+ required_ruby_version: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: "0"
47
+ version:
48
+ required_rubygems_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: "0"
53
+ version:
54
+ requirements: []
55
+
56
+ rubyforge_project:
57
+ rubygems_version: 1.3.5
58
+ signing_key:
59
+ specification_version: 3
60
+ summary: Library to manage css and js assets in any rack-based framework
61
+ test_files: []
62
+