prefixr 0.0.1

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/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in prefixr.gemspec
4
+ gemspec
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env ruby
2
+ Prefixr.new ARGV
@@ -0,0 +1,65 @@
1
+ require "uri"
2
+ require "net/http"
3
+
4
+ class Prefixr
5
+ def initialize(args)
6
+ @url = URI.parse "http://prefixr.com/api/index.php"
7
+ @input = args[0]
8
+ @output = args[1]
9
+ unless @input
10
+ puts "\n$ prefixr [input file] [output file]"
11
+ puts "- If no output file is specified input file will be overwritten."
12
+ puts "- If a direcotry is passed in as the input file, all of the .css file inside the directory will be overwritten."
13
+ return
14
+ end
15
+ run
16
+ end
17
+
18
+ private
19
+ def run
20
+ unless is_dir?(@input)
21
+ content = read_file @input
22
+ puts "\nReading content of #{@input}."
23
+ css = get_prefix_css content
24
+ puts "Applying prefixes."
25
+ write_file css, @input, @output
26
+ puts "\n#{@output || @input} received prefixes."
27
+ else
28
+ files = Dir.glob "*.css"
29
+ files.each do |f|
30
+ puts "\nReading content of #{f}."
31
+ content = read_file f
32
+ css = get_prefix_css content
33
+ puts "Applying prefixes."
34
+ write_file css, f
35
+ end
36
+ puts "\nAll .css files in #{@input} received prefixes."
37
+ end
38
+ end
39
+
40
+ private
41
+ def is_dir?(input)
42
+ File.directory? input
43
+ end
44
+
45
+ private
46
+ def read_file(input_file)
47
+ File.open(input_file, "rb") do |f|
48
+ f.read
49
+ end
50
+ end
51
+
52
+ private
53
+ def get_prefix_css(file_read)
54
+ Net::HTTP.post_form(@url, {'css'=>file_read}).body
55
+ end
56
+
57
+ private
58
+ def write_file(css, input, output = nil)
59
+ File.open(output || input, "w+") do |f|
60
+ f.write css
61
+ end
62
+ end
63
+ end
64
+
65
+
@@ -0,0 +1 @@
1
+ "0.0.1"
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = "prefixr"
6
+ s.version = "0.0.1"
7
+ s.authors = ["Jeremy Michel"]
8
+ s.email = ["jeremymichel91@gmail.com"]
9
+ s.homepage = ""
10
+ s.summary = %q{Prefixr command line utility}
11
+ s.description = %q{Simple command line utility for Prefixr}
12
+
13
+ s.rubyforge_project = "prefixr"
14
+
15
+ s.files = `git ls-files`.split("\n")
16
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
+ s.require_paths = ["lib"]
19
+ end
metadata ADDED
@@ -0,0 +1,53 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: prefixr
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Jeremy Michel
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-03-03 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: Simple command line utility for Prefixr
15
+ email:
16
+ - jeremymichel91@gmail.com
17
+ executables:
18
+ - prefixr
19
+ extensions: []
20
+ extra_rdoc_files: []
21
+ files:
22
+ - .gitignore
23
+ - Gemfile
24
+ - Rakefile
25
+ - bin/prefixr
26
+ - lib/prefixr.rb
27
+ - lib/prefixr/version.rb
28
+ - prefixr.gemspec
29
+ homepage: ''
30
+ licenses: []
31
+ post_install_message:
32
+ rdoc_options: []
33
+ require_paths:
34
+ - lib
35
+ required_ruby_version: !ruby/object:Gem::Requirement
36
+ none: false
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ required_rubygems_version: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ requirements: []
48
+ rubyforge_project: prefixr
49
+ rubygems_version: 1.8.15
50
+ signing_key:
51
+ specification_version: 3
52
+ summary: Prefixr command line utility
53
+ test_files: []