ro_support 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 257bea16081e546928a459209384bb2438b464e8
4
- data.tar.gz: 30c139fa9ef8d66a5b70452d49819235b769af39
3
+ metadata.gz: c99ccdf4846ce2282ddaca96d20b2b7624912128
4
+ data.tar.gz: 68323c88b3dbd24eeb1f27806baee8374cbafb7f
5
5
  SHA512:
6
- metadata.gz: cd8c98bb26e1593e8c62547576f00b7cba7f3bd0f4f7e6522317d03abf963eab360f938caf0580f5361f4d42983eb319e9c737922a159d05677c858092965754
7
- data.tar.gz: 31391888fd01491d42124fb97162e4b4a3b20d0b3e6f50ce4db22970323b807214371319291c4343b78f26879ab0b80ee7a27948ea7bcc790efa253ef70660e8
6
+ metadata.gz: c8bf2abaa72c64cf1edd3a869d5e9e04e45a116785e02f7d035f80e8fd00b3bc38dc467a3c857b760f358e07ab24b6d1fea662442c8a63ed1ca2e5b99c61e7f6
7
+ data.tar.gz: b2a40242697e0aada27f081fd9da208543166c4cec150525a6898fd36e687801f935446a22d9190ea4fcc9f276b0f96432b7714b1e667d24ec6b57b18e55d689
@@ -1,21 +1,3 @@
1
1
  require "ro_commands/helpers/bash"
2
2
  require "ro_commands/helpers/out"
3
- require "open3"
4
- module RoSupport
5
- module Bash
6
- include ::Bash
7
3
 
8
- def _bash(cmd)
9
- stdout, stderr, status = Open3.capture3(cmd)
10
- @@lastest_status = status
11
-
12
- Out.out(stdout)
13
- end
14
-
15
- class << self
16
- def lastest_status
17
- @@lastest_status ||= ''
18
- end
19
- end
20
- end
21
- end
@@ -0,0 +1,6 @@
1
+ require "ro_commands/dsl/file"
2
+
3
+ module RoSupport
4
+
5
+ include RoCommands::DSL::File
6
+ end
@@ -19,10 +19,10 @@ module RoSupport
19
19
  File.write path
20
20
  end
21
21
 
22
- def file(path)
23
- parent(path)
24
- File.new(path, 'w+')
25
- end
22
+ #def file(path)
23
+ # parent(path)
24
+ # File.new(path, 'w+')
25
+ #end
26
26
 
27
27
  def parent(path)
28
28
  file = File.basename path
@@ -0,0 +1,29 @@
1
+ require "pry"
2
+ require "ro_support/out"
3
+
4
+ module RoSupport
5
+ module GuardHelpers
6
+ module BaseHelper
7
+ class << self
8
+ def included(base)
9
+ base.extend(ClsMeths)
10
+ end
11
+ end
12
+
13
+ module ClsMeths
14
+ def included(base)
15
+ super
16
+ end
17
+
18
+ def append_features(mod)
19
+ super
20
+ mod.class_eval do
21
+ include self.const_get(:ClassMethods)
22
+ extend self.const_get(:ClassMethods)
23
+ ::Pry::Command.send :include, self.const_get(:ClassMethods)
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,52 @@
1
+ require "active_support/concern"
2
+ require_relative "base_helper"
3
+
4
+ module GuardHelpers
5
+ module GuardHelper
6
+ include ::RoSupport::GuardHelpers::BaseHelper
7
+
8
+ module ClassMethods
9
+ def site_build
10
+ bash "jekyll build"
11
+ end
12
+
13
+ def get_erb_name(erb)
14
+ Find.find("templates").grep(%r{#{erb}}).first
15
+ end
16
+
17
+ def create_erb_name(erb)
18
+ basename = Time.now.strftime("%Y-%m-%d-#{erb}.md.erb")
19
+ File.join("templates", basename)
20
+ end
21
+
22
+ def create_erb(erb)
23
+ FileUtils.touch create_erb_name(erb)
24
+ end
25
+
26
+
27
+ def erb_build(erb)
28
+ #full_name = get_erb_name(erb)
29
+ #puts "full_name:#{full_name} file:#{File.basename __FILE__} line:#{__LINE__}"
30
+ basename = File.basename(erb).gsub(%r{\.erb}) do |m|
31
+ ""
32
+ end
33
+
34
+ to = File.join("_posts", basename)
35
+ ctn = File.read(erb)
36
+ result = ERB.new(ctn).result(binding)
37
+ File.write(to, result)
38
+ notify "#{to} writing success"
39
+ end
40
+
41
+ def erb_build_all
42
+ Find.find("templates") do |erb|
43
+ if test(?f, erb)
44
+ Out.out(erb, "red")
45
+ erb_build(erb)
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
52
+
@@ -0,0 +1,45 @@
1
+ require "ro_support/out"
2
+ require_relative "base_helper"
3
+
4
+ module GuardHelpers
5
+ module MdHelper
6
+ include ::RoSupport::GuardHelpers::BaseHelper
7
+
8
+ module ClassMethods
9
+
10
+ def anchor(name, url)
11
+ "[#{name}](#{url})"
12
+ end
13
+
14
+ def h2(title)
15
+ "##<a name='#{get_name(title)}'></a> #{title}"
16
+ end
17
+
18
+ def h3(title)
19
+ "###<a name='#{get_name(title)}'></a> #{title}"
20
+ end
21
+
22
+
23
+ def get_name(title)
24
+ title.split(" ").map(&:downcase).join("-")
25
+ end
26
+
27
+ def ref(url)
28
+ "####[#{url}](#{url})"
29
+ end
30
+
31
+ def l (title)
32
+ list(title)
33
+ end
34
+
35
+ def l1 (title)
36
+ list(title, 1)
37
+ end
38
+
39
+ def list (title, level=0)
40
+ ref = "##{title.split(" ").map(&:downcase).join("-")}"
41
+ "#{" "*4*level}- [#{title}](#{ref})"
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,9 @@
1
+ module RoSupport
2
+ class Load
3
+ class << self
4
+ def all(dir)
5
+
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,2 @@
1
+ require "ro_commands/helpers/out"
2
+
@@ -1,10 +1,42 @@
1
1
  require "guard"
2
2
  require "guard/guard"
3
3
  require "active_support/concern"
4
+ require "ro_support/out"
5
+ require "find"
6
+ require "erb"
7
+ require "fileutils"
4
8
 
5
9
  module RoSupport
6
10
  module RoGuard
11
+ class << self
12
+
13
+ def def_meth(name, &blk)
14
+ define_method(:"#{name}") do |*args|
15
+ blk.call *args
16
+ end
17
+
18
+ define_singleton_method(:"#{name}") do |*args|
19
+ blk.call *args
20
+ end
21
+
22
+ Pry::Command.send :define_method, :"#{name}" do |*args|
23
+ blk.call *args
24
+ end
25
+ end
26
+ end
27
+
28
+ def_meth "bash" do |*cmds|
29
+ cmd = cmds.flatten.join(" && ")
30
+ Out.out(cmd)
31
+ ::Kernel.system cmd
32
+ end
33
+
34
+ def_meth "guard_reset" do
35
+ bash "bundle exec guard"
36
+ end
37
+
7
38
  def start
39
+ super if defined? super
8
40
  commands = Pry::CommandSet.new do
9
41
  block_command "install" do |*args|
10
42
  system "rake install"
@@ -16,12 +48,39 @@ module RoSupport
16
48
  end
17
49
 
18
50
  def run_on_modifications(paths)
51
+ super if defined? super
19
52
  @paths = paths
20
- handle('Guardfile') do
21
- bash "bundle exec guard"
53
+ Out.out "paths:#{paths} file:#{File.basename __FILE__} line:#{__LINE__}", "green"
54
+ handle(%r{Guardfile|(^lib/guard_helpers/(.+)\.rb)}) do
55
+ guard_reset
56
+ end
57
+
58
+ handle(%r{README.md.erb}) do
59
+ ctn = File.read("README.md.erb")
60
+ result = ERB.new(ctn).result(binding)
61
+ Out.out("writting README.md")
62
+ File.write("README.md", result)
22
63
  end
23
64
 
24
- bash "rake install"
65
+ unless Dir['**'].grep(%r{(.+)\.gemspec}).empty?
66
+ bash "rake install"
67
+ end
68
+ end
69
+
70
+ def_meth "file_read" do |file|
71
+ File.read(file)
72
+ notify "read #{file}"
73
+ end
74
+
75
+ def_meth "file_write" do |file, ctn|
76
+ File.write(file, ctn)
77
+ notify "writing #{file} success"
78
+ end
79
+
80
+ def_meth "install" do
81
+ cmd = "rake install"
82
+ bash cmd
83
+ notify cmd
25
84
  end
26
85
 
27
86
  def paths
@@ -30,16 +89,18 @@ module RoSupport
30
89
  @paths ||= []
31
90
  end
32
91
 
33
- def notify(msg)
92
+ def_meth "notify" do |msg|
34
93
  puts msg
35
- Notifier.notify msg
94
+ ::Guard::Notifier.notify msg
36
95
  end
37
96
 
38
97
  def handle(file, &blk)
39
98
  #puts "Handling #{paths.flatten}"
40
99
  r = paths.flatten.grep /#{file}$/
41
100
  unless r.empty?
42
- blk.call
101
+ r.each do |*args|
102
+ blk.call *args
103
+ end
43
104
  end
44
105
  end
45
106
 
@@ -1,3 +1,3 @@
1
1
  module RoSupport
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
@@ -1,8 +1,16 @@
1
1
  require "spec_helper"
2
+ require "ro_support/bash"
3
+
4
+ class Klass
5
+ include Bash
6
+ end
7
+
8
+ describe "Klass" do
9
+ let(:o) do
10
+ Klass.new
11
+ end
2
12
 
3
- include ::RoSupport::Bash
4
- describe ::RoSupport::Bash do
5
13
  it "bash" do
6
- bash("echo one", "echo two", "echo three")
14
+ o.bash("echo one", "echo two", "echo three")
7
15
  end
8
16
  end
@@ -1,76 +1,76 @@
1
- require 'spec_helper'
2
-
3
-
4
- class C
5
-
6
- include RoSupport::Debug
7
-
8
- def initialize
9
- @foo = 'foo'
10
- @bar = 'bar'
11
- end
12
-
13
- def try_ro_raise
14
- foo = 'foo'
15
- bar = 'bar'
16
- ro_raise err('msg', output: ['@foo', '@bar', 'bar', 'foo'])
17
- end
18
-
19
- #def try_ro_return
20
- # foo = 'foo'
21
- # bar = 'bar'
22
- # ro_return valid(nil, output:['foo', 'bar'])
23
- #end
24
-
25
- def try_ro_print
26
- foo = 'foo'
27
- bar = 'bar'
28
- ro_print vars('foo', 'bar')
29
- end
30
- end
31
-
32
- describe Debug do
33
- let(:c) { C.new }
34
-
35
- it 'ro_raise' do
36
- expect do
37
- c.try_ro_raise
38
- end.to raise_error RuntimeError
39
- end
40
-
41
- #describe 'ro_return' do
42
- # it 'raise error when return a invalid argument' do
43
- # expect do
44
- # c.try_ro_return
45
- # end.to raise_error RuntimeError
46
- # end
47
- #end
48
-
49
- it 'ro_print' do
50
- expect(c.try_ro_print).to be == "bar:bar"
51
- end
52
- it 'self' do
53
- pending
54
- end
55
-
56
- it 'vars' do
57
- pending
58
- end
59
-
60
- it 'err' do
61
- pending
62
- end
63
-
64
- it 'valid' do
65
- pending
66
- end
67
-
68
- it 'ro_error' do
69
- pending
70
- end
71
-
72
- it 'ro_return_valid' do
73
- pending
74
- end
75
-
76
- end
1
+ #require 'spec_helper'
2
+ #
3
+ #
4
+ #class C
5
+ #
6
+ # include RoSupport::Debug
7
+ #
8
+ # def initialize
9
+ # @foo = 'foo'
10
+ # @bar = 'bar'
11
+ # end
12
+ #
13
+ # def try_ro_raise
14
+ # foo = 'foo'
15
+ # bar = 'bar'
16
+ # ro_raise err('msg', output: ['@foo', '@bar', 'bar', 'foo'])
17
+ # end
18
+ #
19
+ # #def try_ro_return
20
+ # # foo = 'foo'
21
+ # # bar = 'bar'
22
+ # # ro_return valid(nil, output:['foo', 'bar'])
23
+ # #end
24
+ #
25
+ # def try_ro_print
26
+ # foo = 'foo'
27
+ # bar = 'bar'
28
+ # ro_print vars('foo', 'bar')
29
+ # end
30
+ #end
31
+ #
32
+ #describe Debug do
33
+ # let(:c) { C.new }
34
+ #
35
+ # it 'ro_raise' do
36
+ # expect do
37
+ # c.try_ro_raise
38
+ # end.to raise_error RuntimeError
39
+ # end
40
+ #
41
+ # #describe 'ro_return' do
42
+ # # it 'raise error when return a invalid argument' do
43
+ # # expect do
44
+ # # c.try_ro_return
45
+ # # end.to raise_error RuntimeError
46
+ # # end
47
+ # #end
48
+ #
49
+ # it 'ro_print' do
50
+ # expect(c.try_ro_print).to be == "bar:bar"
51
+ # end
52
+ # it 'self' do
53
+ # pending
54
+ # end
55
+ #
56
+ # it 'vars' do
57
+ # pending
58
+ # end
59
+ #
60
+ # it 'err' do
61
+ # pending
62
+ # end
63
+ #
64
+ # it 'valid' do
65
+ # pending
66
+ # end
67
+ #
68
+ # it 'ro_error' do
69
+ # pending
70
+ # end
71
+ #
72
+ # it 'ro_return_valid' do
73
+ # pending
74
+ # end
75
+ #
76
+ #end
@@ -1,43 +1,26 @@
1
- require 'spec_helper'
2
-
3
- class Klass
4
- include FileActions
5
- end
6
-
7
- describe FileActions do
8
-
9
- let(:o) do
10
- Klass.new
11
- end
12
-
13
- before do
14
- cdfix('file_actions')
15
- end
16
-
17
- it 'create dir file' do
18
- path = 'path/to/target'
19
- result = o.send(:"file", path)
20
- expect(File.exist? path).to be_true
21
- end
22
-
23
- #it 'ls' do
24
- # FileActions.ls Dir.pwd
25
- #end
26
-
27
- it 'create_dir_file' do
28
- pending
29
- end
30
-
31
- it 'get_tree_in' do
32
- pending
33
- end
34
-
35
- it 'self' do
36
- pending
37
- end
38
-
39
- it 'autoload_all_files_in' do
40
- pending
41
- end
42
-
43
- end
1
+ #require 'spec_helper'
2
+ #
3
+ #class Klass
4
+ # include FileActions
5
+ #end
6
+ #
7
+ #describe FileActions do
8
+ #
9
+ # let(:o) do
10
+ # Klass.new
11
+ # end
12
+ #
13
+ # before do
14
+ # cdfix('file_actions')
15
+ # end
16
+ #
17
+ # it 'create dir file' do
18
+ # path = 'path/to/target'
19
+ # result = o.send(:"file", path)
20
+ # expect(File.exist? path).to be_true
21
+ # end
22
+ #
23
+ # #it 'ls' do
24
+ # # FileActions.ls Dir.pwd
25
+ # #end
26
+ #end
@@ -1,10 +1,7 @@
1
- require 'spec_helper'
2
-
3
- include Misc
4
- describe Misc do
5
-
6
-
7
-
1
+ #require 'spec_helper'
2
+ #
3
+ #include Misc
4
+ #describe Misc do
8
5
  #describe Autoload do
9
6
  # it 'all files in' do
10
7
  # include Misc::Autoload
@@ -32,22 +29,4 @@ describe Misc do
32
29
  # end
33
30
  # end
34
31
  #end
35
-
36
-
37
- it 'set_instance_variable_from' do
38
- pending
39
- end
40
-
41
- it 'that' do
42
- pending
43
- end
44
-
45
- it 'self' do
46
- pending
47
- end
48
-
49
- it 'dir_load' do
50
- pending
51
- end
52
-
53
- end
32
+ #end
@@ -1,27 +1,27 @@
1
- require 'spec_helper'
2
-
3
- class Project
4
- class << self
5
- def root
6
- '/nimabi/nimabi'
7
- end
8
- end
9
- end
10
-
11
- module Try
12
- include RoDebug
13
- end
14
-
15
- describe 'RoDebug' do
16
-
17
- describe 'check_env' do
18
- it 'check' do
19
- Try.check_env %w(Project.root)
20
- end
21
-
22
- it 'check nil' do
23
- Try.check_env %w(Project.nimabi)
24
- end
25
- end
26
-
27
- end
1
+ #require 'spec_helper'
2
+ #
3
+ #class Project
4
+ # class << self
5
+ # def root
6
+ # '/nimabi/nimabi'
7
+ # end
8
+ # end
9
+ #end
10
+ #
11
+ #module Try
12
+ # include RoDebug
13
+ #end
14
+ #
15
+ #describe 'RoDebug' do
16
+ #
17
+ # describe 'check_env' do
18
+ # it 'check' do
19
+ # Try.check_env %w(Project.root)
20
+ # end
21
+ #
22
+ # it 'check nil' do
23
+ # Try.check_env %w(Project.nimabi)
24
+ # end
25
+ # end
26
+ #
27
+ #end
@@ -0,0 +1,33 @@
1
+ require 'spec_helper'
2
+ require "ro_support/ro_guard/base_helper"
3
+
4
+ module ModHelper1
5
+ include ::RoSupport::GuardHelpers::BaseHelper
6
+
7
+ module ClassMethods
8
+ def try1
9
+
10
+ end
11
+ end
12
+ end
13
+
14
+ class Klass
15
+ include ModHelper1
16
+ end
17
+
18
+ describe "Klass" do
19
+ let(:o) do
20
+ Klass
21
+ end
22
+
23
+ it "#" do
24
+ expect(o).to respond_to :try1
25
+ expect(::Pry::Command.new).to respond_to :try1
26
+ expect(o.new).to respond_to :try1
27
+ end
28
+ end
29
+
30
+
31
+ describe "BaseHelper" do
32
+
33
+ end
@@ -1,9 +1,9 @@
1
1
  require 'spec_helper'
2
2
 
3
- include StringHandler
4
- describe StringHandler do
5
- before :all do
3
+ include ::RoSupport::StringHandler
6
4
 
5
+ describe "StringHandler" do
6
+ before :all do
7
7
  end
8
8
 
9
9
  it 'camelize' do
@@ -23,9 +23,5 @@ describe StringHandler do
23
23
  it 'blank?' do
24
24
  expect(' '.blank?).to be_true
25
25
  end
26
- it 'self' do
27
- pending
28
- end
29
-
30
26
  end
31
27
 
@@ -1,10 +1,8 @@
1
1
  require 'rspec'
2
- require 'headless'
3
2
  require 'faker'
4
3
  require "ro_support"
5
- include RoSupport
6
4
 
7
- $root = File.expand_path("../../", __FILE__)
5
+ $root = File.expand_path("../..", __FILE__)
8
6
  $lib = File.join($root, 'lib')
9
7
  $LOAD_PATH.unshift $root
10
8
  $LOAD_PATH.unshift $lib
@@ -21,10 +19,6 @@ def cdfix(name)
21
19
  end
22
20
 
23
21
  RSpec.configure do |config|
24
- config.before(:all) do
25
- Headless.new.start
26
- end
27
-
28
22
  config.treat_symbols_as_metadata_keys_with_true_values = true
29
23
  config.run_all_when_everything_filtered = true
30
24
  config.filter_run :focus
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ro_support
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - ro
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-22 00:00:00.000000000 Z
11
+ date: 2013-11-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -111,6 +111,7 @@ files:
111
111
  - db/seeds.rb
112
112
  - lib/ro_support.rb
113
113
  - lib/ro_support/rspec.rb
114
+ - lib/ro_support/out.rb
114
115
  - lib/ro_support/string_handler/common.rb
115
116
  - lib/ro_support/bash.rb
116
117
  - lib/ro_support/rspec_helpers.rb
@@ -127,12 +128,17 @@ files:
127
128
  - lib/ro_support/debug.rb
128
129
  - lib/ro_support/git.rb
129
130
  - lib/ro_support/misc.rb
131
+ - lib/ro_support/dsl/file.rb
130
132
  - lib/ro_support/string_handler.rb
131
133
  - lib/ro_support/guard.rb
134
+ - lib/ro_support/guard_helpers/base_helper.rb
135
+ - lib/ro_support/guard_helpers/md_helper.rb
136
+ - lib/ro_support/guard_helpers/erb_helper.rb
132
137
  - lib/ro_support/ssh.rb
133
138
  - lib/ro_support/log.rb
134
139
  - lib/ro_support/file.rb
135
140
  - lib/ro_support/ro_guard.rb
141
+ - lib/ro_support/load.rb
136
142
  - lib/tasks/ro_support_tasks.rake
137
143
  - Rakefile
138
144
  - README.rdoc
@@ -155,6 +161,7 @@ files:
155
161
  - spec/lib/ro_support/array_spec.rb
156
162
  - spec/lib/ro_support/bash_spec.rb
157
163
  - spec/lib/ro_support/misc/zw_spec.rb
164
+ - spec/lib/ro_support/ro_guard/base_helper_spec.rb
158
165
  - spec/lib/ro_support/misc_spec.rb
159
166
  - spec/lib/ro_support/debug_spec.rb
160
167
  - spec/lib/ro_support/git_spec.rb
@@ -199,7 +206,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
199
206
  version: '0'
200
207
  requirements: []
201
208
  rubyforge_project:
202
- rubygems_version: 2.0.3
209
+ rubygems_version: 2.0.14
203
210
  signing_key:
204
211
  specification_version: 4
205
212
  summary: ''
@@ -223,6 +230,7 @@ test_files:
223
230
  - spec/lib/ro_support/array_spec.rb
224
231
  - spec/lib/ro_support/bash_spec.rb
225
232
  - spec/lib/ro_support/misc/zw_spec.rb
233
+ - spec/lib/ro_support/ro_guard/base_helper_spec.rb
226
234
  - spec/lib/ro_support/misc_spec.rb
227
235
  - spec/lib/ro_support/debug_spec.rb
228
236
  - spec/lib/ro_support/git_spec.rb