dhclient 0.1.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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 43bb45515f3ea6a84d36ad4a483163de8a8aa0af
4
+ data.tar.gz: a09e6918428ba98f1f39c3cf5752a278a6e949e6
5
+ SHA512:
6
+ metadata.gz: e1e88b913675a5741d09f97b9171a704f05947e21dc985248383c98ab6b99570c9f255f0c1dfe7caf48e914a234c86e363962910ea5adf756b32ec793bd62dc4
7
+ data.tar.gz: f48147c2e4c6413a8ce926fa10f12dc4c798adbb7639092a059e4905ef307d982675c63016b79e4bc91230186ee33c7e521103c1a5924e9fae7f11e89f05a590
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ .DS_Store
2
+ results.html
3
+ pkg
4
+ html
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm use ruby-2.4.0@dh-client --create
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in dhclient.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,88 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ dhclient (0.1.0)
5
+ json (~> 2.0.2)
6
+ methadone (~> 1.9.5)
7
+ pry
8
+ rest-client (~> 2.0.1)
9
+
10
+ GEM
11
+ remote: https://rubygems.org/
12
+ specs:
13
+ aruba (0.14.2)
14
+ childprocess (~> 0.5.6)
15
+ contracts (~> 0.9)
16
+ cucumber (>= 1.3.19)
17
+ ffi (~> 1.9.10)
18
+ rspec-expectations (>= 2.99)
19
+ thor (~> 0.19)
20
+ builder (3.2.3)
21
+ childprocess (0.5.9)
22
+ ffi (~> 1.0, >= 1.0.11)
23
+ coderay (1.1.1)
24
+ contracts (0.15.0)
25
+ cucumber (2.4.0)
26
+ builder (>= 2.1.2)
27
+ cucumber-core (~> 1.5.0)
28
+ cucumber-wire (~> 0.0.1)
29
+ diff-lcs (>= 1.1.3)
30
+ gherkin (~> 4.0)
31
+ multi_json (>= 1.7.5, < 2.0)
32
+ multi_test (>= 0.1.2)
33
+ cucumber-core (1.5.0)
34
+ gherkin (~> 4.0)
35
+ cucumber-wire (0.0.1)
36
+ diff-lcs (1.3)
37
+ domain_name (0.5.20170223)
38
+ unf (>= 0.0.5, < 1.0.0)
39
+ ffi (1.9.18)
40
+ gherkin (4.1.1)
41
+ http-cookie (1.0.3)
42
+ domain_name (~> 0.5)
43
+ json (2.0.3)
44
+ methadone (1.9.5)
45
+ bundler
46
+ method_source (0.8.2)
47
+ mime-types (3.1)
48
+ mime-types-data (~> 3.2015)
49
+ mime-types-data (3.2016.0521)
50
+ multi_json (1.12.1)
51
+ multi_test (0.1.2)
52
+ netrc (0.11.0)
53
+ power_assert (1.0.1)
54
+ pry (0.10.4)
55
+ coderay (~> 1.1.0)
56
+ method_source (~> 0.8.1)
57
+ slop (~> 3.4)
58
+ rake (10.5.0)
59
+ rdoc (5.1.0)
60
+ rest-client (2.0.1)
61
+ http-cookie (>= 1.0.2, < 2.0)
62
+ mime-types (>= 1.16, < 4.0)
63
+ netrc (~> 0.8)
64
+ rspec-expectations (3.5.0)
65
+ diff-lcs (>= 1.2.0, < 2.0)
66
+ rspec-support (~> 3.5.0)
67
+ rspec-support (3.5.0)
68
+ slop (3.6.0)
69
+ test-unit (3.2.3)
70
+ power_assert
71
+ thor (0.19.4)
72
+ unf (0.1.4)
73
+ unf_ext
74
+ unf_ext (0.0.7.2)
75
+
76
+ PLATFORMS
77
+ ruby
78
+
79
+ DEPENDENCIES
80
+ aruba
81
+ bundler (~> 1.14)
82
+ dhclient!
83
+ rake (~> 10.0)
84
+ rdoc
85
+ test-unit
86
+
87
+ BUNDLED WITH
88
+ 1.14.6
data/README.md ADDED
@@ -0,0 +1,60 @@
1
+ # DHClient
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/dhclient`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'dhclient'
12
+ ```
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install dhclient
21
+
22
+ ## Usage
23
+
24
+ There are several commands available, covering loading data and starting and monitoring compositions and publications. These are their usages:
25
+
26
+ ```
27
+ $ dhclient --url http://localhost:8080/datahub-webapp/v1 --user admin --password nimda version
28
+ # displays Datahub version
29
+
30
+ $ dhclient --url http://localhost:8080/datahub-webapp/v1 --user admin --password nimda status
31
+ # display raw/canonical/target item processing status
32
+
33
+ $ dhclient --url http://localhost:8080/datahub-webapp/v1 --user admin --password nimda compositions
34
+ # displays a XML with information about all compositions
35
+
36
+ $ dhclient --url http://localhost:8080/datahub-webapp/v1 --user admin --password nimda publications
37
+ # displays an JSON with information about all publications
38
+
39
+ $ dhclient --url http://localhost:8080/datahub-webapp/v1 --user admin --password nimda load_data --file MY_CSV_FILE --feed SOME_FEED --raw MyRawItem
40
+ # loads data from MY_CSV_FILE into SOME_FEED as MyRawItem.
41
+
42
+ $ dhclient --url http://localhost:8080/datahub-webapp/v1 --user admin --password nimda start_composition --pool SOME_POOL
43
+ # starts composition at SOME_POOL
44
+
45
+ $ dhclient --url http://localhost:8080/datahub-webapp/v1 --user admin --password nimda start_publication --pool SOME_POOL --target SOME_TARGET_SYSTEM
46
+ # starts publication at SOME_POOL into SOME_TAREGT_SYSTEM
47
+
48
+ ```
49
+
50
+
51
+ ## Development
52
+
53
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
54
+
55
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
56
+
57
+ ## Contributing
58
+
59
+ Bug reports and pull requests are welcome on GitHub at https://github.com/danielqo/dhclient.
60
+
data/README.rdoc ADDED
@@ -0,0 +1,19 @@
1
+ = dhclient - DESCRIBE YOUR GEM
2
+
3
+ Author:: YOUR NAME (YOUR EMAIL)
4
+ Copyright:: Copyright (c) 2017 YOUR NAME
5
+
6
+
7
+ DESCRIBE YOUR GEM HERE
8
+
9
+ == Links
10
+
11
+ * {Source on Github}[LINK TO GITHUB]
12
+ * RDoc[LINK TO RDOC.INFO]
13
+
14
+ == Install
15
+
16
+ == Examples
17
+
18
+ == Contributing
19
+
data/Rakefile ADDED
@@ -0,0 +1,61 @@
1
+ def dump_load_path
2
+ puts $LOAD_PATH.join("\n")
3
+ found = nil
4
+ $LOAD_PATH.each do |path|
5
+ if File.exists?(File.join(path,"rspec"))
6
+ puts "Found rspec in #{path}"
7
+ if File.exists?(File.join(path,"rspec","core"))
8
+ puts "Found core"
9
+ if File.exists?(File.join(path,"rspec","core","rake_task"))
10
+ puts "Found rake_task"
11
+ found = path
12
+ else
13
+ puts "!! no rake_task"
14
+ end
15
+ else
16
+ puts "!!! no core"
17
+ end
18
+ end
19
+ end
20
+ if found.nil?
21
+ puts "Didn't find rspec/core/rake_task anywhere"
22
+ else
23
+ puts "Found in #{path}"
24
+ end
25
+ end
26
+ require 'bundler'
27
+ require 'rake/clean'
28
+
29
+ require 'rake/testtask'
30
+
31
+ require 'cucumber'
32
+ require 'cucumber/rake/task'
33
+ gem 'rdoc' # we need the installed RDoc gem, not the system one
34
+ require 'rdoc/task'
35
+
36
+ include Rake::DSL
37
+
38
+ Bundler::GemHelper.install_tasks
39
+
40
+
41
+ Rake::TestTask.new do |t|
42
+ t.pattern = 'test/tc_*.rb'
43
+ end
44
+
45
+
46
+ CUKE_RESULTS = 'results.html'
47
+ CLEAN << CUKE_RESULTS
48
+ Cucumber::Rake::Task.new(:features) do |t|
49
+ t.cucumber_opts = "features --format html -o #{CUKE_RESULTS} --format pretty --no-source -x"
50
+ t.fork = false
51
+ end
52
+
53
+ Rake::RDocTask.new do |rd|
54
+
55
+ rd.main = "README.rdoc"
56
+
57
+ rd.rdoc_files.include("README.rdoc","lib/**/*.rb","bin/**/*")
58
+ end
59
+
60
+ task :default => [:test,:features]
61
+
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "dhclient"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ require "pry"
11
+ Pry.start
12
+
13
+ # require "irb"
14
+ # IRB.start(__FILE__)
data/bin/dhclient ADDED
@@ -0,0 +1,49 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'optparse'
4
+ require 'methadone'
5
+ require 'dhclient.rb'
6
+
7
+ class App
8
+ include Methadone::Main
9
+ include Methadone::CLILogging
10
+
11
+ # bin/dhclient load
12
+
13
+ main do |command|
14
+ GETCMD = ["version", "status", "compositions", "publications"]
15
+ POSTCMD = ["load_data", "start_composition", "start_publication"]
16
+ dh = DHClient::Datahub.new(options['url'], options['user'], options['password'])
17
+ if GETCMD.include? command
18
+ puts dh.send(command.to_sym)
19
+ else
20
+ case command
21
+ when "load_data"
22
+ puts dh.load_data options['file'], options['feed'], options['raw']
23
+ when "start_composition"
24
+ puts dh.start_composition options['pool']
25
+ when "start_publication"
26
+ puts dh.start_publication options['pool'], options['target']
27
+ end
28
+ end
29
+
30
+ end
31
+
32
+
33
+ version DHClient::VERSION
34
+
35
+ on '--url URL', "Datahub base URL (e.g.: http://localhost:8080/datahub-webapp/v1)."
36
+ on '--user USER', "Datahub user for HTTP Basic Authentication."
37
+ on '--password PASSWORD', "Datahub password for HTTP Basic Authentication."
38
+ on '--file FILE', 'File path with data to be loaded into Datahub for the <load_data> command.'
39
+ on '--feed FEED', 'Feed name where data should be loaded into Datahub for the <load_data> command.'
40
+ on '--raw RAW', 'Raw item name that represents the data that will be loaded using <load_data> command.'
41
+ on '--pool POOL', 'Pool name for <start_composition> and <start_publication> commands.'
42
+ on '--target TARGET', 'Target system name for <start_publication> command.'
43
+
44
+ arg :command, "Datahub operation you want to perform: [version | status | compositions | publications | load_data | start_composition | start_publication]."
45
+
46
+ use_log_level_option :toggle_debug_on_signal => 'USR1'
47
+
48
+ go!
49
+ end
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/dhclient.gemspec ADDED
@@ -0,0 +1,43 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'dhclient/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "dhclient"
8
+ spec.license = "MIT"
9
+ spec.version = DHClient::VERSION
10
+ spec.authors = ["Daniel Quirino Oliveira"]
11
+ spec.email = ["daniel.oliveura@hybris.com"]
12
+
13
+ spec.summary = %q{Simple SAP Hybris Datahub client}
14
+ spec.description = %q{Simple SAP Hybris Datahub client for performing the most common operations}
15
+ spec.homepage = "http://hybris.com"
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+ # if spec.respond_to?(:metadata)
20
+ # spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
21
+ # else
22
+ # raise "RubyGems 2.0 or newer is required to protect against " \
23
+ # "public gem pushes."
24
+ # end
25
+
26
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
27
+ f.match(%r{^(test|spec|features)/})
28
+ end
29
+ spec.bindir = "exe"
30
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
31
+ spec.require_paths = ["lib"]
32
+
33
+ spec.add_dependency('methadone', '~> 1.9.5')
34
+ spec.add_dependency('json', '~> 2.0.2')
35
+ spec.add_dependency('rest-client', '~> 2.0.1')
36
+ spec.add_dependency('pry')
37
+
38
+ spec.add_development_dependency("bundler", "~> 1.14")
39
+ spec.add_development_dependency("rake", "~> 10.0")
40
+ spec.add_development_dependency('rdoc')
41
+ spec.add_development_dependency('aruba')
42
+ spec.add_development_dependency('test-unit')
43
+ end
@@ -0,0 +1,55 @@
1
+ module DHClient
2
+ class Datahub
3
+
4
+ def initialize(base_url="http://localhost:8080/datahub-webapp/v1", username="admin", password="nimda")
5
+ uri = URI.parse(base_url)
6
+ @datahub_base_url = "#{uri.scheme}://#{username}:#{password}@#{uri.host}:#{uri.port}#{uri.path}"
7
+ end
8
+
9
+ #GET
10
+
11
+ def version
12
+ response = ::RestClient.get "#{@datahub_base_url}/version"
13
+ response.body
14
+ end
15
+
16
+ def status
17
+ response = RestClient.get "#{@datahub_base_url}/status-counts"
18
+ response.body
19
+ end
20
+
21
+ def compositions(pool_name='GLOBAL')
22
+ response = RestClient.get "#{@datahub_base_url}/pools/#{pool_name}/compositions"
23
+ response.body
24
+ end
25
+
26
+ def publications(pool_name='GLOBAL')
27
+ response = RestClient.get "#{@datahub_base_url}/pools/#{pool_name}/publications"
28
+ response.body
29
+ end
30
+
31
+ #POST
32
+
33
+ def load_data(file, feed_name='DEFAULT_FEED', raw_item_name)
34
+ data = File.new(file, 'rb')
35
+ http_post "#{@datahub_base_url}/data-feeds/#{feed_name}/items/#{raw_item_name}", data, content_type: 'application/octet-stream'
36
+ end
37
+
38
+ def start_composition(pool_name='GLOBAL')
39
+ http_post "#{@datahub_base_url}/pools/#{pool_name}/compositions"
40
+ end
41
+
42
+ def start_publication(pool_name='GLOBAL', target_system)
43
+ json_payload = {targetSystemPublications: [
44
+ {targetSystemName: target_system}
45
+ ]}.to_json
46
+ http_post "#{@datahub_base_url}/pools/#{pool_name}/publications", json_payload, {content_type: :json, accept: :json}
47
+ end
48
+
49
+ private
50
+
51
+ def http_post(url, payload={}, headers={})
52
+ RestClient.post url, payload, headers
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,3 @@
1
+ module DHClient
2
+ VERSION = "0.1.0"
3
+ end
data/lib/dhclient.rb ADDED
@@ -0,0 +1,8 @@
1
+ require 'rest_client'
2
+ require 'json'
3
+ require "dhclient/version"
4
+ require "dhclient/datahub"
5
+
6
+ module DHClient
7
+
8
+ end
metadata ADDED
@@ -0,0 +1,184 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dhclient
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Daniel Quirino Oliveira
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-03-30 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: methadone
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 1.9.5
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 1.9.5
27
+ - !ruby/object:Gem::Dependency
28
+ name: json
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 2.0.2
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 2.0.2
41
+ - !ruby/object:Gem::Dependency
42
+ name: rest-client
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 2.0.1
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 2.0.1
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: bundler
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.14'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.14'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '10.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '10.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rdoc
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: aruba
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: test-unit
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ description: Simple SAP Hybris Datahub client for performing the most common operations
140
+ email:
141
+ - daniel.oliveura@hybris.com
142
+ executables: []
143
+ extensions: []
144
+ extra_rdoc_files: []
145
+ files:
146
+ - ".gitignore"
147
+ - ".rvmrc"
148
+ - Gemfile
149
+ - Gemfile.lock
150
+ - README.md
151
+ - README.rdoc
152
+ - Rakefile
153
+ - bin/console
154
+ - bin/dhclient
155
+ - bin/setup
156
+ - dhclient.gemspec
157
+ - lib/dhclient.rb
158
+ - lib/dhclient/datahub.rb
159
+ - lib/dhclient/version.rb
160
+ homepage: http://hybris.com
161
+ licenses:
162
+ - MIT
163
+ metadata: {}
164
+ post_install_message:
165
+ rdoc_options: []
166
+ require_paths:
167
+ - lib
168
+ required_ruby_version: !ruby/object:Gem::Requirement
169
+ requirements:
170
+ - - ">="
171
+ - !ruby/object:Gem::Version
172
+ version: '0'
173
+ required_rubygems_version: !ruby/object:Gem::Requirement
174
+ requirements:
175
+ - - ">="
176
+ - !ruby/object:Gem::Version
177
+ version: '0'
178
+ requirements: []
179
+ rubyforge_project:
180
+ rubygems_version: 2.6.8
181
+ signing_key:
182
+ specification_version: 4
183
+ summary: Simple SAP Hybris Datahub client
184
+ test_files: []