stylesheets_for_all 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/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm use @rubygems
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ group :test do
4
+ gem 'rails', '> 3.2.0'
5
+ end
6
+
7
+ # Specify your gem's dependencies in stylesheets_for_all.gemspec
8
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Philip Hallstrom
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,29 @@
1
+ # StylesheetsForAll
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/stylesheets_for_all.png)](http://badge.fury.io/rb/stylesheets_for_all)
4
+
5
+ In a call to `stylesheet_link_tag` Rails will set `media=screen` which means that
6
+ by default if you print a web page it will look nothing like what it looks like one
7
+ the screen. This plugin changes it so the default is `method=all`.
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ gem 'stylesheets_for_all'
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install stylesheets_for_all
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,9 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ require 'rake/testtask'
4
+ Rake::TestTask.new(:test) do |test|
5
+ test.libs << 'lib'
6
+ test.libs << 'test'
7
+ test.pattern = 'test/**/test_*.rb'
8
+ test.verbose = true
9
+ end
@@ -0,0 +1,3 @@
1
+ module StylesheetsForAll
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,16 @@
1
+ require "stylesheets_for_all/version"
2
+ require "action_view"
3
+
4
+ module StylesheetsForAll
5
+ module ActionViewExtensions
6
+
7
+ def stylesheet_link_tag(*sources)
8
+ options = sources.last.is_a?(Hash) ? sources.pop.stringify_keys : { }
9
+ sources << {'media' => 'all'}.merge(options)
10
+ super
11
+ end
12
+
13
+ end
14
+ end
15
+
16
+ ActionView::Base.send :include, StylesheetsForAll::ActionViewExtensions
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'stylesheets_for_all/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "stylesheets_for_all"
8
+ gem.version = StylesheetsForAll::VERSION
9
+ gem.authors = ["Philip Hallstrom"]
10
+ gem.email = ["philip@pjkh.com"]
11
+ gem.description = %q{Enable stylesheets for all media (screen,print, etc.) by default.}
12
+ gem.summary = %q{Enable stylesheets for all media (screen,print, etc.) by default by defaulting to media=all}
13
+ gem.homepage = "https://github.com/phallstrom/stylesheets_for_all"
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+ end
@@ -0,0 +1,27 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+
4
+ require 'action_controller'
5
+ require 'action_view'
6
+ require 'action_view/template'
7
+ require 'action_view/test_case'
8
+
9
+ require 'stylesheets_for_all'
10
+
11
+ class TestStylesheetsForAll < ActionView::TestCase
12
+ tests ActionView::Helpers::AssetTagHelper
13
+ tests StylesheetsForAll::ActionViewExtensions
14
+
15
+ StyleLinkToTag = {
16
+ %(stylesheet_link_tag("style")) => %(<link href="/stylesheets/style.css" media="all" rel="stylesheet" type="text/css" />),
17
+ %(stylesheet_link_tag("style", :type => "foo/bar")) => %(<link href="/stylesheets/style.css" media="all" rel="stylesheet" type="foo/bar" />),
18
+ %(stylesheet_link_tag("style", :media => "screen")) => %(<link href="/stylesheets/style.css" media="screen" rel="stylesheet" type="text/css" />),
19
+ %(stylesheet_link_tag("style", :media => "screen", :type => "foo/bar")) => %(<link href="/stylesheets/style.css" media="screen" rel="stylesheet" type="foo/bar" />),
20
+ }
21
+
22
+ def test_stylesheet_link_tag
23
+ ENV["RAILS_ASSET_ID"] = ""
24
+ StyleLinkToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) }
25
+ end
26
+
27
+ end
metadata ADDED
@@ -0,0 +1,63 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: stylesheets_for_all
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Philip Hallstrom
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-01-24 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: Enable stylesheets for all media (screen,print, etc.) by default.
15
+ email:
16
+ - philip@pjkh.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - .gitignore
22
+ - .rvmrc
23
+ - Gemfile
24
+ - LICENSE.txt
25
+ - README.md
26
+ - Rakefile
27
+ - lib/stylesheets_for_all.rb
28
+ - lib/stylesheets_for_all/version.rb
29
+ - stylesheets_for_all.gemspec
30
+ - test/test_stylesheets_for_all.rb
31
+ homepage: https://github.com/phallstrom/stylesheets_for_all
32
+ licenses: []
33
+ post_install_message:
34
+ rdoc_options: []
35
+ require_paths:
36
+ - lib
37
+ required_ruby_version: !ruby/object:Gem::Requirement
38
+ none: false
39
+ requirements:
40
+ - - ! '>='
41
+ - !ruby/object:Gem::Version
42
+ version: '0'
43
+ segments:
44
+ - 0
45
+ hash: -665988447778940222
46
+ required_rubygems_version: !ruby/object:Gem::Requirement
47
+ none: false
48
+ requirements:
49
+ - - ! '>='
50
+ - !ruby/object:Gem::Version
51
+ version: '0'
52
+ segments:
53
+ - 0
54
+ hash: -665988447778940222
55
+ requirements: []
56
+ rubyforge_project:
57
+ rubygems_version: 1.8.24
58
+ signing_key:
59
+ specification_version: 3
60
+ summary: Enable stylesheets for all media (screen,print, etc.) by default by defaulting
61
+ to media=all
62
+ test_files:
63
+ - test/test_stylesheets_for_all.rb