ro_commands 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.
Files changed (102) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.rdoc +3 -0
  4. data/Rakefile +54 -0
  5. data/bin/ro +32 -0
  6. data/bin/ro_client +6 -0
  7. data/bin/ro_server +8 -0
  8. data/config/rorc.rb +2 -0
  9. data/lib/bash_builder.rb +92 -0
  10. data/lib/bash_builder_helper.rb +34 -0
  11. data/lib/bash_debug.rb +55 -0
  12. data/lib/bash_templates/git.sh +10 -0
  13. data/lib/bash_templates/gitflow.sh +0 -0
  14. data/lib/bash_templates/misc.sh +66 -0
  15. data/lib/bash_templates/rails.sh +0 -0
  16. data/lib/bash_templates/rubymine_idea.sh +5 -0
  17. data/lib/bash_templates/shortcuts.sh +1 -0
  18. data/lib/builder_templates/completions.erb +18 -0
  19. data/lib/builder_templates/git_flow.erb +3 -0
  20. data/lib/builder_templates/rails.erb +3 -0
  21. data/lib/builder_templates/set_envs.erb +9 -0
  22. data/lib/drb/client.rb +22 -0
  23. data/lib/drb/server.rb +33 -0
  24. data/lib/git_flow_builder_helper.rb +34 -0
  25. data/lib/methods.rb +19 -0
  26. data/lib/rails_builder_helper.rb +41 -0
  27. data/lib/ro_commands.rb +34 -0
  28. data/lib/ro_commands/base.rb +95 -0
  29. data/lib/ro_commands/core_ext/hash.rb +5 -0
  30. data/lib/ro_commands/core_ext/string.rb +14 -0
  31. data/lib/ro_commands/core_ext/symbol.rb +0 -0
  32. data/lib/ro_commands/core_ext/thor.rb +71 -0
  33. data/lib/ro_commands/dsl/file.rb +25 -0
  34. data/lib/ro_commands/file_actions.rb +128 -0
  35. data/lib/ro_commands/generate.rb +32 -0
  36. data/lib/ro_commands/generators/base_generator.rb +68 -0
  37. data/lib/ro_commands/generators/ex.rb +56 -0
  38. data/lib/ro_commands/generators/lib.rb +25 -0
  39. data/lib/ro_commands/generators/spec_file.rb +74 -0
  40. data/lib/ro_commands/generators/templates/ex.erb +30 -0
  41. data/lib/ro_commands/generators/templates/spec.erb +2 -0
  42. data/lib/ro_commands/git.rb +89 -0
  43. data/lib/ro_commands/git_flow.rb +111 -0
  44. data/lib/ro_commands/helpers/all.rb +8 -0
  45. data/lib/ro_commands/helpers/all_files.rb +21 -0
  46. data/lib/ro_commands/helpers/bash.rb +33 -0
  47. data/lib/ro_commands/helpers/out.rb +29 -0
  48. data/lib/ro_commands/hook.rb +102 -0
  49. data/lib/ro_commands/info.rb +55 -0
  50. data/lib/ro_commands/misc.rb +77 -0
  51. data/lib/ro_commands/navigate.rb +56 -0
  52. data/lib/ro_commands/processes.rb +12 -0
  53. data/lib/ro_commands/rails.rb +210 -0
  54. data/lib/ro_commands/refactor.rb +78 -0
  55. data/lib/ro_commands/ro_helper.rb +76 -0
  56. data/lib/ro_commands/ro_procs.rb +106 -0
  57. data/lib/ro_commands/rubymine.rb +17 -0
  58. data/lib/ro_commands/shortcuts.rb +67 -0
  59. data/lib/ro_commands/try.rb +11 -0
  60. data/lib/ro_commands/version.rb +3 -0
  61. data/lib/ro_commands/zeus.rb +18 -0
  62. data/lib/ro_commands/zeus_templates/custom_plan.rb +18 -0
  63. data/lib/ro_commands/zeus_templates/zeus.json +24 -0
  64. data/lib/ro_helper.rb +25 -0
  65. data/lib/shortcuts.rb +43 -0
  66. data/lib/spec_element.rb +24 -0
  67. data/lib/spec_element/describe.rb.erb +9 -0
  68. data/lib/tasks/roro_commands_tasks.rake +4 -0
  69. data/test/dummy/README.rdoc +28 -0
  70. data/test/dummy/Rakefile +6 -0
  71. data/test/dummy/app/assets/javascripts/application.js +13 -0
  72. data/test/dummy/app/assets/stylesheets/application.css +13 -0
  73. data/test/dummy/app/controllers/application_controller.rb +5 -0
  74. data/test/dummy/app/helpers/application_helper.rb +2 -0
  75. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  76. data/test/dummy/bin/bundle +3 -0
  77. data/test/dummy/bin/rails +4 -0
  78. data/test/dummy/bin/rake +4 -0
  79. data/test/dummy/config.ru +4 -0
  80. data/test/dummy/config/application.rb +23 -0
  81. data/test/dummy/config/boot.rb +5 -0
  82. data/test/dummy/config/database.yml +25 -0
  83. data/test/dummy/config/environment.rb +5 -0
  84. data/test/dummy/config/environments/development.rb +29 -0
  85. data/test/dummy/config/environments/production.rb +80 -0
  86. data/test/dummy/config/environments/test.rb +36 -0
  87. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  88. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  89. data/test/dummy/config/initializers/inflections.rb +16 -0
  90. data/test/dummy/config/initializers/mime_types.rb +5 -0
  91. data/test/dummy/config/initializers/secret_token.rb +12 -0
  92. data/test/dummy/config/initializers/session_store.rb +3 -0
  93. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  94. data/test/dummy/config/locales/en.yml +23 -0
  95. data/test/dummy/config/routes.rb +56 -0
  96. data/test/dummy/public/404.html +58 -0
  97. data/test/dummy/public/422.html +58 -0
  98. data/test/dummy/public/500.html +57 -0
  99. data/test/dummy/public/favicon.ico +0 -0
  100. data/test/roro_commands_test.rb +7 -0
  101. data/test/test_helper.rb +15 -0
  102. metadata +235 -0
@@ -0,0 +1,32 @@
1
+ #module RoCommands
2
+ # module Generator
3
+ # class BaseGenerator < Thor::Group
4
+ # include Thor::Actions
5
+ # end
6
+ # end
7
+ #end
8
+ #
9
+ Dir[File.expand_path("../generators/**", __FILE__)].each do |file|
10
+ if test(?f, file)
11
+ require file
12
+ end
13
+ end
14
+
15
+
16
+ module RoCommands
17
+ class Generate < Base
18
+ include Generators
19
+
20
+ desc usage('ex'), ''
21
+ def ex
22
+ Ex.create
23
+ Ex.open
24
+ end
25
+
26
+ desc usage("spec_file"), ""
27
+ def spec_file(name)
28
+ SpecFile.create(name)
29
+ SpecFile.open
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,68 @@
1
+ require "fileutils"
2
+
3
+ module RoCommands
4
+ module Generators
5
+ module BaseGenerator
6
+
7
+ class << self
8
+ def included(base)
9
+ base.extend(ClsMeths)
10
+ end
11
+ end
12
+
13
+ module ClsMeths
14
+ def bash(*cmds)
15
+ Kernel.system(cmds.flatten.join(" && "))
16
+ end
17
+
18
+ def file_write(path)
19
+ dir = File.dirname(path)
20
+ FileUtils.mkpath dir
21
+ puts "writing #{path}"
22
+ File.write(path, ctn)
23
+ end
24
+
25
+ def lib_path
26
+ name.split("::").map do |i|
27
+ i.downcase
28
+ end.join("/")
29
+ end
30
+
31
+ def lastest_file
32
+ Find.find(Dir.pwd, dir).select do |f|
33
+ test(?f, f)
34
+ end.sort_by do |f|
35
+ Time.at(File.ctime(f).to_f)
36
+ end.last
37
+ end
38
+
39
+ def open
40
+ bash "rubymine #{created_file}"
41
+ end
42
+
43
+ def created_file
44
+ @created_file ||= lastest_file
45
+ end
46
+
47
+ def ctn
48
+ @ctn ||= ""
49
+ end
50
+
51
+ def path
52
+ File.join(dir, file)
53
+ end
54
+
55
+ def to
56
+ puts "writing to #{path}"
57
+ end
58
+
59
+ def tt(name)
60
+ puts "creating #{path}"
61
+ ctn = File.read File.expand_path("../templates/#{dir}.erb", __FILE__)
62
+ @ctn = ERB.new(ctn).result(binding)
63
+ to
64
+ end
65
+ end
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,56 @@
1
+ require 'fileutils'
2
+ require_relative "base_generator"
3
+ require "erb"
4
+ require "find"
5
+ module RoCommands
6
+ module Generators
7
+ class Ex
8
+ include BaseGenerator
9
+ class << self
10
+ def create
11
+ FileUtils.mkpath dir
12
+ tt dir
13
+ end
14
+
15
+ private
16
+
17
+ def dir
18
+ @dir ||= 'ex'
19
+ end
20
+
21
+ def list
22
+ Dir[File.join(dir, '**')]
23
+ end
24
+
25
+ def oldest_file
26
+ Dir['ex/**'].sort_by do |f|
27
+ Time.at(File.atime f).to_f
28
+ end.map do |f|
29
+ File.basename f
30
+ end.first
31
+ end
32
+
33
+ def file
34
+ len = list.length
35
+ if len > 0 and len < 10
36
+ num = list.map do |file|
37
+ result = File.basename(file).match(%r{ex(\d+).*})
38
+ result ? result[1].to_i : 0
39
+ end.max
40
+ num += 1 unless num.nil?
41
+ filename = "ex#{num}.rb"
42
+ elsif len == 0
43
+ 'ex.rb'
44
+ else
45
+ File.basename oldest_file
46
+ end
47
+ end
48
+
49
+ def to
50
+ super
51
+ File.write(path, ctn)
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,25 @@
1
+ #require 'fileutils'
2
+ #module RoCommands
3
+ # module Generator
4
+ # class Lib < BaseGenerator
5
+ #
6
+ # argument :name
7
+ #
8
+ # def create
9
+ # FileUtils.mkdir_p "lib/#{name}"
10
+ # template 'lib.erb', "lib/#{name}.rb"
11
+ # end
12
+ #
13
+ # private
14
+ # def template(src, target)
15
+ # if test(?e, File.join(Dir.pwd, 'config'))
16
+ # puts "generating #{target}"
17
+ # ctn = File.read File.expand_path("../templates/#{src}", __FILE__)
18
+ # ctn = ERB.new(ctn).result(binding)
19
+ # File.write target, ctn
20
+ # end
21
+ # end
22
+ #
23
+ # end
24
+ # end
25
+ #end
@@ -0,0 +1,74 @@
1
+ require 'fileutils'
2
+ require_relative "base_generator"
3
+ require "erb"
4
+ require "find"
5
+ module RoCommands
6
+ module Generators
7
+ class SpecFile
8
+
9
+ include BaseGenerator
10
+ class << self
11
+
12
+ def create(name)
13
+ @name = name
14
+ FileUtils.mkpath dir
15
+ tt name
16
+ end
17
+
18
+ private
19
+
20
+ def name
21
+ @name ||= ""
22
+ end
23
+
24
+ def dir
25
+ @dir ||= 'spec'
26
+ end
27
+
28
+ # get dir file
29
+ def get_df
30
+ if name
31
+ f = File.basename name
32
+ r = name.split("/")
33
+ d = (r - [f]).join("/")
34
+ end
35
+ return d, f
36
+ end
37
+
38
+ def path
39
+ d, f = get_df
40
+ #puts "d:#{d} line:#{__LINE__}"
41
+ if test(?d, 'lib')
42
+ dir_full_path = Find.find('lib').select do |file|
43
+ test(?d, file)
44
+ end.select do |dir|
45
+ basename = File.basename dir
46
+
47
+ #puts "basename:#{basename} line:#{__LINE__}"
48
+ basename.match(%r{^#{d.split("").join(".*")}})
49
+ end.first
50
+
51
+ #puts "dir_full_path:#{dir_full_path} line:#{__LINE__}"
52
+
53
+ files = Dir[File.join(dir_full_path, '**')].select do |file|
54
+ basename = File.basename file
55
+ test(?f, file) and basename.match(%r{^#{f}})
56
+ end
57
+ file = files.first.gsub(%r{\.rb}, "")
58
+ file = File.basename(file)
59
+ File.join(dir, dir_full_path, "#{file}_spec.rb")
60
+ end
61
+ end
62
+
63
+ def to
64
+ super
65
+ unless test(?f, path)
66
+ file_write(path)
67
+ end
68
+
69
+ @created_file = path
70
+ end
71
+ end
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,30 @@
1
+ class C
2
+ def m
3
+ puts 'm'
4
+ end
5
+ end
6
+
7
+ module M
8
+ class C2
9
+ def m
10
+ puts 'm'
11
+ end
12
+
13
+ class << self
14
+ def m2
15
+ puts 'm2'
16
+ end
17
+ end
18
+
19
+ end
20
+
21
+ class C3 < C2
22
+ def m3
23
+ puts 'm2'
24
+ end
25
+
26
+ class << self
27
+
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,2 @@
1
+ require 'spec_helper'
2
+
@@ -0,0 +1,89 @@
1
+ require 'net/ssh'
2
+ require_relative "base"
3
+
4
+ module RoCommands
5
+ class Git < Base
6
+
7
+ desc 'exe', ''
8
+
9
+ def exe(cmd, *args)
10
+ _cmd = specific(cmd)
11
+
12
+ _cmd = "git #{_cmd} #{args.join " "}"
13
+ puts _cmd
14
+ bash _cmd
15
+ end
16
+
17
+ private
18
+
19
+ def specific(cmd)
20
+ dict = {
21
+ a: 'add',
22
+ aa: 'add .',
23
+ b: 'branch',
24
+ co: 'checkout',
25
+ c: 'commit -am',
26
+ i: 'add -i',
27
+ l: 'lo --oneline --all --color --raph --decorate',
28
+ m: 'mere',
29
+ po: 'push -u oriin develop',
30
+ pv: 'push -u vps develop',
31
+ st: 'status',
32
+ t: 'tag'
33
+ }
34
+
35
+ dict[cmd.to_sym] if dict.has_key?(cmd.to_sym)
36
+ end
37
+ #desc 'run KEYWORDS', 'e.g. run r a means git remote add'
38
+ #
39
+ #def git(shortcuts.rb, *smth)
40
+ # shortcuts.rb.shift
41
+ #
42
+ # match implicit(shortcuts.rb)
43
+ #end
44
+ #
45
+ #def update_dict
46
+ # ls = bash_lines("git")
47
+ # cmds = ls.map do |l|
48
+ # r = l.match cmd?
49
+ # if r
50
+ #
51
+ # end
52
+ # end
53
+ #end
54
+ #
55
+ #private
56
+ #
57
+ #class Cmd
58
+ # attr_accessor :sup, :cmd, :sub, :whole
59
+ #
60
+ # def initialize(sup, cmd, sub)
61
+ # @sup = sup
62
+ # @cmd = cmd
63
+ # @sub = get_child
64
+ # @whole = "#{sup.whole} #{cmd}"
65
+ # end
66
+ #
67
+ # def to_s
68
+ # @cmd
69
+ # end
70
+ #
71
+ # def help
72
+ # "#{@whole} -h"
73
+ # end
74
+ #end
75
+ #
76
+ #def cmd?
77
+ # /\s{3}(\w+)/
78
+ #end
79
+ #
80
+ #def dict
81
+ #
82
+ #end
83
+ #
84
+ #def match(implicit)
85
+ #
86
+ #end
87
+ end
88
+ end
89
+
@@ -0,0 +1,111 @@
1
+ require File.expand_path('../git', __FILE__)
2
+ module RoCommands
3
+ class GitFlow < Base
4
+ %w(feature release).each do |stage|
5
+ desc usage("get_#{stage}s"), ''
6
+ define_method("get_#{stage}s".to_sym) do |*args|
7
+ result = %x{git flow #{stage}}
8
+ result = result.split("\n").map do |i|
9
+ i.gsub(%r{\*}, "")
10
+ end
11
+ puts result
12
+ result
13
+ end
14
+ end
15
+
16
+ private
17
+ #def exe(cmd, *names)
18
+ # case cmd
19
+ # when 'fs'
20
+ # feature_start names
21
+ # else
22
+ # r = cmd.split("")
23
+ # f = flags.select do |f|
24
+ # f[0] == r[0]
25
+ # end.first
26
+ #
27
+ # a = arguments.select do |a|
28
+ # a[0] == r[1]
29
+ # end.first
30
+ #
31
+ # git_flow_cmd = "git flow #{f} #{a} #{names.join(" ")}"
32
+ # _exe(git_flow_cmd)
33
+ # end
34
+ #end
35
+ #
36
+ #private
37
+ #
38
+ #def _exe(git_flow_cmd)
39
+ # puts git_flow_cmd
40
+ # bash git_flow_cmd
41
+ #end
42
+ #
43
+ #def feature_start(features)
44
+ # features.each do |f|
45
+ # _exe "git flow feature start #{f}"
46
+ # end
47
+ # _exe "git flow feature checkout #{features.first}"
48
+ #end
49
+ #
50
+ #def flags
51
+ # @flags ||= %w(feature help hotfix init release support version)
52
+ #end
53
+ #
54
+ #def arguments
55
+ # @arguments ||= %w(finish help list publish start track checkout)
56
+ #end
57
+ #def gem_release
58
+ # Methods.change_current_version(Methods.get_version)
59
+ # bashes ''
60
+ #end
61
+
62
+ #alias_method :git, :bashes
63
+ #
64
+ #desc 'gfi', 'git flow init'
65
+ #
66
+ #def init
67
+ # #git push_to_github("git flow init at #{DateTime.now}") + ['git flow init']
68
+ #end
69
+ #
70
+ #desc 'gff feature_name', 'git flow feature'
71
+ #
72
+ #def feature(feature_name)
73
+ # git push_to_github("feature start at #{DateTime.now}")
74
+ # bash "git flow feature start #{feature_name}"
75
+ #end
76
+ #
77
+ #desc 'gfr version', 'git flow release'
78
+ #
79
+ #def release
80
+ # git push_to_github("start release at #{DateTime.now}")
81
+ # bash "git flow release start #{version}"
82
+ #end
83
+ #
84
+ #desc 'grh bug_name', 'git flow hotfix'
85
+ #
86
+ #def hotfix(bug)
87
+ # git push_to_github("start a hotfix at #{DateTime.now}")
88
+ # bash "git flow hotfix start #{bug}"
89
+ #end
90
+ #
91
+ #desc 'finish', 'finish current branch'
92
+ #
93
+ #def finish
94
+ # branch_type, branch_name = check_current_branch
95
+ # if branch_type && branch_name
96
+ # bash "git flow #{branch_type} finish #{branch_name}"
97
+ # else
98
+ # p 'Branch just has develop and master, Please firstly use "git flow xx start xx"'
99
+ # end
100
+ #end
101
+ #
102
+ #private
103
+ #def check_current_branch
104
+ # result = bash('git branch')
105
+ # result = result[/(?<=\*\s)(\/|\w)+/] if result
106
+ # result = result.split('/') if result
107
+ # return if result.nil?
108
+ # return result[0], result[1] if result.is_a?(Array)
109
+ #end
110
+ end
111
+ end