Module: RubyJS
- Defined in:
- lib/ruby_js.rb,
lib/ruby_js/helper.rb,
lib/ruby_js/version.rb,
lib/ruby_js/scaffold.rb,
lib/ruby_js/code_join.rb,
lib/ruby_js/constants.rb
Defined Under Namespace
Modules: Constants, Helper, Scaffold
Classes: CodeJoin, FileS
Constant Summary
collapse
- VERSION =
"1.1.3"
Class Method Summary
collapse
Class Method Details
.compile(path_f, options) ⇒ Object
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/ruby_js.rb', line 21
def self.compile path_f, options
path_o = Helper.absolute_path(path_f,
{ path_s: options[:path_s], path_o: options[:path_o] }, options[:type_o])
begin
content_rb = Helper.open(path_f)
content_js = Ruby2JS.convert(content_rb, eslevel: options[:eslevel]
) unless content_rb.empty?
path_write = Helper.write(path_o, content_js)
puts Helper.event_p("compiled", path_o)
rescue => exception
puts Helper.event_p("error", "#{path_o} #{exception}")
end
end
|
.free(path_f, options) ⇒ Object
.generate_cj(path_s, path_g) ⇒ Object
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
# File 'lib/ruby_js.rb', line 38
def self.generate_cj path_s, path_g
path_hfd = path_s
unless File.exist?(File.join(path_s, CodeJoin::FILE_HN))
path_hfd = Dir.pwd
end
code_join = CodeJoin.new path_hfd
get_files(path_s).each do |path_f|
unless path_f.index(/#{code_join.get_ignore_r}/)
code_join.add_file(path_f)
end
end
content_join = code_join.to_s
name_f = "#{code_join.json_cj.parse(:name).downcase.gsub(' ', '_')}_" +
"#{Time.now.strftime("%ya%m%d")}.#{Constants::FILE_TYPE}"
path_w = path_g.empty? ? path_s : path_g
path_f = File.join(path_w, name_f)
RubyJS::Helper.write(path_f, content_join)
puts Helper.event_p("generated", path_f)
return code_join
end
|
.get_files(path_s) ⇒ Object
70
71
72
73
|
# File 'lib/ruby_js.rb', line 70
def self.get_files(path_s)
path = "#{path_s}/**/*.#{Constants::FILE_TYPE}"
Dir.glob(path)
end
|
.watch(path, ignore = "") ⇒ Object
13
14
15
16
17
18
19
|
# File 'lib/ruby_js.rb', line 13
def self.watch path, ignore = ""
listener = Listen.to(path, only: /\.#{Constants::FILE_TYPE}$/, ignore: /#{ignore}/) do |modified, added, removed|
yield modified, added, removed
end
listener.start
sleep
end
|