puppet-library 0.4.0 → 0.5.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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZTgwMTJmOWUxMDllNDMyMjFjNTgyZmI2ZmQ2NDc0NmM0NDEwYjRlNQ==
4
+ MzE2OGYxMDE4NjM3NTVkMDFmOGFjYTcwMmM3Y2YwYTg0ZmE1MzIxYg==
5
5
  data.tar.gz: !binary |-
6
- MmYzYzNiN2MxMTBhYTc1NzRlZGQ4OTExN2QyNzhmY2RhYjBlZDcyMw==
6
+ NGE3YWE2MWUwZGFiZjBhZDVhZjA2NzZkNDg3YmUyNDk1MThiYTk1Nw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- Njk2ZmJmM2JmNDlhNzRmYzA3NDcyYWFmNjAwYTBmODQ2MzFmYmIxZmZmMGVh
10
- MWFiNGRiOTM1NGYyMjQzY2NjNGFhMDdmOWUxNmM1YWVkOTRjMzhjNzVkMmE5
11
- ZTA3ZWU0NDZiNTVlMjZjYzYzMjI5MDU2YzcxYmRmMzI5YmYwZDg=
9
+ MmI3ZTljMjZmNjYxMWM2ODEwZjY5ZDJjODJiMzEyZGE3OTNmOTI2NzJhOTM2
10
+ NjNjNzQ1YWVhMmJkZGNiOGQyNTAxNGJlN2Y0ZDAyM2U3OWEwZjMzNzg5Nzkw
11
+ NGMzNDc2YmM3YjFmMjQwN2ZlMGEyNTUxMGM3M2IyZGJjOWJkMmM=
12
12
  data.tar.gz: !binary |-
13
- ZWUzODAwZTRmOTNlY2U1MjRkZGI5NGY2YzAyOTJhMTFhNTc1N2U0MjJlMGUy
14
- Yjc0MzQyN2FkNTRmOWY2ZTBlNmRmODhlY2ExMjk4MDIzYjJjNWFkMTJiZGI1
15
- YWY1MTYxZTQ1ZmJhOWQ1NWZmOGU3YWVlZGM5MTJhNDUxODUxYjU=
13
+ ZTkzNjBmN2UwMjlmZTkwNWQ3OGQ4OTM1MGU5OTQzZmNiYTNkZWZlZmY1ODg4
14
+ MGQ2ZGExZmIzM2U0ZDEzZGViMmYyMzBkZWVkY2U5ZDEyYmQ0NzE5ZTlmYWQx
15
+ ZTdkNGZkYTdiNzAwNzg3ODQ5ZDQ2NGViMmYyOTBhYmM0NTE0MzM=
data/CHANGELOG.yml CHANGED
@@ -34,7 +34,10 @@
34
34
  - Improved performance of proxy
35
35
  - tag: v0.4.0
36
36
  changes:
37
- - Added '--version' option to CLI
37
+ - Added `--version` option to CLI
38
38
  - Added option to daemonize server (with optional pidfile)
39
39
  - Added web UI to browse modules
40
+ - tag: v0.5.0
41
+ changes:
42
+ - Added module search field to web UI
40
43
 
data/Rakefile CHANGED
@@ -18,6 +18,9 @@
18
18
  require 'bundler/gem_tasks'
19
19
  require 'rspec/core/rake_task'
20
20
  require 'coveralls/rake/task'
21
+ require 'json'
22
+ require 'yaml'
23
+ require 'net/http'
21
24
 
22
25
  SUPPORTED_VERSIONS = %w[1.8 1.9 2.0 2.1]
23
26
  # The integration test doesn't work on Ruby 1.8, and Puppet doesn't work on 2.1
@@ -166,6 +169,9 @@ task "push-release" => ["check-license", :verify] do
166
169
  puts "Releasing #{PuppetLibrary::VERSION}"
167
170
  Rake::Task[:release].invoke
168
171
 
172
+ puts "Registering release notes for #{PuppetLibrary::VERSION}"
173
+ Rake::Task["register-release[#{PuppetLibrary::VERSION}]"].invoke
174
+
169
175
  major, minor, patch = PuppetLibrary::VERSION.split(".").map {|n| n.to_i}
170
176
  new_version = "#{major}.#{minor + 1}.0"
171
177
  puts "Updating version number to #{new_version}"
@@ -173,3 +179,87 @@ task "push-release" => ["check-license", :verify] do
173
179
  PuppetLibrary::VERSION.replace new_version
174
180
  system "git commit lib/puppet_library/version.rb --message='[release] Incremented version number'" or fail "Couldn't commit new version number"
175
181
  end
182
+
183
+ desc "Register release with Github"
184
+ task "register-release", [:version] do |task, args|
185
+ github = Github.new
186
+
187
+ version = args[:version]
188
+ unless version =~ /\d+\.\d+\.\d+/
189
+ raise "Bad version: '#{version}'"
190
+ end
191
+ unless system("git tag | grep v#{version} > /dev/null")
192
+ raise "Couldn't find tag 'v#{version}'"
193
+ end
194
+
195
+ tag = "v#{version}"
196
+ changelog = YAML.load_file("CHANGELOG.yml")
197
+ release_notes = changelog.find {|release| release["tag"] == tag}
198
+ changes = release_notes ? release_notes["changes"] : []
199
+ description = changes.map { |change| "- #{change}" }.join("\n")
200
+ data = {
201
+ "tag_name" => tag,
202
+ "target_commitish" => "master",
203
+ "name" => "Version #{version}",
204
+ "body" => description,
205
+ "draft" => false,
206
+ "prerelease" => false
207
+ }
208
+ release = github.get("/repos/drrb/puppet-library/releases").find {|release| release["tag_name"] == tag}
209
+ if release
210
+ puts "Release #{tag} exists. Updating it..."
211
+ github.patch("/repos/drrb/puppet-library/releases/#{release['id']}", data)
212
+ else
213
+ puts "Creating release #{tag}..."
214
+ github.post("/repos/drrb/puppet-library/releases", data)
215
+ end
216
+ puts "Done"
217
+ end
218
+
219
+ class Github
220
+ def initialize
221
+ @base_url = "https://api.github.com"
222
+ api_key_file = File.expand_path("~/.github/release.apikey")
223
+ raise "Put your github credentials in ~/.github/release.apikey as 'username:key'" unless File.exist? api_key_file
224
+ @username, @key = File.read(api_key_file).strip.split ":"
225
+ end
226
+
227
+ def post(path, data, &block)
228
+ puts "POST #{path}"
229
+ request = Net::HTTP::Post.new(path)
230
+ request.body = data.to_json
231
+ send request
232
+ end
233
+
234
+ def patch(path, data, &block)
235
+ puts "PATCH #{path}"
236
+ request = Net::HTTP::Patch.new(path)
237
+ request.body = data.to_json
238
+ response = send(request, &block)
239
+ end
240
+
241
+ def get(path, &block)
242
+ puts "GET #{path}"
243
+ request = Net::HTTP::Get.new(path)
244
+ send request
245
+ end
246
+
247
+ def send(request)
248
+ request.add_field('Content-Type', 'application/json')
249
+ request.basic_auth @username, @key
250
+
251
+ uri = URI.parse(@base_url)
252
+ http = Net::HTTP.new(uri.host, uri.port)
253
+ http.use_ssl = true
254
+ response = http.request(request)
255
+ puts response.code
256
+ if block_given?
257
+ yield(response)
258
+ else
259
+ unless response.code =~ /^2../
260
+ raise "Request returned non-success:\n#{response.body}"
261
+ end
262
+ JSON.parse(response.body)
263
+ end
264
+ end
265
+ end
@@ -17,8 +17,8 @@
17
17
 
18
18
  Feature: Module page
19
19
  As a user
20
- I want to see a list of available modules
21
- So that I can quickly tell what's on the server
20
+ I want to see the details of a module
21
+ So that I can tell exactly what's on the server
22
22
 
23
23
  Scenario: Visit the module page
24
24
  Given the "puppetlabs/apache" module is available at version "1.0.0"
@@ -0,0 +1,29 @@
1
+ # -*- encoding: utf-8 -*-
2
+ # Puppet Library
3
+ # Copyright (C) 2014 drrb
4
+ #
5
+ # This program is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU General Public License as published by
7
+ # the Free Software Foundation, either version 3 of the License, or
8
+ # (at your option) any later version.
9
+ #
10
+ # This program is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU General Public License
16
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+
18
+ Feature: Module search
19
+ As a user
20
+ I want to search the modules
21
+ So that I can find details about specific modules
22
+
23
+ Scenario: Visit the module list page
24
+ Given the "puppetlabs/apache" module is available at version "1.0.0"
25
+ And the "puppetlabs/stdlib" module is available at version "1.0.0"
26
+ When I visit the module list page
27
+ And I search for "apache"
28
+ Then I should see "puppetlabs/apache"
29
+ And I should not see "puppetlabs/stdlib"
@@ -62,6 +62,13 @@ When /^I click on "(.*?)"$/ do |link_text|
62
62
  click_link link_text
63
63
  end
64
64
 
65
+ When /^I search for "(.*?)"$/ do |term|
66
+ within("form#module-search") do
67
+ fill_in 'search', :with => term
68
+ click_button "Search"
69
+ end
70
+ end
71
+
65
72
  Then /^I should be on the module page for "(.*?)"$/ do |module_name|
66
73
  expect(URI.parse(current_url).path).to eq "/#{module_name}"
67
74
  end
@@ -70,6 +77,10 @@ Then /^I should see "(.*?)"$/ do |text|
70
77
  expect(page).to have_content text
71
78
  end
72
79
 
80
+ Then /^I should not see "(.*?)"$/ do |text|
81
+ expect(page).not_to have_content text
82
+ end
83
+
73
84
  Then /^I should see '(.*?)'$/ do |text|
74
85
  expect(page).to have_content text
75
86
  end
@@ -20,6 +20,7 @@
20
20
  %meta{ :charset => "utf-8" }
21
21
  %title Puppet Library
22
22
  %link{ :href => "https://netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css", :type => "text/css", :rel => "stylesheet" }
23
+ -#%link{ :href => "https://netdna.bootstrapcdn.com/bootstrap/3.1.0/css/bootstrap-theme.min.css", :type => "text/css", :rel => "stylesheet" }
23
24
  /[if lt IE 9]
24
25
  %script{:src => "https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"}
25
26
  %script{:src => "https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"}
@@ -28,9 +29,24 @@
28
29
  body {
29
30
  padding-top: 50px;
30
31
  }
31
- .starter-template {
32
- padding: 40px 15px;
33
- text-align: center;
32
+ input.search-query {
33
+ padding-left:32px;
34
+ }
35
+ form.form-search {
36
+ position: relative;
37
+ }
38
+ form.form-search:before {
39
+ content:'';
40
+ display: block;
41
+ width: 14px;
42
+ height: 14px;
43
+ background-image: url(http://getbootstrap.com/2.3.2/assets/img/glyphicons-halflings.png);
44
+ background-position: -48px 0;
45
+ position: absolute;
46
+ top:10px;
47
+ left:26px;
48
+ opacity: .5;
49
+ z-index: 1000;
34
50
  }
35
51
  %body
36
52
  .navbar.navbar-inverse.navbar-fixed-top{ :role => "navigation" }
@@ -48,6 +64,11 @@
48
64
  %a{:href => '/'} Modules
49
65
  %li
50
66
  %a{:href => 'https://github.com/drrb/puppet-library', :target => "puppet-library"} Help
67
+ %form#module-search.navbar-form.navbar-right.form-search{ :action => "/", :method => "get", :role => "form" }
68
+ .input-group
69
+ %input.form-control.search-query{ :name => "search", :type => "search", :placeholder => "Search modules" }
70
+ %span.input-group-btn
71
+ %button.btn.btn-primary{ :type => "submit" } Search
51
72
  .container
52
73
  = yield
53
74
  %script{ :src => "https://code.jquery.com/jquery-2.1.0.min.js" }
@@ -50,7 +50,8 @@ module PuppetLibrary
50
50
  end
51
51
 
52
52
  get "/" do
53
- modules = @forge.search_modules(nil)
53
+ query = params[:search]
54
+ modules = @forge.search_modules(query)
54
55
 
55
56
  haml :index, { :locals => { "modules" => modules } }
56
57
  end
@@ -16,5 +16,5 @@
16
16
  # along with this program. If not, see <http://www.gnu.org/licenses/>.
17
17
 
18
18
  module PuppetLibrary
19
- VERSION = "0.4.0"
19
+ VERSION = "0.5.0"
20
20
  end
@@ -46,7 +46,7 @@ Gem::Specification.new do |spec|
46
46
  spec.add_development_dependency "librarian-puppet"
47
47
  spec.add_development_dependency "mime-types", "< 2"
48
48
  spec.add_development_dependency "pry"
49
- spec.add_development_dependency "puppet"
49
+ spec.add_development_dependency "puppet", "~> 3.3.0"
50
50
  spec.add_development_dependency "rack-test"
51
51
  spec.add_development_dependency "rake"
52
52
  spec.add_development_dependency "rspec"
data/spec/server_spec.rb CHANGED
@@ -51,6 +51,31 @@ module PuppetLibrary
51
51
  expect(last_response.body).to include "0.0.1"
52
52
  expect(last_response.body).to include "0.0.2"
53
53
  end
54
+
55
+ context "when a search term is provided" do
56
+ it "lists matching modules" do
57
+ modules = [
58
+ {
59
+ "author" => "puppetlabs",
60
+ "name" => "apache",
61
+ "tag_list" => ["apache", "httpd"],
62
+ "releases" => [{"version"=>"0.0.1"}, {"version"=>"0.0.2"}],
63
+ "full_name" => "puppetlabs/apache",
64
+ "version" => "0.0.2",
65
+ "project_url" => "http://github.com/puppetlabs/puppetlabs-apache",
66
+ "desc" => "Puppet module for Apache"
67
+ }
68
+ ]
69
+ expect(forge).to receive(:search_modules).with("apache").and_return(modules)
70
+
71
+ get "/?search=apache"
72
+
73
+ expect(last_response.body).to include "Modules"
74
+ expect(last_response.body).to include "puppetlabs/apache"
75
+ expect(last_response.body).to include "0.0.1"
76
+ expect(last_response.body).to include "0.0.2"
77
+ end
78
+ end
54
79
  end
55
80
 
56
81
  describe "GET /modules.json" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puppet-library
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - drrb
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-31 00:00:00.000000000 Z
11
+ date: 2014-02-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sinatra
@@ -140,16 +140,16 @@ dependencies:
140
140
  name: puppet
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
- - - ! '>='
143
+ - - ~>
144
144
  - !ruby/object:Gem::Version
145
- version: '0'
145
+ version: 3.3.0
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
- - - ! '>='
150
+ - - ~>
151
151
  - !ruby/object:Gem::Version
152
- version: '0'
152
+ version: 3.3.0
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: rack-test
155
155
  requirement: !ruby/object:Gem::Requirement
@@ -313,6 +313,7 @@ files:
313
313
  - config.ru
314
314
  - features/module_list.feature
315
315
  - features/module_page.feature
316
+ - features/module_search.feature
316
317
  - features/step_definitions/sinatra_steps.rb
317
318
  - features/support/env.rb
318
319
  - lib/puppet_library.rb
@@ -378,6 +379,7 @@ summary: Puppet Library is a private Puppet module server that's compatible with
378
379
  test_files:
379
380
  - features/module_list.feature
380
381
  - features/module_page.feature
382
+ - features/module_search.feature
381
383
  - features/step_definitions/sinatra_steps.rb
382
384
  - features/support/env.rb
383
385
  - spec/forge/abstract_spec.rb