gooddata-bricks-poc 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,30 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ <<<<<<< HEAD
6
+ coverage
7
+ InstalledFiles
8
+ =======
9
+ .yardoc
10
+ Gemfile.lock
11
+ InstalledFiles
12
+ _yardoc
13
+ coverage
14
+ doc/
15
+ >>>>>>> Initial commit
16
+ lib/bundler/man
17
+ pkg
18
+ rdoc
19
+ spec/reports
20
+ test/tmp
21
+ test/version_tmp
22
+ tmp
23
+ <<<<<<< HEAD
24
+
25
+ # YARD artifacts
26
+ .yardoc
27
+ _yardoc
28
+ doc/
29
+ =======
30
+ >>>>>>> Initial commit
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in gooddata-bricks.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2013 Tomas Svarovsky
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Tomas Svarovsky
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,62 @@
1
+ bricks
2
+ ======
3
+
4
+ A short POC for bricks infrastructure
5
+ =======
6
+ # Gooddata::Bricks
7
+
8
+ Bricks is a quick POC how could reusable apps in GD infrastructure work.
9
+
10
+ ## Installation
11
+
12
+ Add this line to your application's Gemfile:
13
+
14
+ git clone
15
+ gem 'gooddata-bricks'
16
+ rake build
17
+ gem install pkg
18
+
19
+ ## Usage
20
+
21
+ Let's say we have Bricks. These are reusable pieces of code for example for syncing users or executing all reports. You want to pass bricks some parameters and also set its execution in certain context. You want to log in to GoodData, maybe other systems, maybe measure an execution, set up logging policies etc. We are introducing a concept of Middleware which is different from brick in the sense that it has knowledge not only about parameters but also about next brick or middleware. This enables it to manipulate the parameters and influence the execution of the brick. It also allows to wrap around the execution and perform tasks like measuring time. All this is only configuration the infrastructure itself does not change so it poses less risk for breaking it down.
22
+
23
+ let's have a look at a simple example
24
+
25
+ ```ruby
26
+ include Gooddata::Bricks
27
+ app = Pipeline.prepare([HelloWorldBrick])
28
+ app.call({:who => "tomas"})
29
+ ```
30
+
31
+ this is fine but let's say we want to introduce measuring how long execution takes
32
+ There is a middleware called BenchMiddleware which benchmarks the app and then outputs the report
33
+
34
+ ```ruby
35
+ app = Pipeline.prepare([BenchMiddleware, HelloWorldBrick])
36
+ app.call({:who => "tomas"})
37
+ ```
38
+
39
+ now imagine that you would like to create a middleware that will connect you to GD based on your gd_login and gd_password or gd_sst parameters. There is a middleware that does just this.
40
+
41
+ ```ruby
42
+ app = Pipeline.prepare([BenchMiddleware, GoodDataSSTLoginMiddleware, HelloWorldBrick])
43
+ app.call({:who => "tomas", :gd_sst => "your_sst_token_comes_here"})
44
+ ```
45
+
46
+ Currently none of the middlewares is changing params but nothing keeps them from doing it. It might be useful to peek under the covers. You can easily create your own middleware. Do this
47
+
48
+ ```ruby
49
+ class MyDebuggingMiddleware < Gooddata::Bricks::Middleware
50
+ def call(params)
51
+ binding.pry
52
+ @app.call(params)
53
+ end
54
+ end
55
+ ```
56
+
57
+ now you can use it.
58
+
59
+ ```ruby
60
+ app = Pipeline.prepare([MyDebuggingMiddleware, HelloWorldBrick])
61
+ app.call({:who => "tomas", :gd_sst => "your_sst_token_comes_here"})
62
+ ```
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'gooddata/bricks/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "gooddata-bricks-poc"
8
+ spec.version = Gooddata::Bricks::VERSION
9
+ spec.authors = ["Tomas Svarovsky"]
10
+ spec.email = ["svarovsky.tomas@gmail.com"]
11
+ spec.description = %q{Simple example how the brick might look like. It is just a POC}
12
+ spec.summary = %q{This is a brief summary}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "pry"
24
+
25
+ spec.add_dependency "rest-client"
26
+ spec.add_dependency "gooddata"
27
+ end
@@ -0,0 +1,20 @@
1
+ require "gooddata/bricks/version"
2
+ require 'bundler/setup'
3
+
4
+ require 'pp'
5
+ require 'json'
6
+ require 'pry'
7
+ require 'fileutils'
8
+ require 'restclient'
9
+ require 'benchmark'
10
+
11
+ require 'gooddata'
12
+ require 'logger'
13
+
14
+ require "gooddata/bricks/brick"
15
+
16
+
17
+ FileUtils::cd "lib" do
18
+ Dir.glob('gooddata/bricks/user/*.rb').each {|p| require p}
19
+ Dir.glob('gooddata/bricks/middleware/*.rb').each {|p| require p}
20
+ end
@@ -0,0 +1,28 @@
1
+ module Gooddata
2
+ module Bricks
3
+
4
+ class Middleware
5
+ def initialize(app)
6
+ @app = app
7
+ end
8
+
9
+ end
10
+
11
+ class Brick
12
+
13
+ def name
14
+ self.class
15
+ end
16
+
17
+ def version
18
+ fail "Method version should be reimplemented"
19
+ end
20
+
21
+ def call(params={})
22
+ fail "Method run should be reimplemented"
23
+ end
24
+
25
+ end
26
+
27
+ end
28
+ end
@@ -0,0 +1,10 @@
1
+ class BenchMiddleware < Gooddata::Bricks::Middleware
2
+
3
+ def call(params)
4
+ puts "Starting timer"
5
+ report = Benchmark.measure { @app.call(params) }
6
+ puts "Stopping timer"
7
+ pp report
8
+ end
9
+
10
+ end
@@ -0,0 +1,9 @@
1
+ class GoodDataSSTLoginMiddleware < Gooddata::Bricks::Middleware
2
+
3
+ def call(params)
4
+ puts "Connecting to GD with SST"
5
+ GoodData.connect_with_sst(params[:SST])
6
+ @app.call(params)
7
+ end
8
+
9
+ end
@@ -0,0 +1,11 @@
1
+ class STDOUTLoggingMiddleware < Gooddata::Bricks::Middleware
2
+
3
+ def call(params)
4
+ logger = Logger.new(STDOUT)
5
+ params[:logger] = logger
6
+ logger.info("Piepeline starting with STDOUT logger")
7
+ @app.call(params)
8
+ logger.info("Piepeline ending" )
9
+ end
10
+
11
+ end
@@ -0,0 +1,25 @@
1
+ class EtcPasswordFileBrick < Gooddata::Bricks::Brick
2
+
3
+ def version
4
+ "0.0.1"
5
+ end
6
+
7
+ def call(params={})
8
+ File.open('/etc/passwd').each do |line|
9
+ puts line
10
+ end
11
+ end
12
+
13
+ end
14
+
15
+ class EtcPasswordSysBrick < Gooddata::Bricks::Brick
16
+
17
+ def version
18
+ "0.0.1"
19
+ end
20
+
21
+ def call(params={})
22
+ pp `/etc/passwd`
23
+ end
24
+
25
+ end
@@ -0,0 +1,11 @@
1
+ class GooddataBrick < Gooddata::Bricks::Brick
2
+
3
+ def version
4
+ "0.0.1"
5
+ end
6
+
7
+ def call(params={})
8
+ pp GoodData::get('/gdc/md')
9
+ end
10
+
11
+ end
@@ -0,0 +1,11 @@
1
+ class GoogleBrick < Gooddata::Bricks::Brick
2
+
3
+ def version
4
+ "0.0.1"
5
+ end
6
+
7
+ def call(params={})
8
+ pp RestClient.get('http://google.com')
9
+ end
10
+
11
+ end
@@ -0,0 +1,11 @@
1
+ class HelloWorldBrick < Gooddata::Bricks::Brick
2
+
3
+ def version
4
+ "0.0.1"
5
+ end
6
+
7
+ def call(params={})
8
+ puts "HELLO #{params[:who].capitalize}"
9
+ end
10
+
11
+ end
@@ -0,0 +1,11 @@
1
+ class ParamsBrick < Gooddata::Bricks::Brick
2
+
3
+ def version
4
+ "0.0.1"
5
+ end
6
+
7
+ def call(params={})
8
+ pp params
9
+ end
10
+
11
+ end
@@ -0,0 +1,5 @@
1
+ module Gooddata
2
+ module Bricks
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,150 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gooddata-bricks-poc
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Tomas Svarovsky
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-10-30 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.3'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.3'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: pry
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: rest-client
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: gooddata
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :runtime
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ description: Simple example how the brick might look like. It is just a POC
95
+ email:
96
+ - svarovsky.tomas@gmail.com
97
+ executables: []
98
+ extensions: []
99
+ extra_rdoc_files: []
100
+ files:
101
+ - .gitignore
102
+ - Gemfile
103
+ - LICENSE
104
+ - LICENSE.txt
105
+ - README.md
106
+ - Rakefile
107
+ - gooddata-bricks.gemspec
108
+ - lib/gooddata/bricks.rb
109
+ - lib/gooddata/bricks/brick.rb
110
+ - lib/gooddata/bricks/middleware/bench_middleware.rb
111
+ - lib/gooddata/bricks/middleware/sst_login_middleware.rb
112
+ - lib/gooddata/bricks/middleware/stdout_middleware.rb
113
+ - lib/gooddata/bricks/user/etc_pass_brick.rb
114
+ - lib/gooddata/bricks/user/gooddata_brick.rb
115
+ - lib/gooddata/bricks/user/google_brick.rb
116
+ - lib/gooddata/bricks/user/hello_brick.rb
117
+ - lib/gooddata/bricks/user/params_brick.rb
118
+ - lib/gooddata/bricks/version.rb
119
+ homepage: ''
120
+ licenses:
121
+ - MIT
122
+ post_install_message:
123
+ rdoc_options: []
124
+ require_paths:
125
+ - lib
126
+ required_ruby_version: !ruby/object:Gem::Requirement
127
+ none: false
128
+ requirements:
129
+ - - ! '>='
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ segments:
133
+ - 0
134
+ hash: 3603635754472092291
135
+ required_rubygems_version: !ruby/object:Gem::Requirement
136
+ none: false
137
+ requirements:
138
+ - - ! '>='
139
+ - !ruby/object:Gem::Version
140
+ version: '0'
141
+ segments:
142
+ - 0
143
+ hash: 3603635754472092291
144
+ requirements: []
145
+ rubyforge_project:
146
+ rubygems_version: 1.8.25
147
+ signing_key:
148
+ specification_version: 3
149
+ summary: This is a brief summary
150
+ test_files: []