cq-ruby 0.0.1

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: 2d0d28e854a85b7cb5559396a8615d587b4d5609
4
+ data.tar.gz: 80a1b5752b45bfbaa80bab5c9cfdbfb4e3714e00
5
+ SHA512:
6
+ metadata.gz: 8947f4277cceebd2ea6cd2cc2e36d1b0495616d020d9679f568e3ddcf75c8d9ba61a08ca83c4eae5455b41d53aa42ff228bcc2ea87777f74a7f6c33201d2670a
7
+ data.tar.gz: 501dcf62d11f4b1c411c73c2c48e41093553ca074e4d5d444fc3ae46f825b3edb89b797d9257105d3c90416f36192c230f70e86d58cfdb4305fd031c7a5831b5
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in cq-ruby.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Yared Tseghu
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,29 @@
1
+ # Cq::Ruby
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'cq-ruby'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install cq-ruby
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it ( http://github.com/<my-github-username>/cq-ruby/fork )
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/cq-ruby.gemspec ADDED
@@ -0,0 +1,29 @@
1
+ # require_relative 'lib/cq'
2
+ # coding: utf-8
3
+ # lib = File.expand_path('../lib', __FILE__)
4
+ # $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ $:.push File.expand_path("../lib", __FILE__)
6
+ require './lib/cq/version'
7
+
8
+ Gem::Specification.new do |spec|
9
+ spec.name = "cq-ruby"
10
+ spec.version = CQ::VERSION
11
+ spec.authors = ["Yared Tseghu"]
12
+ spec.email = ["yared.tseghu@gmail.com"]
13
+ spec.summary = %q{ Client to get json format from CQ5 and later version }
14
+ spec.description = %q{ Write a longer description. Optional.}
15
+ spec.homepage = ""
16
+ spec.license = "MIT"
17
+
18
+ # spec.files = Dir["README.md","Gemfile","Rakefile", "spec/*", "lib/**/*"]
19
+ spec.files = `git ls-files -z`.split("\x0")
20
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
21
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.5"
25
+ spec.add_development_dependency "rake"
26
+ spec.add_development_dependency "railties"
27
+ spec.add_runtime_dependency "activesupport"
28
+ spec.add_development_dependency "rspec"
29
+ end
data/lib/.DS_Store ADDED
Binary file
data/lib/cq-ruby.rb ADDED
@@ -0,0 +1,19 @@
1
+ $: << File.expand_path(File.dirname(__FILE__))
2
+
3
+ require 'active_support/inflector'
4
+ ActiveSupport::Inflector.inflections do |inflector|
5
+ inflector.singular 'status', 'status'
6
+ end
7
+
8
+ require 'cq/client'
9
+ require 'cq/http_client'
10
+ require 'cq/http_error'
11
+ require 'cq/request_client'
12
+ require 'cq/version'
13
+
14
+
15
+ require 'cq/resources/component'
16
+ require 'cq/resources/content'
17
+ require 'cq/resources/cq_users'
18
+ require 'cq/resources/node'
19
+ require 'cq/resources/page'
data/lib/cq/.DS_Store ADDED
Binary file
data/lib/cq/client.rb ADDED
@@ -0,0 +1,66 @@
1
+ require 'json'
2
+ require 'forwardable'
3
+ # require_relative "http_client"
4
+
5
+ module CQ
6
+ class Client
7
+
8
+ # The configuration options for this client instance
9
+ attr_reader :options
10
+
11
+ DEFAULT_OPTIONS = {
12
+ :auth_type => :basic
13
+ }
14
+
15
+ def initialize(options={})
16
+ options = DEFAULT_OPTIONS.merge(options)
17
+ options[:site] ||= 'http://localhost:4502'
18
+ @options = options
19
+
20
+ case options[:auth_type]
21
+ when :basic
22
+ @request_client = HttpClient.new(@options)
23
+ end
24
+
25
+ @options.freeze
26
+ end
27
+
28
+ # HTTP methods without a body
29
+ def delete(path, headers = {})
30
+ request(:delete, path, nil, merge_default_headers(headers))
31
+ end
32
+
33
+ def get(path, headers = {})
34
+ request(:get, path, nil, merge_default_headers(headers))
35
+ end
36
+
37
+ def head(path, headers = {})
38
+ request(:head, path, nil, merge_default_headers(headers))
39
+ end
40
+
41
+ # HTTP methods with a body
42
+ def post(path, body = '', headers = {})
43
+ headers = {'Content-Type' => 'application/json'}.merge(headers)
44
+ request(:post, path, body, merge_default_headers(headers))
45
+ end
46
+
47
+ def put(path, body = '', headers = {})
48
+ headers = {'Content-Type' => 'application/json'}.merge(headers)
49
+ request(:put, path, body, merge_default_headers(headers))
50
+ end
51
+
52
+ # Sends the specified HTTP request to the REST API through the
53
+ # appropriate method (oauth, basic).
54
+ def request(http_method, path, body = '', headers={})
55
+ @request_client.request(http_method, path, body, headers)
56
+ end
57
+
58
+ protected
59
+
60
+ def merge_default_headers(headers)
61
+ {'Accept' => 'application/json'}.merge(headers)
62
+ end
63
+
64
+ end
65
+ end
66
+
@@ -0,0 +1,45 @@
1
+ require 'json'
2
+ require 'net/https'
3
+ require_relative "request_client"
4
+
5
+ module CQ
6
+ class HttpClient < RequestClient
7
+
8
+ DEFAULT_OPTIONS = {
9
+ :username => 'admin',
10
+ :password => 'admin'
11
+ }
12
+
13
+ attr_reader :options
14
+
15
+ def initialize(options)
16
+ @options = DEFAULT_OPTIONS.merge(options)
17
+ end
18
+
19
+ def make_request(http_method, path, body='', headers={})
20
+ request = Net::HTTP.const_get(http_method.to_s.capitalize).new(path, headers)
21
+ request.body = body unless body.nil?
22
+ request.basic_auth(@options[:username], @options[:password])
23
+ response = basic_auth_http_conn.request(request)
24
+ response
25
+ end
26
+
27
+ def basic_auth_http_conn
28
+ http_conn(uri)
29
+ end
30
+
31
+ def http_conn(uri)
32
+ # if @options[:proxy_address]
33
+ # http_class = Net::HTTP::Proxy(@options[:proxy_address], @options[:proxy_port] ? @options[:proxy_port] : 80)
34
+ # else
35
+ # http_class = Net::HTTP
36
+ # end
37
+ http_conn = Net::HTTP.new(uri.host, uri.port)
38
+ http_conn
39
+ end
40
+
41
+ def uri
42
+ uri = URI.parse(@options[:site])
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,17 @@
1
+ require 'forwardable'
2
+
3
+ module CQ
4
+
5
+ class HTTPError < StandardError
6
+ extend Forwardable
7
+
8
+ def_instance_delegators :@response, :message, :code
9
+ attr_reader :response
10
+
11
+ def initialize(response)
12
+ @response = response
13
+ end
14
+
15
+ end
16
+
17
+ end
@@ -0,0 +1,29 @@
1
+ require 'json'
2
+ require 'net/https'
3
+ # require_relative "http_error"
4
+
5
+ module CQ
6
+ class RequestClient
7
+
8
+ def request(*args)
9
+ response = make_request(*args)
10
+ raise HTTPError.new(response) unless response.kind_of?(Net::HTTPSuccess)
11
+ response
12
+ end
13
+ end
14
+ end
15
+
16
+ # class Bar
17
+ # def name
18
+ # name_test
19
+ # end
20
+ # end
21
+
22
+ # class Foo < Bar
23
+ # def name_test
24
+ # puts "Hello World"
25
+ # end
26
+ # end
27
+
28
+ # a = Foo.new
29
+ # puts a.name
@@ -0,0 +1,14 @@
1
+ module CQ
2
+ module Resource
3
+ class Component
4
+
5
+ def initialize
6
+
7
+ end
8
+
9
+ def components
10
+
11
+ end
12
+ end
13
+ end
14
+ end
File without changes
File without changes
File without changes
@@ -0,0 +1,27 @@
1
+ module CQ
2
+ module Resource
3
+ class Page
4
+
5
+ def initialize
6
+
7
+ end
8
+
9
+ def pages
10
+
11
+ end
12
+
13
+ def activate
14
+
15
+ end
16
+
17
+ def deactivate
18
+
19
+ end
20
+
21
+ def activate?
22
+
23
+ end
24
+
25
+ end
26
+ end
27
+ end
data/lib/cq/version.rb ADDED
@@ -0,0 +1,3 @@
1
+ module CQ
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,133 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cq-ruby
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Yared Tseghu
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-05-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.5'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: railties
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: activesupport
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: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: ' Write a longer description. Optional.'
84
+ email:
85
+ - yared.tseghu@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - .gitignore
91
+ - Gemfile
92
+ - LICENSE.txt
93
+ - README.md
94
+ - Rakefile
95
+ - cq-ruby.gemspec
96
+ - lib/.DS_Store
97
+ - lib/cq-ruby.rb
98
+ - lib/cq/.DS_Store
99
+ - lib/cq/client.rb
100
+ - lib/cq/http_client.rb
101
+ - lib/cq/http_error.rb
102
+ - lib/cq/request_client.rb
103
+ - lib/cq/resources/component.rb
104
+ - lib/cq/resources/content.rb
105
+ - lib/cq/resources/cq_users.rb
106
+ - lib/cq/resources/node.rb
107
+ - lib/cq/resources/page.rb
108
+ - lib/cq/version.rb
109
+ homepage: ''
110
+ licenses:
111
+ - MIT
112
+ metadata: {}
113
+ post_install_message:
114
+ rdoc_options: []
115
+ require_paths:
116
+ - lib
117
+ required_ruby_version: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - '>='
120
+ - !ruby/object:Gem::Version
121
+ version: '0'
122
+ required_rubygems_version: !ruby/object:Gem::Requirement
123
+ requirements:
124
+ - - '>='
125
+ - !ruby/object:Gem::Version
126
+ version: '0'
127
+ requirements: []
128
+ rubyforge_project:
129
+ rubygems_version: 2.2.2
130
+ signing_key:
131
+ specification_version: 4
132
+ summary: Client to get json format from CQ5 and later version
133
+ test_files: []