hw 0.3.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,4 @@
1
+ require 'pry'
1
2
  require 'hw/base'
2
3
 
3
4
  module HW
@@ -13,7 +14,7 @@ module HW
13
14
  packages = Hash.new
14
15
 
15
16
  if ARGV.empty?
16
- SOURCES.keys.each do |directory|
17
+ sources.keys.each do |directory|
17
18
  full_path = File.join(SOURCES_PATH, directory, "*.rb")
18
19
 
19
20
  Dir[full_path].each do |file|
@@ -33,7 +34,7 @@ module HW
33
34
  require 'hw/packages/system'
34
35
  register(HW::Packages::System, "system", "system <command>", "Perform system commands")
35
36
  else
36
- SOURCES.keys.each do |directory|
37
+ sources.keys.each do |directory|
37
38
  full_path = File.join(SOURCES_PATH, directory, "#{name}.rb")
38
39
  packages[name] = full_path if File.exists?(full_path)
39
40
  end
@@ -16,17 +16,26 @@ module HW
16
16
  invoke :add_source, ["default", DEFAULT_SOURCE]
17
17
  end
18
18
 
19
- SOURCES.each do |name, url|
19
+ # Iterate through sources and take appropriate actions. TODO: Refactor.
20
+ Thor.sources.each do |name, url|
20
21
  begin
21
- repo_path = "#{SOURCES_PATH}/#{name}"
22
+ path = "#{SOURCES_PATH}/#{name}"
23
+ local = Thor.local?(url)
22
24
 
23
- if File.exists?(repo_path)
24
- Git.open(repo_path).pull
25
+ unless local
26
+ if File.exists?(path)
27
+ Git.open(path).pull
28
+ else
29
+ Git.clone(url, name, :path => SOURCES_PATH) unless local
30
+ end
31
+ end
32
+
33
+ if local and !File.exists?(url)
34
+ error "Local directory '#{url}' not found. Please check your sources at #{CONFIG_PATH}"
25
35
  else
26
- Git.clone(url, name, :path => SOURCES_PATH)
36
+ success "Successfully pulled updates from #{url} to #{SOURCES_PATH}#{name}"
27
37
  end
28
- success "Successfully pulled updates from #{url} to #{SOURCES_PATH}#{name}"
29
- rescue Git::GitExecuteError
38
+ rescue Git::GitExecuteError => e
30
39
  warn "Nothing was pulled from #{url}"
31
40
  end
32
41
  end
@@ -1,14 +1,13 @@
1
1
  module HW
2
2
  module Utilities
3
- extend ActiveSupport::Concern
3
+ DEFAULT_SOURCE = "git@github.com:carrot/hw-packages.git"
4
+ DIRECTORY = File.expand_path("~/.hw/")
5
+ CONFIG_PATH = "#{DIRECTORY}/config"
6
+ SOURCES_PATH = "#{DIRECTORY}/sources/"
7
+ RESERVED_WORDS = %w(help system)
4
8
 
5
- included do
6
- DEFAULT_SOURCE = "git@github.com:carrot/hw-packages.git"
7
- DIRECTORY = File.expand_path("~/.hw/")
8
- CONFIG_PATH = "#{DIRECTORY}/config"
9
- SOURCES_PATH = "#{DIRECTORY}/sources/"
10
- RESERVED_WORDS = %w(help system)
11
- SOURCES = self.sources
9
+ def self.included(base) #:nodoc:
10
+ base.extend ClassMethods
12
11
  end
13
12
 
14
13
  module ClassMethods
@@ -18,7 +17,13 @@ module HW
18
17
 
19
18
  File.readlines(CONFIG_PATH).each do |line|
20
19
  source = line.split("=")
21
- sources[source[0]] = source[1].strip
20
+ path = source[1].strip
21
+
22
+ if self.local?(path)
23
+ path = File.expand_path(path)
24
+ end
25
+
26
+ sources[source[0]] = path
22
27
  end
23
28
 
24
29
  sources
@@ -26,6 +31,11 @@ module HW
26
31
  {}
27
32
  end
28
33
  end
34
+
35
+ def local? path
36
+ git_regex = /([A-Za-z0-9]+@|http(|s)\:\/\/)([A-Za-z0-9.]+)(:|\/)([A-Za-z0-9\-\/]+)/
37
+ (path =~ git_regex).nil?
38
+ end
29
39
  end
30
40
  end
31
41
  end
@@ -1,3 +1,3 @@
1
1
  module HW
2
- VERSION = "0.3.0"
2
+ VERSION = "1.0.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hw
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 1.0.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-05 00:00:00.000000000 Z
12
+ date: 2013-02-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
16
- requirement: &70278592665240 !ruby/object:Gem::Requirement
16
+ requirement: &70195226163260 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70278592665240
24
+ version_requirements: *70195226163260
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: thor
27
- requirement: &70278592653920 !ruby/object:Gem::Requirement
27
+ requirement: &70195226162660 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -35,10 +35,10 @@ dependencies:
35
35
  version: '2.0'
36
36
  type: :runtime
37
37
  prerelease: false
38
- version_requirements: *70278592653920
38
+ version_requirements: *70195226162660
39
39
  - !ruby/object:Gem::Dependency
40
40
  name: rails
41
- requirement: &70278592651820 !ruby/object:Gem::Requirement
41
+ requirement: &70195226161660 !ruby/object:Gem::Requirement
42
42
  none: false
43
43
  requirements:
44
44
  - - ! '>='
@@ -46,10 +46,10 @@ dependencies:
46
46
  version: '0'
47
47
  type: :runtime
48
48
  prerelease: false
49
- version_requirements: *70278592651820
49
+ version_requirements: *70195226161660
50
50
  - !ruby/object:Gem::Dependency
51
51
  name: rake
52
- requirement: &70278592651140 !ruby/object:Gem::Requirement
52
+ requirement: &70195226160960 !ruby/object:Gem::Requirement
53
53
  none: false
54
54
  requirements:
55
55
  - - ! '>='
@@ -57,10 +57,10 @@ dependencies:
57
57
  version: '0'
58
58
  type: :runtime
59
59
  prerelease: false
60
- version_requirements: *70278592651140
60
+ version_requirements: *70195226160960
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: httparty
63
- requirement: &70278592650380 !ruby/object:Gem::Requirement
63
+ requirement: &70195226160300 !ruby/object:Gem::Requirement
64
64
  none: false
65
65
  requirements:
66
66
  - - ! '>='
@@ -68,10 +68,10 @@ dependencies:
68
68
  version: '0'
69
69
  type: :runtime
70
70
  prerelease: false
71
- version_requirements: *70278592650380
71
+ version_requirements: *70195226160300
72
72
  - !ruby/object:Gem::Dependency
73
73
  name: pg
74
- requirement: &70278592649580 !ruby/object:Gem::Requirement
74
+ requirement: &70195226195620 !ruby/object:Gem::Requirement
75
75
  none: false
76
76
  requirements:
77
77
  - - ! '>='
@@ -79,10 +79,10 @@ dependencies:
79
79
  version: '0'
80
80
  type: :runtime
81
81
  prerelease: false
82
- version_requirements: *70278592649580
82
+ version_requirements: *70195226195620
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: git
85
- requirement: &70278592648940 !ruby/object:Gem::Requirement
85
+ requirement: &70195226193480 !ruby/object:Gem::Requirement
86
86
  none: false
87
87
  requirements:
88
88
  - - ! '>='
@@ -90,10 +90,10 @@ dependencies:
90
90
  version: '0'
91
91
  type: :runtime
92
92
  prerelease: false
93
- version_requirements: *70278592648940
93
+ version_requirements: *70195226193480
94
94
  - !ruby/object:Gem::Dependency
95
95
  name: rspec-rails
96
- requirement: &70278592648280 !ruby/object:Gem::Requirement
96
+ requirement: &70195226191800 !ruby/object:Gem::Requirement
97
97
  none: false
98
98
  requirements:
99
99
  - - ! '>='
@@ -101,10 +101,10 @@ dependencies:
101
101
  version: '0'
102
102
  type: :development
103
103
  prerelease: false
104
- version_requirements: *70278592648280
104
+ version_requirements: *70195226191800
105
105
  - !ruby/object:Gem::Dependency
106
106
  name: ruby-prof
107
- requirement: &70278592647560 !ruby/object:Gem::Requirement
107
+ requirement: &70195226190740 !ruby/object:Gem::Requirement
108
108
  none: false
109
109
  requirements:
110
110
  - - ! '>='
@@ -112,10 +112,10 @@ dependencies:
112
112
  version: '0'
113
113
  type: :development
114
114
  prerelease: false
115
- version_requirements: *70278592647560
115
+ version_requirements: *70195226190740
116
116
  - !ruby/object:Gem::Dependency
117
117
  name: debugger
118
- requirement: &70278592646380 !ruby/object:Gem::Requirement
118
+ requirement: &70195226189640 !ruby/object:Gem::Requirement
119
119
  none: false
120
120
  requirements:
121
121
  - - ! '>='
@@ -123,10 +123,10 @@ dependencies:
123
123
  version: '0'
124
124
  type: :development
125
125
  prerelease: false
126
- version_requirements: *70278592646380
126
+ version_requirements: *70195226189640
127
127
  - !ruby/object:Gem::Dependency
128
128
  name: ronn
129
- requirement: &70278592645660 !ruby/object:Gem::Requirement
129
+ requirement: &70195226188440 !ruby/object:Gem::Requirement
130
130
  none: false
131
131
  requirements:
132
132
  - - ! '>='
@@ -134,10 +134,10 @@ dependencies:
134
134
  version: '0'
135
135
  type: :development
136
136
  prerelease: false
137
- version_requirements: *70278592645660
137
+ version_requirements: *70195226188440
138
138
  - !ruby/object:Gem::Dependency
139
139
  name: rspec
140
- requirement: &70278592644060 !ruby/object:Gem::Requirement
140
+ requirement: &70195226050180 !ruby/object:Gem::Requirement
141
141
  none: false
142
142
  requirements:
143
143
  - - ~>
@@ -145,10 +145,21 @@ dependencies:
145
145
  version: '2.11'
146
146
  type: :development
147
147
  prerelease: false
148
- version_requirements: *70278592644060
148
+ version_requirements: *70195226050180
149
+ - !ruby/object:Gem::Dependency
150
+ name: pry
151
+ requirement: &70195226049200 !ruby/object:Gem::Requirement
152
+ none: false
153
+ requirements:
154
+ - - ! '>='
155
+ - !ruby/object:Gem::Version
156
+ version: '0'
157
+ type: :development
158
+ prerelease: false
159
+ version_requirements: *70195226049200
149
160
  - !ruby/object:Gem::Dependency
150
161
  name: sqlite3
151
- requirement: &70278592638880 !ruby/object:Gem::Requirement
162
+ requirement: &70195226043560 !ruby/object:Gem::Requirement
152
163
  none: false
153
164
  requirements:
154
165
  - - ! '>='
@@ -156,7 +167,7 @@ dependencies:
156
167
  version: '0'
157
168
  type: :development
158
169
  prerelease: false
159
- version_requirements: *70278592638880
170
+ version_requirements: *70195226043560
160
171
  description: Package manager for random tasks
161
172
  email:
162
173
  - tmilewski@gmail.com