dev_commands 0.0.14 → 0.0.15
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 +4 -4
- data/README.md +7 -0
- data/lib/clean.rb +14 -0
- data/lib/clobber.rb +13 -0
- data/lib/command.rb +17 -7
- data/lib/commands.rb +3 -0
- data/lib/dev_commands.rb +8 -0
- data/lib/doc.rb +3 -3
- data/spec/command_spec.rb +9 -0
- data/spec/text_spec.rb +12 -0
- metadata +4 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1395060459405d06abfe9eceb2e6b26eecb31dac
|
4
|
+
data.tar.gz: b3b04ad925e635bd7fabc683e7b76803b478fe92
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 772e2a96a3b7db63c4adedfa532eac1629727776f41be24b91e6003c687f33a31f56db0355437c5ddb692a78acfaf989ba179b2a1c8058116f96ffd31b0f671e
|
7
|
+
data.tar.gz: df0982510f6a7715bef37221883cb9afd0d4fb210c83930c0bca28cbebd2c41476d9bfb2244b5aa1793185beb89c7acd09159d6226b3da532aba836ad8f7bf70
|
data/README.md
CHANGED
data/lib/clean.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
class Clean < Array
|
2
|
+
def update
|
3
|
+
['.yardoc','log','tmp','obj'].each{|dir|
|
4
|
+
CLEAN.include(dir) if File.exists?(dir)
|
5
|
+
}
|
6
|
+
|
7
|
+
#CLEAN.include('.yardoc','log','tmp','*.gem','obj')
|
8
|
+
CLEAN.include('*.gem')
|
9
|
+
CLEAN.include('**/*.{suo,sdf}')
|
10
|
+
|
11
|
+
add '<%Rake::Task[:clean].reenable%>'
|
12
|
+
add '<%Rake::Task[:clean].invoke%>'
|
13
|
+
end
|
14
|
+
end
|
data/lib/clobber.rb
ADDED
data/lib/command.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
1
|
require 'open3'
|
4
2
|
require_relative('./array.rb')
|
5
3
|
require_relative('./hash.rb')
|
@@ -45,11 +43,8 @@ class Command < Hash
|
|
45
43
|
ruby = self[:input].gsub("<%","").gsub("%>","")
|
46
44
|
|
47
45
|
begin
|
48
|
-
#puts "eval(#{ruby})"
|
49
46
|
self[:output]=eval(ruby)
|
50
47
|
rescue
|
51
|
-
#puts "unable to eval(#{ruby})"
|
52
|
-
#raise "unable to eval(#{ruby})"
|
53
48
|
self[:exit_code]=1
|
54
49
|
self[:error]="unable to eval(#{ruby})"
|
55
50
|
end
|
@@ -62,7 +57,6 @@ class Command < Hash
|
|
62
57
|
self[:exit_code]=status.to_i
|
63
58
|
self[:elapsed] = timer.elapsed_str
|
64
59
|
self[:end_time] = Time.now
|
65
|
-
#self[:exit_code]=$?.to_i
|
66
60
|
rescue Exception => e
|
67
61
|
self[:elapsed] = timer.elapsed_str
|
68
62
|
self[:end_time] = Time.now
|
@@ -80,7 +74,9 @@ class Command < Hash
|
|
80
74
|
puts self[:output]
|
81
75
|
puts self[:error]
|
82
76
|
puts ' '
|
83
|
-
|
77
|
+
if(!self.has_key?(:ignore_failure) || !self[:ignore_failure])
|
78
|
+
raise "#{self[:input]} failed"
|
79
|
+
end #unless (self.has_key?(:ignore_failure) && self[:ignore_failure]==true)
|
84
80
|
end
|
85
81
|
end
|
86
82
|
|
@@ -98,6 +94,20 @@ class Command < Hash
|
|
98
94
|
ENV['USER'].nil? ? ENV['USERNAME'] : ENV['USER']
|
99
95
|
end
|
100
96
|
|
97
|
+
def self.exit_code command
|
98
|
+
cmd = Command.new(command)
|
99
|
+
cmd[:ignore_failure]=true
|
100
|
+
cmd.execute
|
101
|
+
cmd[:exit_code]
|
102
|
+
end
|
103
|
+
|
104
|
+
def self.output command
|
105
|
+
cmd = Command.new(command)
|
106
|
+
cmd[:ignore_failure]=true
|
107
|
+
cmd.execute
|
108
|
+
cmd[:output]
|
109
|
+
end
|
110
|
+
|
101
111
|
def to_html
|
102
112
|
if self[:exit_code] == 0
|
103
113
|
[
|
data/lib/commands.rb
CHANGED
@@ -4,6 +4,8 @@ require_relative('build.rb')
|
|
4
4
|
require_relative('test.rb')
|
5
5
|
require_relative('publish.rb')
|
6
6
|
require_relative('doc.rb')
|
7
|
+
require_relative('clean.rb')
|
8
|
+
require_relative('clobber.rb')
|
7
9
|
require_relative('add.rb')
|
8
10
|
require_relative('commit.rb')
|
9
11
|
require_relative('push.rb')
|
@@ -17,6 +19,7 @@ class Commands < Hash
|
|
17
19
|
self[:test]=Test.new
|
18
20
|
self[:publish]=Publish.new
|
19
21
|
self[:doc]=Doc.new
|
22
|
+
self[:clean]=Clean.new
|
20
23
|
self[:add]=Add.new
|
21
24
|
self[:commit]=Commit.new
|
22
25
|
self[:push]=Push.new
|
data/lib/dev_commands.rb
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
require 'json'
|
2
2
|
require 'rake/clean'
|
3
|
+
|
4
|
+
#CLEAN.include('.yardoc','log','tmp','*.gem','obj')
|
5
|
+
#CLEAN.include('**/*.{suo,sdf}')
|
6
|
+
CLOBBER.include('bin','doc')
|
7
|
+
|
8
|
+
|
3
9
|
require_relative('command.rb')
|
4
10
|
require_relative('commands.rb')
|
5
11
|
require_relative('text.rb')
|
6
12
|
require_relative('gemspec.rb')
|
7
13
|
require_relative('git.rb')
|
14
|
+
|
15
|
+
COMMANDS=Commands.new
|
data/lib/doc.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
class Doc < Array
|
2
2
|
def update
|
3
|
-
cmd=Command.new ({ :input => 'yard --version', :ignore_failure => true})
|
4
|
-
cmd.execute
|
5
|
-
if(
|
3
|
+
#cmd=Command.new ({ :input => 'yard --version', :ignore_failure => true})
|
4
|
+
#cmd.execute
|
5
|
+
if(Command.exit_code('yard --version'))
|
6
6
|
add 'yard doc - LICENSE' if File.exists?('README.md') && File.exists?('LICENSE')
|
7
7
|
end
|
8
8
|
end
|
data/spec/command_spec.rb
CHANGED
@@ -95,6 +95,15 @@ describe Command do
|
|
95
95
|
File.open('commands.html','w'){|f|f.write(commands.to_html)}
|
96
96
|
end
|
97
97
|
|
98
|
+
it "hsould be able to get the output" do
|
99
|
+
expect(Command.output('git --version').include?('git version')).to eq(true)
|
100
|
+
expect(Command.output('bogus --version').include?('bogus version')).to eq(false)
|
101
|
+
end
|
102
|
+
|
103
|
+
it "should be able to get the exit_code" do
|
104
|
+
expect(Command.exit_code('rake --version')).to eq(0)
|
105
|
+
expect(Command.exit_code('bogus --version')).not_to eq(0)
|
106
|
+
end
|
98
107
|
#it "should fail this test" do
|
99
108
|
# expect(false).to eq(true)
|
100
109
|
#end
|
data/spec/text_spec.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require_relative '../lib/text.rb'
|
2
|
+
|
3
|
+
describe Text do
|
4
|
+
it "should be able to replace text in file" do
|
5
|
+
FileUtils.mkdir('tmp') if(!File.exists?('tmp'))
|
6
|
+
File.open('tmp/test.txt','w'){|f|
|
7
|
+
f.write("test thing")
|
8
|
+
}
|
9
|
+
Text.replace_in_file('tmp/test.txt','thing','string')
|
10
|
+
expect(IO.read('tmp/test.txt').include?('test string')).to eq(true)
|
11
|
+
end
|
12
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dev_commands
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lou Parslow
|
@@ -131,6 +131,8 @@ files:
|
|
131
131
|
- lib/add.rb
|
132
132
|
- lib/array.rb
|
133
133
|
- lib/build.rb
|
134
|
+
- lib/clean.rb
|
135
|
+
- lib/clobber.rb
|
134
136
|
- lib/command.rb
|
135
137
|
- lib/commands.rb
|
136
138
|
- lib/commit.rb
|
@@ -147,6 +149,7 @@ files:
|
|
147
149
|
- lib/timer.rb
|
148
150
|
- spec/command_spec.rb
|
149
151
|
- spec/commands_spec.rb
|
152
|
+
- spec/text_spec.rb
|
150
153
|
- LICENSE
|
151
154
|
- README.md
|
152
155
|
homepage: http://github.com/lou-parslow/dev_commands.gem
|