spout 0.12.0.rc → 0.12.0.rc2

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: b6b577bc1b70562b8fd31c019ebfaf216fbb903c
4
- data.tar.gz: 84a57bcf18809bcbe7241e969247ae45023fc583
3
+ metadata.gz: 0ee597968159c66c33d492721f38b5ba41a682df
4
+ data.tar.gz: 50ff21c4c9bf2053b9c094c46284cf7e589c1311
5
5
  SHA512:
6
- metadata.gz: 4498b53635947fb0810c6e3165b58048cf0855130cb6b3a75e47c24ba075d6509cbe10fe2ddcf7c2df01248a73d74f45e79b0847d4a35629c1f399c5ca4b17b0
7
- data.tar.gz: c81170c50d3cf60e70f931a8eb75fa09dee569705ec687e513b09fdf7d67cbb418c8e5e5c7b9373d3e5fd7649b9f2feb92a114540e0987d8a18df767d47f7c0c
6
+ metadata.gz: aba1faeace9de13a80ef0f5e6ae59cd67be9f9baa15704f9439a7701d42f00d9880692a7d4b2d7d1de7045765b5000e9910695e81611d1aea78663e55f5bedf2
7
+ data.tar.gz: 6e874dadba90dda413a60fc14e7fac481a5526cbd9bcd6376427cd783dd90656d100466d14dc8f938201adcd58e3a2c1451970cf5ac3aac22b73acef4b30579d
data/CHANGELOG.md CHANGED
@@ -5,8 +5,11 @@
5
5
  - Spout now provides a warning and skips columns in CSVs with blank headers
6
6
  - `spout new` command now generates `CHANGELOG.md`, `README.md`, and `VERSION`
7
7
  placeholder files
8
- - Check for the latest version available using `spout update`
9
8
  - Integer and numeric variables can now reference a domain for missing values
9
+ - **Update Command Added**
10
+ - Check for the latest version available using `spout update`
11
+ - The update command provides steps to upgrade the data dictionary to the
12
+ latest version Spout
10
13
  - **Exporter Changes**
11
14
  - The export command now exports the variable forms attribute
12
15
  - Dictionary exports now are in `exports` instead of `dd` folder
@@ -1,16 +1,16 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'colorize'
4
- require 'date'
5
- require 'erb'
6
4
  require 'fileutils'
7
5
 
8
- TEMPLATES_DIRECTORY = File.expand_path('../../templates', __FILE__)
6
+ require 'spout/helpers/framework'
9
7
 
10
8
  module Spout
11
9
  module Commands
12
10
  # Generates folder and file structure for a new spout data dictionary.
13
11
  class ProjectGenerator
12
+ include Spout::Helpers::Framework
13
+
14
14
  def initialize(argv)
15
15
  generate_folder_structure!(argv)
16
16
  end
@@ -54,33 +54,6 @@ EOT
54
54
  Dir.chdir(@full_path)
55
55
  system 'bundle install'
56
56
  end
57
-
58
- private
59
-
60
- def copy_file(template_file, file_name = '')
61
- file_name = template_file if file_name == ''
62
- file_path = File.join(@full_path, file_name)
63
- template_file_path = File.join(TEMPLATES_DIRECTORY, template_file)
64
- puts ' create'.colorize(:green) + " #{file_name}"
65
- FileUtils.copy(template_file_path, file_path)
66
- end
67
-
68
- def evaluate_file(template_file, file_name)
69
- template_file_path = File.join(TEMPLATES_DIRECTORY, template_file)
70
- template = ERB.new(File.read(template_file_path))
71
- file_path = File.join(@full_path, file_name)
72
- file_out = File.new(file_path, 'w')
73
- file_out.syswrite(template.result(binding))
74
- puts ' create'.colorize(:green) + " #{file_name}"
75
- ensure
76
- file_out.close if file_out
77
- end
78
-
79
- def directory(directory_name)
80
- directory_path = File.join(@full_path, directory_name)
81
- puts ' create'.colorize(:green) + " #{directory_name}"
82
- FileUtils.mkpath(directory_path)
83
- end
84
57
  end
85
58
  end
86
59
  end
@@ -2,11 +2,14 @@
2
2
 
3
3
  require 'colorize'
4
4
  require 'spout/helpers/json_request'
5
+ require 'spout/helpers/framework'
5
6
 
6
7
  module Spout
7
8
  module Commands
8
9
  # Command to check if there is an updated version of the gem available.
9
10
  class Update
11
+ include Spout::Helpers::Framework
12
+
10
13
  class << self
11
14
  def start(*args)
12
15
  new(*args).start
@@ -14,6 +17,7 @@ module Spout
14
17
  end
15
18
 
16
19
  def initialize(argv)
20
+ @full_path = File.join('.')
17
21
  end
18
22
 
19
23
  def start
@@ -21,17 +25,88 @@ module Spout
21
25
  if json
22
26
  if json['version'] == Spout::VERSION::STRING
23
27
  puts 'The spout gem is ' + 'up-to-date'.colorize(:green) + '!'
28
+ check_framework if File.exist?('Gemfile')
24
29
  else
25
- puts
26
- puts "A newer version (v#{json['version']}) is available! Type the following command to update:"
27
- puts
28
- puts ' gem install spout --no-document'.colorize(:white)
29
- puts
30
+ puts "A newer version (v#{json['version']}) is available!\n\n"
31
+ if File.exist?('Gemfile')
32
+ puts 'Add the following to your Gemfile and run ' + 'bundle update'.colorize(:green) + ".\n\n"
33
+ puts " gem 'spout', '~> #{json['version']}'\n".colorize(:white)
34
+ else
35
+ puts "Type the following command to update:\n\n"
36
+ puts ' gem install spout --no-document'.colorize(:white) + "\n\n"
37
+ end
30
38
  end
31
39
  else
32
40
  puts 'Unable to connect to RubyGems.org. Please try again later.'
33
41
  end
34
42
  end
43
+
44
+ def check_framework
45
+ check_gitignore_file
46
+ check_ruby_version
47
+ check_file_presence
48
+ check_folder_presence
49
+ check_test_folder
50
+ end
51
+
52
+ def check_gitignore_file
53
+ if File.exist?('.gitignore')
54
+ lines = IO.readlines('.gitignore').collect(&:strip)
55
+ addables = ['/coverage', '/csvs', '/exports', '/graphs']
56
+ removables = ['/dd', '/images']
57
+ unless ((removables & lines) | (addables - lines)).empty?
58
+ puts 'File: ' + '.gitignore'.colorize(:white)
59
+ puts '----------------'
60
+ (removables & lines).each do |removable|
61
+ puts 'REMOVE LINE '.colorize(:red) + removable.colorize(:white)
62
+ end
63
+ (addables - lines).each do |addable|
64
+ puts ' ADD LINE '.colorize(:green) + addable.colorize(:white)
65
+ end
66
+ puts
67
+ end
68
+ else
69
+ copy_file 'gitignore', '.gitignore'
70
+ end
71
+ end
72
+
73
+ def check_ruby_version
74
+ if File.exist?('.ruby-version')
75
+ lines = IO.readlines('.ruby-version').collect(&:strip)
76
+ template_lines = IO.readlines(File.expand_path('../../templates/ruby-version', __FILE__)).collect(&:strip)
77
+ if template_lines.first != lines.first
78
+ puts 'File: ' + '.ruby-version'.colorize(:white)
79
+ puts '-------------------'
80
+ print 'Update Ruby from ' + lines.first.to_s.colorize(:red)
81
+ print ' to ' + template_lines.first.to_s.colorize(:green)
82
+ puts "\n\n"
83
+ end
84
+ else
85
+ copy_file 'ruby-version', '.ruby-version'
86
+ end
87
+ end
88
+
89
+ def check_file_presence
90
+ @project_name = File.basename(Dir.pwd)
91
+ evaluate_file 'CHANGELOG.md.erb', 'CHANGELOG.md' unless File.exist?('CHANGELOG.md')
92
+ evaluate_file 'README.md.erb', 'README.md' unless File.exist?('README.md')
93
+ copy_file 'VERSION' unless File.exist?('VERSION')
94
+ end
95
+
96
+ def check_folder_presence
97
+ folders = %w(domains forms variables).reject { |f| Dir.exist?(f) }
98
+ folders.each do |folder|
99
+ directory folder
100
+ copy_file 'keep', "#{folder}/.keep"
101
+ end
102
+ end
103
+
104
+ def check_test_folder
105
+ return if Dir.exist?('test')
106
+ directory 'test'
107
+ copy_file 'test/dictionary_test.rb'
108
+ copy_file 'test/test_helper.rb'
109
+ end
35
110
  end
36
111
  end
37
112
  end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'colorize'
4
+ require 'date'
5
+ require 'erb'
6
+ require 'fileutils'
7
+
8
+ TEMPLATES_DIRECTORY = File.expand_path('../../templates', __FILE__)
9
+
10
+ module Spout
11
+ module Helpers
12
+ # Helpers to generate and update Spout dictionary framework.
13
+ module Framework
14
+ def copy_file(template_file, file_name = '')
15
+ file_name = template_file if file_name == ''
16
+ file_path = File.join(@full_path, file_name)
17
+ template_file_path = File.join(TEMPLATES_DIRECTORY, template_file)
18
+ puts ' create'.colorize(:green) + " #{file_name}"
19
+ FileUtils.copy(template_file_path, file_path)
20
+ end
21
+
22
+ def evaluate_file(template_file, file_name)
23
+ template_file_path = File.join(TEMPLATES_DIRECTORY, template_file)
24
+ template = ERB.new(File.read(template_file_path))
25
+ file_path = File.join(@full_path, file_name)
26
+ file_out = File.new(file_path, 'w')
27
+ file_out.syswrite(template.result(binding))
28
+ puts ' create'.colorize(:green) + " #{file_name}"
29
+ ensure
30
+ file_out.close if file_out
31
+ end
32
+
33
+ def directory(directory_name)
34
+ directory_path = File.join(@full_path, directory_name)
35
+ puts ' create'.colorize(:green) + " #{directory_name}"
36
+ FileUtils.mkpath(directory_path)
37
+ end
38
+ end
39
+ end
40
+ end
data/lib/spout/version.rb CHANGED
@@ -5,7 +5,7 @@ module Spout
5
5
  MAJOR = 0
6
6
  MINOR = 12
7
7
  TINY = 0
8
- BUILD = 'rc' # 'pre', 'rc', 'rc2', nil
8
+ BUILD = 'rc2' # 'pre', 'rc', 'rc2', nil
9
9
 
10
10
  STRING = [MAJOR, MINOR, TINY, BUILD].compact.join('.').freeze
11
11
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spout
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.0.rc
4
+ version: 0.12.0.rc2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Remo Mueller
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-27 00:00:00.000000000 Z
11
+ date: 2017-03-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -121,6 +121,7 @@ files:
121
121
  - lib/spout/helpers/array_statistics.rb
122
122
  - lib/spout/helpers/chart_types.rb
123
123
  - lib/spout/helpers/config_reader.rb
124
+ - lib/spout/helpers/framework.rb
124
125
  - lib/spout/helpers/iterators.rb
125
126
  - lib/spout/helpers/json_loader.rb
126
127
  - lib/spout/helpers/json_request.rb