falkorlib 0.4.2 → 0.4.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 66b087ab11950e193ccd65ee4139b55641d00afe
4
- data.tar.gz: 9c0addcd32c2e2f4c4f42cd8ef82173b351fd641
3
+ metadata.gz: 24b688866a7028d56fb245d36207f12b727484ed
4
+ data.tar.gz: 3ceb29d135eeb2f9273fb51bd5c9efd560897337
5
5
  SHA512:
6
- metadata.gz: 38b0b4b09e4535c68c63ff4df89bf67eb268b7547c637679e50a5e0c8894090113c3a39e3ae3708d1605cac75c8e1d629f16cba408e9b46a51670cea8f537f6a
7
- data.tar.gz: ee95891a9412a8ebe66d124a56aa8f59d6ccbcc4553dcfc3f4d36e14abcfa32e46d64b7503ded8fd3287fa5c4e42fdc7dfa2dc2ef2bac82eb905ceeb7b5c75ec
6
+ metadata.gz: 9dab597ad919ab7b58606cd89d295f463a7a3c05e4e132cdebea876bed110286ce640c21d63acf0a3f01084c29419c02ec638fdee859cc00fe43fd23171d0611
7
+ data.tar.gz: b330a6ec0382afd5035005a95caa940a2a0a4440b67409d35312edf6181b549afa0de3a7aff6717b17431174ada84b8b50ed783d290e0b0365837ced27d67328
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- falkorlib (0.4.2)
4
+ falkorlib (0.4.3)
5
5
  artii (>= 2.1)
6
6
  awesome_print (~> 1.2)
7
7
  configatron (~> 3.2)
@@ -1,6 +1,6 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  ################################################################################
3
- # Time-stamp: <Mar 2015-02-24 21:58 svarrette>
3
+ # Time-stamp: <Mer 2015-02-25 00:02 svarrette>
4
4
  ################################################################################
5
5
  # Interface for the main Bootstrapping operations
6
6
  #
@@ -34,7 +34,7 @@ module FalkorLib #:nodoc:
34
34
  :tags => []
35
35
  },
36
36
  :trashdir => '.Trash',
37
- :types => [ :latex, :gem, :octopress, :puppet_module, :rvm, :pyenv ],
37
+ :types => [ :none, :latex, :gem, :octopress, :puppet_module, :rvm, :pyenv ],
38
38
  :licenses => {
39
39
  "none" => {},
40
40
  "Apache-2.0" => {
@@ -181,6 +181,7 @@ module FalkorLib
181
181
  ###### repo ######
182
182
  # Initialize a Git repository for a project with my favorite layout
183
183
  # Supported options:
184
+ # * :no_interaction [boolean]: do not interact
184
185
  # :interactive [boolean] Confirm Gitflow branch names
185
186
  # :master [string] Branch name for production releases
186
187
  # :develop [string] Branch name for development commits
@@ -315,6 +316,7 @@ module FalkorLib
315
316
  ###### readme ######
316
317
  # Bootstrap a README file for various context
317
318
  # Supported options:
319
+ # * :no_interaction [boolean]: do not interact
318
320
  # * :force [boolean] force overwritting
319
321
  # * :latex [boolean] describe a LaTeX project
320
322
  # * :octopress [boolean] octopress site
@@ -333,7 +335,7 @@ module FalkorLib
333
335
  config[:type] << :latex if options[:latex]
334
336
  if config[:type].empty?
335
337
  t = select_from( FalkorLib::Config::Bootstrap::DEFAULTS[:types],
336
- 'Select the type of project to describe:')
338
+ 'Select the type of project to describe:', 1)
337
339
  config[:type] << t
338
340
  config[:type] << [ :ruby, :rvm ] if [ :gem, :rvm, :octopress, :puppet_module ].include?( t )
339
341
  config[:type] << :python if t == :pyenv
@@ -1,6 +1,6 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  ################################################################################
3
- # Time-stamp: <Mar 2015-02-24 22:03 svarrette>
3
+ # Time-stamp: <Mer 2015-02-25 00:05 svarrette>
4
4
  ################################################################################
5
5
 
6
6
  require 'thor'
@@ -107,7 +107,6 @@ These files will be committed in Git to ensure a consistent environment for the
107
107
  #......................................
108
108
  desc "readme PATH [options]", "Initiate a README file in the PATH directory ('./' by default)"
109
109
  def readme(path = '.')
110
- ap options
111
110
  FalkorLib::Bootstrap.readme(path, options)
112
111
  end # readme
113
112
  end # class Init
@@ -1,6 +1,6 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  ################################################################################
3
- # Time-stamp: <Mar 2015-02-24 22:09 svarrette>
3
+ # Time-stamp: <Mar 2015-02-24 23:50 svarrette>
4
4
  ################################################################################
5
5
 
6
6
  require "falkorlib"
@@ -84,6 +84,7 @@ module FalkorLib #:nodoc:
84
84
 
85
85
  ## Ask a question
86
86
  def ask(question, default_answer='')
87
+ return default_answer if FalkorLib.config[:no_interaction]
87
88
  print "#{question} "
88
89
  print "[Default: #{default_answer}]" unless default_answer == ''
89
90
  print ": "
@@ -94,6 +95,7 @@ module FalkorLib #:nodoc:
94
95
 
95
96
  ## Ask whether or not to really continue
96
97
  def really_continue?(default_answer = 'Yes')
98
+ return if FalkorLib.config[:no_interaction]
97
99
  pattern = (default_answer =~ /yes/i) ? '(Y|n)' : '(y|N)'
98
100
  answer = ask( cyan("=> Do you really want to continue #{pattern}?"), default_answer)
99
101
  exit 0 if answer =~ /n.*/i
@@ -1,6 +1,6 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  ################################################################################
3
- # Time-stamp: <Mar 2015-02-24 11:58 svarrette>
3
+ # Time-stamp: <Mer 2015-02-25 00:19 svarrette>
4
4
  ################################################################################
5
5
  # FalkorLib Configuration
6
6
  #
@@ -41,14 +41,15 @@ module FalkorLib #:nodoc:
41
41
  module Config #:nodoc:
42
42
  # Defaults global settings
43
43
  DEFAULTS = {
44
- :debug => false,
45
- :verbose => false,
46
- :root => Dir.pwd,
47
- :config_files => {
48
- :local => '.falkor/config',
49
- :private => '.falkor/private',
50
- #:project => '.falkor/project',
51
- },
44
+ :debug => false,
45
+ :verbose => false,
46
+ :no_interaction => false,
47
+ :root => Dir.pwd,
48
+ :config_files => {
49
+ :local => '.falkor/config',
50
+ :private => '.falkor/private',
51
+ #:project => '.falkor/project',
52
+ },
52
53
  #:custom_cfg => '.falkorlib.yaml',
53
54
  :rvm => {
54
55
  :rubies => [ '1.9.3', '2.0.0', '2.1.0'],
@@ -69,7 +70,7 @@ module FalkorLib #:nodoc:
69
70
  ## Build the default configuration hash, to be used to initiate the default.
70
71
  # The hash is built depending on the loaded files.
71
72
  def default
72
- res = FalkorLib::Config::DEFAULTS
73
+ res = FalkorLib::Config::DEFAULTS.clone
73
74
  $LOADED_FEATURES.each do |path|
74
75
  res[:git] = FalkorLib::Config::Git::DEFAULTS if path.include?('lib/falkorlib/git.rb')
75
76
  res[:gitflow] = FalkorLib::Config::GitFlow::DEFAULTS if path.include?('lib/falkorlib/git.rb')
@@ -95,31 +96,37 @@ module FalkorLib #:nodoc:
95
96
  # * :file [string] filename for the local configuration
96
97
  ##
97
98
  def get(dir = Dir.pwd, type = :local, options = {})
98
- path = normalized_path(dir)
99
- path = FalkorLib::Git.rootdir(path) if FalkorLib::Git.init?(path)
100
- raise FalkorLib::Error, "Wrong FalkorLib configuration type" unless FalkorLib.config[:config_files].keys.include?( type.to_sym)
101
- local_config_file = options[:file] ? options[:file] : File.join(path, FalkorLib.config[:config_files][type.to_sym])
99
+ conffile = config_file(dir,type,options)
102
100
  res = {}
103
- res = load_config( local_config_file ) if File.exists?( local_config_file )
101
+ res = load_config( conffile ) if File.exists?( conffile )
104
102
  res
105
103
  end # get
106
104
 
105
+ ###### get_or_save ######
106
+ # wrapper for get and save operations
107
+ ##
108
+ def config_file(dir = Dir.pwd, type = :local, options = {})
109
+ path = normalized_path(dir)
110
+ path = FalkorLib::Git.rootdir(path) if FalkorLib::Git.init?(path)
111
+ raise FalkorLib::Error, "Wrong FalkorLib configuration type" unless FalkorLib.config[:config_files].keys.include?( type.to_sym)
112
+ return options[:file] ? options[:file] : File.join(path, FalkorLib.config[:config_files][type.to_sym])
113
+ end # get_or_save
114
+
115
+
107
116
  ###### save ######
108
117
  # save the { local | private } configuration on YAML format
109
118
  # Supported options:
110
119
  # * :file [string] filename for the saved configuration
120
+ # * :no_interaction [boolean]: do not interact
111
121
  ##
112
122
  def save(dir = Dir.pwd, config = {}, type = :local, options = {})
113
- path = normalized_path(dir)
114
- path = FalkorLib::Git.rootdir(path) if FalkorLib::Git.init?(path)
115
- raise FalkorLib::Error, "Wrong FalkorLib configuration type"unless FalkorLib.config[:config_files].keys.include?( type.to_sym)
116
- conffile = options[:file] ? options[:file] : File.join(path, FalkorLib.config[:config_files][type.to_sym])
123
+ conffile = config_file(dir,type,options)
117
124
  confdir = File.dirname( conffile )
118
125
  unless File.directory?( confdir )
119
- really_continue? "about to create the configuration directory #{confdir}"
126
+ really_continue? "about to create the configuration directory #{confdir}" unless options[:no_interaction]
120
127
  run %{ mkdir -p #{confdir} }
121
128
  end
122
- store_config(conffile, config)
129
+ store_config(conffile, config, options)
123
130
  end # save
124
131
 
125
132
  end
@@ -36,6 +36,7 @@ begin
36
36
  #t.pattern = "spec/**/bootstrap*spec.rb"
37
37
  #t.pattern = "spec/**/gitf*spec.rb"
38
38
  #t.pattern = "spec/**/error*spec.rb"
39
+ #t.pattern = "spec/**/config*spec.rb"
39
40
 
40
41
  # Whether or not to fail Rake when an error occurs (typically when
41
42
  # examples fail).
@@ -19,7 +19,7 @@ module FalkorLib #:nodoc:
19
19
  # MAJOR: Defines the major version
20
20
  # MINOR: Defines the minor version
21
21
  # PATCH: Defines the patch version
22
- MAJOR, MINOR, PATCH = 0, 4, 2
22
+ MAJOR, MINOR, PATCH = 0, 4, 3
23
23
 
24
24
  module_function
25
25
 
@@ -2,7 +2,7 @@
2
2
  #########################################
3
3
  # bootstrap_spec.rb
4
4
  # @author Sebastien Varrette <Sebastien.Varrette@uni.lu>
5
- # Time-stamp: <Sam 2015-01-24 19:05 svarrette>
5
+ # Time-stamp: <Mer 2015-02-25 00:03 svarrette>
6
6
  #
7
7
  # @description Check the Bootstrapping operations
8
8
  #
@@ -20,9 +20,9 @@ describe FalkorLib::Bootstrap do
20
20
 
21
21
  dirs = {
22
22
  :without_git => Dir.mktmpdir,
23
- :with_git => Dir.mktmpdir
23
+ :with_git => Dir.mktmpdir,
24
+ :default => Dir.mktmpdir
24
25
  }
25
-
26
26
  before :all do
27
27
  $stdout.sync = true
28
28
  end
@@ -31,6 +31,7 @@ describe FalkorLib::Bootstrap do
31
31
  dirs.each do |t,d|
32
32
  FileUtils.remove_entry_secure d
33
33
  end
34
+ FalkorLib.config[:no_interaction] = false
34
35
  end
35
36
 
36
37
  [ :without_git, :with_git ].each do |ctx|
@@ -111,8 +112,59 @@ describe FalkorLib::Bootstrap do
111
112
  content[:gemsetfile].should == opts[:gemset]
112
113
  end
113
114
 
115
+ it "#select_forge - none" do
116
+ STDIN.should_receive(:gets).and_return('1')
117
+ t = FalkorLib::Bootstrap.select_forge()
118
+ t.should == :none
119
+ end
120
+
121
+ it "#select_forge -- default to github" do
122
+ STDIN.should_receive(:gets).and_return('')
123
+ t = FalkorLib::Bootstrap.select_forge(:github)
124
+ t.should == :github
125
+ end
126
+
127
+ FalkorLib::Config::Bootstrap::DEFAULTS[:licenses].keys.each do |lic|
128
+ it "#select_licence -- default to #{lic}" do
129
+ STDIN.should_receive(:gets).and_return('')
130
+ t = FalkorLib::Bootstrap.select_licence(lic)
131
+ t.should == lic
132
+ end
133
+ end
134
+
135
+ it "#get_badge " do
136
+ subject = 'licence'
137
+ status = 'GPL-2.0'
138
+ t = FalkorLib::Bootstrap.get_badge(subject, status)
139
+ t.should =~ /#{subject}/
140
+ t.should =~ /#{status.sub(/-/, '--')}/
141
+ end
142
+
143
+ it "#readme" do
144
+ #Array.new(6).each { |e| STDIN.should_receive(:gets).and_return('') }
145
+ #STDIN.should_receive(:gets).and_return('')
146
+ #STDIN.should_receive(:gets).and_return('1')
147
+ FalkorLib.config[:no_interaction] = true
148
+ FalkorLib::Bootstrap.readme(dir, { :no_interaction => true })
149
+ t = File.exists?(File.join(dir, 'README.md'))
150
+ t.should be_true
151
+ FalkorLib.config[:no_interaction] = false
152
+ end
114
153
  end # context
115
154
 
116
155
  end # each
156
+
157
+ ############################################
158
+ context 'boostrap repo' do
159
+ dir = dirs[:default]
160
+
161
+ it '#repo' do
162
+ FalkorLib.config[:no_interaction] = true
163
+ FalkorLib::Bootstrap.repo(dir, { :no_interaction => true })
164
+ FalkorLib.config[:no_interaction] = false
165
+ end
166
+
167
+ end
117
168
 
169
+
118
170
  end
@@ -0,0 +1,45 @@
1
+ require 'spec_helper'
2
+ require 'tempfile'
3
+
4
+ describe FalkorLib::Config do
5
+
6
+ include FalkorLib::Common
7
+
8
+ dir = Dir.mktmpdir
9
+ test_hash = {
10
+ :str => "simple string",
11
+ :array => [ 'a', 'b' ],
12
+ :hash => {
13
+ :key => 'val'
14
+ }
15
+ }
16
+
17
+ after :all do
18
+ FileUtils.remove_entry_secure dir
19
+ end
20
+
21
+ #############################################
22
+ context "Test default configuration object" do
23
+
24
+ it "#default" do
25
+ hash = FalkorLib::Config.default
26
+ t = hash.is_a? Hash
27
+ t.should be_true
28
+ hash[:rvm][:versionfile].should == FalkorLib::Config::DEFAULTS[:rvm][:versionfile]
29
+ end
30
+
31
+ it "#save" do
32
+ FalkorLib::Config.save(dir, test_hash, :local, { :no_interaction => true })
33
+ t = File.exists?( File.join(dir, FalkorLib::Config::DEFAULTS[:config_files][:local]))
34
+ t. should be_true
35
+ end
36
+
37
+ it "#get" do
38
+ h = FalkorLib::Config.get(dir, :local, { :no_interaction => true })
39
+ h.should == test_hash
40
+ end
41
+
42
+ end
43
+
44
+
45
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: falkorlib
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sebastien Varrette
@@ -379,6 +379,7 @@ files:
379
379
  - lib/falkorlib/versioning.rb
380
380
  - spec/falkorlib/bootstrap_spec.rb
381
381
  - spec/falkorlib/common_spec.rb
382
+ - spec/falkorlib/config_spec.rb
382
383
  - spec/falkorlib/error_spec.rb
383
384
  - spec/falkorlib/git_spec.rb
384
385
  - spec/falkorlib/gitflow_spec.rb
@@ -440,6 +441,7 @@ summary: Sebastien Varrette aka Falkor's Common library to share Ruby code and {
440
441
  test_files:
441
442
  - spec/falkorlib/bootstrap_spec.rb
442
443
  - spec/falkorlib/common_spec.rb
444
+ - spec/falkorlib/config_spec.rb
443
445
  - spec/falkorlib/error_spec.rb
444
446
  - spec/falkorlib/git_spec.rb
445
447
  - spec/falkorlib/gitflow_spec.rb