webs 0.1.11 → 0.1.12

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -3,7 +3,7 @@ require 'rubygems'
3
3
  require 'rake'
4
4
  require 'echoe'
5
5
 
6
- Echoe.new('webs', '0.1.11') do |p|
6
+ Echoe.new('webs', '0.1.12') do |p|
7
7
  p.description = "Reusable webs stuff."
8
8
  p.url = "https://colczak@github.com/websdev/websgem.git"
9
9
  p.author = "Chuck Olczak"
@@ -53,11 +53,11 @@ module Webs
53
53
  value_for_level( k ) >= v
54
54
  end
55
55
  end
56
-
56
+
57
57
  module CommentsOrder
58
- ASC = 0
59
- DESC = 1
60
- VIEWS = [[ASC, "Oldest first (default)"], [DESC, "Newest first"]]
58
+ DESC = 0
59
+ ASC = 1
60
+ VIEWS = [[DESC, "Newest first (default)"], [ASC, "Oldest first"]]
61
61
  SELECT_OPTIONS = VIEWS.map { |val, disp| [disp, val] }
62
62
  VAL_LIST = VIEWS.map {|val, disp| val}
63
63
  def self.val_to_str(val)
@@ -100,13 +100,16 @@ module Webs
100
100
  render(:text => "You are not authorized.") unless webs_admin?
101
101
  end
102
102
 
103
+ def require_sitebuilder
104
+ render( :text => "You are not an admin.", :status=>403 ) unless webs_sitebuilder?
105
+ end
106
+
103
107
  def webs_site
104
108
  @webs_site
105
109
  end
106
110
 
107
111
  # options include primary_key_col
108
112
  def load_site_model modelname, options={}
109
- Rails.logger.debug "load_site_model #{modelname} #{options.inspect}"
110
113
  model = modelname.constantize
111
114
  pk = options.delete(:primary_key_col)
112
115
  if pk
@@ -116,7 +119,6 @@ module Webs
116
119
  end
117
120
 
118
121
  rescue
119
- Rails.logger.debug "!!!!!!!!!!!!!!!!!!! load_site_model Failed"
120
122
  nil
121
123
  end
122
124
 
@@ -0,0 +1,80 @@
1
+ module Webs
2
+ module WebsTestHelper
3
+ def fw_test_params options={}
4
+ { :fw_sig_site=>rand(100000),
5
+ :fw_sig_is_admin=>'0',
6
+ :fw_sig_permission_level=>Webs::PermissionLevel[:anyone],
7
+ :fw_sig_tier=>'0',
8
+ :fw_sig_url=>'localhost:3000',
9
+ :fw_sig_user=>rand(100000),
10
+ :fw_sig_social=>'1',
11
+ :fw_sig_premium=>'0',
12
+ :fw_sig_width=>800 }.merge( options )
13
+ end
14
+
15
+ def fw_sitebuilder_test_params options={}
16
+ fw_test_params options.merge( :fw_sig_is_admin=>'1' )
17
+ end
18
+
19
+ def fw_test_scenarios options={}
20
+ scenarios = []
21
+ fw_param_permuter( options ){ |params| scenarios << params }
22
+ scenarios
23
+ end
24
+
25
+ # Permute: is_admin, permission_level, tier, social & premium
26
+ # fw_param_permuter( :only=>[:fw_sig_is_admin, :fw_sig_social, :fw_sig_permission_level] )
27
+ # fw_param_permuter( :except=>[:fw_sig_tier, :fw_sig_premium]} )
28
+ # fw_param_permuter( :vals=>{:test=>['a', 'b', 'c'] )
29
+ def fw_param_permuter options={}, &block
30
+ param_vals = {
31
+ :fw_sig_is_admin=>[0,1],
32
+ :fw_sig_permission_level=>Webs::PermissionLevel::VALUES,
33
+ :fw_sig_social=>[0,1],
34
+ :fw_sig_premium=>[0,1],
35
+ :fw_sig_tier=>[0,1,2,3]
36
+ }
37
+
38
+ if (only = options.delete(:only))
39
+ param_vals.keys.each { |k| param_vals.delete(k) if !only.include?(k)}
40
+ end
41
+ if (except = options.delete(:except))
42
+ param_vals.keys.each { |k| param_vals.delete(k) if except.include?(k)}
43
+ end
44
+
45
+ if (vals = options.delete(:vals))
46
+ param_vals.merge!( vals )
47
+ end
48
+
49
+ params = fw_test_params( options )
50
+ permute_params params, param_vals, block
51
+ end
52
+
53
+ def permute_params params, h_vals, block
54
+ if h_vals.size == 0
55
+ block.call( params.clone )
56
+ else
57
+ k = h_vals.keys.first
58
+ vals = h_vals.delete(k)
59
+ vals.each do |v|
60
+ params[k] = v.to_s
61
+ permute_params params, h_vals.clone, block
62
+ end
63
+ end
64
+ end
65
+
66
+ def assert_difference(executable, how_many = 1, &block)
67
+ before = eval(executable)
68
+ yield
69
+ after = eval(executable)
70
+ after.should == before + how_many
71
+ end
72
+
73
+ def assert_no_difference(executable, &block)
74
+ before = eval(executable)
75
+ yield
76
+ after = eval(executable)
77
+ after.should == before
78
+ end
79
+ end
80
+ end
data/lib/webs.rb CHANGED
@@ -7,7 +7,7 @@ require dir + 'helper/params'
7
7
  require dir + 'helper/tags'
8
8
 
9
9
  module Webs
10
- VERSION = "0.1.11".freeze
10
+ VERSION = "0.1.12".freeze
11
11
 
12
12
  # def self.load_constants
13
13
  # s = File.read("#{Pathname(__FILE__).dirname.expand_path}/config/webs_constants.yml")
data/webs.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{webs}
5
- s.version = "0.1.11"
5
+ s.version = "0.1.12"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Chuck Olczak"]
9
- s.date = %q{2011-01-19}
9
+ s.date = %q{2011-01-28}
10
10
  s.description = %q{Reusable webs stuff.}
11
11
  s.email = %q{chuck@webs.com}
12
12
  gemfiles = [
@@ -22,6 +22,7 @@ Gem::Specification.new do |s|
22
22
  "lib/helper/tags.rb",
23
23
  "lib/views/layouts/webs_page.html.erb",
24
24
  "lib/views/layouts/webs_utility.html.erb",
25
+ "lib/test/webs_test_helper.rb",
25
26
  "lib/views/shared/_webs_info.html.erb"
26
27
  ]
27
28
  s.extra_rdoc_files = gemfiles
metadata CHANGED
@@ -1,21 +1,20 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webs
3
3
  version: !ruby/object:Gem::Version
4
- hash: 13
5
4
  prerelease: false
6
5
  segments:
7
- - 0
8
- - 1
9
- - 11
10
- version: 0.1.11
6
+ - 0
7
+ - 1
8
+ - 12
9
+ version: 0.1.12
11
10
  platform: ruby
12
11
  authors:
13
- - Chuck Olczak
12
+ - Chuck Olczak
14
13
  autorequire:
15
14
  bindir: bin
16
15
  cert_chain: []
17
16
 
18
- date: 2011-01-19 00:00:00 -05:00
17
+ date: 2011-01-28 00:00:00 -05:00
19
18
  default_executable:
20
19
  dependencies: []
21
20
 
@@ -26,72 +25,70 @@ executables: []
26
25
  extensions: []
27
26
 
28
27
  extra_rdoc_files:
29
- - README.rdoc
30
- - lib/webs.rb
31
- - lib/cache/cache.rb
32
- - lib/config/webs_constants.rb
33
- - lib/config/webs_initializer.rb
34
- - lib/controller/url_for_context_path.rb
35
- - lib/controller/webs_controller.rb
36
- - lib/helper/application.rb
37
- - lib/helper/params.rb
38
- - lib/helper/tags.rb
39
- - lib/views/layouts/webs_page.html.erb
40
- - lib/views/layouts/webs_utility.html.erb
41
- - lib/views/shared/_webs_info.html.erb
28
+ - README.rdoc
29
+ - lib/webs.rb
30
+ - lib/cache/cache.rb
31
+ - lib/config/webs_constants.rb
32
+ - lib/config/webs_initializer.rb
33
+ - lib/controller/url_for_context_path.rb
34
+ - lib/controller/webs_controller.rb
35
+ - lib/helper/application.rb
36
+ - lib/helper/params.rb
37
+ - lib/helper/tags.rb
38
+ - lib/views/layouts/webs_page.html.erb
39
+ - lib/views/layouts/webs_utility.html.erb
40
+ - lib/test/webs_test_helper.rb
41
+ - lib/views/shared/_webs_info.html.erb
42
42
  files:
43
- - README.rdoc
44
- - lib/webs.rb
45
- - lib/cache/cache.rb
46
- - lib/config/webs_constants.rb
47
- - lib/config/webs_initializer.rb
48
- - lib/controller/url_for_context_path.rb
49
- - lib/controller/webs_controller.rb
50
- - lib/helper/application.rb
51
- - lib/helper/params.rb
52
- - lib/helper/tags.rb
53
- - lib/views/layouts/webs_page.html.erb
54
- - lib/views/layouts/webs_utility.html.erb
55
- - lib/views/shared/_webs_info.html.erb
56
- - Rakefile
57
- - webs.gemspec
43
+ - README.rdoc
44
+ - lib/webs.rb
45
+ - lib/cache/cache.rb
46
+ - lib/config/webs_constants.rb
47
+ - lib/config/webs_initializer.rb
48
+ - lib/controller/url_for_context_path.rb
49
+ - lib/controller/webs_controller.rb
50
+ - lib/helper/application.rb
51
+ - lib/helper/params.rb
52
+ - lib/helper/tags.rb
53
+ - lib/views/layouts/webs_page.html.erb
54
+ - lib/views/layouts/webs_utility.html.erb
55
+ - lib/test/webs_test_helper.rb
56
+ - lib/views/shared/_webs_info.html.erb
57
+ - Rakefile
58
+ - webs.gemspec
58
59
  has_rdoc: true
59
60
  homepage: http://github.com/websdotcom/websgem
60
61
  licenses: []
61
62
 
62
63
  post_install_message:
63
64
  rdoc_options:
64
- - --line-numbers
65
- - --inline-source
66
- - --title
67
- - Webs
68
- - --main
69
- - README.rdoc
65
+ - --line-numbers
66
+ - --inline-source
67
+ - --title
68
+ - Webs
69
+ - --main
70
+ - README.rdoc
70
71
  require_paths:
71
- - lib
72
+ - lib
72
73
  required_ruby_version: !ruby/object:Gem::Requirement
73
- none: false
74
74
  requirements:
75
- - - ">="
76
- - !ruby/object:Gem::Version
77
- hash: 3
78
- segments:
79
- - 0
80
- version: "0"
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ segments:
78
+ - 0
79
+ version: "0"
81
80
  required_rubygems_version: !ruby/object:Gem::Requirement
82
- none: false
83
81
  requirements:
84
- - - ">="
85
- - !ruby/object:Gem::Version
86
- hash: 11
87
- segments:
88
- - 1
89
- - 2
90
- version: "1.2"
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ segments:
85
+ - 1
86
+ - 2
87
+ version: "1.2"
91
88
  requirements: []
92
89
 
93
90
  rubyforge_project: webs
94
- rubygems_version: 1.3.7
91
+ rubygems_version: 1.3.6
95
92
  signing_key:
96
93
  specification_version: 3
97
94
  summary: Reusable webs stuff.