towsta 2.1.2 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/lib/towsta.rb CHANGED
@@ -1,41 +1,18 @@
1
1
  #coding: utf-8
2
- require 'net/http'
3
- require 'json'
4
- require 'bresson'
5
- require 'cameraman'
6
- require 'active_support/all'
7
-
8
- require File.expand_path('../towsta/vertical-core/base', __FILE__)
9
- require File.expand_path('../towsta/vertical-core/attributes', __FILE__)
10
- require File.expand_path('../towsta/vertical-core/crud', __FILE__)
11
- require File.expand_path('../towsta/vertical-core/locales', __FILE__)
12
- require File.expand_path('../towsta/vertical-core/mail', __FILE__)
13
- require File.expand_path('../towsta/vertical-core/references', __FILE__)
14
- require File.expand_path('../towsta/kinds/main', __FILE__)
15
- require File.expand_path('../towsta/vertical', __FILE__)
16
- require File.expand_path('../towsta/synchronizer', __FILE__)
17
- require File.expand_path('../towsta/login', __FILE__)
18
- require File.expand_path('../towsta/shell', __FILE__)
19
- require File.expand_path('../towsta/kinds/boolean', __FILE__)
20
- require File.expand_path('../towsta/kinds/date', __FILE__)
21
- require File.expand_path('../towsta/kinds/datetime', __FILE__)
22
- require File.expand_path('../towsta/kinds/file', __FILE__)
23
- require File.expand_path('../towsta/kinds/formated', __FILE__)
24
- require File.expand_path('../towsta/kinds/gallery', __FILE__)
25
- require File.expand_path('../towsta/kinds/image', __FILE__)
26
- require File.expand_path('../towsta/kinds/integer', __FILE__)
27
- require File.expand_path('../towsta/kinds/link', __FILE__)
28
- require File.expand_path('../towsta/kinds/list', __FILE__)
29
- require File.expand_path('../towsta/kinds/money', __FILE__)
30
- require File.expand_path('../towsta/kinds/password', __FILE__)
31
- require File.expand_path('../towsta/kinds/text', __FILE__)
32
- require File.expand_path('../towsta/kinds/user', __FILE__)
33
- require File.expand_path('../towsta/kinds/vertical', __FILE__)
34
- require File.expand_path('../towsta/kinds/video', __FILE__)
35
- require File.expand_path('../towsta/kinds/multiple', __FILE__)
2
+ files = %w(cgi net/http json bresson cameraman active_support/all)
3
+ files.each {|file| require file}
36
4
 
37
5
  module Towsta
38
- mattr_accessor :secret, :global, :author
6
+ mattr_accessor :secret, :global, :author, :models_path, :env
39
7
  end
40
8
 
41
- require File.expand_path("../towsta/envs/#{ENV['RACK_ENV'] || 'development'}", __FILE__)
9
+ files = %w(base attributes crud mail references)
10
+ files.each {|file| require "towsta/core/#{file}"}
11
+
12
+ files = %w(version synchronizer vertical sync_with_towsta)
13
+ files.each {|file| require "towsta/#{file}"}
14
+
15
+ files = %w(main boolean date datetime file formated gallery image integer link list money multiple password text user vertical video)
16
+ files.each {|file| require "towsta/kinds/#{file}"}
17
+
18
+ require 'towsta/frameworks/rails' if defined? Rails
@@ -1,13 +1,11 @@
1
1
  module Towsta
2
2
 
3
- class VerticalCore
3
+ class Core
4
4
 
5
5
  class << self
6
6
  attr_accessor :attributes
7
7
  end
8
8
 
9
- self.attributes ||= []
10
-
11
9
  def attributes
12
10
  horizontal = {}
13
11
  self.class.attributes.each do |attr|
@@ -1,6 +1,6 @@
1
1
  module Towsta
2
2
 
3
- class VerticalCore
3
+ class Core
4
4
 
5
5
  def initialize args={}
6
6
  self.attributes.merge(args).each {|k,v| self.send("#{k}=".to_sym, v)}
@@ -1,6 +1,6 @@
1
1
  module Towsta
2
2
 
3
- class VerticalCore
3
+ class Core
4
4
 
5
5
  attr_accessor :message
6
6
 
@@ -26,7 +26,6 @@ module Towsta
26
26
  @message = response[:message]
27
27
  self.id = response[:id] if response[:status]
28
28
  self.author = User.find_by_email creator
29
- #Towsta::Memory.flush if production?
30
29
  response[:status]
31
30
  end
32
31
 
@@ -1,6 +1,6 @@
1
1
  module Towsta
2
2
 
3
- class VerticalCore
3
+ class Core
4
4
 
5
5
  def to_mail
6
6
  string = ''
@@ -8,10 +8,6 @@ module Towsta
8
8
  string
9
9
  end
10
10
 
11
- def notify args
12
- Pony.mail({:html_body => to_mail}.merge(args))
13
- end
14
-
15
11
  end
16
12
 
17
13
  end
@@ -1,12 +1,12 @@
1
1
  module Towsta
2
2
 
3
- class VerticalCore
3
+ class Core
4
4
 
5
5
  class << self
6
6
  attr_accessor :all, :count
7
7
  end
8
8
 
9
- self.all ||= []
9
+ self.all = []
10
10
 
11
11
  def self.first
12
12
  self.all.first
@@ -0,0 +1,8 @@
1
+ module Towsta
2
+ class Engine < Rails::Engine
3
+ initializer 'towsta.initialize', :after => :disable_dependency_loading do |app|
4
+ Towsta.models_path = "#{Rails.root}/app/models/"
5
+ Towsta.env = Rails.env
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,3 @@
1
+ def sync_with_towsta params={}
2
+ Towsta::Synchronizer.new(params: params, request: :all).status
3
+ end
@@ -1,3 +1,3 @@
1
1
  module Towsta
2
- VERSION = "2.1.2"
2
+ VERSION = "3.0.0"
3
3
  end
@@ -2,16 +2,12 @@ module Towsta
2
2
 
3
3
  class Vertical
4
4
 
5
- cattr_accessor :all
6
-
7
- self.all ||= []
8
-
9
5
  def self.create args
10
- klass = Class.new(VerticalCore) { args[:slices].each { |attr, kind| define_attribute attr, kind } }
6
+ model_file = Towsta.models_path + args[:name].underscore + '.rb'
7
+ File.open(model_file, 'w') {|f| f.write("class #{args[:name]} < Towsta::Core\nend")} unless File.exists? model_file || Towsta.env == 'production'
8
+ klass = Object.const_get args[:name]
9
+ args[:slices].each { |attr, kind| klass.define_attribute attr, kind }
11
10
  klass.all = []
12
- Vertical.all << klass
13
- Object.const_set args[:name], klass
14
- puts " class #{args[:name]} was created"
15
11
  end
16
12
 
17
13
  def self.populate classname, horizontals, count, occurrences = []
data/towsta.gemspec CHANGED
@@ -10,16 +10,13 @@ Gem::Specification.new do |s|
10
10
  s.authors = ["Mortaro"]
11
11
  s.email = ["mortaro@towsta.com"]
12
12
  s.homepage = "http://rubygems.org/gems/towsta"
13
- s.summary = %q{Api Integration gem with towsta}
14
- s.description = %q{Simply integrates the towsta api}
13
+ s.summary = %q{Towsta's Api Integration Gem}
14
+ s.description = %q{Simply integrates the Towsta api}
15
15
 
16
16
  s.rubyforge_project = "towsta"
17
17
 
18
- s.add_dependency "json"
19
18
  s.add_dependency "bresson"
20
19
  s.add_dependency "cameraman"
21
- s.add_dependency "active_support"
22
- s.add_dependency 'dalli'
23
20
 
24
21
  s.add_development_dependency 'rspec'
25
22
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: towsta
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.2
4
+ version: 3.0.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,22 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-19 00:00:00.000000000 Z
12
+ date: 2012-05-27 00:00:00.000000000 Z
13
13
  dependencies:
14
- - !ruby/object:Gem::Dependency
15
- name: json
16
- requirement: &21240300 !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
19
- - - ! '>='
20
- - !ruby/object:Gem::Version
21
- version: '0'
22
- type: :runtime
23
- prerelease: false
24
- version_requirements: *21240300
25
14
  - !ruby/object:Gem::Dependency
26
15
  name: bresson
27
- requirement: &21280200 !ruby/object:Gem::Requirement
16
+ requirement: &26972220 !ruby/object:Gem::Requirement
28
17
  none: false
29
18
  requirements:
30
19
  - - ! '>='
@@ -32,32 +21,10 @@ dependencies:
32
21
  version: '0'
33
22
  type: :runtime
34
23
  prerelease: false
35
- version_requirements: *21280200
24
+ version_requirements: *26972220
36
25
  - !ruby/object:Gem::Dependency
37
26
  name: cameraman
38
- requirement: &21279804 !ruby/object:Gem::Requirement
39
- none: false
40
- requirements:
41
- - - ! '>='
42
- - !ruby/object:Gem::Version
43
- version: '0'
44
- type: :runtime
45
- prerelease: false
46
- version_requirements: *21279804
47
- - !ruby/object:Gem::Dependency
48
- name: active_support
49
- requirement: &21279444 !ruby/object:Gem::Requirement
50
- none: false
51
- requirements:
52
- - - ! '>='
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
- type: :runtime
56
- prerelease: false
57
- version_requirements: *21279444
58
- - !ruby/object:Gem::Dependency
59
- name: dalli
60
- requirement: &21278976 !ruby/object:Gem::Requirement
27
+ requirement: &26971752 !ruby/object:Gem::Requirement
61
28
  none: false
62
29
  requirements:
63
30
  - - ! '>='
@@ -65,10 +32,10 @@ dependencies:
65
32
  version: '0'
66
33
  type: :runtime
67
34
  prerelease: false
68
- version_requirements: *21278976
35
+ version_requirements: *26971752
69
36
  - !ruby/object:Gem::Dependency
70
37
  name: rspec
71
- requirement: &21278580 !ruby/object:Gem::Requirement
38
+ requirement: &26971236 !ruby/object:Gem::Requirement
72
39
  none: false
73
40
  requirements:
74
41
  - - ! '>='
@@ -76,12 +43,11 @@ dependencies:
76
43
  version: '0'
77
44
  type: :development
78
45
  prerelease: false
79
- version_requirements: *21278580
80
- description: Simply integrates the towsta api
46
+ version_requirements: *26971236
47
+ description: Simply integrates the Towsta api
81
48
  email:
82
49
  - mortaro@towsta.com
83
- executables:
84
- - towsta
50
+ executables: []
85
51
  extensions: []
86
52
  extra_rdoc_files: []
87
53
  files:
@@ -89,11 +55,13 @@ files:
89
55
  - Gemfile
90
56
  - Gemfile.lock
91
57
  - Rakefile
92
- - bin/towsta
93
58
  - lib/towsta.rb
94
- - lib/towsta/envs/development.rb
95
- - lib/towsta/envs/production.rb
96
- - lib/towsta/envs/test.rb
59
+ - lib/towsta/core/attributes.rb
60
+ - lib/towsta/core/base.rb
61
+ - lib/towsta/core/crud.rb
62
+ - lib/towsta/core/mail.rb
63
+ - lib/towsta/core/references.rb
64
+ - lib/towsta/frameworks/rails.rb
97
65
  - lib/towsta/kinds/boolean.rb
98
66
  - lib/towsta/kinds/date.rb
99
67
  - lib/towsta/kinds/datetime.rb
@@ -112,17 +80,9 @@ files:
112
80
  - lib/towsta/kinds/user.rb
113
81
  - lib/towsta/kinds/vertical.rb
114
82
  - lib/towsta/kinds/video.rb
115
- - lib/towsta/login.rb
116
- - lib/towsta/memory.rb
117
- - lib/towsta/shell.rb
83
+ - lib/towsta/sync_with_towsta.rb
118
84
  - lib/towsta/synchronizer.rb
119
85
  - lib/towsta/version.rb
120
- - lib/towsta/vertical-core/attributes.rb
121
- - lib/towsta/vertical-core/base.rb
122
- - lib/towsta/vertical-core/crud.rb
123
- - lib/towsta/vertical-core/locales.rb
124
- - lib/towsta/vertical-core/mail.rb
125
- - lib/towsta/vertical-core/references.rb
126
86
  - lib/towsta/vertical.rb
127
87
  - spec/kinds/boolean_spec.rb
128
88
  - spec/kinds/date_spec.rb
@@ -175,5 +135,5 @@ rubyforge_project: towsta
175
135
  rubygems_version: 1.8.16
176
136
  signing_key:
177
137
  specification_version: 3
178
- summary: Api Integration gem with towsta
138
+ summary: Towsta's Api Integration Gem
179
139
  test_files: []
data/bin/towsta DELETED
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require 'towsta'
3
-
4
- Towsta::Shell.send ARGV.first, ARGV.last
@@ -1,5 +0,0 @@
1
- def sync_with_towsta params={}
2
- sync = Towsta::Synchronizer.new params: params, request: :all
3
- (Dir["./controllers/*.rb"] + Dir["./models/*.rb"]).each {|file| load file}
4
- sync.status
5
- end
@@ -1,15 +0,0 @@
1
- require 'dalli'
2
- set :cache, Dalli::Client.new
3
- require File.expand_path('../../memory', __FILE__)
4
-
5
- def sync_with_towsta params={}
6
- sync = Towsta::Synchronizer.new params: params, request: :all
7
- (Dir["./controllers/*.rb"] + Dir["./models/*.rb"]).each {|file| load file}
8
- sync.status
9
- end
10
-
11
- #Towsta::Synchronizer.new params: {}, request: :structure
12
-
13
- #def sync_with_towsta params={}
14
- # Towsta::Memory.recover(params).status
15
- #end
@@ -1,5 +0,0 @@
1
- def sync_with_towsta params={}
2
- sync = Towsta::Synchronizer.new params: params, request: :all
3
- (Dir["./controllers/*.rb"] + Dir["./models/*.rb"]).each {|file| load file}
4
- sync.status
5
- end
data/lib/towsta/login.rb DELETED
@@ -1,19 +0,0 @@
1
- module Towsta
2
-
3
- class Login
4
-
5
- def self.authenticate params
6
- response = Towsta::Synchronizer.authentication_request params
7
- session[:current_user] = response[:id] if response[:status]
8
- response[:status]
9
- end
10
-
11
- def self.rescue
12
- return User.find(session[:current_user]) if defined? User
13
- session[:current_user]
14
- end
15
-
16
-
17
- end
18
-
19
- end
data/lib/towsta/memory.rb DELETED
@@ -1,27 +0,0 @@
1
- module Towsta
2
-
3
- class Memory
4
-
5
- def self.recover params
6
- md5 = Memory.md5(params)
7
- if settings.cache.get(md5)
8
- puts "\nUsing cache to Towst"
9
- Towsta::Synchronizer.new cache: settings.cache.get(md5), request: :horizontals
10
- else
11
- puts "\nCreating cache"
12
- syn = Towsta::Synchronizer.new params: params, request: :horizontals
13
- settings.cache.set(md5,syn.response)
14
- syn
15
- end
16
- end
17
-
18
- def self.flush
19
- settings.cache.flush
20
- end
21
-
22
- def self.md5 params
23
- digest = Digest::MD5.hexdigest(params.inspect.to_s + 'Towsta')
24
- end
25
-
26
- end
27
- end
data/lib/towsta/shell.rb DELETED
@@ -1,22 +0,0 @@
1
- module Towsta
2
- class Shell
3
- def self.sinatra_init *args
4
- towsta_rb 'configs'
5
- add_gem
6
- system 'bundle install'
7
- end
8
-
9
- def self.towsta_rb folder
10
- code = "require 'towsta'\n\n"
11
- code += "Towsta.secret = ''\n"
12
- code += "#Towsta.author = 'your@email.com'\n"
13
- code += "#Towsta.global = {}"
14
- File.open("#{folder}/towsta.rb", 'w') {|f| f.write(code)}
15
- end
16
-
17
- def self.add_gem
18
- gemfile = File.read("Gemfile") << "\ngem 'towsta'"
19
- File.open("Gemfile", 'w') {|f| f.write(gemfile)}
20
- end
21
- end
22
- end
@@ -1,21 +0,0 @@
1
- module Towsta
2
-
3
- class VerticalCore
4
-
5
- include R18n::Helpers rescue nil
6
-
7
- def i18n attr
8
- self.send :"#{attr.to_s}_#{R18n.get.locales.first.code}"
9
- end
10
-
11
- def method_missing meth, *args, &block
12
- begin
13
- return self.i18n meth.to_sym
14
- rescue
15
- super
16
- end
17
- end
18
-
19
- end
20
-
21
- end