alchemy_cms 2.1.11 → 2.1.12

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -18,8 +18,10 @@ group :assets do
18
18
  end
19
19
 
20
20
  group :development do
21
- gem 'ruby-debug19', :require => 'ruby-debug', :platform => :ruby_19
22
- gem 'ruby-debug', :platform => :ruby_18
23
- gem 'guard-spork'
24
- gem 'yard'
21
+ if !ENV["CI"]
22
+ gem 'debugger', :platform => :ruby_19
23
+ gem 'ruby-debug', :platform => :ruby_18
24
+ gem 'guard-spork'
25
+ gem 'yard'
26
+ end
25
27
  end
@@ -51,7 +51,7 @@ module Alchemy
51
51
  end
52
52
 
53
53
  def leave
54
- ::I18n.locale = current_user.language.to_sym
54
+ ::I18n.locale = current_user.try(:language)
55
55
  render :layout => false
56
56
  end
57
57
 
@@ -340,7 +340,7 @@ module Alchemy
340
340
  :active => false,
341
341
  :link_options => {},
342
342
  :overlay_options => {},
343
- :loading_indicator => false
343
+ :loading_indicator => true
344
344
  }
345
345
  options = defaults.merge(options)
346
346
  button = content_tag('div', :class => 'button_with_label' + (options[:active] ? ' active' : '')) do
@@ -355,7 +355,7 @@ module Alchemy
355
355
  }
356
356
  )
357
357
  else
358
- link_to options[:url], {:class => "icon_button#{options[:loading_indicator] ? nil : ' please_wait'}", :title => options[:title]}.merge(options[:link_options]) do
358
+ link_to options[:url], {:class => "icon_button#{options[:loading_indicator] ? ' please_wait' : nil}", :title => options[:title]}.merge(options[:link_options]) do
359
359
  render_icon(options[:icon])
360
360
  end
361
361
  end
@@ -5,13 +5,13 @@ module Alchemy #:nodoc:
5
5
  def self.included(base)
6
6
  base.extend(ClassMethods)
7
7
  end
8
-
8
+
9
9
  # Delivers various methods we need for Essences in Alchemy.
10
10
  # To turn a model into an essence call acts_as_essence inside your model and you will get:
11
11
  # * validations
12
12
  # * several getters (ie: page, element, content, ingredient, preview_text)
13
13
  module ClassMethods
14
-
14
+
15
15
  # Configuration options are:
16
16
  #
17
17
  # * +ingredient_column+ - specifies the column name you use for storing the content in the database (default: +body+)
@@ -24,64 +24,60 @@ module Alchemy #:nodoc:
24
24
  ingredient_column = configuration[:ingredient_column].blank? ? 'body' : configuration[:ingredient_column]
25
25
  preview_text_column = configuration[:preview_text_column].blank? ? ingredient_column : configuration[:preview_text_column]
26
26
  validate_column = configuration[:validate_column].blank? ? ingredient_column : configuration[:validate_column]
27
-
27
+
28
28
  class_eval <<-EOV
29
29
  attr_accessor :validation_errors
30
30
  include Alchemy::Essence::InstanceMethods
31
31
  stampable
32
32
  validate :essence_validations, :on => :update
33
33
  has_many :contents, :as => :essence
34
-
34
+
35
35
  def acts_as_essence_class
36
36
  #{self.name}
37
37
  end
38
-
38
+
39
39
  def validation_column
40
40
  '#{validate_column}'
41
41
  end
42
-
42
+
43
43
  def ingredient_column
44
44
  '#{ingredient_column}'
45
45
  end
46
-
47
- def ingredient
48
- send('#{ingredient_column}')
49
- end
50
-
46
+
51
47
  def preview_text_column
52
48
  '#{preview_text_column}'
53
49
  end
54
-
50
+
55
51
  def preview_text_method
56
52
  '#{configuration[:preview_text_method]}'
57
53
  end
58
-
54
+
59
55
  EOV
60
56
  end
61
-
57
+
62
58
  end
63
-
59
+
64
60
  module InstanceMethods
65
-
61
+
66
62
  # Essence Validations:
67
- #
63
+ #
68
64
  # Essence validations can be set inside the config/elements.yml file.
69
65
  # Currently supported validations are:
70
66
  # * presence
71
67
  # * format
72
68
  # * uniqueness
73
- #
69
+ #
74
70
  # If you want to validate the format you must additionally pass validate_format_as or validate_format_with:
75
- #
71
+ #
76
72
  # * validate_format_with has to be regex
77
73
  # * validate_format_as can be one of:
78
74
  # ** url
79
75
  # ** email
80
- #
76
+ #
81
77
  # Example:
82
- #
78
+ #
83
79
  # - name: person
84
- # contents:
80
+ # contents:
85
81
  # - name: name
86
82
  # type: EssenceText
87
83
  # validate: [presence]
@@ -93,7 +89,7 @@ module Alchemy #:nodoc:
93
89
  # type: EssenceText
94
90
  # validate: [format]
95
91
  # validate_format_with: '^[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$'
96
- #
92
+ #
97
93
  def essence_validations
98
94
  self.validation_errors ||= []
99
95
  return true if description.blank? || description['validate'].blank?
@@ -127,29 +123,36 @@ module Alchemy #:nodoc:
127
123
  end
128
124
  end
129
125
 
126
+ # Returns the value stored from the database column that is configured as ingredient column.
127
+ def ingredient
128
+ if self.respond_to?(ingredient_column)
129
+ self.send(ingredient_column)
130
+ end
131
+ end
132
+
130
133
  # Essence description from config/elements.yml
131
134
  def description
132
135
  return {} if element.nil? or element.content_descriptions.nil?
133
136
  element.content_descriptions.detect { |c| c['name'] == self.content.name }
134
137
  end
135
-
138
+
136
139
  # Returns the Content Essence is in
137
140
  def content
138
141
  Alchemy::Content.find_by_essence_type_and_essence_id(acts_as_essence_class.to_s, self.id)
139
142
  end
140
-
143
+
141
144
  # Returns the Element Essence is in
142
145
  def element
143
146
  return nil if content.nil?
144
147
  content.element
145
148
  end
146
-
149
+
147
150
  # Returns the Page Essence is on
148
151
  def page
149
152
  return nil if element.nil?
150
153
  element.page
151
154
  end
152
-
155
+
153
156
  # Returns the first x (default 30) characters of ingredient for the Element#preview_text method.
154
157
  def preview_text(maxlength = 30)
155
158
  if preview_text_method.blank?
@@ -159,17 +162,17 @@ module Alchemy #:nodoc:
159
162
  ingredient.send(preview_text_method).to_s[0..maxlength]
160
163
  end
161
164
  end
162
-
165
+
163
166
  def open_link_in_new_window?
164
167
  respond_to?(:link_target) && link_target == 'blank'
165
168
  end
166
-
169
+
167
170
  def partial_name
168
171
  self.class.name.split('::').last.underscore
169
172
  end
170
173
 
171
174
  end
172
-
175
+
173
176
  end
174
177
  end
175
178
  ActiveRecord::Base.class_eval { include Alchemy::Essence } if defined?(Alchemy::Essence)
@@ -1,5 +1,5 @@
1
1
  module Alchemy
2
2
 
3
- VERSION = "2.1.11"
3
+ VERSION = "2.1.12"
4
4
 
5
5
  end
@@ -48,7 +48,7 @@ describe Alchemy::Element do
48
48
 
49
49
  it "should raise an error if no descriptions are found" do
50
50
  FileUtils.mv(File.join(File.dirname(__FILE__), '..', '..', 'config', 'alchemy', 'elements.yml'), File.join(File.dirname(__FILE__), '..', '..', 'config', 'alchemy', 'elements.yml.bak'))
51
- expect { Alchemy::Element.descriptions }.should raise_error
51
+ expect { Alchemy::Element.descriptions }.to raise_error
52
52
  FileUtils.mv(File.join(File.dirname(__FILE__), '..', '..', 'config', 'alchemy', 'elements.yml.bak'), File.join(File.dirname(__FILE__), '..', '..', 'config', 'alchemy', 'elements.yml'))
53
53
  end
54
54
 
@@ -100,7 +100,7 @@ describe Alchemy::Element do
100
100
  end
101
101
 
102
102
  it "should raise error if all_for_page method has no page" do
103
- expect { Alchemy::Element.all_for_page(nil) }.should raise_error(TypeError)
103
+ expect { Alchemy::Element.all_for_page(nil) }.to raise_error(TypeError)
104
104
  end
105
105
 
106
106
  describe "#content_by_type" do
@@ -58,7 +58,7 @@ describe Alchemy::Language do
58
58
  if !@default_language
59
59
  @default_language = Factory(:language, :name => "default", :code => "aa", :frontpage_name => "intro", :default => true)
60
60
  end
61
- expect { @default_language.destroy }.should raise_error
61
+ expect { @default_language.destroy }.to raise_error
62
62
  end
63
63
 
64
64
  describe "before save" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alchemy_cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.11
4
+ version: 2.1.12
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2012-06-15 00:00:00.000000000 Z
14
+ date: 2012-09-14 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rails
@@ -889,18 +889,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
889
889
  - - ! '>='
890
890
  - !ruby/object:Gem::Version
891
891
  version: '0'
892
- segments:
893
- - 0
894
- hash: 3542557089447580413
895
892
  required_rubygems_version: !ruby/object:Gem::Requirement
896
893
  none: false
897
894
  requirements:
898
895
  - - ! '>='
899
896
  - !ruby/object:Gem::Version
900
897
  version: '0'
901
- segments:
902
- - 0
903
- hash: 3542557089447580413
904
898
  requirements:
905
899
  - ImageMagick (libmagick), v6.6 or greater.
906
900
  rubyforge_project: