dutws_foo_rails3 0.0.3

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/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in dutws_foo.gemspec
4
+ gemspec
5
+
6
+ gem 'json'
7
+
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require 'bundler/gem_tasks'
@@ -0,0 +1,22 @@
1
+ module DutwsFoo
2
+ class ServicesController < ::ApplicationController
3
+ def workspace
4
+ parsed_json = JSON.parse(ActiveSupport::JSON.encode(params))
5
+ if parsed_json['Message']
6
+
7
+ operation = parsed_json['Message']['Body'].keys.first
8
+ data = parsed_json['Message']['Body'][operation]
9
+ logger.debug(data)
10
+
11
+ @output = WebService.handle_request(parsed_json['Message'])
12
+ else
13
+ @output = {:error => 'Invalid Request Format'}
14
+ end
15
+
16
+ respond_to do |format|
17
+ format.json { render :json => @output.to_json }
18
+ end
19
+
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,20 @@
1
+ module DutwsFoo
2
+ class WebService
3
+ class << self
4
+ def handle_request(args)
5
+ if (args['Command'] == 'data_update_notification')
6
+ #begin
7
+ attrs = args['Body']["attributes"]
8
+ operation = attrs.keys.first
9
+ data = attrs[operation]#["Data"]
10
+ args['Document'].singularize.classify.constantize.send(operation.downcase.to_sym, data)
11
+ #rescue
12
+ # return {:success => false}
13
+ #end
14
+ {:success => true}
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
20
+
data/config/routes.rb ADDED
@@ -0,0 +1,3 @@
1
+ Rails.application.routes.draw do |map|
2
+ post "services/workspace" => "dutws_foo/services#workspace"
3
+ end
@@ -0,0 +1,20 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "dutws_foo/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "dutws_foo_rails3"
7
+ s.version = DutwsFoo::VERSION
8
+ s.authors = ["Muntasim Ahmed"]
9
+ s.email = ["muntasim@tasawr.com"]
10
+ s.homepage = "http://www.tasawr.com"
11
+ s.summary = %q{It will open a web service that take db update request and update the underlying database}
12
+ s.description = %q{right now only mongoid is supported}
13
+
14
+ s.rubyforge_project = "dutws_foo_rails3"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+ end
data/lib/dutws_foo.rb ADDED
@@ -0,0 +1,8 @@
1
+ require "dutws_foo/version"
2
+ require "dutws_foo/engine"
3
+ require "dutws_foo/mongoid/class_methods"
4
+ module DutwsFoo
5
+ def dutws_friendly(options = {})
6
+ extend DutwsFoo::Mongoid::ClassMethods
7
+ end
8
+ end
@@ -0,0 +1,12 @@
1
+ require "dutws_foo"
2
+ require 'rails'
3
+
4
+ module DutwsFoo
5
+ class Engine < Rails::Engine
6
+ initializer "static assets" do |app|
7
+ if app.config.serve_static_assets
8
+ app.middleware.insert_after ::ActionDispatch::Static, ::ActionDispatch::Static, "#{root}/public"
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,19 @@
1
+ module DutwsFoo
2
+ module Mongoid
3
+ module ClassMethods
4
+ def insert(p_data)
5
+ data = p_data["Data"]
6
+ self.create(data)
7
+ end
8
+
9
+ def update(p_data)
10
+ data = p_data["Data"]
11
+ self.where(:reference_id => p_data["ID"].to_i).first.update_attributes(p_data["Data"])
12
+ end
13
+
14
+ def remove(p_data)
15
+ self.where(:reference_id => p_data["ID"].to_i).first.destroy
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,3 @@
1
+ module DutwsFoo
2
+ VERSION = "0.0.3"
3
+ end
metadata ADDED
@@ -0,0 +1,76 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dutws_foo_rails3
3
+ version: !ruby/object:Gem::Version
4
+ hash: 25
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 3
10
+ version: 0.0.3
11
+ platform: ruby
12
+ authors:
13
+ - Muntasim Ahmed
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-10-22 00:00:00 Z
19
+ dependencies: []
20
+
21
+ description: right now only mongoid is supported
22
+ email:
23
+ - muntasim@tasawr.com
24
+ executables: []
25
+
26
+ extensions: []
27
+
28
+ extra_rdoc_files: []
29
+
30
+ files:
31
+ - .gitignore
32
+ - Gemfile
33
+ - Rakefile
34
+ - app/controllers/dutws_foo/services_controller.rb
35
+ - app/models/dutws_foo/web_service.rb
36
+ - config/routes.rb
37
+ - dutws_foo_rails3.gemspec
38
+ - lib/dutws_foo.rb
39
+ - lib/dutws_foo/engine.rb
40
+ - lib/dutws_foo/mongoid/class_methods.rb
41
+ - lib/dutws_foo/version.rb
42
+ homepage: http://www.tasawr.com
43
+ licenses: []
44
+
45
+ post_install_message:
46
+ rdoc_options: []
47
+
48
+ require_paths:
49
+ - lib
50
+ required_ruby_version: !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ hash: 3
56
+ segments:
57
+ - 0
58
+ version: "0"
59
+ required_rubygems_version: !ruby/object:Gem::Requirement
60
+ none: false
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ hash: 3
65
+ segments:
66
+ - 0
67
+ version: "0"
68
+ requirements: []
69
+
70
+ rubyforge_project: dutws_foo_rails3
71
+ rubygems_version: 1.8.11
72
+ signing_key:
73
+ specification_version: 3
74
+ summary: It will open a web service that take db update request and update the underlying database
75
+ test_files: []
76
+