common-ruby-monupco 0.0.5

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,6 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+
6
+ *~
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in common-ruby-monupco.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012, Svetlozar Argirov <zarrro [AT] gmail.com>
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
20
+
data/README.md ADDED
@@ -0,0 +1,4 @@
1
+ This is a generic Ruby module used by monupco.com.
2
+
3
+ If you want to install into your Ruby application see
4
+ the monupco-\<cloud_vendor\>-ruby packages for usage.
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "common-ruby-monupco/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "common-ruby-monupco"
7
+ s.version = Monupco::MonupcoBase::VERSION
8
+ s.authors = ["Svetlozar Argirov"]
9
+ s.email = ["zarrro@gmail.com"]
10
+ s.homepage = "http://github.com/monupco/common-ruby-monupco"
11
+ s.summary = %q{Common module for Monupco ruby clients}
12
+ s.description = %q{Common module for Monupco ruby clients. Not intended for direct use. Use a monupco-\<cloud_vendor\>-ruby gem instead. }
13
+
14
+ s.rubyforge_project = "common-ruby-monupco"
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
+
21
+ # specify any dependencies here; for example:
22
+ # s.add_development_dependency "rspec"
23
+ s.add_runtime_dependency "json"
24
+ end
@@ -0,0 +1,87 @@
1
+ require "common-ruby-monupco/version"
2
+ require "bundler"
3
+ require 'net/http'
4
+ require 'net/https'
5
+ require 'json'
6
+
7
+ module Monupco
8
+ class MonupcoBase
9
+ @@monupco_url = "https://monupco-otb.rhcloud.com/application/register/"
10
+ @@post_data = {
11
+ 'user_id' => nil,
12
+ 'app_name' => nil,
13
+ 'app_uuid' => nil,
14
+ 'app_type' => 'Ruby',
15
+ 'app_url' => nil,
16
+ 'app_vendor' => nil,
17
+ 'pkg_type' => 1,
18
+ 'installed' => [],
19
+ }
20
+
21
+ def self.configure(options)
22
+ if options['url']
23
+ @@monupco_url = options['url']
24
+ end
25
+ @@post_data.each do |k,v|
26
+ @@post_data[k] = options[k] if options[k]
27
+ end
28
+ end
29
+
30
+ def get_module_list()
31
+ Bundler.load.lock
32
+ gems = []
33
+ Bundler.load.specs.each do |g|
34
+ gems << {'n' => g.name, 'v' => "#{g.version}#{g.git_version}" }
35
+ end
36
+ return gems
37
+ end
38
+
39
+ def get_deps_as_json(gems=nil)
40
+ data = @@post_data.clone()
41
+ data['installed'] = gems || get_module_list()
42
+ return JSON.dump(data)
43
+ end
44
+
45
+ def post_to_monupco()
46
+ gems = get_module_list()
47
+ json = get_deps_as_json(gems)
48
+ this_module = vendor_module = nil
49
+ gems.each do |m|
50
+ if m['n'] == "common-ruby-monupco"
51
+ this_module = m['n'] + '/' + m['v']
52
+ end
53
+ if m['n'] =~ /monupco-(.*?)-ruby/
54
+ vendor_module = m['n'] + '/' + m['v']
55
+ end
56
+ end
57
+ headers = {
58
+ 'User-Agent' => vendor_module + ' ' + this_module
59
+ }
60
+ uri = URI(@@monupco_url)
61
+ req = Net::HTTP::Post.new(uri.path,headers)
62
+ req.set_form_data({ 'json_data' => json})
63
+ http = Net::HTTP.new(uri.host, uri.port)
64
+ http.use_ssl = true
65
+ #http.set_debug_output $stderr
66
+ res = http.start do |h|
67
+ h.request(req)
68
+ end
69
+
70
+ res
71
+ end
72
+
73
+ def cli()
74
+ if ARGV.include? '--printJSON'
75
+ puts get_deps_as_json()
76
+ exit
77
+ end
78
+ result = post_to_monupco()
79
+ case result
80
+ when Net::HTTPSuccess
81
+ puts "Monupco: #{result.body}"
82
+ else
83
+ puts "Monupco: #{result.code} #{result.message}"
84
+ end
85
+ end
86
+ end
87
+ end
@@ -0,0 +1,5 @@
1
+ module Monupco
2
+ class MonupcoBase
3
+ VERSION = "0.0.5"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,86 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: common-ruby-monupco
3
+ version: !ruby/object:Gem::Version
4
+ hash: 21
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 5
10
+ version: 0.0.5
11
+ platform: ruby
12
+ authors:
13
+ - Svetlozar Argirov
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2012-04-10 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: json
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 3
29
+ segments:
30
+ - 0
31
+ version: "0"
32
+ type: :runtime
33
+ version_requirements: *id001
34
+ description: "Common module for Monupco ruby clients. Not intended for direct use. Use a monupco-\\<cloud_vendor\\>-ruby gem instead. "
35
+ email:
36
+ - zarrro@gmail.com
37
+ executables: []
38
+
39
+ extensions: []
40
+
41
+ extra_rdoc_files: []
42
+
43
+ files:
44
+ - .gitignore
45
+ - Gemfile
46
+ - LICENSE
47
+ - README.md
48
+ - Rakefile
49
+ - common-ruby-monupco.gemspec
50
+ - lib/common-ruby-monupco.rb
51
+ - lib/common-ruby-monupco/version.rb
52
+ homepage: http://github.com/monupco/common-ruby-monupco
53
+ licenses: []
54
+
55
+ post_install_message:
56
+ rdoc_options: []
57
+
58
+ require_paths:
59
+ - lib
60
+ required_ruby_version: !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ hash: 3
66
+ segments:
67
+ - 0
68
+ version: "0"
69
+ required_rubygems_version: !ruby/object:Gem::Requirement
70
+ none: false
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ hash: 3
75
+ segments:
76
+ - 0
77
+ version: "0"
78
+ requirements: []
79
+
80
+ rubyforge_project: common-ruby-monupco
81
+ rubygems_version: 1.8.10
82
+ signing_key:
83
+ specification_version: 3
84
+ summary: Common module for Monupco ruby clients
85
+ test_files: []
86
+