zikaron 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.console_history +100 -0
- data/lib/zikaron.rb +8 -0
- data/lib/zikaron/remembers/actions.rb +1 -1
- data/lib/zikaron/version.rb +1 -1
- metadata +4 -3
data/.console_history
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
1.0 / nil.to+f
|
2
|
+
1.0 / nil.to_f
|
3
|
+
0.0 / 0.0
|
4
|
+
0.0 / 100
|
5
|
+
0.0 / 0
|
6
|
+
0 / 0.0
|
7
|
+
1.0 / 0
|
8
|
+
RabbitReplay::Config
|
9
|
+
RabbitReplay.configure do
|
10
|
+
:notifier => 'foo'
|
11
|
+
RabbitReplay.configure do |config|
|
12
|
+
config.notifier = 'foo'
|
13
|
+
RabbitReplay.config
|
14
|
+
props = {:foo => 'bar'}
|
15
|
+
props.merge(:bat => 'naz')
|
16
|
+
message = RabbitReplay::Message.last
|
17
|
+
message.last_replay_at
|
18
|
+
message = RabbitReplay::Message.new
|
19
|
+
message.replay_successful?
|
20
|
+
Message
|
21
|
+
{}.keys
|
22
|
+
{}.keys.present?
|
23
|
+
{}.keys.empty?
|
24
|
+
require 'rabbit_replay'
|
25
|
+
RabbitReplay::Message.new
|
26
|
+
def start_date
|
27
|
+
Date.today.beginning_of_month
|
28
|
+
def end_date
|
29
|
+
Date.today.end_of_month
|
30
|
+
def days_in_month
|
31
|
+
(end_date - start_date).days
|
32
|
+
days_in_month
|
33
|
+
(params.keys && YUBI_KEYS).inject{|hash, key| hash[key] = params[key].gsub(" ",""); hash}
|
34
|
+
YUBI_KEYS = [:yubi_key_public, :yubi_key_private, :yubi_key_aes]
|
35
|
+
params = {:yubi_key_aes => '123', :foo => 'bar'}
|
36
|
+
(params.keys & YUBI_KEYS).inject{|hash, key| hash[key] = params[key].gsub(" ",""); hash}
|
37
|
+
def extracted_yubi_pairs_from(params)
|
38
|
+
(params.keys & YUBI_KEYS).inject({}) {|hash, key| hash[key] = params[key].gsub(" ",""); hash}
|
39
|
+
end
|
40
|
+
params = {:yubi_key_aes => '1 2 3', :foo => 'bar'}
|
41
|
+
extracted_yubi_pairs_from(params)
|
42
|
+
yy = _
|
43
|
+
params | yy
|
44
|
+
params.merge(yy)
|
45
|
+
params = {:foo => 'bar'}
|
46
|
+
params[:id] && 1 == 0 || "trouble"
|
47
|
+
params[:id].present? && 1 == 0 || "trouble"
|
48
|
+
module ScopesAndPersistsModel
|
49
|
+
def self.included(base)
|
50
|
+
base.extend ClassMethods
|
51
|
+
base.send(:before_fiter, :scope_model, {:except => [:index]})
|
52
|
+
base.send(:before_fiter, :persist_model, {:only => [:create, update]})
|
53
|
+
def persist_model(params)
|
54
|
+
scoped_model.update_attributes(params[symbolized_model_name])
|
55
|
+
def handle_errors_on(action)
|
56
|
+
scoped_model.errors.present? && render(action)
|
57
|
+
def symbolized_model_name
|
58
|
+
base_model.name.downcase.to_sym
|
59
|
+
def scope_model
|
60
|
+
@scoped_model = params[:id] && base_model.where(:id => params[:id]).first || base_model.new(params[symbolized_model_name])
|
61
|
+
instance_variable_set("@#{symbolized_model_name.to_s}", @scoped_model)
|
62
|
+
module ClassMethods
|
63
|
+
def scopes_and_persists(model_name)
|
64
|
+
@base_model = eval(model_name.classify)
|
65
|
+
end
|
66
|
+
@base_model
|
67
|
+
end
|
68
|
+
base.send(:before_fiter, :scope_model, {:except => [:index]})
|
69
|
+
base.send(:before_fiter, :persist_model, {:only => [:create, update]})
|
70
|
+
class Foo
|
71
|
+
module ScopesAndPersistsModel
|
72
|
+
def self.included(base)
|
73
|
+
base.extend ClassMethods
|
74
|
+
def persist_model(params)
|
75
|
+
scoped_model.update_attributes(params[symbolized_model_name])
|
76
|
+
def handle_errors_on(action)
|
77
|
+
scoped_model.errors.present? && render(action)
|
78
|
+
def symbolized_model_name
|
79
|
+
base_model.name.downcase.to_sym
|
80
|
+
def scope_model
|
81
|
+
@scoped_model = params[:id] && base_model.where(:id => params[:id]).first || base_model.new(params[symbolized_model_name])
|
82
|
+
instance_variable_set("@#{symbolized_model_name.to_s}", @scoped_model)
|
83
|
+
module ClassMethods
|
84
|
+
def scopes_and_persists(model_name)
|
85
|
+
@base_model = eval(model_name.classify)
|
86
|
+
def base_model
|
87
|
+
@base_model
|
88
|
+
class Bar; end
|
89
|
+
class Foo
|
90
|
+
include ScopesAndPersistsModel
|
91
|
+
scopes_and_persists :bar
|
92
|
+
end
|
93
|
+
require 'base64'
|
94
|
+
Base64.decode64('RGVjb2RlIHRoaXMgbWVzc2FnZSBmaXJzdCBmb3IgZGlubmVyIGFuZCBkcmlu\na3Mgd2l0aCB0aGUgdGVjaCB0ZWFtIGF0IEFwYXJ0bWVudHMuY29tLg==\n')
|
95
|
+
Base64.decode64("RGVjb2RlIHRoaXMgbWVzc2FnZSBmaXJzdCBmb3IgZGlubmVyIGFuZCBkcmlu\na3Mgd2l0aCB0aGUgdGVjaCB0ZWFtIGF0IEFwYXJ0bWVudHMuY29tLg==\n")
|
96
|
+
Zikaron.redis
|
97
|
+
require 'zikaron'
|
98
|
+
Zikaron.redis.ping
|
99
|
+
Zikaron.redis_exists?
|
100
|
+
exit
|
data/lib/zikaron.rb
CHANGED
@@ -8,6 +8,14 @@ module Zikaron
|
|
8
8
|
attr_accessor :config
|
9
9
|
end
|
10
10
|
|
11
|
+
def self.redis_exists?
|
12
|
+
begin
|
13
|
+
redis.ping
|
14
|
+
rescue
|
15
|
+
false
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
11
19
|
def self.redis
|
12
20
|
@redis ||= Redis::Namespace.new(config.cache_name, :redis => Redis.connect(:url => config.redis_url))
|
13
21
|
end
|
data/lib/zikaron/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zikaron
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -84,6 +84,7 @@ executables: []
|
|
84
84
|
extensions: []
|
85
85
|
extra_rdoc_files: []
|
86
86
|
files:
|
87
|
+
- .console_history
|
87
88
|
- .gitignore
|
88
89
|
- Gemfile
|
89
90
|
- LICENSE.txt
|
@@ -108,7 +109,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
108
109
|
version: '0'
|
109
110
|
segments:
|
110
111
|
- 0
|
111
|
-
hash:
|
112
|
+
hash: 2999350474931661743
|
112
113
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
113
114
|
none: false
|
114
115
|
requirements:
|
@@ -117,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
117
118
|
version: '0'
|
118
119
|
segments:
|
119
120
|
- 0
|
120
|
-
hash:
|
121
|
+
hash: 2999350474931661743
|
121
122
|
requirements: []
|
122
123
|
rubyforge_project:
|
123
124
|
rubygems_version: 1.8.24
|