stylesheet_flipper 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in stylesheet_flipper.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Jeppe Liisberg
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,65 @@
1
+ # StylesheetFlipper
2
+
3
+ Flip stylesheets on-the-fly and during asset compilation
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'stylesheet_flipper'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install stylesheet_flipper
18
+
19
+ ## Usage
20
+
21
+ Edit your application to serve up a copy of your stylesheets with '-flipped' postfixed to the name
22
+
23
+ *app/assets/stylesheets/application.css*
24
+
25
+ body {
26
+ direction: ltr;
27
+ }
28
+
29
+ *app/assets/stylesheets/application-flipped.css*
30
+
31
+ /*
32
+ *= require application
33
+ */
34
+
35
+ *app/helpers/application_helper.rb*
36
+
37
+ def stylesheet_name(options = {})
38
+ options[:for] ||= 'application'
39
+ if [:ar, :ckb, :fa, :he, :ug].include? I18n.locale
40
+ "#{options[:for]}-flipped"
41
+ else
42
+ options[:for]
43
+ end
44
+ end
45
+
46
+ *app/views/layouts/application.html.erb*
47
+
48
+ <%= stylesheet_link_tag stylesheet_name %>
49
+
50
+ *config/environments/development.rb*
51
+
52
+ # for flipped versions to work, we need to bundle the stylesheet in dev mode as well
53
+ config.assets.debug = false
54
+
55
+ *config/environments/production.rb*
56
+
57
+ config.assets.precompile += %w( application-flipped.css )
58
+
59
+ ## Contributing
60
+
61
+ 1. Fork it
62
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
63
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
64
+ 4. Push to the branch (`git push origin my-new-feature`)
65
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,16 @@
1
+ require "stylesheet_flipper/version"
2
+ require "r2"
3
+
4
+ module StylesheetFlipper
5
+ class Railtie < ::Rails::Railtie
6
+ initializer "stylesheet_flipper.initialize_rails", :group => :assets do |app|
7
+ app.assets.register_bundle_processor 'text/css', :stylesheet_flipper do |context, data|
8
+ if context.logical_path.include?('-flipped')
9
+ R2.r2 data
10
+ else
11
+ data
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,3 @@
1
+ module StylesheetFlipper
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,20 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/stylesheet_flipper/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Jeppe Liisberg"]
6
+ gem.email = ["jeppe@liisberg.net"]
7
+ gem.description = %q{Flip stylesheets on-the-fly and during asset compilation}
8
+ gem.summary = %q{Flip stylesheets on-the-fly and during asset compilation}
9
+ gem.homepage = "https://github.com/monibuds/stylesheet_flipper"
10
+
11
+ gem.add_runtime_dependency "rails", "~>3.0"
12
+ gem.add_runtime_dependency "r2"
13
+
14
+ gem.files = `git ls-files`.split($\)
15
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
16
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
17
+ gem.name = "stylesheet_flipper"
18
+ gem.require_paths = ["lib"]
19
+ gem.version = StylesheetFlipper::VERSION
20
+ end
metadata ADDED
@@ -0,0 +1,75 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: stylesheet_flipper
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Jeppe Liisberg
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-08-06 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rails
16
+ requirement: &70226222079300 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '3.0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70226222079300
25
+ - !ruby/object:Gem::Dependency
26
+ name: r2
27
+ requirement: &70226222078660 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70226222078660
36
+ description: Flip stylesheets on-the-fly and during asset compilation
37
+ email:
38
+ - jeppe@liisberg.net
39
+ executables: []
40
+ extensions: []
41
+ extra_rdoc_files: []
42
+ files:
43
+ - .gitignore
44
+ - Gemfile
45
+ - LICENSE
46
+ - README.md
47
+ - Rakefile
48
+ - lib/stylesheet_flipper.rb
49
+ - lib/stylesheet_flipper/version.rb
50
+ - stylesheet_flipper.gemspec
51
+ homepage: https://github.com/monibuds/stylesheet_flipper
52
+ licenses: []
53
+ post_install_message:
54
+ rdoc_options: []
55
+ require_paths:
56
+ - lib
57
+ required_ruby_version: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ! '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ required_rubygems_version: !ruby/object:Gem::Requirement
64
+ none: false
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ requirements: []
70
+ rubyforge_project:
71
+ rubygems_version: 1.8.10
72
+ signing_key:
73
+ specification_version: 3
74
+ summary: Flip stylesheets on-the-fly and during asset compilation
75
+ test_files: []