submodule 0.0.3 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
File without changes
data/Gemfile CHANGED
File without changes
data/README.md CHANGED
File without changes
data/Rakefile CHANGED
File without changes
data/lib/submodule.rb CHANGED
@@ -5,10 +5,10 @@ require "inifile"
5
5
 
6
6
  module Submodule
7
7
  class Task < ::Rake::TaskLib
8
-
9
8
  attr_reader :path
9
+ attr_accessor :branch
10
10
 
11
- def initialize
11
+ def initialize
12
12
  @cwd = Dir.pwd
13
13
 
14
14
  base = File.basename Dir["*.gemspec"][0], ".gemspec"
@@ -19,17 +19,29 @@ module Submodule
19
19
 
20
20
  gitmodules = IniFile.new('./.gitmodules').to_h
21
21
  @path = gitmodules[gitmodules.keys.first]["path"]
22
+ @path = File.expand_path(@path, @cwd)
22
23
  @submodule_name = gitmodules.keys.first.gsub('submodule ', '').gsub('"', '').gsub('vendor/', '')
23
24
  @github = gitmodules[gitmodules.keys.first]["url"].gsub('https://github.com/', '').gsub('.git', '')
24
- define
25
- end
26
25
 
27
- def test
28
- p "define tests in test function"
26
+ # TODO: detect default branch
27
+ @branch = "master"
28
+
29
+ yield self if block_given?
30
+ define
29
31
  end
30
32
 
31
- def after_pull
32
- p "after pull"
33
+ [:test, :after_pull].each do |method|
34
+ define_method method do |&block|
35
+ instance_variable_set("@#{method}", block)
36
+ end
37
+ define_method "run_#{method}" do
38
+ callback = instance_variable_get("@#{method}")
39
+ if callback.respond_to?(:call)
40
+ callback.call
41
+ else
42
+ warn "define #{method}"
43
+ end
44
+ end
33
45
  end
34
46
 
35
47
  private
@@ -45,18 +57,18 @@ module Submodule
45
57
  if hash_before == hash_after
46
58
  abort "submodule #{@submodule_name} already up-to-date"
47
59
  end
48
- test
60
+ run_test
49
61
  update_version hash_after
50
62
  cd @cwd
51
63
  git_add
52
- after_pull
64
+ run_after_pull
53
65
  git_commit hash_after
54
66
  end
55
67
  desc "Test submodule #{@submodule_name}"
56
68
  task "submodule:test" do
57
69
  git_update
58
70
  cd path
59
- test
71
+ run_test
60
72
  cd @cwd
61
73
  end
62
74
  self
@@ -77,7 +89,7 @@ module Submodule
77
89
 
78
90
  def git_pull
79
91
  sh "git clean -f"
80
- sh "git checkout master"
92
+ sh "git checkout #{branch}"
81
93
  sh "git pull"
82
94
  # res = my_sh "git pull"
83
95
  # if res =~ /Already up-to-date/
@@ -1,3 +1,3 @@
1
1
  module Submodule
2
- VERSION = "0.0.3"
2
+ VERSION = "0.1.0"
3
3
  end
data/submodule.gemspec CHANGED
File without changes
metadata CHANGED
@@ -1,58 +1,46 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: submodule
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 0
8
- - 3
9
- version: 0.0.3
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
10
6
  platform: ruby
11
- authors:
7
+ authors:
12
8
  - stereobooster
13
9
  autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
-
17
- date: 2012-05-07 00:00:00 +03:00
18
- default_executable:
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
12
+ date: 2012-05-22 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
21
15
  name: rake
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &27841152 !ruby/object:Gem::Requirement
24
17
  none: false
25
- requirements:
26
- - - ">="
27
- - !ruby/object:Gem::Version
28
- segments:
29
- - 0
30
- version: "0"
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
31
22
  type: :runtime
32
- version_requirements: *id001
33
- - !ruby/object:Gem::Dependency
34
- name: inifile
35
23
  prerelease: false
36
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: *27841152
25
+ - !ruby/object:Gem::Dependency
26
+ name: inifile
27
+ requirement: &27840900 !ruby/object:Gem::Requirement
37
28
  none: false
38
- requirements:
39
- - - ">="
40
- - !ruby/object:Gem::Version
41
- segments:
42
- - 0
43
- version: "0"
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
44
33
  type: :runtime
45
- version_requirements: *id002
46
- description: Small gem to simplify building process of gems with git submodules. Tended to be used for ruby gems which wrap js libraries or another assets
47
- email:
34
+ prerelease: false
35
+ version_requirements: *27840900
36
+ description: Small gem to simplify building process of gems with git submodules. Tended
37
+ to be used for ruby gems which wrap js libraries or another assets
38
+ email:
48
39
  - stereobooster@gmail.com
49
40
  executables: []
50
-
51
41
  extensions: []
52
-
53
42
  extra_rdoc_files: []
54
-
55
- files:
43
+ files:
56
44
  - .gitignore
57
45
  - Gemfile
58
46
  - README.md
@@ -60,37 +48,34 @@ files:
60
48
  - lib/submodule.rb
61
49
  - lib/submodule/version.rb
62
50
  - submodule.gemspec
63
- has_rdoc: true
64
51
  homepage: https://github.com/stereobooster/submodule
65
52
  licenses: []
66
-
67
53
  post_install_message:
68
54
  rdoc_options: []
69
-
70
- require_paths:
55
+ require_paths:
71
56
  - lib
72
- required_ruby_version: !ruby/object:Gem::Requirement
57
+ required_ruby_version: !ruby/object:Gem::Requirement
73
58
  none: false
74
- requirements:
75
- - - ">="
76
- - !ruby/object:Gem::Version
77
- segments:
59
+ requirements:
60
+ - - ! '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ segments:
78
64
  - 0
79
- version: "0"
80
- required_rubygems_version: !ruby/object:Gem::Requirement
65
+ hash: -511528945
66
+ required_rubygems_version: !ruby/object:Gem::Requirement
81
67
  none: false
82
- requirements:
83
- - - ">="
84
- - !ruby/object:Gem::Version
85
- segments:
68
+ requirements:
69
+ - - ! '>='
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ segments:
86
73
  - 0
87
- version: "0"
74
+ hash: -511528945
88
75
  requirements: []
89
-
90
76
  rubyforge_project:
91
- rubygems_version: 1.3.7
77
+ rubygems_version: 1.8.15
92
78
  signing_key:
93
79
  specification_version: 3
94
80
  summary: Small gem to simplify building process of gems with git submodules
95
81
  test_files: []
96
-