dev_task 0.0.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,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 dev_task.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Maxim
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,33 @@
1
+ # DevTask
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'dev_task'
10
+
11
+ ## Task:
12
+
13
+ 1. Routes group by controller
14
+
15
+ $ bundle exec rake dev_task:nroutes
16
+
17
+ 2. Conver css -> scss
18
+
19
+ input - css
20
+
21
+ output - scss
22
+
23
+ prefix - namespace for assets
24
+
25
+ $ bundle exec rake dev_task:css2scss[input,output,prefix]
26
+
27
+ ## Contributing
28
+
29
+ 1. Fork it
30
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
31
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
32
+ 4. Push to the branch (`git push origin my-new-feature`)
33
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
data/dev_task.gemspec ADDED
@@ -0,0 +1,22 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/dev_task/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Maxim"]
6
+ gem.email = ["parallel588@gmail.com"]
7
+ gem.description = %q{Dev ror task}
8
+ gem.summary = %q{Dev ror task}
9
+ gem.homepage = ""
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "dev_task"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = DevTask::VERSION
17
+
18
+ gem.add_dependency(%q<rails>, [">= 3.2"])
19
+ gem.add_dependency(%q<rake>, [">= 0"])
20
+ gem.add_dependency(%q<sass>, ["= 3.1.10"])
21
+
22
+ end
@@ -0,0 +1,10 @@
1
+ class String
2
+ def red; colorize(self, "\e[1m\e[31m"); end
3
+ def green; colorize(self, "\e[1m\e[32m"); end
4
+ def dark_green; colorize(self, "\e[32m"); end
5
+ def yellow; colorize(self, "\e[1m\e[33m"); end
6
+ def blue; colorize(self, "\e[1m\e[34m"); end
7
+ def dark_blue; colorize(self, "\e[34m"); end
8
+ def pur; colorize(self, "\e[1m\e[35m"); end
9
+ def colorize(text, color_code) "#{color_code}#{text}\e[0m" end
10
+ end
@@ -0,0 +1,29 @@
1
+ # encoding: utf-8
2
+ require 'sass/css'
3
+
4
+ module DevTask
5
+ class Css2scss
6
+ class << self
7
+ def convert(css, options = { })
8
+ @scss = Sass::CSS.new(css).render(:scss)
9
+
10
+ @scss.gsub!(/url\(.*?\)/){ |v|
11
+ _file = (v.match(/([^\/]+)\)/) && $1).gsub(/'/, '')
12
+ case
13
+ when v =~ /\/images\// then "image-url('#{ _file }')"
14
+ when v =~ /\/fonts\// then "font-url('#{ _file }')"
15
+ else
16
+ v
17
+ end
18
+ }
19
+
20
+ @scss.gsub(/@import url\(([^\)]*).css\);?/){ "@import '#{options[:prefix]}/#{$1}';" }
21
+ rescue Sass::SyntaxError => e
22
+ puts "!"*90
23
+ puts "[ CSS -> SCSS ] #{e}"
24
+
25
+ end
26
+ end
27
+ end
28
+
29
+ end
@@ -0,0 +1,5 @@
1
+ module DevTask
2
+ class Engine < Rails::Engine
3
+ # auto wire
4
+ end
5
+ end
@@ -0,0 +1,9 @@
1
+ module DevTask
2
+ class Railtie < Rails::Railtie
3
+
4
+ rake_tasks do
5
+ load "path/to/my_railtie.tasks"
6
+ end
7
+
8
+ end
9
+ end
@@ -0,0 +1,3 @@
1
+ module DevTask
2
+ VERSION = "0.0.1"
3
+ end
data/lib/dev_task.rb ADDED
@@ -0,0 +1,20 @@
1
+ require "dev_task/version"
2
+ require "dev_task/css2scss"
3
+ require "dev_task/core_ext/string"
4
+
5
+ module DevTask
6
+ if defined?(Rails) && defined?(Rails::Engine)
7
+ class Engine < ::Rails::Engine
8
+ require 'dev_task/engine'
9
+ end
10
+
11
+ module Rails
12
+ class Railtie < ::Rails::Railtie
13
+ rake_tasks do
14
+ load "tasks/routes.rake"
15
+ load "tasks/css2sass.rake"
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,39 @@
1
+ # encoding: utf-8
2
+ require 'sass/css'
3
+
4
+ namespace :dev_task do
5
+
6
+ desc "Convert css -> scss "
7
+ task :css2scss, [ :input, :output, :prefix ] => :environment do |t, args|
8
+ return "File is not found" if args.input.to_s.blank?
9
+ @input_file_path = File.expand_path args.input.to_s
10
+ puts @input_file_path
11
+ @prefix = args.prefix.blank? ? "" : args.prefix.to_s
12
+
13
+ if File.exist?(@input_file_path)
14
+ begin
15
+ @scss = DevTask::Css2scss.convert(File.open(@input_file_path, 'r').read, { :prefix => @prefix })
16
+
17
+ unless args.output.blank?
18
+ File.open(File.expand_path( args.output), "w+") do |f|
19
+ f << @scss
20
+ end
21
+ else
22
+ puts "!"*90
23
+ puts @scss
24
+ puts "!"*90
25
+ end
26
+
27
+ rescue Sass::SyntaxError => e
28
+ puts "!"*90
29
+ puts "[ CSS -> SCSS ] #{e}"
30
+ end
31
+ else
32
+ puts "!"*90
33
+ puts "File is not exist: #{@input_file_path}"
34
+ end
35
+
36
+ end
37
+
38
+
39
+ end
@@ -0,0 +1,37 @@
1
+ require 'rails/application/route_inspector'
2
+
3
+ class String
4
+
5
+ def red; colorize(self, "\e[1m\e[31m"); end
6
+ def green; colorize(self, "\e[1m\e[32m"); end
7
+ def dark_green; colorize(self, "\e[32m"); end
8
+ def yellow; colorize(self, "\e[1m\e[33m"); end
9
+ def blue; colorize(self, "\e[1m\e[34m"); end
10
+ def dark_blue; colorize(self, "\e[34m"); end
11
+ def pur; colorize(self, "\e[1m\e[35m"); end
12
+ def colorize(text, color_code) "#{color_code}#{text}\e[0m" end
13
+ end
14
+
15
+
16
+ namespace :dev_task do
17
+ desc "Alt routes"
18
+ task :nroutes => :environment do
19
+ Rails.application.reload_routes!
20
+ all_routes = Rails.application.routes.routes
21
+ inspector = Rails::Application::RouteInspector.new
22
+
23
+ routes = inspector.collect_routes(all_routes)
24
+ name_width = routes.map{ |r| r[:name].length }.max
25
+ verb_width = routes.map{ |r| r[:verb].length }.max
26
+ path_width = routes.map{ |r| r[:path].length }.max
27
+
28
+ group_routes = routes.group_by{ |j| j[:reqs].to_s.split("#").first.to_s}
29
+ group_routes.each do |controller, _routes|
30
+ puts controller.to_s.upcase.dark_green
31
+ puts ('-'*(name_width+verb_width+path_width+30)).dark_green
32
+ _routes.each do |r|
33
+ puts "#{r[:name].rjust(name_width)} #{r[:verb].ljust(verb_width)} #{r[:path].ljust(path_width)} #{r[:reqs]}"
34
+ end
35
+ end
36
+ end
37
+ end
metadata ADDED
@@ -0,0 +1,107 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dev_task
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Maxim
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-06-12 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rails
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '3.2'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '3.2'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: sass
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - '='
52
+ - !ruby/object:Gem::Version
53
+ version: 3.1.10
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - '='
60
+ - !ruby/object:Gem::Version
61
+ version: 3.1.10
62
+ description: Dev ror task
63
+ email:
64
+ - parallel588@gmail.com
65
+ executables: []
66
+ extensions: []
67
+ extra_rdoc_files: []
68
+ files:
69
+ - .gitignore
70
+ - Gemfile
71
+ - LICENSE
72
+ - README.md
73
+ - Rakefile
74
+ - dev_task.gemspec
75
+ - lib/dev_task.rb
76
+ - lib/dev_task/core_ext/string.rb
77
+ - lib/dev_task/css2scss.rb
78
+ - lib/dev_task/engine.rb
79
+ - lib/dev_task/railtie.rb
80
+ - lib/dev_task/version.rb
81
+ - lib/tasks/css2sass.rake
82
+ - lib/tasks/routes.rake
83
+ homepage: ''
84
+ licenses: []
85
+ post_install_message:
86
+ rdoc_options: []
87
+ require_paths:
88
+ - lib
89
+ required_ruby_version: !ruby/object:Gem::Requirement
90
+ none: false
91
+ requirements:
92
+ - - ! '>='
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ required_rubygems_version: !ruby/object:Gem::Requirement
96
+ none: false
97
+ requirements:
98
+ - - ! '>='
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ requirements: []
102
+ rubyforge_project:
103
+ rubygems_version: 1.8.24
104
+ signing_key:
105
+ specification_version: 3
106
+ summary: Dev ror task
107
+ test_files: []