sugar-high 0.4.6.3 → 0.4.6.4

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.
@@ -10,16 +10,33 @@ Inspired by the 'zucker' project.
10
10
 
11
11
  See specs for example use
12
12
 
13
+ ## Update June 22, 2011
14
+
15
+ file_mutate is now backwards compatible again in order nt to break gems such as cream et. al. that depend on auto inclusion of all File extensions into
16
+ File object
17
+
13
18
  ## Sugar packs
14
19
 
15
20
  * alias
16
21
  * arguments
22
+ * array
23
+ * blank
24
+ * class_ext
25
+ * enumerable
17
26
  * file
27
+ * file_mutate (backwards compatible)
28
+ * file_mutation
29
+ * includes
18
30
  * kind_of
31
+ * math
19
32
  * metaclass
20
33
  * methods
21
34
  * module
22
- * string
35
+ * not
36
+ * numeric
37
+ * path
38
+ * properties
39
+ * reg_exp
23
40
 
24
41
  ### Alias
25
42
 
@@ -29,6 +46,48 @@ See specs for example use
29
46
 
30
47
  * args (Used in generator CLI testing)
31
48
  * last_option *args : Returns last argument if hash or empty hash otherwise
49
+ * ...
50
+
51
+ ### Array
52
+
53
+ * to_symbols
54
+ * to_symbols_uniq
55
+ * to_strings
56
+ * flat_uniq
57
+ * file_join
58
+ * ...
59
+
60
+ ### Blank
61
+
62
+ * blank?
63
+
64
+ ### Class Extension
65
+
66
+ * is_class?
67
+ * is_module?
68
+ * class_exists?
69
+ * module_exists?
70
+ * try_class
71
+ * try_module
72
+ * try_module_only
73
+ * find_first_class(*class_names)
74
+ * find_first_module(*module_names)
75
+
76
+ ### Enumerable
77
+
78
+ * only_kinds_of?(*modules)
79
+ * only_labels?
80
+ * select_kinds_of(*modules)
81
+ * select_kinds_of!
82
+ * select_labels
83
+ * select_labels!
84
+ * select_symbols
85
+ * select_symbols!
86
+ * select_uniq_symbols!
87
+ * select_strings
88
+ * select_strings!
89
+ * select_only(type)
90
+ * select_only!(type)
32
91
 
33
92
  ### Hash
34
93
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.6.3
1
+ 0.4.6.4
@@ -1,58 +1,2 @@
1
- require 'sugar-high/blank'
2
- require 'sugar-high/arguments'
3
- require 'sugar-high/path'
4
- require 'sugar-high/regexp'
5
- require 'sugar-high/string'
6
- require 'sugar-high/file'
7
- require 'sugar-high/array'
8
-
9
- require 'sugar-high/file_mutate/delete'
10
- require 'sugar-high/file_mutate/overwrite_content'
11
- require 'sugar-high/file_mutate/append_content'
12
- require 'sugar-high/file_mutate/remove_content'
13
- require 'sugar-high/file_mutate/replace_content'
14
- require 'sugar-high/file_mutate/insert_content'
15
-
16
- require 'sugar-high/class_ext'
17
- require 'active_support/inflector'
18
-
19
- module SugarHigh
20
- module FileMutate
21
- autoload :Mutate, 'sugar-high/file_mutate/mutate'
22
- autoload :Delete, 'sugar-high/file_mutate/delete'
23
- autoload :AppendContent, 'sugar-high/file_mutate/append_content'
24
- autoload :InsertContent, 'sugar-high/file_mutate/insert_content'
25
- autoload :OverwriteContent, 'sugar-high/file_mutate/overwrite_content'
26
- autoload :RemoveContent, 'sugar-high/file_mutate/remove_content'
27
- autoload :ReplaceContent, 'sugar-high/file_mutate/replace_content'
28
- end
29
- end
30
-
31
-
32
- class File
33
- def self.mutate_ext name
34
- if name == :all
35
- add_mutate_exts mutate_apis
36
- return
37
- end
38
- raise ArgumentError, "Unknown FileMutate API: #{name}, must be one of: #{mutate_apis}" if !mutate_apis.include? name
39
- add_mutate_exts [:mutate, name]
40
- end
41
-
42
- protected
43
-
44
- def self.mutate_apis
45
- [:delete, :mutate, :append_content, :insert_content, :overwrite_content, :remove_content, :replace_content]
46
- end
47
-
48
- def self.add_mutate_exts *names
49
- names.flat_uniq.each do |api|
50
- ns = "SugarHigh::FileMutate::#{api.to_s.camelize}"
51
- begin
52
- self.send :include, ns.constantize
53
- self.extend "#{ns}::ClassMethods".constantize
54
- end
55
- end
56
- end
57
-
58
- end
1
+ require 'sugar-high/file_mutation'
2
+ File.mutate_ext :all
@@ -0,0 +1,58 @@
1
+ require 'sugar-high/blank'
2
+ require 'sugar-high/arguments'
3
+ require 'sugar-high/path'
4
+ require 'sugar-high/regexp'
5
+ require 'sugar-high/string'
6
+ require 'sugar-high/file'
7
+ require 'sugar-high/array'
8
+
9
+ require 'sugar-high/file_mutate/delete'
10
+ require 'sugar-high/file_mutate/overwrite_content'
11
+ require 'sugar-high/file_mutate/append_content'
12
+ require 'sugar-high/file_mutate/remove_content'
13
+ require 'sugar-high/file_mutate/replace_content'
14
+ require 'sugar-high/file_mutate/insert_content'
15
+
16
+ require 'sugar-high/class_ext'
17
+ require 'active_support/inflector'
18
+
19
+ module SugarHigh
20
+ module FileMutate
21
+ autoload :Mutate, 'sugar-high/file_mutate/mutate'
22
+ autoload :Delete, 'sugar-high/file_mutate/delete'
23
+ autoload :AppendContent, 'sugar-high/file_mutate/append_content'
24
+ autoload :InsertContent, 'sugar-high/file_mutate/insert_content'
25
+ autoload :OverwriteContent, 'sugar-high/file_mutate/overwrite_content'
26
+ autoload :RemoveContent, 'sugar-high/file_mutate/remove_content'
27
+ autoload :ReplaceContent, 'sugar-high/file_mutate/replace_content'
28
+ end
29
+ end
30
+
31
+
32
+ class File
33
+ def self.mutate_ext name
34
+ if name == :all
35
+ add_mutate_exts mutate_apis
36
+ return
37
+ end
38
+ raise ArgumentError, "Unknown FileMutate API: #{name}, must be one of: #{mutate_apis}" if !mutate_apis.include? name
39
+ add_mutate_exts [:mutate, name]
40
+ end
41
+
42
+ protected
43
+
44
+ def self.mutate_apis
45
+ [:delete, :mutate, :append_content, :insert_content, :overwrite_content, :remove_content, :replace_content]
46
+ end
47
+
48
+ def self.add_mutate_exts *names
49
+ names.flat_uniq.each do |api|
50
+ ns = "SugarHigh::FileMutate::#{api.to_s.camelize}"
51
+ begin
52
+ self.send :include, ns.constantize
53
+ self.extend "#{ns}::ClassMethods".constantize
54
+ end
55
+ end
56
+ end
57
+
58
+ end
@@ -1,11 +1,20 @@
1
1
  module NumericCheckExt
2
2
  def is_numeric? arg
3
3
  arg.is_a? Numeric
4
- end
5
-
6
- alias_method :is_num?, :is_numeric?
4
+ end
5
+ alias_method :numeric?, :is_numeric?
7
6
 
8
7
  def check_numeric! arg
9
8
  raise ArgumentError, "Argument must be Numeric" if !is_numeric? arg
10
9
  end
11
10
  end
11
+
12
+ module NumberDslExt
13
+ def thousand
14
+ self * 1000
15
+ end
16
+
17
+ def hundred
18
+ self * 100
19
+ end
20
+ end
@@ -1,7 +1,6 @@
1
1
  require 'spec_helper'
2
2
  require 'sugar-high/file'
3
3
  require 'sugar-high/file_mutate'
4
- File.mutate_ext :all
5
4
 
6
5
  describe "SugarHigh" do
7
6
  describe "File" do
@@ -0,0 +1,52 @@
1
+ require 'spec_helper'
2
+ require 'sugar-high/numeric'
3
+
4
+ class Numeric
5
+ include NumberDslExt
6
+ end
7
+
8
+ module Num
9
+ extend NumericCheckExt
10
+ end
11
+
12
+ describe "SugarHigh" do
13
+ describe 'NumericCheckExt' do
14
+ describe '#numeric?' do
15
+ it 'string "x1" is not numeric' do
16
+ Num.numeric?("x0").should be_false
17
+ end
18
+
19
+ it '123 is numeric' do
20
+ Num.numeric?(123).should be_true
21
+ end
22
+
23
+ it '12.3 is numeric' do
24
+ Num.numeric?(12.3).should be_true
25
+ end
26
+ end
27
+
28
+ describe 'check_numeric!' do
29
+ it 'string "x1" is not numeric' do
30
+ lambda {Num.check_numeric!("x0")}.should raise_error
31
+ end
32
+
33
+ it '123 is numeric' do
34
+ lambda {Num.check_numeric!(123)}.should_not raise_error
35
+ end
36
+ end
37
+ end
38
+
39
+ describe 'NumberDslExt' do
40
+ describe '#hundred' do
41
+ it '2 hundred is 200' do
42
+ 2.hundred.should == 200
43
+ end
44
+ end
45
+ describe '#thousand' do
46
+ it '3 thousand is 3000' do
47
+ 3.thousand.should == 3000
48
+ end
49
+ end
50
+ end
51
+ end
52
+
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{sugar-high}
8
- s.version = "0.4.6.3"
8
+ s.version = "0.4.6.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = [%q{Kristian Mandrup}]
12
- s.date = %q{2011-06-13}
12
+ s.date = %q{2011-06-22}
13
13
  s.description = %q{More Ruby sugar - inspired by the 'zuker' project}
14
14
  s.email = %q{kmandrup@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -40,6 +40,7 @@ Gem::Specification.new do |s|
40
40
  "lib/sugar-high/file_mutate/overwrite_content.rb",
41
41
  "lib/sugar-high/file_mutate/remove_content.rb",
42
42
  "lib/sugar-high/file_mutate/replace_content.rb",
43
+ "lib/sugar-high/file_mutation.rb",
43
44
  "lib/sugar-high/hash.rb",
44
45
  "lib/sugar-high/includes.rb",
45
46
  "lib/sugar-high/kind_of.rb",
@@ -61,7 +62,6 @@ Gem::Specification.new do |s|
61
62
  "spec/fixtures/class_file.txt",
62
63
  "spec/fixtures/content_file.txt",
63
64
  "spec/fixtures/empty.txt",
64
- "spec/fixtures/file.txt",
65
65
  "spec/fixtures/non-empty.txt",
66
66
  "spec/fixtures/routes_file.rb",
67
67
  "spec/fixtures/search_file.txt",
@@ -85,6 +85,7 @@ Gem::Specification.new do |s|
85
85
  "spec/sugar-high/kind_of_spec.rb",
86
86
  "spec/sugar-high/methods_spec.rb",
87
87
  "spec/sugar-high/module_spec.rb",
88
+ "spec/sugar-high/numeric_spec.rb",
88
89
  "spec/sugar-high/path_spec.rb",
89
90
  "spec/sugar-high/properties_spec.rb",
90
91
  "spec/sugar-high/regexp_spec.rb",
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sugar-high
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.6.3
4
+ version: 0.4.6.4
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: 2011-06-13 00:00:00.000000000Z
12
+ date: 2011-06-22 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &2156352420 !ruby/object:Gem::Requirement
16
+ requirement: &2152711460 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: '2.5'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *2156352420
24
+ version_requirements: *2152711460
25
25
  description: More Ruby sugar - inspired by the 'zuker' project
26
26
  email: kmandrup@gmail.com
27
27
  executables: []
@@ -53,6 +53,7 @@ files:
53
53
  - lib/sugar-high/file_mutate/overwrite_content.rb
54
54
  - lib/sugar-high/file_mutate/remove_content.rb
55
55
  - lib/sugar-high/file_mutate/replace_content.rb
56
+ - lib/sugar-high/file_mutation.rb
56
57
  - lib/sugar-high/hash.rb
57
58
  - lib/sugar-high/includes.rb
58
59
  - lib/sugar-high/kind_of.rb
@@ -74,7 +75,6 @@ files:
74
75
  - spec/fixtures/class_file.txt
75
76
  - spec/fixtures/content_file.txt
76
77
  - spec/fixtures/empty.txt
77
- - spec/fixtures/file.txt
78
78
  - spec/fixtures/non-empty.txt
79
79
  - spec/fixtures/routes_file.rb
80
80
  - spec/fixtures/search_file.txt
@@ -98,6 +98,7 @@ files:
98
98
  - spec/sugar-high/kind_of_spec.rb
99
99
  - spec/sugar-high/methods_spec.rb
100
100
  - spec/sugar-high/module_spec.rb
101
+ - spec/sugar-high/numeric_spec.rb
101
102
  - spec/sugar-high/path_spec.rb
102
103
  - spec/sugar-high/properties_spec.rb
103
104
  - spec/sugar-high/regexp_spec.rb
@@ -1 +0,0 @@
1
- Hello Me