sugar-high 0.2.2 → 0.2.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.
- data/.document +0 -0
- data/.gitignore +0 -0
- data/.rspec +0 -0
- data/LICENSE +0 -0
- data/README.markdown +0 -0
- data/Rakefile +0 -0
- data/VERSION +1 -1
- data/lib/sugar-high.rb +0 -0
- data/lib/sugar-high/alias.rb +0 -0
- data/lib/sugar-high/arguments.rb +0 -0
- data/lib/sugar-high/array.rb +6 -7
- data/lib/sugar-high/blank.rb +0 -0
- data/lib/sugar-high/file.rb +5 -1
- data/lib/sugar-high/hash.rb +0 -0
- data/lib/sugar-high/includes.rb +0 -0
- data/lib/sugar-high/kind_of.rb +0 -0
- data/lib/sugar-high/metaclass.rb +0 -0
- data/lib/sugar-high/methods.rb +0 -0
- data/lib/sugar-high/module.rb +0 -0
- data/lib/sugar-high/not.rb +0 -0
- data/lib/sugar-high/path.rb +0 -0
- data/lib/sugar-high/regexp.rb +0 -0
- data/lib/sugar-high/rspec/configure.rb +0 -0
- data/lib/sugar-high/rspec/matchers/have_aliases.rb +0 -0
- data/spec/fixtures/empty.txt +0 -0
- data/spec/fixtures/non-empty.txt +0 -0
- data/spec/spec_helper.rb +0 -0
- data/spec/sugar-high/alias_spec.rb +0 -0
- data/spec/sugar-high/arguments_spec.rb +0 -0
- data/spec/sugar-high/array_spec.rb +0 -0
- data/spec/sugar-high/blank_spec.rb +0 -0
- data/spec/sugar-high/file/file_mutate_spec.rb +19 -6
- data/spec/sugar-high/file/file_spec.rb +0 -0
- data/spec/sugar-high/includes_spec.rb +0 -0
- data/spec/sugar-high/kind_of_spec.rb +0 -0
- data/spec/sugar-high/methods_spec.rb +0 -0
- data/spec/sugar-high/module_spec.rb +0 -0
- data/spec/sugar-high/path_spec.rb +0 -0
- data/spec/sugar-high/regexp_spec.rb +0 -0
- data/sugar-high.gemspec +2 -2
- metadata +3 -3
data/.document
CHANGED
File without changes
|
data/.gitignore
CHANGED
File without changes
|
data/.rspec
CHANGED
File without changes
|
data/LICENSE
CHANGED
File without changes
|
data/README.markdown
CHANGED
File without changes
|
data/Rakefile
CHANGED
File without changes
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.4
|
data/lib/sugar-high.rb
CHANGED
File without changes
|
data/lib/sugar-high/alias.rb
CHANGED
File without changes
|
data/lib/sugar-high/arguments.rb
CHANGED
File without changes
|
data/lib/sugar-high/array.rb
CHANGED
@@ -3,12 +3,11 @@ require 'sugar-high/kind_of'
|
|
3
3
|
class Array
|
4
4
|
def to_symbols option=nil
|
5
5
|
res = self.flatten
|
6
|
-
res
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
res.map(&:to_s).map(&:to_sym)
|
6
|
+
res.map!{|a| a.kind_of?(Fixnum) ? "_#{a}" : a} if option == :num
|
7
|
+
res.select_labels.map(&:to_s).map(&:to_sym)
|
8
|
+
end
|
9
|
+
|
10
|
+
def to_strings option=nil
|
11
|
+
self.select_labels.map(&:to_s)
|
13
12
|
end
|
14
13
|
end
|
data/lib/sugar-high/blank.rb
CHANGED
File without changes
|
data/lib/sugar-high/file.rb
CHANGED
@@ -35,6 +35,10 @@ class File
|
|
35
35
|
f.puts content ||= yield
|
36
36
|
end
|
37
37
|
end
|
38
|
+
|
39
|
+
def self.remove_from file_name, content, &block
|
40
|
+
replace_content_from file_name, :content => content, :with => '', &block
|
41
|
+
end
|
38
42
|
|
39
43
|
# replaces content found at replacement_expr with content resulting from yielding block
|
40
44
|
# File.replace_content_from 'myfile.txt', where => /HelloWorld/, with => 'GoodBye'
|
@@ -150,7 +154,7 @@ class File
|
|
150
154
|
when String
|
151
155
|
args.first
|
152
156
|
when Hash
|
153
|
-
options[:content] || yield if block
|
157
|
+
options[:content] || (yield if block)
|
154
158
|
else
|
155
159
|
return yield if block
|
156
160
|
raise ArgumentError, "You must supply content to insert, either as a String before the options hash, a :content option or a block"
|
data/lib/sugar-high/hash.rb
CHANGED
File without changes
|
data/lib/sugar-high/includes.rb
CHANGED
File without changes
|
data/lib/sugar-high/kind_of.rb
CHANGED
File without changes
|
data/lib/sugar-high/metaclass.rb
CHANGED
File without changes
|
data/lib/sugar-high/methods.rb
CHANGED
File without changes
|
data/lib/sugar-high/module.rb
CHANGED
File without changes
|
data/lib/sugar-high/not.rb
CHANGED
File without changes
|
data/lib/sugar-high/path.rb
CHANGED
File without changes
|
data/lib/sugar-high/regexp.rb
CHANGED
File without changes
|
File without changes
|
File without changes
|
data/spec/fixtures/empty.txt
CHANGED
File without changes
|
data/spec/fixtures/non-empty.txt
CHANGED
File without changes
|
data/spec/spec_helper.rb
CHANGED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -46,6 +46,18 @@ describe "SugarHigh::File" do
|
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
|
+
describe '#remove_from with String/Regexp argument that is content to remove' do
|
50
|
+
let(:replace_file) { fixture_file 'file.txt' }
|
51
|
+
|
52
|
+
it "should remove content from existing file" do
|
53
|
+
File.overwrite(replace_file) do
|
54
|
+
'Hello You'
|
55
|
+
end
|
56
|
+
File.remove_from replace_file, 'You'
|
57
|
+
File.read(replace_file).should_not match /You/
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
49
61
|
|
50
62
|
describe '#insert_into' do
|
51
63
|
let(:insertion_file) { fixture_file 'insertion.txt' }
|
@@ -64,28 +76,29 @@ describe "SugarHigh::File" do
|
|
64
76
|
File.insert_into insertion_file, :before => 'Goodbye' do
|
65
77
|
'Hello'
|
66
78
|
end
|
79
|
+
File.read(insertion_file).should match /Hello\s+Goodbye/
|
67
80
|
end
|
68
81
|
|
69
82
|
it "should insert Hello before Goodbye using a content string arg" do
|
70
83
|
File.insert_into insertion_file, "Hello ", :before => 'Goodbye'
|
71
|
-
File.read(insertion_file).
|
84
|
+
File.read(insertion_file).should match /Hello\s+Goodbye/
|
72
85
|
end
|
73
86
|
|
74
87
|
it "should insert Hello before Goodbye using a :content option" do
|
75
|
-
File.insert_into insertion_file, :content => 'Hello
|
76
|
-
File.read(insertion_file).
|
88
|
+
File.insert_into insertion_file, :content => 'Hello', :before => 'Goodbye'
|
89
|
+
File.read(insertion_file).should match /Hello\s+Goodbye/
|
77
90
|
end
|
78
91
|
|
79
92
|
it "should insert Hello before Goodbye using a block as content to insert" do
|
80
93
|
File.insert_into insertion_file, :before => 'Goodbye' do
|
81
|
-
'Hello
|
94
|
+
'Hello'
|
82
95
|
end
|
83
|
-
File.read(insertion_file).
|
96
|
+
File.read(insertion_file).should match /Hello\s+Goodbye/
|
84
97
|
end
|
85
98
|
|
86
99
|
it "should insert Hello after Goodbye using a :with option and a Regexp for the after expression" do
|
87
100
|
File.insert_into insertion_file, :content => ' Hello', :after => /Goodbye/
|
88
|
-
File.read(insertion_file).
|
101
|
+
File.read(insertion_file).should match /Goodbye\s+Hello/
|
89
102
|
end
|
90
103
|
end
|
91
104
|
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/sugar-high.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{sugar-high}
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.4"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Kristian Mandrup"]
|
12
|
-
s.date = %q{2010-09-
|
12
|
+
s.date = %q{2010-09-13}
|
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 = [
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 2
|
8
|
-
-
|
9
|
-
version: 0.2.
|
8
|
+
- 4
|
9
|
+
version: 0.2.4
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Kristian Mandrup
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-09-
|
17
|
+
date: 2010-09-13 00:00:00 +02:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|