mq_reporter 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/mq_reporter +4 -0
- data/lib/mq_reporter.rb +51 -0
- data/lib/mq_reporter/cli.rb +28 -0
- data/lib/mq_reporter/version.rb +6 -0
- data/spec/mq_reporter_spec.rb +5 -0
- metadata +91 -0
data/bin/mq_reporter
ADDED
data/lib/mq_reporter.rb
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'mq_reporter/version'
|
2
|
+
require 'thread'
|
3
|
+
require 'curb'
|
4
|
+
|
5
|
+
module MqReporter
|
6
|
+
|
7
|
+
class << self
|
8
|
+
|
9
|
+
# Copies the mq_reporter.css file to vendor/assets/stylesheets and adds it
|
10
|
+
# the application layout file.
|
11
|
+
#
|
12
|
+
# @see MqReporter::MqReporter.init
|
13
|
+
#
|
14
|
+
# @param [String] mq_reporter the name of the CSS file to add to vendor/assets/stylesheets
|
15
|
+
#
|
16
|
+
def init(filename = "mq_reporter")
|
17
|
+
stylesheet = "#{ Dir.pwd }/vendor/assets/stylesheets/#{ filename }.css"
|
18
|
+
# TODO Make it so it doesn't hard code the .erb file. (Allow use of HAML, etc.)
|
19
|
+
layout_file = "#{ Dir.pwd }/app/views/layouts/application.html.erb"
|
20
|
+
|
21
|
+
# TODO Turn this into a begin, rescue, end block like Guard uses.
|
22
|
+
if !File.exist?(stylesheet)
|
23
|
+
# Add mq_reporter.css to vendor/assets/stylesheets if the file isn't already there.
|
24
|
+
download_file(stylesheet)
|
25
|
+
else
|
26
|
+
# TODO Verify the file contents are the same. If they aren't, overwrite the old file with the new one.
|
27
|
+
end
|
28
|
+
|
29
|
+
add_stylesheet_to_layout(stylesheet, layout_file, filename)
|
30
|
+
end
|
31
|
+
|
32
|
+
def download_file(stylesheet)
|
33
|
+
url = "https://raw.github.com/davidcochran/CSS3-Media-Query-Reporter/master/mediaquery-reporter.css"
|
34
|
+
c = Curl::Easy.perform(url).body_str
|
35
|
+
File.open("#{ stylesheet }", 'w') { |f| f.write(c) }
|
36
|
+
end
|
37
|
+
|
38
|
+
def add_stylesheet_to_layout(stylesheet, layout_file, filename)
|
39
|
+
layout_content = File.read(layout_file)
|
40
|
+
add_to_layout = "<% if Rails.env.development? %>\n\t<%= stylesheet_link_tag \"#{filename}\" %>\n<% end %>"
|
41
|
+
File.open(layout_file, 'wb') do |f|
|
42
|
+
# TODO rather than just appending to the end of the file, put it in the <head>
|
43
|
+
# of the document immediately under the stylesheet_include_tag
|
44
|
+
f.puts layout_content
|
45
|
+
f.puts ""
|
46
|
+
f.puts add_to_layout
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'mq_reporter'
|
3
|
+
|
4
|
+
module MqReporter
|
5
|
+
# Facade for the MqReporter command line interface managed by [Thor](https://github.com/wycats/thor).
|
6
|
+
# This is the main interface to MqReporter that is called by the MqReporter binary `bin/mq_reporter`.
|
7
|
+
# Do not put any logic in here, create a class and delegate instead.
|
8
|
+
#
|
9
|
+
class CLI < Thor
|
10
|
+
default_task :init
|
11
|
+
|
12
|
+
desc 'init', 'Initalizes MqReporter'
|
13
|
+
desc 'init [FILENAME]', 'Copies mq_reporter.css (as FILENAME.css) file into vendor/assets/stylesheets and adds it to the application.html.erb file'
|
14
|
+
|
15
|
+
# Copies the mq_reporter.css file to vendor/assets/stylesheets and adds it
|
16
|
+
# the application layout file.
|
17
|
+
#
|
18
|
+
# @see MqReporter.init
|
19
|
+
#
|
20
|
+
# @param [String] filename the name of the file to add to the application
|
21
|
+
#
|
22
|
+
def init(filename = "mq_reporter")
|
23
|
+
# Provide an option for someone to pass a name they want for the file (not including the .css extention.)
|
24
|
+
MqReporter.init(filename)
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mq_reporter
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.2
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Christopher Moeller
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2011-12-08 00:00:00 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: thor
|
17
|
+
prerelease: false
|
18
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
19
|
+
none: false
|
20
|
+
requirements:
|
21
|
+
- - ~>
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.14.6
|
24
|
+
type: :runtime
|
25
|
+
version_requirements: *id001
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: curb
|
28
|
+
prerelease: false
|
29
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
30
|
+
none: false
|
31
|
+
requirements:
|
32
|
+
- - ~>
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 0.7.16
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: *id002
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: rspec
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: "2.6"
|
46
|
+
type: :development
|
47
|
+
version_requirements: *id003
|
48
|
+
description: David Cochran's CSS3 Media Query Reporter can be found at http://alittlecode.com/a-little-css3-media-query-reporter/
|
49
|
+
email:
|
50
|
+
- christopher.moeller@gmail.com
|
51
|
+
executables:
|
52
|
+
- mq_reporter
|
53
|
+
extensions: []
|
54
|
+
|
55
|
+
extra_rdoc_files: []
|
56
|
+
|
57
|
+
files:
|
58
|
+
- bin/mq_reporter
|
59
|
+
- lib/mq_reporter/cli.rb
|
60
|
+
- lib/mq_reporter/version.rb
|
61
|
+
- lib/mq_reporter.rb
|
62
|
+
- spec/mq_reporter_spec.rb
|
63
|
+
homepage: http://github.com/cmoel/mq_reporter
|
64
|
+
licenses: []
|
65
|
+
|
66
|
+
post_install_message:
|
67
|
+
rdoc_options: []
|
68
|
+
|
69
|
+
require_paths:
|
70
|
+
- lib
|
71
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: "0"
|
77
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
|
+
none: false
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: "0"
|
83
|
+
requirements: []
|
84
|
+
|
85
|
+
rubyforge_project: mq_reporter
|
86
|
+
rubygems_version: 1.8.11
|
87
|
+
signing_key:
|
88
|
+
specification_version: 3
|
89
|
+
summary: Adds CSS3 Media Query Reporter by David Cochran to your Rails app
|
90
|
+
test_files:
|
91
|
+
- spec/mq_reporter_spec.rb
|