ronin-support 0.1.0.rc1 → 0.1.0.rc2

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,5 +1,3 @@
1
- require 'ore/specification'
2
-
3
1
  source 'https://rubygems.org'
4
2
 
5
3
  gemspec
@@ -11,9 +9,14 @@ end
11
9
  group :development do
12
10
  gem 'rake', '~> 0.8.7'
13
11
 
14
- gem 'ore-core', '~> 0.1.1'
15
- gem 'ore-tasks', '~> 0.3.0'
16
- gem 'rspec', '~> 2.3.0'
12
+ gem 'ore-tasks', '~> 0.4'
13
+ gem 'rspec', '~> 2.4'
14
+
15
+ gem 'kramdown', '~> 0.12'
16
+ end
17
17
 
18
- gem 'kramdown', '~> 0.12.0'
18
+ group :test do
19
+ gem 'i18n', '~> 0.4'
20
+ gem 'tzinfo', '~> 0.3.0'
21
+ gem 'activesupport', '~> 3.0.0'
19
22
  end
data/gemspec.yml CHANGED
@@ -10,13 +10,14 @@ email: postmodern.mod3@gmail.com
10
10
  homepage: http://github.com/ronin-ruby/ronin-support
11
11
  has_yard: true
12
12
 
13
- required_ruby_version: >= 1.8.7
13
+ required_ruby_version: ">= 1.8.7"
14
14
 
15
15
  dependencies:
16
- chars: ~> 0.2.0
17
- uri-query_params: ~> 0.5.2
18
- data_paths: ~> 0.2.1
16
+ chars: ~> 0.2
17
+ combinatorics: ~> 0.3
18
+ uri-query_params: ~> 0.5, >= 0.5.2
19
+ data_paths: ~> 0.2, >= 0.2.1
19
20
 
20
21
  development_dependencies:
21
- bundler: ~> 1.0.0
22
+ bundler: ~> 1.0.10
22
23
  yard: ~> 0.6.4
@@ -20,6 +20,7 @@
20
20
  require 'ipaddr'
21
21
  require 'resolv'
22
22
  require 'strscan'
23
+ require 'combinatorics/list_comprehension'
23
24
 
24
25
  class IPAddr
25
26
 
@@ -135,38 +136,29 @@ class IPAddr
135
136
  end
136
137
 
137
138
  # split the address
138
- ranges = cidr_or_glob.split(separator)
139
+ segments = cidr_or_glob.split(separator)
140
+ ranges = []
139
141
 
140
142
  # map the components of the address to numeric ranges
141
- ranges.map! do |segment|
142
- if segment == '*'
143
- (1..254)
144
- elsif segment.include?('-')
145
- start, stop = segment.split('-',2).map { |i| i.to_i(base) }
146
-
147
- (start..stop)
148
- elsif !(segment.empty?)
149
- segment.to_i(base)
150
- end
143
+ segments.each do |segment|
144
+ next if segment.empty?
145
+
146
+ ranges << if segment == '*'
147
+ (1..254)
148
+ elsif segment.include?('-')
149
+ start, stop = segment.split('-',2)
150
+
151
+ (start.to_i(base)..stop.to_i(base))
152
+ else
153
+ segment.to_i(base)
154
+ end
151
155
  end
152
- ranges.compact!
153
-
154
- expand_range = lambda { |address,remaining|
155
- if remaining.empty?
156
- block.call(format.call(address))
157
- else
158
- n = remaining.first
159
- remaining = remaining[1..-1]
160
-
161
- if n.kind_of?(Range)
162
- n.each { |i| expand_range.call(address + [i], remaining) }
163
- else
164
- expand_range.call(address + [n], remaining)
165
- end
166
- end
167
- }
168
-
169
- expand_range.call([], ranges)
156
+
157
+ # cycle through the address ranges
158
+ ranges.comprehension do |address|
159
+ yield format[address]
160
+ end
161
+
170
162
  return nil
171
163
  end
172
164
 
@@ -182,7 +182,10 @@ module Ronin
182
182
  # The camel-case HTTP header name.
183
183
  #
184
184
  def HTTP.header_name(name)
185
- name.to_s.split(/[\s+_-]/).map { |word| word.capitalize }.join('-')
185
+ words = name.to_s.split(/[\s+_-]/)
186
+
187
+ words.each { |word| word.capitalize! }
188
+ return words.join('-')
186
189
  end
187
190
 
188
191
  #
data/lib/ronin/path.rb CHANGED
@@ -70,7 +70,8 @@ module Ronin
70
70
  # #<Ronin::Path:../../..>]
71
71
  #
72
72
  def self.up(n,separator=File::SEPARATOR)
73
- if n.kind_of?(Integer)
73
+ case n
74
+ when Integer
74
75
  if n == 0
75
76
  return separator
76
77
  elsif n < 0
@@ -83,7 +84,7 @@ module Ronin
83
84
  dirs = (['..'] * (n-1))
84
85
 
85
86
  return Path.new(path.join(*dirs))
86
- elsif n.kind_of?(Enumerable)
87
+ when Enumerable
87
88
  return n.map { |i| self.up(i) }
88
89
  else
89
90
  raise(ArgumentError,"The first argument of Path.up must be either an Integer or Enumerable")
@@ -105,13 +106,13 @@ module Ronin
105
106
  # # => #<Ronin::Path:../../../../../../../etc/passwd>
106
107
  #
107
108
  def join(*names)
108
- sub_dirs = names.map { |name| name.to_s }
109
+ names.map! { |name| name.to_s }
109
110
 
110
111
  # filter out errant directory separators
111
- sub_dirs.reject! { |dir| dir == @separator }
112
+ names.reject! { |dir| dir == @separator }
112
113
 
113
114
  # join the path
114
- sub_path = sub_dirs.join(@separator)
115
+ sub_path = names.join(@separator)
115
116
 
116
117
  path = if self.root?
117
118
  # prefix the root dir
@@ -17,23 +17,37 @@
17
17
  # along with Ronin Support. If not, see <http://www.gnu.org/licenses/>.
18
18
  #
19
19
 
20
- begin
21
- require 'active_support/inflector'
22
- rescue LoadError
23
- begin
24
- require 'extlib/inflection'
25
- rescue LoadError
26
- raise(LoadError,"unable to load 'active_support/inflector' or 'extlib/inflection'",caller)
27
- end
28
- end
29
-
30
20
  module Ronin
31
21
  module Support
32
- # The Inflector that Ronin will use.
33
- Inflector = if Object.const_defined?(:ActiveSupport)
34
- ActiveSupport::Inflector
35
- else
36
- Extlib::Inflection
37
- end
22
+ inflectors = [
23
+ {
24
+ :path => 'dm-core/support/inflector',
25
+ :const => 'DataMapper::Inflector'
26
+ },
27
+ {
28
+ :path => 'active_support/inflector',
29
+ :const => 'ActiveSupport::Inflector'
30
+ },
31
+ {
32
+ :path => 'extlib/inflection',
33
+ :const => 'Extlib::Inflection'
34
+ }
35
+ ]
36
+ inflector_const = 'Inflector'
37
+
38
+ inflectors.each do |inflector|
39
+ begin
40
+ require inflector[:path]
41
+ rescue LoadError
42
+ next
43
+ end
44
+
45
+ const_set(inflector_const, eval("::#{inflector[:const]}"))
46
+ break
47
+ end
48
+
49
+ unless const_defined?(inflector_const)
50
+ raise(LoadError,"unable to load or find any Inflectors")
51
+ end
38
52
  end
39
53
  end
@@ -20,6 +20,6 @@
20
20
  module Ronin
21
21
  module Support
22
22
  # ronin-support version
23
- VERSION = '0.1.0.rc1'
23
+ VERSION = '0.1.0.rc2'
24
24
  end
25
25
  end
@@ -9,7 +9,7 @@ rescue NameError
9
9
  require 'ore/specification'
10
10
  retry
11
11
  rescue LoadError
12
- STDERR.puts "The 'ronin-support.gemspec' file requires Ore."
12
+ STDERR.puts "The '#{__FILE__}' file requires Ore."
13
13
  STDERR.puts "Run `gem install ore-core` to install Ore."
14
14
  end
15
15
  end
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+ require 'ronin/support/inflector'
3
+
4
+ describe "Ronin::Support::Inflector" do
5
+ subject { Ronin::Support::Inflector }
6
+
7
+ it "should not be nil" do
8
+ subject.should_not be_nil
9
+ end
10
+
11
+ it "should support pluralizing words" do
12
+ subject.pluralize('word').should == 'words'
13
+ end
14
+
15
+ it "should support singularizing words" do
16
+ subject.singularize('words').should == 'word'
17
+ end
18
+
19
+ it "should support humanizing words" do
20
+ subject.humanize('word_id').should == 'Word'
21
+ end
22
+ end
metadata CHANGED
@@ -1,13 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ronin-support
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: true
5
- segments:
6
- - 0
7
- - 1
8
- - 0
9
- - rc1
10
- version: 0.1.0.rc1
4
+ prerelease: 6
5
+ version: 0.1.0.rc2
11
6
  platform: ruby
12
7
  authors:
13
8
  - Postmodern
@@ -15,7 +10,7 @@ autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
12
 
18
- date: 2011-01-26 00:00:00 -08:00
13
+ date: 2011-03-06 00:00:00 -08:00
19
14
  default_executable:
20
15
  dependencies:
21
16
  - !ruby/object:Gem::Dependency
@@ -25,76 +20,74 @@ dependencies:
25
20
  requirements:
26
21
  - - ~>
27
22
  - !ruby/object:Gem::Version
28
- segments:
29
- - 0
30
- - 2
31
- - 0
32
- version: 0.2.0
23
+ version: "0.2"
33
24
  type: :runtime
34
25
  prerelease: false
35
26
  version_requirements: *id001
36
27
  - !ruby/object:Gem::Dependency
37
- name: uri-query_params
28
+ name: combinatorics
38
29
  requirement: &id002 !ruby/object:Gem::Requirement
39
30
  none: false
40
31
  requirements:
41
32
  - - ~>
42
33
  - !ruby/object:Gem::Version
43
- segments:
44
- - 0
45
- - 5
46
- - 2
47
- version: 0.5.2
34
+ version: "0.3"
48
35
  type: :runtime
49
36
  prerelease: false
50
37
  version_requirements: *id002
51
38
  - !ruby/object:Gem::Dependency
52
- name: data_paths
39
+ name: uri-query_params
53
40
  requirement: &id003 !ruby/object:Gem::Requirement
54
41
  none: false
55
42
  requirements:
56
43
  - - ~>
57
44
  - !ruby/object:Gem::Version
58
- segments:
59
- - 0
60
- - 2
61
- - 1
62
- version: 0.2.1
45
+ version: "0.5"
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: 0.5.2
63
49
  type: :runtime
64
50
  prerelease: false
65
51
  version_requirements: *id003
66
52
  - !ruby/object:Gem::Dependency
67
- name: bundler
53
+ name: data_paths
68
54
  requirement: &id004 !ruby/object:Gem::Requirement
69
55
  none: false
70
56
  requirements:
71
57
  - - ~>
72
58
  - !ruby/object:Gem::Version
73
- segments:
74
- - 1
75
- - 0
76
- - 0
77
- version: 1.0.0
78
- type: :development
59
+ version: "0.2"
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: 0.2.1
63
+ type: :runtime
79
64
  prerelease: false
80
65
  version_requirements: *id004
81
66
  - !ruby/object:Gem::Dependency
82
- name: yard
67
+ name: bundler
83
68
  requirement: &id005 !ruby/object:Gem::Requirement
84
69
  none: false
85
70
  requirements:
86
71
  - - ~>
87
72
  - !ruby/object:Gem::Version
88
- segments:
89
- - 0
90
- - 6
91
- - 4
92
- version: 0.6.4
73
+ version: 1.0.10
93
74
  type: :development
94
75
  prerelease: false
95
76
  version_requirements: *id005
77
+ - !ruby/object:Gem::Dependency
78
+ name: yard
79
+ requirement: &id006 !ruby/object:Gem::Requirement
80
+ none: false
81
+ requirements:
82
+ - - ~>
83
+ - !ruby/object:Gem::Version
84
+ version: 0.6.4
85
+ type: :development
86
+ prerelease: false
87
+ version_requirements: *id006
96
88
  description: Ronin Support is a support library for Ronin. Ronin Support contains many of the convenience methods used by Ronin and additional libraries.
97
- email: postmodern.mod3@gmail.com
89
+ email:
90
+ - postmodern.mod3@gmail.com
98
91
  executables: []
99
92
 
100
93
  extensions: []
@@ -223,6 +216,7 @@ files:
223
216
  - spec/network/ssl_spec.rb
224
217
  - spec/path_spec.rb
225
218
  - spec/spec_helper.rb
219
+ - spec/support/inflector_spec.rb
226
220
  - spec/support_spec.rb
227
221
  - spec/templates/classes/example_erb.rb
228
222
  - spec/templates/classes/example_template.rb
@@ -245,25 +239,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
245
239
  requirements:
246
240
  - - ">="
247
241
  - !ruby/object:Gem::Version
248
- segments:
249
- - 1
250
- - 8
251
- - 7
252
242
  version: 1.8.7
253
243
  required_rubygems_version: !ruby/object:Gem::Requirement
254
244
  none: false
255
245
  requirements:
256
246
  - - ">="
257
247
  - !ruby/object:Gem::Version
258
- segments:
259
- - 1
260
- - 3
261
- - 6
262
248
  version: 1.3.6
263
249
  requirements: []
264
250
 
265
251
  rubyforge_project: ronin-support
266
- rubygems_version: 1.3.7
252
+ rubygems_version: 1.5.2
267
253
  signing_key:
268
254
  specification_version: 3
269
255
  summary: A support library for Ronin.
@@ -274,6 +260,7 @@ test_files:
274
260
  - spec/network/ssl_spec.rb
275
261
  - spec/templates/erb_spec.rb
276
262
  - spec/templates/template_spec.rb
263
+ - spec/support/inflector_spec.rb
277
264
  - spec/path_spec.rb
278
265
  - spec/extensions/file_spec.rb
279
266
  - spec/extensions/kernel_spec.rb