dev_commands 0.0.10 → 0.0.11

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: 2bf6bd51e45b9c16b1389e81393dc5f7f3418936
4
- data.tar.gz: 6629c5669dc7c52461e6be0836e729249d16819a
3
+ metadata.gz: bc46c831f6d378f8e4f8636404710d3145bd6fc8
4
+ data.tar.gz: 7e16338ba218e784ca7f2f530b0e76fc295e1817
5
5
  SHA512:
6
- metadata.gz: 9b406adf163157db56d19b808beb3ca512f2aceea9c763e6ac4b4c2b2dea29b6071a0b5cd876de2a052145a979e940a5920d6bc04ed3de2253deb4b427a41e83
7
- data.tar.gz: ffdb1c0862886ce90d86299cc793b9b189737836c34f9e40513a56a1342a48041ef5df6ac3e6f524207fa6e0ff5a2c8b6b4f80a6211d54ef40bbed8d7a1d2525
6
+ metadata.gz: bf0334fabafa3815a761b7f945b21e6344d38dfa29a0530c6e7a94e7c58763e34e480a8b009da064f621941211e4fd92335b23fe72b9f3183501663f2a7c5dc2
7
+ data.tar.gz: b3cf64cfaee150f851c0c17332c82f452c37a55389255a9a0806050a8665a6d34386afbe112bfdda57b420069bd4b344c0800af75e25a3e60cea154c10ded389
data/README.md CHANGED
@@ -26,6 +26,29 @@ This is an example of a simple usage
26
26
  # output": ruby 2.0.0p481 (2014-05-08 revision 45883) [universal.x86_64-darwin14]
27
27
  ```
28
28
 
29
+ Using commands in an array
30
+
31
+ ```
32
+ commands=['ruby -version','git --version']
33
+ commands.execute
34
+ ```
35
+
36
+ Using commands in a hash
37
+
38
+ ```
39
+ commands=
40
+ {
41
+ build: ['gem build dev_commands.gemspec'],
42
+ test: ['rspec'],
43
+ doc: ['yard doc - LICENSE'],
44
+ add: ['git add --all'],
45
+ commit: ["git commit -m'commit all'"],
46
+
47
+ }
48
+ commands.execute
49
+
50
+ ```
51
+
29
52
  ### License
30
53
  Copyright 2014-2015 Lou Parslow
31
54
 
@@ -0,0 +1,9 @@
1
+ class Add < Array
2
+ def update
3
+ if(File.exists?('.gitignore'))
4
+ add 'git add --all'
5
+ else
6
+
7
+ end
8
+ end
9
+ end
@@ -9,6 +9,10 @@ class Array
9
9
  end
10
10
  end
11
11
 
12
+ def add command
13
+ self << command if(!include?(command))
14
+ end
15
+
12
16
  def to_html
13
17
  html=Array.new
14
18
  html << '<div>'
@@ -0,0 +1,7 @@
1
+ class Build < Array
2
+ def update
3
+ Dir.glob('*.gemspec'){|gemspec|
4
+ add "gem build #{gemspec}"
5
+ }
6
+ end
7
+ end
@@ -48,6 +48,7 @@ class Command < Hash
48
48
  rescue
49
49
  #puts "unable to eval(#{ruby})"
50
50
  #raise "unable to eval(#{ruby})"
51
+ self[:exit_code]=1
51
52
  self[:error]="unable to eval(#{ruby})"
52
53
  end
53
54
 
@@ -0,0 +1,26 @@
1
+ require_relative('hash.rb')
2
+ require_relative('setup.rb')
3
+ require_relative('build.rb')
4
+ require_relative('test.rb')
5
+ require_relative('publish.rb')
6
+ require_relative('doc.rb')
7
+ require_relative('add.rb')
8
+ require_relative('commit.rb')
9
+ require_relative('push.rb')
10
+
11
+ class Commands < Hash
12
+
13
+ def initialize directory=Dir.pwd
14
+ Dir.chdir(directory) do
15
+ self[:setup]=Setup.new
16
+ self[:build]=Build.new
17
+ self[:test]=Test.new
18
+ self[:publish]=Publish.new
19
+ self[:doc]=Doc.new
20
+ self[:add]=Add.new
21
+ self[:commit]=Commit.new
22
+ self[:push]=Push.new
23
+ end
24
+ end
25
+
26
+ end
@@ -0,0 +1,7 @@
1
+ class Commit < Array
2
+ def update
3
+ if(File.exists?('.git'))
4
+ add "git commit -m'all'"
5
+ end
6
+ end
7
+ end
@@ -1,3 +1,7 @@
1
1
  require 'json'
2
+ require 'rake/clean'
2
3
  require_relative('command.rb')
4
+ require_relative('commands.rb')
3
5
  require_relative('text.rb')
6
+ require_relative('gemspec.rb')
7
+ require_relative('git.rb')
@@ -0,0 +1,5 @@
1
+ class Doc < Array
2
+ def update
3
+ add 'yard doc - LICENSE' if File.exists?('README.md') && File.exists?('LICENSE')
4
+ end
5
+ end
@@ -0,0 +1,36 @@
1
+ class Gemspec
2
+ def self.update gemspec_file
3
+ Text.replace_in_file gemspec_file,
4
+ /('\d{4}-\d{2}-\d{2}')/,
5
+ "'#{Time.now.strftime('%Y-%m-%d')}'"
6
+ end
7
+
8
+ def self.gemfile gemspec_file
9
+ spec=Gem::Specification.load(gemspec_file)
10
+ return "#{spec.name}-#{spec.version}.gem"
11
+ end
12
+
13
+ def self.version gemspec_file
14
+ spec=Gem::Specification.load(gemspec_file)
15
+ return spec.version.to_s
16
+ end
17
+
18
+ def self.published_version gemspec_file
19
+ published_version=''
20
+ spec=Gem::Specification.load(gemspec_file)
21
+ begin
22
+ published_version = `gem list #{spec.name} -r`.scan(/\((\d+.\d+.\d+)\)/)[0][0]
23
+ rescue
24
+ published_version=''
25
+ end
26
+ published_version
27
+ end
28
+ def self.published? gemspec_file
29
+ published_version(gemspec_file)==version(gemspec_file) ? true : false
30
+ end
31
+
32
+ def self.normalize gemspec_file
33
+ spec=Gem::Specification.load(gemspec_file)
34
+ File.open(gemspec_file,'w'){|f|f.write(spec.to_ruby)}
35
+ end
36
+ end
@@ -0,0 +1,9 @@
1
+ class Git
2
+ def self.branch
3
+ begin
4
+ `git branch`.scan(/\* ([.\w-]+)/)[0][0]
5
+ rescue
6
+ ''
7
+ end
8
+ end
9
+ end
@@ -1,10 +1,12 @@
1
1
  class Hash
2
2
  def execute
3
3
  self.each{|k,v|
4
+ v.update if v.respond_to?(:update)
4
5
  if(v.is_a?(Array) && v.length==0)
5
6
  self.delete k
6
7
  else
7
8
  #puts "executing #{k}"
9
+
8
10
  v.execute if v.respond_to?(:execute)
9
11
  end
10
12
  }
@@ -0,0 +1,7 @@
1
+ class Publish < Array
2
+ def update
3
+ Dir.glob('*.gemspec').each{|gemspec_file|
4
+ add "gem push #{Gemspec.gemfile(gemspec_file)}" if !Gemspec.published? gemspec_file
5
+ }
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ class Push < Array
2
+ def update
3
+ if(File.exists?('.git'))
4
+ add 'git push' if Git.branch != 'develop'
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,5 @@
1
+ class Setup < Array
2
+ def update
3
+
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class Test < Array
2
+ def update
3
+ add 'rspec' if File.exists?('spec')
4
+ end
5
+ end
@@ -0,0 +1,7 @@
1
+ require_relative '../lib/commands.rb'
2
+
3
+ describe Commands do
4
+ it "should be able to automatically generate commands for a particular directory" do
5
+ commands=Commands.new
6
+ end
7
+ 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.10
4
+ version: 0.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lou Parslow
@@ -24,20 +24,6 @@ dependencies:
24
24
  - - '>='
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
- - !ruby/object:Gem::Dependency
28
- name: rspec
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - '>='
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - '>='
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: json
43
29
  requirement: !ruby/object:Gem::Requirement
@@ -52,20 +38,6 @@ dependencies:
52
38
  - - '>='
53
39
  - !ruby/object:Gem::Version
54
40
  version: '0'
55
- - !ruby/object:Gem::Dependency
56
- name: rake
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - '>='
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - '>='
67
- - !ruby/object:Gem::Version
68
- version: '0'
69
41
  - !ruby/object:Gem::Dependency
70
42
  name: rspec
71
43
  requirement: !ruby/object:Gem::Requirement
@@ -100,13 +72,25 @@ executables: []
100
72
  extensions: []
101
73
  extra_rdoc_files: []
102
74
  files:
75
+ - lib/add.rb
103
76
  - lib/array.rb
77
+ - lib/build.rb
104
78
  - lib/command.rb
79
+ - lib/commands.rb
80
+ - lib/commit.rb
105
81
  - lib/dev_commands.rb
82
+ - lib/doc.rb
83
+ - lib/gemspec.rb
84
+ - lib/git.rb
106
85
  - lib/hash.rb
86
+ - lib/publish.rb
87
+ - lib/push.rb
88
+ - lib/setup.rb
89
+ - lib/test.rb
107
90
  - lib/text.rb
108
91
  - lib/timer.rb
109
92
  - spec/command_spec.rb
93
+ - spec/commands_spec.rb
110
94
  - LICENSE
111
95
  - README.md
112
96
  homepage: http://github.com/lou-parslow/dev_commands.gem