poet 0.6 → 0.7

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,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7a1c22167979b956323e1722622e55dc797f4dd1
4
- data.tar.gz: cb6db04649fb4bb6419deda704d8973e48eca4ab
3
+ metadata.gz: 4fb7070a342cae74fbd9cb0b7c018ffc8537c2cb
4
+ data.tar.gz: 916e6110ccacfb8e8ec5c9984a5c3cd01266f7fa
5
5
  SHA512:
6
- metadata.gz: 764a303b1d55051d77222ea392f84d47a147b5142253826d1bdb806c809f22c1e5a65bdb8ac5e16469178a0d17d14e79ff5a7a4a14a6d6260921ef174cece617
7
- data.tar.gz: 21780a1d05d1bb5bf1fb7ea86928f76c73d8e25da282acad005c1dc9986364e5bff30a706a2f862d68c72c86c9edcc74456d57e479c546f070b2a0e940315014
6
+ metadata.gz: d9a3871ae91f7784d750b1760191ec4041b516cd2db37d8747bc14a610559678d3f7b55abc2b5c33dcb9aeaa25d2ec06ed99e17dfc666cbab96d549d432ec832
7
+ data.tar.gz: 7e20f7e476af2418b350bc153562bd75bff9fe3372e998054c4520f05aced137fd2ba2263dbe90cc0bac1ab4f8277314d79ec8e4e60e1caaab1d7d8df0be7951
@@ -1,10 +1,10 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 1.9.2
4
3
  - 1.9.3
5
- - rbx-18mode
6
- - jruby
4
+ - 2.0.0
5
+ - rbx-19mode
6
+ - jruby-19mode
7
7
  matrix:
8
8
  allow_failures:
9
- - rvm: jruby
10
- - rvm: rbx-18mode
9
+ - rvm: jruby-19mode
10
+ - rvm: rbx-19mode
@@ -1,5 +1,11 @@
1
1
  master
2
2
 
3
+ - list config files with `poet ls` or `poet ls --tree`
4
+
5
+ - drop suport for Ruby 1.9.2, officially support 2.0
6
+
7
+ - `poet edit` re-generates files only when they are actually changed
8
+
3
9
  0.6
4
10
 
5
11
  - show original file where stanzas came from (thanks @sethiele)
data/README.md CHANGED
@@ -1,4 +1,5 @@
1
1
  [![Build Status](https://secure.travis-ci.org/awendt/poet.png)](http://travis-ci.org/awendt/poet)
2
+ [![Gem Version](https://badge.fury.io/rb/poet.png)](http://badge.fury.io/rb/poet)
2
3
 
3
4
  # Split your `ssh_config` into separate files!
4
5
 
@@ -25,6 +26,8 @@ Every now and then, when you do need it, run `poet --with CONFIG` to explicitly
25
26
  `CONFIG.disabled` in your generated ssh_config. You can even include several by running several
26
27
  `--with` options or using `--with CONFIG1,CONFIG2`.
27
28
 
29
+ Use `poet ls` (or `poet ls --tree`) to see a list (or tree) of all your config files.
30
+
28
31
  ## Note on Patches/Pull Requests
29
32
 
30
33
  * Fork the project.
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ double_spaced = File.readlines(ARGV.first).join("\n")
4
+ File.write(ARGV.first, double_spaced)
@@ -1,15 +1,4 @@
1
1
  Feature: Editing files
2
- Scenario: User wants to edit files quickly
3
- Given a file named "favorite_editor" with:
4
- """
5
- Host vim
6
- User me
7
- """
8
- When I set env variable "EDITOR" to "/bin/cat"
9
- And I run `poet edit favorite_editor`
10
- Then the output from "poet edit favorite_editor" should contain "Host vim"
11
- And the file "ssh_config" should contain "Host vim"
12
-
13
2
  Scenario: Show warning when user does not have EDITOR set
14
3
  Given a file named "no_editor" with:
15
4
  """
@@ -29,4 +18,42 @@ Feature: Editing files
29
18
  When I set env variable "EDITOR" to "/bin/cat"
30
19
  And I run `poet edit missing -o important`
31
20
  Then the output from "poet edit missing -o important" should not contain "Found hand-crafted ssh_config"
32
- And the exit status should be 0
21
+ And the exit status should be 0
22
+
23
+ Scenario: ssh_config is re-generated after changing files
24
+ Given a file named "file1" with:
25
+ """
26
+ Host one
27
+ User me
28
+ """
29
+ And the file "ssh_config" should not exist
30
+
31
+ When I poet-edit file "file1" and change something
32
+ Then the exit status should be 0
33
+ And the file "ssh_config" should contain "Host one"
34
+
35
+ Scenario: ssh_config is not re-generated after not changing files
36
+ Given a file named "file1" with:
37
+ """
38
+ Host one
39
+ User me
40
+ """
41
+ And the file "ssh_config" should not exist
42
+
43
+ When I poet-edit file "file1" without changing something
44
+ Then the exit status should be 0
45
+ And the file "ssh_config" should not exist
46
+
47
+ Scenario: ssh_config includes disabled file after editing it
48
+ Given a file named "homeoffice.disabled" with:
49
+ """
50
+ Host normally_disabled
51
+ User me
52
+ """
53
+ When I run `poet`
54
+ Then the exit status should be 0
55
+ And the file "ssh_config" should not contain "Host normally_disabled"
56
+
57
+ When I poet-edit file "homeoffice.disabled" and change something
58
+ Then the exit status should be 0
59
+ And the file "ssh_config" should contain "Host normally_disabled"
@@ -0,0 +1,39 @@
1
+ Feature: Listing files
2
+
3
+ Scenario: Listing files without tree
4
+ Given a directory named "foo/bar"
5
+ And a file named "foo/bar/conf1" with:
6
+ """
7
+ Host one
8
+ """
9
+ And a file named "foo/conf2.disabled" with:
10
+ """
11
+ Host two
12
+ """
13
+ When I run `poet ls`
14
+ Then the output should contain exactly:
15
+ """
16
+ foo/bar/conf1
17
+ foo/conf2.disabled
18
+
19
+ """
20
+
21
+ Scenario: Listing files with tree
22
+ Given a directory named "foo/bar"
23
+ And a file named "foo/bar/conf1" with:
24
+ """
25
+ Host one
26
+ """
27
+ And a file named "foo/conf2.disabled" with:
28
+ """
29
+ Host two
30
+ """
31
+ When I run `poet ls -t`
32
+ Then the output should contain exactly:
33
+ """
34
+ |-- foo
35
+ | |-- bar
36
+ | | |-- conf1
37
+ | |-- conf2.disabled
38
+
39
+ """
@@ -1,3 +1,13 @@
1
1
  When /^I set env variable "(\w+)" to "([^"]*)"$/ do |var, value|
2
2
  ENV[var] = value
3
3
  end
4
+
5
+ When /^I poet\-edit file "([^"]*)" and change something$/ do |filename|
6
+ ENV['EDITOR'] = File.expand_path('../../../editors/double_space.rb', __FILE__)
7
+ step "I run `poet edit #{filename}`"
8
+ end
9
+
10
+ When /^I poet\-edit file "([^"]*)" without changing something$/ do |filename|
11
+ ENV['EDITOR'] = "/bin/cat"
12
+ step "I run `poet edit #{filename}`"
13
+ end
@@ -6,6 +6,8 @@ class PoetCLI < Thor
6
6
 
7
7
  MAGIC_LINE = "# Generated by #{File.basename(__FILE__, '.rb')}"
8
8
 
9
+ attr_accessor :files_to_include
10
+
9
11
  default_task :create
10
12
  class_option :dir,
11
13
  desc: 'Use specified directory to collect conf files',
@@ -23,6 +25,18 @@ class PoetCLI < Thor
23
25
  aliases: '-v',
24
26
  type: :boolean
25
27
 
28
+ no_tasks do
29
+ def print_tree(dir = ".", nesting = 0)
30
+ Dir.entries(dir).sort.each do |entry|
31
+ next if entry =~ /^\.{1,2}/ # Ignore ".", "..", or hidden files
32
+ puts "| " * nesting + "|-- #{entry}"
33
+ if File.stat(d = "#{dir}#{File::SEPARATOR}#{entry}").directory?
34
+ print_tree(d, nesting + 1)
35
+ end
36
+ end
37
+ end
38
+ end
39
+
26
40
  desc "bootstrap [FILE]",
27
41
  "Move ~/.ssh/config (or whatever you specified) to ~/.ssh/config.d/ to help you get started"
28
42
  def bootstrap(file=nil)
@@ -50,10 +64,10 @@ class PoetCLI < Thor
50
64
  Process.exit!(2)
51
65
  end
52
66
 
53
- whitelist = options[:with].split(',')
67
+ whitelist = files_to_include || options[:with].split(',').map{|file| "#{file}.disabled"}
54
68
  files = Dir["#{options[:dir]}/**/*"].reject do |file|
55
69
  File.directory?(file) || \
56
- file =~ /\.disabled$/ && !whitelist.include?("#{File.basename(file, '.disabled')}")
70
+ file =~ /\.disabled$/ && !whitelist.include?(File.basename(file))
57
71
  end
58
72
 
59
73
  files -= [options[:output]]
@@ -81,8 +95,20 @@ class PoetCLI < Thor
81
95
  Process.exit!(4)
82
96
  end
83
97
  filepath = File.join(options[:dir], file)
98
+ checksum_before = Digest::MD5.file(filepath) rescue '0'*16
84
99
  system("#{ENV['EDITOR']} #{filepath}")
85
- create if File.exists?(filepath)
100
+ self.files_to_include = [file]
101
+ create if File.exists?(filepath) && checksum_before != Digest::MD5.file(filepath)
86
102
  end
87
103
 
88
- end
104
+ desc "ls", "List all configuration files"
105
+ option :tree, aliases: '-t', type: :boolean, desc: 'Print tree of config dir'
106
+ def ls
107
+ if options[:tree]
108
+ print_tree(options[:dir])
109
+ else
110
+ files = Dir["#{options[:dir]}/**/*"].sort.reject { |file| File.directory?(file) }
111
+ puts files.map{|filename| filename[options[:dir].size+1..-1]}.join("\n")
112
+ end
113
+ end
114
+ end
@@ -1,3 +1,3 @@
1
1
  module Poet
2
- VERSION = "0.6"
2
+ VERSION = "0.7"
3
3
  end
@@ -14,7 +14,7 @@ Gem::Specification.new do |s|
14
14
  s.rubyforge_project = "poet"
15
15
 
16
16
  s.files = `git ls-files`.split("\n")
17
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features,editors}/*`.split("\n")
18
18
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
19
  s.require_paths = ["lib"]
20
20
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: poet
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.6'
4
+ version: '0.7'
5
5
  platform: ruby
6
6
  authors:
7
7
  - André Wendt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-07 00:00:00.000000000 Z
11
+ date: 2013-08-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cucumber
@@ -83,8 +83,10 @@ files:
83
83
  - README.md
84
84
  - Rakefile
85
85
  - bin/poet
86
+ - editors/double_space.rb
86
87
  - features/bootstrapping.feature
87
88
  - features/editing_files.feature
89
+ - features/listing_files.feature
88
90
  - features/permissions.feature
89
91
  - features/running.feature
90
92
  - features/selective_files.feature
@@ -119,8 +121,10 @@ signing_key:
119
121
  specification_version: 4
120
122
  summary: Poet concatenates stanzas
121
123
  test_files:
124
+ - editors/double_space.rb
122
125
  - features/bootstrapping.feature
123
126
  - features/editing_files.feature
127
+ - features/listing_files.feature
124
128
  - features/permissions.feature
125
129
  - features/running.feature
126
130
  - features/selective_files.feature