pulp 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +33 -19
- data/Rakefile +3 -3
- data/VERSION +1 -1
- data/lib/pulp/connection/base.rb +24 -11
- data/lib/pulp/connection/handler.rb +4 -4
- data/lib/pulp/package.rb +2 -2
- data/lib/pulp/service.rb +3 -4
- data/pulp.gemspec +116 -0
- data/spec/pulp/common/lifecycle_spec.rb +2 -2
- data/spec/pulp/connection/base_spec.rb +62 -1
- data/spec/pulp/service_spec.rb +2 -2
- metadata +106 -154
data/README.rdoc
CHANGED
@@ -5,7 +5,7 @@ A ruby gem to talk to a pulp server using its REST-api.
|
|
5
5
|
Pulp is juicy software repository managment and so we want to talk to it in a juicy language.
|
6
6
|
|
7
7
|
The library provides easy to use, `activerecord`-like objects for the different resources you can manage
|
8
|
-
via Pulp's REST-Api. So
|
8
|
+
via Pulp's REST-Api. So if you for example like to create a new repository, you need to do only the
|
9
9
|
following:
|
10
10
|
|
11
11
|
repo = Pulp::Repository.create(
|
@@ -13,39 +13,52 @@ following:
|
|
13
13
|
:name => 'Example Repository for pulp on RHEL 6 x86_64',
|
14
14
|
:arch => 'x86_64',
|
15
15
|
:feed => "http://repos.fedorapeople.org/repos/pulp/pulp/6Server/x86_64/",
|
16
|
-
:relative_path => "pulp_test
|
16
|
+
:relative_path => "pulp_test/pulp-rhel6-x86_64",
|
17
17
|
:sync_schedule => ''
|
18
18
|
)
|
19
19
|
|
20
20
|
You can then search by any field that is allowed as search field for that repository:
|
21
21
|
|
22
|
-
Pulp::Repository.find_by_arch('x86_64').find{
|
22
|
+
repo = Pulp::Repository.find_by_arch('x86_64').find{|r| r.name == 'pulp-rhel6-x86_64' }
|
23
23
|
puts repo.name
|
24
|
+
=> 'Example Repository for pulp on RHEL 6 x86_64',
|
24
25
|
|
25
|
-
Or simply
|
26
|
+
Or simply fetch the repo by its id:
|
26
27
|
|
27
28
|
repo = Pulp::Repository.get('pulp-rhel6-x86_64')
|
28
29
|
puts repo.name
|
30
|
+
=> 'Example Repository for pulp on RHEL 6 x86_64',
|
29
31
|
|
30
|
-
|
32
|
+
You can then edit some of its fields:
|
33
|
+
|
34
|
+
repo.name => 'Example Repository for pulp on RHEL 6 x86_64 - Extended NAME'
|
35
|
+
repo.save
|
36
|
+
repo = Pulp::Repository.get('pulp-rhel6-x86_64')
|
37
|
+
puts repo.name
|
38
|
+
=> 'Example Repository for pulp on RHEL 6 x86_64 - Extended NAME'
|
39
|
+
|
40
|
+
If you don't like it anymore, you can also delete it:
|
31
41
|
|
32
42
|
repo.delete
|
33
43
|
|
34
|
-
As you
|
44
|
+
As you see, it behaves as you know things from working with activerecord.
|
35
45
|
|
36
46
|
== Disclaimer
|
37
47
|
|
38
48
|
Not all parts have already been used and tested against a real pulp server. Pulp is still a piece of software
|
39
|
-
that is moving very quickly forward. So use it only with the latest pulp version
|
40
|
-
are broken.
|
49
|
+
that is moving very quickly forward. So use it only with the latest pulp version and you might find various things
|
50
|
+
that are broken.
|
41
51
|
|
42
52
|
Bug reports / Pull requests (including tests) are welcome! See below.
|
43
53
|
|
44
54
|
== Configuration
|
45
55
|
|
46
|
-
When requiring the gem, it is looking for the
|
47
|
-
|
48
|
-
the
|
56
|
+
When requiring the gem, it is looking for the following config resources:
|
57
|
+
|
58
|
+
* an existing path in the environment variable PULP_YML
|
59
|
+
* does a yaml file exist at `~/.pulp.yaml` or `/etc/pulp/pulp.yaml`.
|
60
|
+
|
61
|
+
The pulp gem then tries to configure itself with the options from that file.
|
49
62
|
|
50
63
|
However, you can also later configure the access credentils with:
|
51
64
|
|
@@ -55,22 +68,23 @@ However, you can also later configure the access credentils with:
|
|
55
68
|
|
56
69
|
== Examples
|
57
70
|
|
58
|
-
A few examples can be found in `examples/`. The main one `repositories.rb` can easily be run
|
59
|
-
pulp server, that
|
60
|
-
It will generate a new repository, clone from it, and will cleanup at the end. Give it a shot
|
61
|
-
reading the code, might give you
|
71
|
+
A few examples can be found in `examples/`. The main one `repositories.rb` can easily be run against a local
|
72
|
+
pulp server, that is connected to the internet.
|
73
|
+
It will generate a new repository, clone from it, and will cleanup everything at the end. Give it a shot and see
|
74
|
+
how things can be used. Otherwise even reading the code, might give you an idea of how to use this gem.
|
62
75
|
|
63
76
|
== Defining resources
|
64
77
|
|
65
78
|
This gem comes with a little framework behind that provides various methods to create the classes for the
|
66
79
|
resources in a very declarative manner. The main idea is that a Pulp resource inherits from `Pulp::Connection::Base`
|
67
80
|
and then declares its field and their behavior with the various class methods. These fields and actions are mainly
|
68
|
-
|
81
|
+
taken from the existing PULP-Api documentation: https://fedorahosted.org/pulp/wiki/UGRESTAPI
|
69
82
|
|
70
83
|
The idea is to make it very easy to declare the fields and actions of resources and to not let you rewrite a lot
|
71
|
-
of common code to
|
84
|
+
of common code to interact with the REST-API. What follows is a short description of the most important fields.
|
72
85
|
|
73
|
-
By default we assume that the objects have an `id` field that is their unique identifier.
|
86
|
+
By default we assume that the objects have an `id` field that is their unique identifier. As pulp uses a mongo db as
|
87
|
+
backend, this is very likely.
|
74
88
|
|
75
89
|
We can then define further fields of the resource, with the `pulp_field(s)` method. For example for a
|
76
90
|
`Pulp::Repository` we can define the fields `arch`, `name`, `release`.
|
@@ -85,7 +99,7 @@ We can then define further fields of the resource, with the `pulp_field(s)` meth
|
|
85
99
|
|
86
100
|
puts repo.name
|
87
101
|
repo.name = 'some other name'
|
88
|
-
repo.save # will
|
102
|
+
repo.save # will do an UPDATE including the new name
|
89
103
|
|
90
104
|
You can also execute various actions on the different pulp resources. These actions can be declared using `pulp_action`:
|
91
105
|
|
data/Rakefile
CHANGED
@@ -15,10 +15,10 @@ require 'jeweler'
|
|
15
15
|
Jeweler::Tasks.new do |gem|
|
16
16
|
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
17
|
gem.name = "pulp"
|
18
|
-
gem.homepage = "https://github.com/duritong"
|
18
|
+
gem.homepage = "https://github.com/duritong/ruby-pulp"
|
19
19
|
gem.license = "MIT"
|
20
|
-
gem.summary = %Q{A little ruby wrapper around
|
21
|
-
gem.description = %Q{A little ruby wrapper around
|
20
|
+
gem.summary = %Q{A little ruby wrapper around the pulp API}
|
21
|
+
gem.description = %Q{A little ruby wrapper around the pulp (http://pulpproject.org) API}
|
22
22
|
gem.email = "mh@immerda.ch"
|
23
23
|
gem.authors = ["mh"]
|
24
24
|
# dependencies defined in Gemfile
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.9
|
data/lib/pulp/connection/base.rb
CHANGED
@@ -25,42 +25,49 @@ module Pulp
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def plain_unparsed_get(cmd, params=nil)
|
28
|
-
plain_base.connection[cmd.sub(/^#{Regexp.escape(plain_base.api_path)}\//,'')].get(merge_params(params)).body
|
28
|
+
plain_base.connection[s(cmd.sub(/^#{Regexp.escape(plain_base.api_path)}\//,''))].get(merge_params(params)).body
|
29
29
|
end
|
30
30
|
|
31
31
|
def base_unparsed_get(cmd,item=nil,params=nil)
|
32
|
-
base.connection[parse_item_cmd(item,cmd)].get(merge_params(params)).body
|
32
|
+
base.connection[s(parse_item_cmd(item,cmd))].get(merge_params(params)).body
|
33
33
|
end
|
34
34
|
|
35
35
|
def base_unparsed_delete(cmd,item=nil,params=nil)
|
36
|
-
base.connection[parse_item_cmd(item,cmd)].delete(merge_params(params)).body
|
36
|
+
base.connection[s(parse_item_cmd(item,cmd))].delete(merge_params(params)).body
|
37
37
|
end
|
38
38
|
|
39
39
|
def base_unparsed_post(cmd,item=nil,params=nil)
|
40
|
-
base.connection[parse_item_cmd(item,cmd)].post(params.nil? ? nil : params.to_json, :content_type => :json ).body
|
40
|
+
base.connection[s(parse_item_cmd(item,cmd))].post(params.nil? ? nil : params.to_json, :content_type => :json ).body
|
41
41
|
end
|
42
42
|
|
43
|
-
def base_unparsed_put(cmd,item=nil,params=nil)
|
44
|
-
|
43
|
+
def base_unparsed_put(cmd,item=nil,params=nil,binary_data=false)
|
44
|
+
if binary_data
|
45
|
+
p = params
|
46
|
+
ct = 'application/stream'
|
47
|
+
else
|
48
|
+
p = params.nil? ? nil : params.to_json
|
49
|
+
ct = :json
|
50
|
+
end
|
51
|
+
base.connection[s(parse_item_cmd(item,cmd))].put(p, :content_type => ct).body
|
45
52
|
end
|
46
53
|
|
47
54
|
def plain_get(cmd, params=nil)
|
48
|
-
plain_base.parsed{|conn| conn[cmd.sub(/^#{Regexp.escape(plain_base.api_path)}\//,'')].get(merge_params(params)) }
|
55
|
+
plain_base.parsed{|conn| conn[s(cmd.sub(/^#{Regexp.escape(plain_base.api_path)}\//,''))].get(merge_params(params)) }
|
49
56
|
end
|
50
57
|
|
51
58
|
def base_get(cmd,item=nil,params=nil)
|
52
|
-
base.parsed{|conn| conn[parse_item_cmd(item,cmd)].get(merge_params(params)) }
|
59
|
+
base.parsed{|conn| conn[s(parse_item_cmd(item,cmd))].get(merge_params(params)) }
|
53
60
|
end
|
54
61
|
|
55
62
|
def base_delete(cmd,item=nil,params=nil)
|
56
|
-
base.parsed{|conn| conn[parse_item_cmd(item,cmd)].delete(merge_params(params)) }
|
63
|
+
base.parsed{|conn| conn[s(parse_item_cmd(item,cmd))].delete(merge_params(params)) }
|
57
64
|
end
|
58
65
|
|
59
66
|
def base_post(cmd,item=nil,params=nil)
|
60
|
-
base.parsed{|conn| conn[parse_item_cmd(item,cmd)].post(params.nil? ? nil : params.to_json, :content_type => :json ) }
|
67
|
+
base.parsed{|conn| conn[s(parse_item_cmd(item,cmd))].post(params.nil? ? nil : params.to_json, :content_type => :json ) }
|
61
68
|
end
|
62
69
|
def base_put(cmd,item=nil,params=nil)
|
63
|
-
base.parsed{|conn| conn[parse_item_cmd(item,cmd)].put(params.nil? ? nil : params.to_json, :content_type => :json ) }
|
70
|
+
base.parsed{|conn| conn[s(parse_item_cmd(item,cmd))].put(params.nil? ? nil : params.to_json, :content_type => :json ) }
|
64
71
|
end
|
65
72
|
|
66
73
|
def base
|
@@ -78,6 +85,12 @@ module Pulp
|
|
78
85
|
def merge_params(params)
|
79
86
|
params.nil? ? {} : { :params => params }
|
80
87
|
end
|
88
|
+
|
89
|
+
# sanitize uri
|
90
|
+
# if uri is already escaped, we don't do anything, otherwise we escape it.
|
91
|
+
def s(uri)
|
92
|
+
(URI.decode(uri) != uri) ? uri : URI.escape(uri)
|
93
|
+
end
|
81
94
|
end
|
82
95
|
end
|
83
96
|
end
|
@@ -6,12 +6,12 @@ module Pulp
|
|
6
6
|
|
7
7
|
class << self
|
8
8
|
attr_accessor :hostname,:username, :password
|
9
|
-
|
9
|
+
|
10
10
|
def instance_for(identifier,h=nil,u=nil,p=nil,https=true)
|
11
11
|
instances[identifier] ||= Handler.new(identifier,
|
12
|
-
h||hostname,
|
13
|
-
u||username,
|
14
|
-
p||password,
|
12
|
+
h||hostname||'localhost',
|
13
|
+
u||username||'admin',
|
14
|
+
p||password||'admin',
|
15
15
|
https
|
16
16
|
)
|
17
17
|
end
|
data/lib/pulp/package.rb
CHANGED
@@ -10,11 +10,11 @@ module Pulp
|
|
10
10
|
pulp_field :_ns, :locked => true
|
11
11
|
pulp_fields :arch, :buildhost, :checksum, :description,
|
12
12
|
:download_url, :epoch, :filename, :group,
|
13
|
-
:license, :name, :provides, :release,
|
13
|
+
:license, :name, :provides, :release, :repoids,
|
14
14
|
:repo_defined, :requires, :size, :vendor, :version
|
15
15
|
|
16
16
|
def self.by_nvrea(name,version,release,epoch,arch)
|
17
17
|
self.new(base_get("#{name}/#{version}/#{release}/#{epoch}/#{arch}"))
|
18
18
|
end
|
19
19
|
end
|
20
|
-
end
|
20
|
+
end
|
data/lib/pulp/service.rb
CHANGED
@@ -19,13 +19,12 @@ module Pulp
|
|
19
19
|
base_post('','upload',params)
|
20
20
|
end
|
21
21
|
|
22
|
-
# TODO: won't work yet probably
|
23
22
|
def self.append_file_content(id,data)
|
24
|
-
|
23
|
+
base_unparsed_put('',"upload/append/#{id}",data,true)
|
25
24
|
end
|
26
25
|
|
27
26
|
def self.import_file(uploadid, metadata)
|
28
|
-
|
27
|
+
base_post('','upload/import',{:uploadid => uploadid, :metadata => metadata})
|
29
28
|
end
|
30
29
|
|
31
30
|
def self.package_checksum(pkglist)
|
@@ -48,4 +47,4 @@ module Pulp
|
|
48
47
|
Pulp::Task.new(base_get('',"discovery/repo/#{taskid}"))
|
49
48
|
end
|
50
49
|
end
|
51
|
-
end
|
50
|
+
end
|
data/pulp.gemspec
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{pulp}
|
8
|
+
s.version = "0.0.9"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["mh"]
|
12
|
+
s.date = %q{2012-06-20}
|
13
|
+
s.description = %q{A little ruby wrapper around the pulp (http://pulpproject.org) API}
|
14
|
+
s.email = %q{mh@immerda.ch}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE.txt",
|
17
|
+
"README.rdoc"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
".rspec",
|
22
|
+
"Gemfile",
|
23
|
+
"Gemfile.lock",
|
24
|
+
"LICENSE.txt",
|
25
|
+
"README.rdoc",
|
26
|
+
"Rakefile",
|
27
|
+
"VERSION",
|
28
|
+
"examples/repositories.rb",
|
29
|
+
"examples/test_pulp.yml",
|
30
|
+
"lib/pulp.rb",
|
31
|
+
"lib/pulp/cds.rb",
|
32
|
+
"lib/pulp/common/debug.rb",
|
33
|
+
"lib/pulp/common/lifecycle.rb",
|
34
|
+
"lib/pulp/common/lifecycle/create.rb",
|
35
|
+
"lib/pulp/common/lifecycle/delete.rb",
|
36
|
+
"lib/pulp/common/lifecycle/get.rb",
|
37
|
+
"lib/pulp/common/lifecycle/update.rb",
|
38
|
+
"lib/pulp/connection/base.rb",
|
39
|
+
"lib/pulp/connection/handler.rb",
|
40
|
+
"lib/pulp/consumer.rb",
|
41
|
+
"lib/pulp/consumergroup.rb",
|
42
|
+
"lib/pulp/content.rb",
|
43
|
+
"lib/pulp/distribution.rb",
|
44
|
+
"lib/pulp/errata.rb",
|
45
|
+
"lib/pulp/event.rb",
|
46
|
+
"lib/pulp/filter.rb",
|
47
|
+
"lib/pulp/package.rb",
|
48
|
+
"lib/pulp/package_group.rb",
|
49
|
+
"lib/pulp/package_group_category.rb",
|
50
|
+
"lib/pulp/repository.rb",
|
51
|
+
"lib/pulp/service.rb",
|
52
|
+
"lib/pulp/task.rb",
|
53
|
+
"lib/pulp/task_history.rb",
|
54
|
+
"lib/pulp/task_snapshot.rb",
|
55
|
+
"lib/pulp/user.rb",
|
56
|
+
"pulp.gemspec",
|
57
|
+
"spec/pulp/common/debug_spec.rb",
|
58
|
+
"spec/pulp/common/lifecycle/create_spec.rb",
|
59
|
+
"spec/pulp/common/lifecycle/delete_spec.rb",
|
60
|
+
"spec/pulp/common/lifecycle/get_spec.rb",
|
61
|
+
"spec/pulp/common/lifecycle/update_spec.rb",
|
62
|
+
"spec/pulp/common/lifecycle_spec.rb",
|
63
|
+
"spec/pulp/connection/base_spec.rb",
|
64
|
+
"spec/pulp/connection/handler_spec.rb",
|
65
|
+
"spec/pulp/content_spec.rb",
|
66
|
+
"spec/pulp/package_spec.rb",
|
67
|
+
"spec/pulp/repository_spec.rb",
|
68
|
+
"spec/pulp/service_spec.rb",
|
69
|
+
"spec/pulp/task_spec.rb",
|
70
|
+
"spec/pulp_spec.rb",
|
71
|
+
"spec/spec.opts",
|
72
|
+
"spec/spec_helper.rb"
|
73
|
+
]
|
74
|
+
s.homepage = %q{https://github.com/duritong/ruby-pulp}
|
75
|
+
s.licenses = ["MIT"]
|
76
|
+
s.require_paths = ["lib"]
|
77
|
+
s.rubygems_version = %q{1.5.0}
|
78
|
+
s.summary = %q{A little ruby wrapper around the pulp API}
|
79
|
+
|
80
|
+
if s.respond_to? :specification_version then
|
81
|
+
s.specification_version = 3
|
82
|
+
|
83
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
84
|
+
s.add_runtime_dependency(%q<rest-client>, ["~> 1.6.7"])
|
85
|
+
s.add_runtime_dependency(%q<activesupport>, [">= 0"])
|
86
|
+
s.add_runtime_dependency(%q<json>, [">= 0"])
|
87
|
+
s.add_runtime_dependency(%q<i18n>, [">= 0"])
|
88
|
+
s.add_development_dependency(%q<rspec>, ["~> 2.3.0"])
|
89
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
90
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
|
91
|
+
s.add_development_dependency(%q<rcov>, [">= 0"])
|
92
|
+
s.add_development_dependency(%q<mocha>, [">= 0"])
|
93
|
+
else
|
94
|
+
s.add_dependency(%q<rest-client>, ["~> 1.6.7"])
|
95
|
+
s.add_dependency(%q<activesupport>, [">= 0"])
|
96
|
+
s.add_dependency(%q<json>, [">= 0"])
|
97
|
+
s.add_dependency(%q<i18n>, [">= 0"])
|
98
|
+
s.add_dependency(%q<rspec>, ["~> 2.3.0"])
|
99
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
100
|
+
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
101
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
102
|
+
s.add_dependency(%q<mocha>, [">= 0"])
|
103
|
+
end
|
104
|
+
else
|
105
|
+
s.add_dependency(%q<rest-client>, ["~> 1.6.7"])
|
106
|
+
s.add_dependency(%q<activesupport>, [">= 0"])
|
107
|
+
s.add_dependency(%q<json>, [">= 0"])
|
108
|
+
s.add_dependency(%q<i18n>, [">= 0"])
|
109
|
+
s.add_dependency(%q<rspec>, ["~> 2.3.0"])
|
110
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
111
|
+
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
112
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
113
|
+
s.add_dependency(%q<mocha>, [">= 0"])
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
@@ -321,7 +321,7 @@ describe Pulp::Common::Lifecycle do
|
|
321
321
|
|
322
322
|
context "with a task lists" do
|
323
323
|
it "gets a get method for tasks" do
|
324
|
-
Pulp::ActionLifecycle.expects(:base_get).with('action7/','foo',nil).returns("foo")
|
324
|
+
Pulp::ActionLifecycle.expects(:base_get).with('action7/','foo',nil).returns(["foo"])
|
325
325
|
(a=Pulp::ActionLifecycle.new('ffo').action7_tasks).should be_kind_of(Array)
|
326
326
|
a.first.should be_kind_of(Pulp::Task)
|
327
327
|
end
|
@@ -390,4 +390,4 @@ describe Pulp::Common::Lifecycle do
|
|
390
390
|
end
|
391
391
|
end
|
392
392
|
|
393
|
-
end
|
393
|
+
end
|
@@ -93,9 +93,49 @@ describe Pulp::Connection::Base do
|
|
93
93
|
end
|
94
94
|
end
|
95
95
|
end
|
96
|
+
describe ".plain_unparsed_get" do
|
97
|
+
context "with special urls" do
|
98
|
+
it "should escape the url" do
|
99
|
+
Pulp::Test.plain_base.connection.expects(:[]).with('fo%20o').returns(@context)
|
100
|
+
@context.expects(:get).with({}).returns(UnparsedDummyResult)
|
101
|
+
Pulp::Test.plain_unparsed_get('fo o').should eql(UnparsedDummyResult.real_body)
|
102
|
+
end
|
103
|
+
end
|
104
|
+
context "with normal urls" do
|
105
|
+
before(:each) do
|
106
|
+
Pulp::Test.plain_base.connection.expects(:[]).with('foo').returns(@context)
|
107
|
+
end
|
108
|
+
context "without params" do
|
109
|
+
before(:each) do
|
110
|
+
@context.expects(:get).with({}).returns(UnparsedDummyResult)
|
111
|
+
end
|
112
|
+
it "should return a parsed get" do
|
113
|
+
Pulp::Test.plain_unparsed_get('foo').should eql(UnparsedDummyResult.real_body)
|
114
|
+
end
|
115
|
+
it "should strip the api url prefix" do
|
116
|
+
Pulp::Test.plain_unparsed_get('/pulp/api/foo').should eql(UnparsedDummyResult.real_body)
|
117
|
+
end
|
118
|
+
end
|
119
|
+
context "with params" do
|
120
|
+
before(:each) do
|
121
|
+
@context.expects(:get).with(:params => { :b => 2}).returns(UnparsedDummyResult)
|
122
|
+
end
|
123
|
+
it "should add the params" do
|
124
|
+
Pulp::Test.plain_unparsed_get('/pulp/api/foo',:b => 2).should eql(UnparsedDummyResult.real_body)
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
96
129
|
context "parsed" do
|
97
130
|
[:get, :delete ].each do |method|
|
98
131
|
describe ".base_#{method}" do
|
132
|
+
context "with a special url" do
|
133
|
+
it "should escape the url for base_#{method}" do
|
134
|
+
Pulp::Test.base.connection.expects(:[]).with('/blub/fo%20o').returns(@context)
|
135
|
+
@context.expects(method).with({ :params => {:b => 2 }}).returns(DummyResult)
|
136
|
+
Pulp::Test.send(:"base_#{method}",'fo o','blub',:b => 2).should eql(DummyResult.real_body)
|
137
|
+
end
|
138
|
+
end
|
99
139
|
context "with an item" do
|
100
140
|
before(:each) do
|
101
141
|
Pulp::Test.base.connection.expects(:[]).with('/blub/foo').returns(@context)
|
@@ -142,6 +182,13 @@ describe Pulp::Connection::Base do
|
|
142
182
|
end
|
143
183
|
[:post,:put].each do |method|
|
144
184
|
describe ".base_#{method}" do
|
185
|
+
context "with a special url" do
|
186
|
+
it "should escape the url for base_#{method}" do
|
187
|
+
Pulp::Test.base.connection.expects(:[]).with('/blub/fo%20o').returns(@context)
|
188
|
+
@context.expects(method).with(nil,{:content_type => :json}).returns(DummyResult)
|
189
|
+
Pulp::Test.send(:"base_#{method}",'fo o','blub').should eql(DummyResult.real_body)
|
190
|
+
end
|
191
|
+
end
|
145
192
|
context "with an item" do
|
146
193
|
before(:each) do
|
147
194
|
Pulp::Test.base.connection.expects(:[]).with('/blub/foo').returns(@context)
|
@@ -190,6 +237,13 @@ describe Pulp::Connection::Base do
|
|
190
237
|
context "unparsed" do
|
191
238
|
[:get, :delete ].each do |method|
|
192
239
|
describe ".base_unparsed_#{method}" do
|
240
|
+
context "with a special url" do
|
241
|
+
it "should escape the url for base_#{method}" do
|
242
|
+
Pulp::Test.base.connection.expects(:[]).with('/blub/fo%20o').returns(@context)
|
243
|
+
@context.expects(method).with({}).returns(UnparsedDummyResult)
|
244
|
+
Pulp::Test.send(:"base_unparsed_#{method}",'fo o','blub').should eql(UnparsedDummyResult.real_body)
|
245
|
+
end
|
246
|
+
end
|
193
247
|
context "with an item" do
|
194
248
|
before(:each) do
|
195
249
|
Pulp::Test.base.connection.expects(:[]).with('/blub/foo').returns(@context)
|
@@ -236,6 +290,13 @@ describe Pulp::Connection::Base do
|
|
236
290
|
end
|
237
291
|
[:post,:put].each do |method|
|
238
292
|
describe ".base_#{method}" do
|
293
|
+
context "with a special url" do
|
294
|
+
it "should escape the url for base_#{method}" do
|
295
|
+
Pulp::Test.base.connection.expects(:[]).with('/blub/fo%20o').returns(@context)
|
296
|
+
@context.expects(method).with(nil,{:content_type => :json}).returns(UnparsedDummyResult)
|
297
|
+
Pulp::Test.send(:"base_unparsed_#{method}",'fo o','blub').should eql(UnparsedDummyResult.real_body)
|
298
|
+
end
|
299
|
+
end
|
239
300
|
context "with an item" do
|
240
301
|
before(:each) do
|
241
302
|
Pulp::Test.base.connection.expects(:[]).with('/blub/foo').returns(@context)
|
@@ -309,4 +370,4 @@ describe Pulp::Connection::Base do
|
|
309
370
|
Pulp::Test.new(:a => 1).fields[:a].should eql(1)
|
310
371
|
end
|
311
372
|
end
|
312
|
-
end
|
373
|
+
end
|
data/spec/pulp/service_spec.rb
CHANGED
@@ -36,14 +36,14 @@ describe Pulp::Service do
|
|
36
36
|
|
37
37
|
describe ".append_file_content" do
|
38
38
|
it "should append file content to the specific id" do
|
39
|
-
Pulp::Service.expects(:
|
39
|
+
Pulp::Service.expects(:base_unparsed_put).with('','upload/append/1',"content",true).returns(1)
|
40
40
|
Pulp::Service.append_file_content(1,'content').should eql(1)
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
44
|
describe ".import_file" do
|
45
45
|
it "should import an uploaded file" do
|
46
|
-
Pulp::Service.expects(:
|
46
|
+
Pulp::Service.expects(:base_post).with('','upload/import',{:uploadid => 1, :metadata => {:a => 1}}).returns(1)
|
47
47
|
Pulp::Service.import_file(1,:a => 1).should eql(1)
|
48
48
|
end
|
49
49
|
end
|
metadata
CHANGED
@@ -1,167 +1,124 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: pulp
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 0
|
9
|
-
- 8
|
10
|
-
version: 0.0.8
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.9
|
5
|
+
prerelease: !!null
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- mh
|
14
|
-
autorequire:
|
9
|
+
autorequire: !!null
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
12
|
+
date: 2012-06-20 00:00:00.000000000 -03:00
|
13
|
+
default_executable: !!null
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rest-client
|
17
|
+
requirement: &7079240 !ruby/object:Gem::Requirement
|
24
18
|
none: false
|
25
|
-
requirements:
|
19
|
+
requirements:
|
26
20
|
- - ~>
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
hash: 1
|
29
|
-
segments:
|
30
|
-
- 1
|
31
|
-
- 6
|
32
|
-
- 7
|
21
|
+
- !ruby/object:Gem::Version
|
33
22
|
version: 1.6.7
|
34
|
-
version_requirements: *id001
|
35
|
-
name: rest-client
|
36
|
-
prerelease: false
|
37
|
-
- !ruby/object:Gem::Dependency
|
38
23
|
type: :runtime
|
39
|
-
requirement: &id002 !ruby/object:Gem::Requirement
|
40
|
-
none: false
|
41
|
-
requirements:
|
42
|
-
- - ">="
|
43
|
-
- !ruby/object:Gem::Version
|
44
|
-
hash: 3
|
45
|
-
segments:
|
46
|
-
- 0
|
47
|
-
version: "0"
|
48
|
-
version_requirements: *id002
|
49
|
-
name: activesupport
|
50
24
|
prerelease: false
|
51
|
-
|
52
|
-
|
53
|
-
|
25
|
+
version_requirements: *7079240
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: activesupport
|
28
|
+
requirement: &7076940 !ruby/object:Gem::Requirement
|
54
29
|
none: false
|
55
|
-
requirements:
|
56
|
-
- -
|
57
|
-
- !ruby/object:Gem::Version
|
58
|
-
|
59
|
-
segments:
|
60
|
-
- 0
|
61
|
-
version: "0"
|
62
|
-
version_requirements: *id003
|
63
|
-
name: json
|
64
|
-
prerelease: false
|
65
|
-
- !ruby/object:Gem::Dependency
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
66
34
|
type: :runtime
|
67
|
-
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: *7076940
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: json
|
39
|
+
requirement: &7074460 !ruby/object:Gem::Requirement
|
68
40
|
none: false
|
69
|
-
requirements:
|
70
|
-
- -
|
71
|
-
- !ruby/object:Gem::Version
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
41
|
+
requirements:
|
42
|
+
- - ! '>='
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '0'
|
45
|
+
type: :runtime
|
46
|
+
prerelease: false
|
47
|
+
version_requirements: *7074460
|
48
|
+
- !ruby/object:Gem::Dependency
|
77
49
|
name: i18n
|
50
|
+
requirement: &7064360 !ruby/object:Gem::Requirement
|
51
|
+
none: false
|
52
|
+
requirements:
|
53
|
+
- - ! '>='
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
type: :runtime
|
78
57
|
prerelease: false
|
79
|
-
|
80
|
-
|
81
|
-
|
58
|
+
version_requirements: *7064360
|
59
|
+
- !ruby/object:Gem::Dependency
|
60
|
+
name: rspec
|
61
|
+
requirement: &7059300 !ruby/object:Gem::Requirement
|
82
62
|
none: false
|
83
|
-
requirements:
|
63
|
+
requirements:
|
84
64
|
- - ~>
|
85
|
-
- !ruby/object:Gem::Version
|
86
|
-
hash: 3
|
87
|
-
segments:
|
88
|
-
- 2
|
89
|
-
- 3
|
90
|
-
- 0
|
65
|
+
- !ruby/object:Gem::Version
|
91
66
|
version: 2.3.0
|
92
|
-
version_requirements: *id005
|
93
|
-
name: rspec
|
94
|
-
prerelease: false
|
95
|
-
- !ruby/object:Gem::Dependency
|
96
67
|
type: :development
|
97
|
-
|
68
|
+
prerelease: false
|
69
|
+
version_requirements: *7059300
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: bundler
|
72
|
+
requirement: &7047260 !ruby/object:Gem::Requirement
|
98
73
|
none: false
|
99
|
-
requirements:
|
74
|
+
requirements:
|
100
75
|
- - ~>
|
101
|
-
- !ruby/object:Gem::Version
|
102
|
-
hash: 23
|
103
|
-
segments:
|
104
|
-
- 1
|
105
|
-
- 0
|
106
|
-
- 0
|
76
|
+
- !ruby/object:Gem::Version
|
107
77
|
version: 1.0.0
|
108
|
-
version_requirements: *id006
|
109
|
-
name: bundler
|
110
|
-
prerelease: false
|
111
|
-
- !ruby/object:Gem::Dependency
|
112
78
|
type: :development
|
113
|
-
|
79
|
+
prerelease: false
|
80
|
+
version_requirements: *7047260
|
81
|
+
- !ruby/object:Gem::Dependency
|
82
|
+
name: jeweler
|
83
|
+
requirement: &7043720 !ruby/object:Gem::Requirement
|
114
84
|
none: false
|
115
|
-
requirements:
|
85
|
+
requirements:
|
116
86
|
- - ~>
|
117
|
-
- !ruby/object:Gem::Version
|
118
|
-
hash: 7
|
119
|
-
segments:
|
120
|
-
- 1
|
121
|
-
- 6
|
122
|
-
- 4
|
87
|
+
- !ruby/object:Gem::Version
|
123
88
|
version: 1.6.4
|
124
|
-
version_requirements: *id007
|
125
|
-
name: jeweler
|
126
|
-
prerelease: false
|
127
|
-
- !ruby/object:Gem::Dependency
|
128
89
|
type: :development
|
129
|
-
requirement: &id008 !ruby/object:Gem::Requirement
|
130
|
-
none: false
|
131
|
-
requirements:
|
132
|
-
- - ">="
|
133
|
-
- !ruby/object:Gem::Version
|
134
|
-
hash: 3
|
135
|
-
segments:
|
136
|
-
- 0
|
137
|
-
version: "0"
|
138
|
-
version_requirements: *id008
|
139
|
-
name: rcov
|
140
90
|
prerelease: false
|
141
|
-
|
142
|
-
|
143
|
-
|
91
|
+
version_requirements: *7043720
|
92
|
+
- !ruby/object:Gem::Dependency
|
93
|
+
name: rcov
|
94
|
+
requirement: &7037620 !ruby/object:Gem::Requirement
|
144
95
|
none: false
|
145
|
-
requirements:
|
146
|
-
- -
|
147
|
-
- !ruby/object:Gem::Version
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
96
|
+
requirements:
|
97
|
+
- - ! '>='
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
100
|
+
type: :development
|
101
|
+
prerelease: false
|
102
|
+
version_requirements: *7037620
|
103
|
+
- !ruby/object:Gem::Dependency
|
153
104
|
name: mocha
|
105
|
+
requirement: &7034340 !ruby/object:Gem::Requirement
|
106
|
+
none: false
|
107
|
+
requirements:
|
108
|
+
- - ! '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
type: :development
|
154
112
|
prerelease: false
|
155
|
-
|
113
|
+
version_requirements: *7034340
|
114
|
+
description: A little ruby wrapper around the pulp (http://pulpproject.org) API
|
156
115
|
email: mh@immerda.ch
|
157
116
|
executables: []
|
158
|
-
|
159
117
|
extensions: []
|
160
|
-
|
161
|
-
extra_rdoc_files:
|
118
|
+
extra_rdoc_files:
|
162
119
|
- LICENSE.txt
|
163
120
|
- README.rdoc
|
164
|
-
files:
|
121
|
+
files:
|
165
122
|
- .document
|
166
123
|
- .rspec
|
167
124
|
- Gemfile
|
@@ -198,6 +155,7 @@ files:
|
|
198
155
|
- lib/pulp/task_history.rb
|
199
156
|
- lib/pulp/task_snapshot.rb
|
200
157
|
- lib/pulp/user.rb
|
158
|
+
- pulp.gemspec
|
201
159
|
- spec/pulp/common/debug_spec.rb
|
202
160
|
- spec/pulp/common/lifecycle/create_spec.rb
|
203
161
|
- spec/pulp/common/lifecycle/delete_spec.rb
|
@@ -215,38 +173,32 @@ files:
|
|
215
173
|
- spec/spec.opts
|
216
174
|
- spec/spec_helper.rb
|
217
175
|
has_rdoc: true
|
218
|
-
homepage: https://github.com/duritong
|
219
|
-
licenses:
|
176
|
+
homepage: https://github.com/duritong/ruby-pulp
|
177
|
+
licenses:
|
220
178
|
- MIT
|
221
|
-
post_install_message:
|
179
|
+
post_install_message: !!null
|
222
180
|
rdoc_options: []
|
223
|
-
|
224
|
-
require_paths:
|
181
|
+
require_paths:
|
225
182
|
- lib
|
226
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
183
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
227
184
|
none: false
|
228
|
-
requirements:
|
229
|
-
- -
|
230
|
-
- !ruby/object:Gem::Version
|
231
|
-
|
232
|
-
segments:
|
185
|
+
requirements:
|
186
|
+
- - ! '>='
|
187
|
+
- !ruby/object:Gem::Version
|
188
|
+
version: '0'
|
189
|
+
segments:
|
233
190
|
- 0
|
234
|
-
|
235
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
191
|
+
hash: 1813687171607222206
|
192
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
236
193
|
none: false
|
237
|
-
requirements:
|
238
|
-
- -
|
239
|
-
- !ruby/object:Gem::Version
|
240
|
-
|
241
|
-
segments:
|
242
|
-
- 0
|
243
|
-
version: "0"
|
194
|
+
requirements:
|
195
|
+
- - ! '>='
|
196
|
+
- !ruby/object:Gem::Version
|
197
|
+
version: '0'
|
244
198
|
requirements: []
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
signing_key:
|
199
|
+
rubyforge_project: !!null
|
200
|
+
rubygems_version: 1.5.0
|
201
|
+
signing_key: !!null
|
249
202
|
specification_version: 3
|
250
|
-
summary: A little ruby wrapper around
|
203
|
+
summary: A little ruby wrapper around the pulp API
|
251
204
|
test_files: []
|
252
|
-
|