asset_finder 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0f2fc8201d1a059c55f43ad00e9bbce3f31e4fd5
4
+ data.tar.gz: 045d6c43ea34c4b8136de9a257ffdc3d6203e56f
5
+ SHA512:
6
+ metadata.gz: 52da41d562fe1dde1ac8c51653d3c099712d1730a66e0bf1edceb833800cad06a18540538015d3b3833cfd296d22f3850172e37fd07cc6b8981b79b1344239be
7
+ data.tar.gz: 1ddd257e6220999ae42b156a7811e51c93656f4ef213a5a11663fb712a0639a222c5d3404a92a1be0c0267dfbbf4eca7edc9af80fa2859d62d02f0dc9480a872
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ /vendor/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.2
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in asset_finder.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # AssetFinder
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/asset_finder`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'asset_finder'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install asset_finder
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ 1. Fork it ( https://github.com/[my-github-username]/asset_finder/fork )
36
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
37
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
38
+ 4. Push to the branch (`git push origin my-new-feature`)
39
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'asset_finder/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "asset_finder"
8
+ spec.version = AssetFinder::VERSION
9
+ spec.authors = ["Takahiro Ooishi"]
10
+ spec.email = ["taka0125@gmail.com"]
11
+
12
+ spec.summary = %q{Find javascripts and stylesheets for `rake asset:precompile`.}
13
+ spec.description = %q{Find javascripts and stylesheets. Configure precompile path.}
14
+ spec.homepage = "https://github.com/taka0125/asset_finder"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = "exe"
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency 'railties', '>= 3.1', '< 5.0'
22
+ spec.add_development_dependency "bundler", "~> 1.9"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+ spec.add_development_dependency "rspec"
25
+ end
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "asset_finder"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,11 @@
1
+ require "asset_finder/version"
2
+ require "asset_finder/finder"
3
+ require "asset_finder/javascript/normalizer"
4
+ require "asset_finder/javascript/finder"
5
+ require "asset_finder/stylesheet/normalizer"
6
+ require "asset_finder/stylesheet/finder"
7
+ require "asset_finder/railtie" if defined?(::Rails::Railtie)
8
+
9
+ module AssetFinder
10
+ # Your code goes here...
11
+ end
@@ -0,0 +1,7 @@
1
+ module AssetFinder
2
+ class Finder
3
+ def self.execute
4
+ Javascript::Finder.execute + Stylesheet::Finder.execute
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,20 @@
1
+ require 'find'
2
+
3
+ module AssetFinder
4
+ module Javascript
5
+ class Finder
6
+ def self.execute
7
+ [].tap do |paths|
8
+ root_dir = File.join(Rails.root, 'app/assets/javascripts/')
9
+ norimalizer = Normalizer.new(root_dir)
10
+
11
+ Find.find(root_dir).each do |path|
12
+ norimalized_path = norimalizer.norimalize(path)
13
+ next if norimalized_path.nil?
14
+ paths << path
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,23 @@
1
+ module AssetFinder
2
+ module Javascript
3
+ class Normalizer
4
+ def initialize(root_dir)
5
+ @root_dir = root_dir.to_s
6
+ end
7
+
8
+ def norimalize(path)
9
+ if path.match(/^(.*)\.js\.coffee$/)
10
+ return $1.sub(@root_dir, '') + '.js'
11
+ end
12
+
13
+ if path.match(/^(.*)\.coffee$/)
14
+ return $1.sub(@root_dir, '') + '.js'
15
+ end
16
+
17
+ if path.match(/^(.*)\.js$/)
18
+ return $1.sub(@root_dir, '') + '.js'
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,7 @@
1
+ module AssetFinder
2
+ class Railtie < ::Rails::Railtie
3
+ initializer 'Initialize asset_finder' do
4
+ Rails.application.config.assets.precompile += AssetFinder::Finder.execute
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,20 @@
1
+ require 'find'
2
+
3
+ module AssetFinder
4
+ module Stylesheet
5
+ class Finder
6
+ def self.execute
7
+ [].tap do |paths|
8
+ root_dir = File.join(Rails.root, 'app/assets/stylesheets/')
9
+ norimalizer = Normalizer.new(root_dir)
10
+
11
+ Find.find(root_dir).each do |path|
12
+ norimalized_path = norimalizer.norimalize(path)
13
+ next if norimalized_path.nil?
14
+ paths << path
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,23 @@
1
+ module AssetFinder
2
+ module Stylesheet
3
+ class Normalizer
4
+ def initialize(root_dir)
5
+ @root_dir = root_dir.to_s
6
+ end
7
+
8
+ def norimalize(path)
9
+ if path.match(/^(.*)\.css\.scss$/)
10
+ return $1.sub(@root_dir, '') + '.css'
11
+ end
12
+
13
+ if path.match(/^(.*)\.css$/)
14
+ return $1.sub(@root_dir, '') + '.css'
15
+ end
16
+
17
+ if path.match(/^(.*)\.scss$/)
18
+ return $1.sub(@root_dir, '') + '.css'
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,3 @@
1
+ module AssetFinder
2
+ VERSION = "1.0.0"
3
+ end
metadata ADDED
@@ -0,0 +1,122 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: asset_finder
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Takahiro Ooishi
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-06-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: railties
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '3.1'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '5.0'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: '3.1'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '5.0'
33
+ - !ruby/object:Gem::Dependency
34
+ name: bundler
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '1.9'
40
+ type: :development
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '1.9'
47
+ - !ruby/object:Gem::Dependency
48
+ name: rake
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '10.0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '10.0'
61
+ - !ruby/object:Gem::Dependency
62
+ name: rspec
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ description: Find javascripts and stylesheets. Configure precompile path.
76
+ email:
77
+ - taka0125@gmail.com
78
+ executables: []
79
+ extensions: []
80
+ extra_rdoc_files: []
81
+ files:
82
+ - ".gitignore"
83
+ - ".rspec"
84
+ - ".travis.yml"
85
+ - Gemfile
86
+ - README.md
87
+ - Rakefile
88
+ - asset_finder.gemspec
89
+ - bin/console
90
+ - bin/setup
91
+ - lib/asset_finder.rb
92
+ - lib/asset_finder/finder.rb
93
+ - lib/asset_finder/javascript/finder.rb
94
+ - lib/asset_finder/javascript/normalizer.rb
95
+ - lib/asset_finder/railtie.rb
96
+ - lib/asset_finder/stylesheet/finder.rb
97
+ - lib/asset_finder/stylesheet/normalizer.rb
98
+ - lib/asset_finder/version.rb
99
+ homepage: https://github.com/taka0125/asset_finder
100
+ licenses: []
101
+ metadata: {}
102
+ post_install_message:
103
+ rdoc_options: []
104
+ require_paths:
105
+ - lib
106
+ required_ruby_version: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ required_rubygems_version: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
116
+ requirements: []
117
+ rubyforge_project:
118
+ rubygems_version: 2.2.2
119
+ signing_key:
120
+ specification_version: 4
121
+ summary: Find javascripts and stylesheets for `rake asset:precompile`.
122
+ test_files: []