acts_as_tokenizable 0.1.0 → 0.2.0
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/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/acts_as_tokenizable.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{acts_as_tokenizable}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.2.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Enrique Garcia Cota", "Francisco de Juan"]
|
@@ -28,7 +28,9 @@ Gem::Specification.new do |s|
|
|
28
28
|
"lib/acts_as_tokenizable.rb",
|
29
29
|
"lib/acts_as_tokenizable/acts_as_tokenizable.rb",
|
30
30
|
"lib/acts_as_tokenizable/string_extensions.rb",
|
31
|
-
"lib/tasks/
|
31
|
+
"lib/tasks/acts_as_tokenizable.rake",
|
32
|
+
"pkg/acts_as_tokenizable-0.1.0.gem",
|
33
|
+
"pkg/acts_as_tokenizable-0.2.0.gem",
|
32
34
|
"test/helper.rb",
|
33
35
|
"test/test_acts_as_tokenizable.rb"
|
34
36
|
]
|
@@ -1,11 +1,23 @@
|
|
1
1
|
require 'config/environment'
|
2
2
|
|
3
|
+
namespace :tokens do
|
4
|
+
desc "Generates the token for objects without tokens."
|
5
|
+
task :generate => :environment do
|
6
|
+
tokenize_models
|
7
|
+
end
|
8
|
+
|
9
|
+
desc "Re-builds the token for all objects."
|
10
|
+
task :regenerate => :environment do
|
11
|
+
tokenize_models(true)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
3
15
|
def array_of_active_record_models
|
4
16
|
Dir.glob(RAILS_ROOT + '/app/models/*.rb').each { |file| require file }
|
5
|
-
|
17
|
+
|
6
18
|
models_with_token = ActiveRecord::Base.send(:subclasses).select{|m| m.respond_to?(:tokenized_by)}
|
7
19
|
end
|
8
|
-
|
20
|
+
|
9
21
|
def tokenize_records(records)
|
10
22
|
total_count = records.size
|
11
23
|
|
@@ -20,7 +32,7 @@ def tokenize_records(records)
|
|
20
32
|
end
|
21
33
|
puts ""
|
22
34
|
end
|
23
|
-
|
35
|
+
|
24
36
|
def tokenize_models(regenerate = false)
|
25
37
|
start = Time.now
|
26
38
|
puts "Start token generation"
|
@@ -30,7 +42,7 @@ def tokenize_models(regenerate = false)
|
|
30
42
|
puts "Generating new tokens for #{model.name.pluralize}"
|
31
43
|
|
32
44
|
conditions = "#{model.token_field_name} IS NULL OR #{model.token_field_name} = ''" unless regenerate
|
33
|
-
|
45
|
+
|
34
46
|
records_without_token = model.all(:conditions => conditions)
|
35
47
|
if records_without_token.size > 0
|
36
48
|
tokenize_records(records_without_token)
|
@@ -42,16 +54,3 @@ def tokenize_models(regenerate = false)
|
|
42
54
|
puts "Elapsed time " + (Time.now - start).seconds.to_s + " seconds"
|
43
55
|
|
44
56
|
end
|
45
|
-
|
46
|
-
namespace :tokens do
|
47
|
-
desc "Generates the token for objects without tokens."
|
48
|
-
task :generate => :environment do
|
49
|
-
tokenize_models
|
50
|
-
end
|
51
|
-
|
52
|
-
desc "Re-builds the token for all objects."
|
53
|
-
task :regenerate => :environment do
|
54
|
-
tokenize_models(true)
|
55
|
-
end
|
56
|
-
|
57
|
-
end
|
Binary file
|
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acts_as_tokenizable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Enrique Garcia Cota
|
@@ -44,7 +44,9 @@ files:
|
|
44
44
|
- lib/acts_as_tokenizable.rb
|
45
45
|
- lib/acts_as_tokenizable/acts_as_tokenizable.rb
|
46
46
|
- lib/acts_as_tokenizable/string_extensions.rb
|
47
|
-
- lib/tasks/
|
47
|
+
- lib/tasks/acts_as_tokenizable.rake
|
48
|
+
- pkg/acts_as_tokenizable-0.1.0.gem
|
49
|
+
- pkg/acts_as_tokenizable-0.2.0.gem
|
48
50
|
- test/helper.rb
|
49
51
|
- test/test_acts_as_tokenizable.rb
|
50
52
|
has_rdoc: true
|