mark_facets 0.0.1
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/LICENSE +21 -0
- data/README +3 -0
- data/lib/mark_facets/rails/rails.rb +15 -0
- data/lib/mark_facets/rails/test/authlogic.rb +38 -0
- data/lib/mark_facets/rails/test/decode_json.rb +3 -0
- data/lib/mark_facets/rails/test/delivered_emails.rb +3 -0
- data/lib/mark_facets/rails/test/enable_ssl.rb +3 -0
- data/lib/mark_facets/rails/test/helpers.rb +3 -0
- data/lib/mark_facets/rails/test/rspec/all.rb +5 -0
- data/lib/mark_facets/rails/test/rspec/should/have_same_elements.rb +22 -0
- data/lib/mark_facets/rails/test/rspec/should/render_404.rb +18 -0
- data/lib/mark_facets/ruby/big_decimal.rb +8 -0
- data/lib/mark_facets/ruby/hash.rb +14 -0
- data/lib/mark_facets/ruby/math.rb +19 -0
- data/lib/mark_facets/ruby/ruby.rb +15 -0
- data/lib/mark_facets/ruby/string.rb +42 -0
- data/lib/mark_facets.rb +20 -0
- metadata +97 -0
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2010 markbates
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
if defined?(Authlogic)
|
2
|
+
|
3
|
+
if Rails.v3?
|
4
|
+
|
5
|
+
def login(user = @user)
|
6
|
+
@current_user = user
|
7
|
+
activate_authlogic
|
8
|
+
sess = UserSession.create(user)
|
9
|
+
UserSession.stub!(:find).and_return(sess)
|
10
|
+
end
|
11
|
+
|
12
|
+
def logout
|
13
|
+
@current_user = nil
|
14
|
+
UserSession.stub!(:find).and_return(nil)
|
15
|
+
end
|
16
|
+
|
17
|
+
end # Rails 3
|
18
|
+
|
19
|
+
if Rails.v2?
|
20
|
+
|
21
|
+
def login(user = @user)
|
22
|
+
@current_user = user
|
23
|
+
UserSession.create(user)
|
24
|
+
controller.stub!(:current_user).and_return(user)
|
25
|
+
end
|
26
|
+
|
27
|
+
def logout
|
28
|
+
@current_user = nil
|
29
|
+
controller.stub!(:current_user).and_return(nil)
|
30
|
+
end
|
31
|
+
|
32
|
+
end # Rails 2
|
33
|
+
|
34
|
+
def current_user
|
35
|
+
@current_user
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
if Rails.v3?
|
2
|
+
|
3
|
+
end
|
4
|
+
|
5
|
+
if Rails.v2?
|
6
|
+
def have_same_elements(expected)
|
7
|
+
simple_matcher("equal #{expected.inspect}") do |given, matcher|
|
8
|
+
matcher.failure_message = "expected #{given.inspect} to include the same elements as #{expected.inspect}"
|
9
|
+
matcher.negative_failure_message = "expected #{given.inspect} not to include the same elements as #{expected.inspect}"
|
10
|
+
unless given.size == expected.size
|
11
|
+
false
|
12
|
+
else
|
13
|
+
ret = true
|
14
|
+
given.each do |v|
|
15
|
+
ret = expected.include?(v)
|
16
|
+
break if !ret
|
17
|
+
end
|
18
|
+
ret
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
if Rails.v3?
|
2
|
+
Rspec::Matchers.define :render_404 do
|
3
|
+
match do |response|
|
4
|
+
response.code.should == '404'
|
5
|
+
end
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
if Rails.v2?
|
10
|
+
def render_404
|
11
|
+
simple_matcher("render a 404 page") do |given, matcher|
|
12
|
+
matcher.failure_message = "expected #{given.inspect} to render a 404 page"
|
13
|
+
matcher.negative_failure_message = "expected #{given.inspect} not to render a 404 page"
|
14
|
+
given.code.should == '404'
|
15
|
+
given.should render_template('public/404')
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'digest/md5' if Ruby.v18?
|
2
|
+
class String
|
3
|
+
|
4
|
+
def md5_hash
|
5
|
+
Digest::MD5.hexdigest(self).to_s
|
6
|
+
end
|
7
|
+
|
8
|
+
def hexdigest
|
9
|
+
Digest::SHA1.hexdigest(self)
|
10
|
+
end
|
11
|
+
|
12
|
+
def hexdigest!
|
13
|
+
self.replace(self.hexdigest)
|
14
|
+
end
|
15
|
+
|
16
|
+
def to_bool
|
17
|
+
case self.downcase
|
18
|
+
when 'n', 'no', 'f', 'false', 'nay'
|
19
|
+
return false
|
20
|
+
end
|
21
|
+
return true
|
22
|
+
end
|
23
|
+
|
24
|
+
alias_method :to_boolean, :to_bool
|
25
|
+
|
26
|
+
class << self
|
27
|
+
|
28
|
+
RANDOM_CHARS = [('A'..'H').to_a, ('J'..'N').to_a, ('P'..'T').to_a, ('W'..'Z').to_a, ('3'..'9').to_a].flatten
|
29
|
+
|
30
|
+
def random(size = 20)
|
31
|
+
newpass = ''
|
32
|
+
1.upto(size) { |i| newpass << RANDOM_CHARS[rand(RANDOM_CHARS.size-1)] }
|
33
|
+
return newpass.upcase
|
34
|
+
end
|
35
|
+
|
36
|
+
def cast_from(object)
|
37
|
+
object.to_s
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
data/lib/mark_facets.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# Dir.glob(File.join(File.dirname(__FILE__), 'mark_facets', '**/*.rb')).each do |f|
|
2
|
+
# require File.expand_path(f)
|
3
|
+
# end
|
4
|
+
|
5
|
+
path = File.join(File.dirname(__FILE__), 'mark_facets')
|
6
|
+
ruby_path = File.join(path, 'ruby')
|
7
|
+
rails_path = File.join(path, 'rails')
|
8
|
+
|
9
|
+
%w{ruby string hash big_decimal math}.each do |f|
|
10
|
+
p = File.expand_path(File.join(ruby_path, f))
|
11
|
+
puts p
|
12
|
+
require p
|
13
|
+
end
|
14
|
+
|
15
|
+
if defined?(Rails)
|
16
|
+
puts "load Rails stuff!"
|
17
|
+
%w{rails}.each do |f|
|
18
|
+
require File.expand_path(File.join(rails_path, f))
|
19
|
+
end
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mark_facets
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- markbates
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-07-14 00:00:00 -04:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: hashie
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
version: "0"
|
33
|
+
type: :runtime
|
34
|
+
version_requirements: *id001
|
35
|
+
description: "mark_facets was developed by: markbates"
|
36
|
+
email: mark@markbates.com
|
37
|
+
executables: []
|
38
|
+
|
39
|
+
extensions: []
|
40
|
+
|
41
|
+
extra_rdoc_files:
|
42
|
+
- README
|
43
|
+
- LICENSE
|
44
|
+
files:
|
45
|
+
- lib/mark_facets/rails/rails.rb
|
46
|
+
- lib/mark_facets/rails/test/authlogic.rb
|
47
|
+
- lib/mark_facets/rails/test/decode_json.rb
|
48
|
+
- lib/mark_facets/rails/test/delivered_emails.rb
|
49
|
+
- lib/mark_facets/rails/test/enable_ssl.rb
|
50
|
+
- lib/mark_facets/rails/test/helpers.rb
|
51
|
+
- lib/mark_facets/rails/test/rspec/all.rb
|
52
|
+
- lib/mark_facets/rails/test/rspec/should/have_same_elements.rb
|
53
|
+
- lib/mark_facets/rails/test/rspec/should/render_404.rb
|
54
|
+
- lib/mark_facets/ruby/big_decimal.rb
|
55
|
+
- lib/mark_facets/ruby/hash.rb
|
56
|
+
- lib/mark_facets/ruby/math.rb
|
57
|
+
- lib/mark_facets/ruby/ruby.rb
|
58
|
+
- lib/mark_facets/ruby/string.rb
|
59
|
+
- lib/mark_facets.rb
|
60
|
+
- README
|
61
|
+
- LICENSE
|
62
|
+
has_rdoc: true
|
63
|
+
homepage: http://www.metabates.com
|
64
|
+
licenses: []
|
65
|
+
|
66
|
+
post_install_message:
|
67
|
+
rdoc_options: []
|
68
|
+
|
69
|
+
require_paths:
|
70
|
+
- lib
|
71
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
hash: 3
|
77
|
+
segments:
|
78
|
+
- 0
|
79
|
+
version: "0"
|
80
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
hash: 3
|
86
|
+
segments:
|
87
|
+
- 0
|
88
|
+
version: "0"
|
89
|
+
requirements: []
|
90
|
+
|
91
|
+
rubyforge_project: magrathea
|
92
|
+
rubygems_version: 1.3.7
|
93
|
+
signing_key:
|
94
|
+
specification_version: 3
|
95
|
+
summary: mark_facets
|
96
|
+
test_files: []
|
97
|
+
|