rrjj 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.
- checksums.yaml +7 -0
- data/README.md +84 -0
- data/Rakefile +14 -0
- data/config/rrjj.rb +35 -0
- data/lib/guard_helpers/file_helper.rb +35 -0
- data/lib/guard_helpers/opal_helper.rb +27 -0
- data/lib/guard_helpers/rails_helper.rb +33 -0
- data/lib/guard_helpers/rrjj_helper.rb +45 -0
- data/lib/guard_helpers/srt_helper.rb +96 -0
- data/lib/rails_handlers/ctrl_handler.rb +7 -0
- data/lib/ro_commands/check.rb +16 -0
- data/lib/ro_commands/model.rb +24 -0
- data/lib/ro_commands/post_handler.rb +85 -0
- data/lib/ro_commands/rails_base.rb +27 -0
- data/lib/ro_commands/rails_shortcuts.rb +18 -0
- data/lib/ro_commands/ro_proc.rb +8 -0
- data/lib/ro_core_ext/object.rb +11 -0
- data/lib/ro_html_handler.rb +8 -0
- data/lib/rrjj.rb +18 -0
- data/lib/rrjj/cmd.rb +7 -0
- data/lib/rrjj/cmds.rb +42 -0
- data/lib/rrjj/railtie.rb +13 -0
- data/lib/rrjj/ro_faker.rb +10 -0
- data/lib/rrjj/version.rb +3 -0
- data/lib/rrjj_ro_commands_bin.rb +4 -0
- data/lib/rubymine_heaven.rb +2 -0
- data/lib/rubymine_heaven/linkable_errors.rb +56 -0
- data/lib/rubymine_heaven/linkable_errors_handler.rb +31 -0
- data/lib/rubymine_heaven/linkable_errors_railtie.rb +21 -0
- data/lib/subtitle.rb +149 -0
- data/lib/subtitles/ex.srt +5 -0
- data/lib/templates/alias.erb +3 -0
- data/lib/templates/srt.erb +4 -0
- data/spec/controllers/app_controller_spec.rb +12 -0
- data/spec/decorators/app_decorator_spec.rb +4 -0
- data/spec/decorators/post_decorator_spec.rb +38 -0
- data/spec/features/posts/index_spec.rb +9 -0
- data/spec/features/posts/search_spec.rb +10 -0
- data/spec/fixtures/handler/error_page.html +1 -0
- data/spec/fixtures/handler/result.html +1 -0
- data/spec/fixtures/post_handler/posts/error/test.md +1 -0
- data/spec/fixtures/post_handler/posts/rails/test.html +0 -0
- data/spec/fixtures/post_handler/tmp/rspec_guard_result +1 -0
- data/spec/fixtures/rails_navigate/app/controllers/app_controller.rb +0 -0
- data/spec/fixtures/rails_navigate/app/controllers/one_controller.rb +0 -0
- data/spec/fixtures/rails_navigate/app/controllers/two_controller.rb +0 -0
- data/spec/fixtures/rails_navigate/app/decorators/two_decorator.rb +0 -0
- data/spec/fixtures/rails_navigate/app/models/two_model.rb +0 -0
- data/spec/fixtures/rails_navigate/opal_lib/path/to/file.rb +0 -0
- data/spec/fixtures/rails_navigate/opal_lib/path/to/file2.rb +0 -0
- data/spec/fixtures/try/origin/ex.erb.ogv +0 -0
- data/spec/helpers/app_helper_spec.rb +15 -0
- data/spec/helpers/posts_helper_spec.rb +15 -0
- data/spec/lib/guard_helpers/rails_helper_spec.rb +1 -0
- data/spec/lib/guard_helpers/ro_helper_spec.rb +23 -0
- data/spec/lib/guard_helpers/srt_helper_spec.rb +18 -0
- data/spec/lib/ro_cells/opal_spec.rb +40 -0
- data/spec/lib/ro_commands/check_spec.rb +21 -0
- data/spec/lib/ro_commands/post_handler_spec.rb +0 -0
- data/spec/lib/ro_commands/rails_navigate_spec.rb +47 -0
- data/spec/lib/rubymine_heaven/linkable_errors_railtie_spec.rb +2 -0
- data/spec/lib/srt_helper_spec.rb +5 -0
- data/spec/lib/subtitle_spec.rb +46 -0
- data/spec/lib/templates/srt_spec.rb +2 -0
- data/spec/lib/video_spec.rb +34 -0
- data/spec/models/ln_spec.rb +5 -0
- data/spec/models/post_spec.rb +8 -0
- data/spec/models/sub_spec.rb +5 -0
- data/spec/models/tag_spec.rb +5 -0
- data/spec/models/try_spec.rb +5 -0
- data/spec/requests/posts_spec.rb +11 -0
- data/spec/routing/posts_routing_spec.rb +35 -0
- data/spec/spec_helper.rb +79 -0
- data/spec/views/app/search.html.erb_spec.rb +5 -0
- metadata +227 -0
@@ -0,0 +1,27 @@
|
|
1
|
+
root_path = if defined? ::Rails
|
2
|
+
::Rails.root
|
3
|
+
else
|
4
|
+
Dir.pwd
|
5
|
+
end
|
6
|
+
|
7
|
+
env_path = File.join(root_path, "config/environment")
|
8
|
+
|
9
|
+
if File.exist?(env_path)
|
10
|
+
require env_path
|
11
|
+
end
|
12
|
+
require File.expand_path('../../../config/rrjj', __FILE__)
|
13
|
+
|
14
|
+
require 'celluloid'
|
15
|
+
|
16
|
+
module RoCommands
|
17
|
+
class RailsBase < Base
|
18
|
+
protected
|
19
|
+
|
20
|
+
def template(from, to)
|
21
|
+
template_path = File.join(::Rrjj.lib, 'templates')
|
22
|
+
ctn = ::RoFile.read(File.join(template_path, "#{from}.erb"))
|
23
|
+
result = ERB.new(ctn).result(binding)
|
24
|
+
::RoFile.write(to, result)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require_relative 'rails_base'
|
2
|
+
module RoCommands
|
3
|
+
class RailsShortcuts < Shortcuts
|
4
|
+
desc usage('open_file'), ''
|
5
|
+
|
6
|
+
def open_file(file)
|
7
|
+
bash "#{Rrjj.default_editor} #{file}"
|
8
|
+
end
|
9
|
+
|
10
|
+
desc usage("work"), ""
|
11
|
+
def work(*args)
|
12
|
+
bx "zeus start"
|
13
|
+
bx 'rails s'
|
14
|
+
bx "guard -P livereload"
|
15
|
+
bx "guard -P rspec"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/rrjj.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require File.expand_path('../../config/rrjj', __FILE__)
|
2
|
+
|
3
|
+
module Rrjj
|
4
|
+
|
5
|
+
end
|
6
|
+
|
7
|
+
module RoCells
|
8
|
+
|
9
|
+
end
|
10
|
+
|
11
|
+
module GuardHelpers
|
12
|
+
|
13
|
+
end
|
14
|
+
|
15
|
+
::Rrjj.autoload_all('rrjj')
|
16
|
+
::Rrjj.autoload_all("ro_cells")
|
17
|
+
::Rrjj.autoload_all("ro_commands")
|
18
|
+
::Rrjj.autoload_all("guard_helpers")
|
data/lib/rrjj/cmd.rb
ADDED
data/lib/rrjj/cmds.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
require_relative 'cmd'
|
2
|
+
module ::Rrjj
|
3
|
+
class Cmds
|
4
|
+
class << self
|
5
|
+
def all
|
6
|
+
zeus('zro', 'ro')
|
7
|
+
zeus('a', 'rails_navigate access')
|
8
|
+
zeus('la', 'rails get_assets')
|
9
|
+
zeus('lc', 'rails get_controllers')
|
10
|
+
zeus('lmo', 'rails get_models')
|
11
|
+
zeus('lm', 'rails get_migrations')
|
12
|
+
zeus('lsc', 'rails get_scaffolds')
|
13
|
+
|
14
|
+
zro('schema', 'check schema')
|
15
|
+
zro('table', 'check table')
|
16
|
+
|
17
|
+
zrk('routes', 'routes')
|
18
|
+
all_shortcuts
|
19
|
+
end
|
20
|
+
|
21
|
+
def zeus(shortcut_name, bash)
|
22
|
+
all_shortcuts << Cmd.new(shortcut_name, "zeus #{bash}")
|
23
|
+
end
|
24
|
+
|
25
|
+
def zro(shortcut_name, bash)
|
26
|
+
all_shortcuts << Cmd.new(shortcut_name, "zeus ro #{bash}")
|
27
|
+
end
|
28
|
+
|
29
|
+
def zrk(shortcut_name, bash)
|
30
|
+
all_shortcuts << Cmd.new(shortcut_name, "zeus rake #{bash}")
|
31
|
+
end
|
32
|
+
|
33
|
+
attr_accessor :all_shortcuts
|
34
|
+
|
35
|
+
def all_shortcuts
|
36
|
+
@all_shortcuts.flatten! if defined?(@all_shortcuts) and @all_shortcuts.respond_to?(:flatten!)
|
37
|
+
@all_shortcuts.uniq! if defined?(@all_shortcuts) and @all_shortcuts.respond_to?(:uniq!)
|
38
|
+
@all_shortcuts ||= []
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
data/lib/rrjj/railtie.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
module Rrjj
|
2
|
+
class Railtie < Rails::Railtie
|
3
|
+
initializer "rorojiang runtime config" do |app|
|
4
|
+
require 'rrjj'
|
5
|
+
require_relative 'cmd'
|
6
|
+
require_relative 'cmds'
|
7
|
+
|
8
|
+
::Rrjj.require_all("guard_helpers")
|
9
|
+
::Rrjj.require_all("ro_commands")
|
10
|
+
require 'ro_html_handler'
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/lib/rrjj/version.rb
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'ro_rails_helpers'
|
2
|
+
|
3
|
+
module RubymineHeaven
|
4
|
+
module LinkableErrors
|
5
|
+
|
6
|
+
def self.included(base)
|
7
|
+
base.class_eval do
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def link_to_code(text)
|
12
|
+
::RoRailsHelpers::Handler.link_to_code(text)
|
13
|
+
# we must create new String, because SafeBuffer#gsub don't set $1, $2, ... variables !!
|
14
|
+
#String.new(text).gsub(/(\/?[\w\/\.@-]+)\:(\d+)/) do |match|
|
15
|
+
# file = $1 || "file??"
|
16
|
+
# line = $2 || "line-no??"
|
17
|
+
# file = Rails.root + file if file =~ Rails::BacktraceCleaner::APP_DIRS_PATTERN
|
18
|
+
# "<a href='x-mine://open?file=#{file}&line=#{line}'>#{match}</a>"
|
19
|
+
#end
|
20
|
+
end
|
21
|
+
|
22
|
+
def render_exception(env, exception)
|
23
|
+
|
24
|
+
begin
|
25
|
+
wrapper = ActionDispatch::ExceptionWrapper.new(env, exception)
|
26
|
+
log_error(env, wrapper)
|
27
|
+
|
28
|
+
if env['action_dispatch.show_detailed_exceptions']
|
29
|
+
template = ActionView::Base.new(\
|
30
|
+
[::ActionDispatch::DebugExceptions::RESCUES_TEMPLATE_PATH],
|
31
|
+
:request => ActionDispatch::Request.new(env),
|
32
|
+
:exception => wrapper.exception,
|
33
|
+
:application_trace => wrapper.application_trace,
|
34
|
+
:framework_trace => wrapper.framework_trace,
|
35
|
+
:full_trace => wrapper.full_trace
|
36
|
+
)
|
37
|
+
|
38
|
+
file = "rescues/#{wrapper.rescue_template}"
|
39
|
+
body = template.render(:template => file, :layout => 'rescues/layout')
|
40
|
+
body = link_to_code(body)
|
41
|
+
|
42
|
+
render(wrapper.status_code, body)
|
43
|
+
else
|
44
|
+
raise exception
|
45
|
+
end
|
46
|
+
rescue => e
|
47
|
+
::Rails.logger.error e
|
48
|
+
e.backtrace.each do |b|
|
49
|
+
::Rails.logger.error b
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'ro_helpers'
|
2
|
+
Out.say_status("set", " $root and $lib #{::File.basename __FILE__}, #{__LINE__}")
|
3
|
+
|
4
|
+
require 'active_support/core_ext'
|
5
|
+
|
6
|
+
module LinkableErrorsHandler
|
7
|
+
class << self
|
8
|
+
def link_to_code(text)
|
9
|
+
text.scan(regexp).each do |part|
|
10
|
+
path = part[0]
|
11
|
+
line = part[1]
|
12
|
+
text.gsub! "#{path}:#{line}", handle_part(path, line)
|
13
|
+
end
|
14
|
+
text
|
15
|
+
end
|
16
|
+
|
17
|
+
def regexp
|
18
|
+
@regexp ||= %r{((?<path>/.*?\.rb)\:(?<line>\d+)\:in)}
|
19
|
+
end
|
20
|
+
|
21
|
+
def handle_part(path, line)
|
22
|
+
href = File.join("/rodebug/start", path, line)
|
23
|
+
anchor_text = "#{path}:#{line}"
|
24
|
+
result = "<a href='http://localhost:3000#{href}'>#{anchor_text}</a>"
|
25
|
+
end
|
26
|
+
|
27
|
+
def handle_path(path)
|
28
|
+
path.gsub(%r{/}, "$").gsub(%r{^$}, "")
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module RubymineHeaven
|
2
|
+
class LinkableErrorsRailtie < ::Rails::Railtie
|
3
|
+
initializer "linkable_errors_railtie.boot" do
|
4
|
+
if Rails.env.development?
|
5
|
+
Rails.backtrace_cleaner.remove_filters!
|
6
|
+
Rails.backtrace_cleaner.add_filter { |line| line.sub("#{Rails.root}/", '') }
|
7
|
+
# point links on rails error pages to rubymine
|
8
|
+
ActionDispatch::DebugExceptions.send(:include, LinkableErrors)
|
9
|
+
|
10
|
+
# point footnotes links to rubymine
|
11
|
+
if defined?(Footnotes)
|
12
|
+
Footnotes::Filter.prefix = 'x-mine://open?url=%s&line=%d'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
generator "rails_debug_navigator" do
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/subtitle.rb
ADDED
@@ -0,0 +1,149 @@
|
|
1
|
+
class Subtitle
|
2
|
+
class << self
|
3
|
+
def handle_time(time)
|
4
|
+
reset
|
5
|
+
time = time.to_s
|
6
|
+
@hour = time[-6..-5] if time.length >= 6
|
7
|
+
@min = time[-4..-3] if time.length >= 4
|
8
|
+
@sec = time[-2..-1] if time.length >= 2
|
9
|
+
start_time = "#{hour}:#{min}:#{sec}"
|
10
|
+
end_time = "#{hour}:#{min}:#{sec.to_i+10}"
|
11
|
+
return start_time, end_time
|
12
|
+
end
|
13
|
+
|
14
|
+
def handle_content(ctn)
|
15
|
+
ctn.gsub(%r{(^\s+)|(\s+$)}, "")
|
16
|
+
end
|
17
|
+
|
18
|
+
def hex2rgb(hexadecimal)
|
19
|
+
deleted_signs = %r{#|0x}
|
20
|
+
|
21
|
+
hex = hex2s(hexadecimal)
|
22
|
+
|
23
|
+
if hex.match(deleted_signs)
|
24
|
+
hex.gsub!(deleted_signs, "")
|
25
|
+
end
|
26
|
+
|
27
|
+
hex_arr = hex.split("")
|
28
|
+
rgb = []
|
29
|
+
r = hex2decimal hex_arr[0..1].join
|
30
|
+
g = hex2decimal hex_arr[2..3].join
|
31
|
+
b = hex2decimal hex_arr[4..5].join
|
32
|
+
|
33
|
+
[r, g, b].map(&:to_i)
|
34
|
+
#if hex.match(%r{#})
|
35
|
+
# hex.gsub(%r{#}, "")
|
36
|
+
#end
|
37
|
+
#
|
38
|
+
#rgb = {}
|
39
|
+
#%w(r g b).inject(hex) do |rest, i|
|
40
|
+
# rest, rgb[i] = rest.divmod 256
|
41
|
+
# rest
|
42
|
+
#end
|
43
|
+
end
|
44
|
+
|
45
|
+
def rgb2hex(r, g, b)
|
46
|
+
hex = [r, g, b].map do |e|
|
47
|
+
format_value(decimal2hex(e))
|
48
|
+
end
|
49
|
+
"#" + hex.join
|
50
|
+
end
|
51
|
+
|
52
|
+
private
|
53
|
+
|
54
|
+
def format_value(value)
|
55
|
+
if value.length == 1
|
56
|
+
"0#{value}"
|
57
|
+
else
|
58
|
+
value
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def decimal2hex(decimal)
|
63
|
+
hex = []
|
64
|
+
rest = decimal
|
65
|
+
begin
|
66
|
+
rest, remainder= rest.divmod 16
|
67
|
+
hex << translate(remainder)
|
68
|
+
end until rest == 0
|
69
|
+
hex.join
|
70
|
+
end
|
71
|
+
|
72
|
+
def hex2s(hex)
|
73
|
+
if hex.is_a? Fixnum
|
74
|
+
hex.to_s
|
75
|
+
else
|
76
|
+
hex
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def hex2decimal(hexadecimal)
|
81
|
+
hex = hex2s(hexadecimal)
|
82
|
+
if hex.is_a? Fixnum
|
83
|
+
hex = hex.to_s
|
84
|
+
end
|
85
|
+
|
86
|
+
if hex.match(%r{#})
|
87
|
+
hex.gsub(%r{#}, "")
|
88
|
+
end
|
89
|
+
|
90
|
+
translate = {}
|
91
|
+
hex_arr = hex.to_s.split("")
|
92
|
+
len = hex_arr.length
|
93
|
+
|
94
|
+
hex_arr.each_with_index do |e, index|
|
95
|
+
place = len.to_i - index - 1
|
96
|
+
translate[place] = translate(e)
|
97
|
+
end
|
98
|
+
|
99
|
+
decimal = 0
|
100
|
+
translate.each do |place, e|
|
101
|
+
decimal += e.to_i*16**place
|
102
|
+
end
|
103
|
+
decimal
|
104
|
+
end
|
105
|
+
|
106
|
+
def power(base_num, index_num)
|
107
|
+
eval [base_num]*index_num.join("*")
|
108
|
+
end
|
109
|
+
|
110
|
+
def translate(value)
|
111
|
+
result = value
|
112
|
+
dict.each do |hex, decimal|
|
113
|
+
if decimal == value
|
114
|
+
result = hex.to_s
|
115
|
+
break
|
116
|
+
end
|
117
|
+
|
118
|
+
if hex.to_s == value
|
119
|
+
result = decimal
|
120
|
+
break
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
result
|
125
|
+
end
|
126
|
+
|
127
|
+
def dict
|
128
|
+
{a: 10, b: 11, c: 12, d: 13, e: 14, f: 15}
|
129
|
+
end
|
130
|
+
|
131
|
+
def reset
|
132
|
+
instance_variables.each do |iv|
|
133
|
+
instance_variable_set iv, nil
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
def hour
|
138
|
+
@hour ||= "00"
|
139
|
+
end
|
140
|
+
|
141
|
+
def min
|
142
|
+
@min ||= "00"
|
143
|
+
end
|
144
|
+
|
145
|
+
def sec
|
146
|
+
@sec ||= "00"
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|