cyborg 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cyborg.rb +7 -14
- data/lib/cyborg/helpers/asset_helpers.rb +25 -11
- data/lib/cyborg/plugin.rb +2 -1
- data/lib/cyborg/plugin/assets/asset.rb +26 -5
- data/lib/cyborg/plugin/assets/javascripts.rb +4 -0
- data/lib/cyborg/plugin/assets/stylesheets.rb +4 -0
- data/lib/cyborg/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a7ea5f2b2cb3f2391a7da731bcf7d97c0f93c540
|
4
|
+
data.tar.gz: 638b2e89fc41f7e18dc62fe4570c27ccc97edfee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef66830311d58f2a3c5890d1e7d2796f85c404b6b1a1071630efe7a1ba2b1d877dc6d3c64966c81269891266b840d225c654bf437f3939e2ca8f788d314f76ba
|
7
|
+
data.tar.gz: c3c43450e044f052b072ef7fad2f1d9b262fabaa6b746d8a18936b1165350fe669de99672cc5539da9b0d04aa43314128aeb7c819b5a0cd1411c491c07ea9dc3
|
data/lib/cyborg.rb
CHANGED
@@ -9,18 +9,19 @@ require "cyborg/assets"
|
|
9
9
|
|
10
10
|
module Cyborg
|
11
11
|
extend self
|
12
|
+
attr_accessor :plugin
|
12
13
|
autoload :Application, "cyborg/middleware"
|
13
14
|
|
14
15
|
def production?
|
15
16
|
ENV['CI'] || ENV['RAILS_ENV'] == 'production'
|
16
17
|
end
|
17
18
|
|
18
|
-
def
|
19
|
-
@
|
19
|
+
def plugin
|
20
|
+
@plugin
|
20
21
|
end
|
21
22
|
|
22
23
|
def register(plugin_module, options={})
|
23
|
-
|
24
|
+
@plugin = plugin_module.new(options)
|
24
25
|
patch_rails
|
25
26
|
end
|
26
27
|
|
@@ -37,10 +38,7 @@ module Cyborg
|
|
37
38
|
|
38
39
|
def build
|
39
40
|
puts 'Building…'
|
40
|
-
|
41
|
-
Cyborg.plugins.each do |plugin|
|
42
|
-
@threads.concat plugin.build
|
43
|
-
end
|
41
|
+
@threads.concat plugin.build
|
44
42
|
end
|
45
43
|
|
46
44
|
def watch
|
@@ -52,9 +50,7 @@ module Cyborg
|
|
52
50
|
exit!
|
53
51
|
}
|
54
52
|
|
55
|
-
|
56
|
-
@threads.concat plugin.watch
|
57
|
-
end
|
53
|
+
@threads.concat plugin.watch
|
58
54
|
end
|
59
55
|
|
60
56
|
def server
|
@@ -63,8 +59,7 @@ module Cyborg
|
|
63
59
|
end
|
64
60
|
|
65
61
|
def load_rake_tasks
|
66
|
-
|
67
|
-
plugins.first.engine.rake_tasks do
|
62
|
+
plugin.engine.rake_tasks do
|
68
63
|
namespace :cyborg do
|
69
64
|
desc "Cyborg build task"
|
70
65
|
task :build do
|
@@ -82,8 +77,6 @@ module Cyborg
|
|
82
77
|
end
|
83
78
|
end
|
84
79
|
end
|
85
|
-
|
86
|
-
@tasks_loaded = true
|
87
80
|
end
|
88
81
|
|
89
82
|
def load_helpers
|
@@ -2,27 +2,41 @@ module Cyborg
|
|
2
2
|
module Helpers
|
3
3
|
module AssetsHelper
|
4
4
|
|
5
|
-
def
|
6
|
-
|
5
|
+
def stylesheet_tag(*args)
|
6
|
+
options = args.last.is_a?(Hash) ? args.pop : {}
|
7
|
+
tags = ''
|
8
|
+
|
9
|
+
stylesheet_url(args).each do |url|
|
10
|
+
tags += stylesheet_link_tag(url, options)
|
11
|
+
end
|
7
12
|
|
8
|
-
|
13
|
+
tags.html_safe
|
9
14
|
end
|
10
15
|
|
11
|
-
def
|
16
|
+
def javascript_tag(*args)
|
17
|
+
options = args.last.is_a?(Hash) ? args.pop : {}
|
12
18
|
tags = ''
|
13
19
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
end
|
18
|
-
plugin.stylesheets.urls.each do |url|
|
19
|
-
tags += stylesheet_link_tag(url)
|
20
|
-
end
|
20
|
+
puts "searching for: #{javascript_url(args)}"
|
21
|
+
javascript_url(args).each do |url|
|
22
|
+
tags += javascript_include_tag(url, options)
|
21
23
|
end
|
22
24
|
|
23
25
|
tags.html_safe
|
24
26
|
end
|
25
27
|
|
28
|
+
def stylesheet_url(*args)
|
29
|
+
Cyborg.plugin.stylesheets.urls(args)
|
30
|
+
end
|
31
|
+
|
32
|
+
def javascript_url(*args)
|
33
|
+
Cyborg.plugin.javascripts.urls(args)
|
34
|
+
end
|
35
|
+
|
36
|
+
def asset_tags
|
37
|
+
stylesheet_tag + javascript_tag
|
38
|
+
end
|
39
|
+
|
26
40
|
def pin_tab_icon(path)
|
27
41
|
%Q{<link rel="mask-icon" mask href="#{path}" color="black">}.html_safe
|
28
42
|
end
|
data/lib/cyborg/plugin.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module Cyborg
|
2
2
|
class Plugin
|
3
|
-
attr_reader :module_name, :gem, :engine,
|
3
|
+
attr_reader :module_name, :gem, :engine, :name,
|
4
4
|
:stylesheets, :javascripts, :svgs, :destination
|
5
5
|
|
6
6
|
def initialize(options)
|
@@ -20,6 +20,7 @@ module Cyborg
|
|
20
20
|
def create_engine
|
21
21
|
# Create a new Rails::Engine
|
22
22
|
return parent_module.const_set('Engine', Class.new(Rails::Engine) do
|
23
|
+
|
23
24
|
def get_plugin_path
|
24
25
|
parent = Object.const_get(self.class.to_s.split('::').first)
|
25
26
|
path = parent.instance_variable_get("@gem_path")
|
@@ -9,10 +9,31 @@ module Cyborg
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def find_files
|
12
|
-
files
|
12
|
+
if @files
|
13
|
+
@files
|
14
|
+
else
|
15
|
+
files = Dir[File.join(base, "*.#{ext}")].reject do |f|
|
16
|
+
# Filter out partials
|
17
|
+
File.basename(f).start_with?('_')
|
18
|
+
end
|
19
|
+
|
20
|
+
@files = files if Cyborg.production?
|
21
|
+
files
|
22
|
+
end
|
23
|
+
end
|
13
24
|
|
14
|
-
|
15
|
-
|
25
|
+
def filter_files(names=nil)
|
26
|
+
names = [names].flatten.compact.map do |n|
|
27
|
+
File.basename(n).sub(/(\..+)$/,'')
|
28
|
+
end
|
29
|
+
|
30
|
+
if !names.empty?
|
31
|
+
find_files.select do |f|
|
32
|
+
names.include? File.basename(f).sub(/(\..+)$/,'')
|
33
|
+
end
|
34
|
+
else
|
35
|
+
find_files
|
36
|
+
end
|
16
37
|
end
|
17
38
|
|
18
39
|
def versioned(path)
|
@@ -56,8 +77,8 @@ module Cyborg
|
|
56
77
|
File.join(plugin.asset_root, versioned(path))
|
57
78
|
end
|
58
79
|
|
59
|
-
def urls
|
60
|
-
|
80
|
+
def urls(names=nil)
|
81
|
+
filter_files(names).map{ |file| url(file) }
|
61
82
|
end
|
62
83
|
|
63
84
|
def watch
|
data/lib/cyborg/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cyborg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brandon Mathis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-07-
|
11
|
+
date: 2016-07-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sass
|