stats_package_syntax_file_generator 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README +127 -127
- data/lib/syntax_file/controller.rb +1 -1
- data/lib/syntax_file/maker_stata.rb +5 -6
- metadata +11 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 40776a454db0dcb677d28ca3d42236dc092b6388
|
4
|
+
data.tar.gz: 30654d635ccf71a4b8a1d505a2c404e86c1752a5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c3114cfa161a6564527b2f5b1ee676b4c1ec4cd2ec4786c76778631f569f911c7293c0367ed0d6d9e0e987cc3c87943ebead88ec28e6b9528d213a03ed8b59c1
|
7
|
+
data.tar.gz: 1c4213eded2e5f30fc1b5046d2aac58988f89662a8da9aaa7f5e4799540a2a737fa4bd9c9b777d6da1205cba22aa0924ce1bf60bfa11048fd829e80f7540ca1a
|
data/README
CHANGED
@@ -1,128 +1,128 @@
|
|
1
|
-
This gem produces statistical package syntax files for fixed-column data files.
|
2
|
-
|
3
|
-
SAS
|
4
|
-
SPSS
|
5
|
-
Stata
|
6
|
-
Stat/Transfer STS metadata files
|
7
|
-
|
8
|
-
|
9
|
-
Metadata can be supplied to the Controller in two general ways:
|
10
|
-
|
11
|
-
- Programmatically, using the API provided by the Controller class.
|
12
|
-
|
13
|
-
- Via one or more YAML files -- typically just one YAML file, but the
|
14
|
-
Controller will accept multiple files and merge their content.
|
15
|
-
|
16
|
-
|
17
|
-
Basic usage:
|
18
|
-
|
19
|
-
require 'stats_package_syntax_file_generator'
|
20
|
-
|
21
|
-
# Supply metadata via one YAML file.
|
22
|
-
sfc = SyntaxFile::Controller.new(:yaml_files => 'metadata.yaml')
|
23
|
-
|
24
|
-
# Or via multiple YAML files.
|
25
|
-
sfc = SyntaxFile::Controller.new(:yaml_files => ['md1.yaml', 'md2.yaml'])
|
26
|
-
|
27
|
-
# Or programmatically.
|
28
|
-
# For a working example, see devel/api_example.rb.
|
29
|
-
|
30
|
-
# Generate all syntax files.
|
31
|
-
sfc.generate_syntax_files
|
32
|
-
|
33
|
-
# Generate a syntax file of a specific TYPE (spss, sas, stata).
|
34
|
-
sfc.generate_syntax_file('TYPE')
|
35
|
-
|
36
|
-
# Ditto, but get the syntax as a list of strings rather than writing a file.
|
37
|
-
syntax_lines = sfc.syntax('TYPE')
|
38
|
-
|
39
|
-
|
40
|
-
Running tests:
|
41
|
-
|
42
|
-
devel/run_all_checks.sh
|
43
|
-
|
44
|
-
|
45
|
-
Project structure:
|
46
|
-
|
47
|
-
devel/
|
48
|
-
# Developer area.
|
49
|
-
# Various scripts, plus the following:
|
50
|
-
|
51
|
-
input/
|
52
|
-
# YAML metadata used during development
|
53
|
-
# and in end-to-end acceptance testing.
|
54
|
-
|
55
|
-
output_expected/
|
56
|
-
# Acceptance testing: expected output.
|
57
|
-
|
58
|
-
output_result/
|
59
|
-
# Acceptance testing: directory where new output
|
60
|
-
# is written. This output is not included in Git.
|
61
|
-
|
62
|
-
lib/ # The syntax file utility itself.
|
63
|
-
tests/ # Unit test scripts and their YAML metadata.
|
64
|
-
|
65
|
-
|
66
|
-
Class overview:
|
67
|
-
|
68
|
-
Controller
|
69
|
-
|
70
|
-
- The API for the gem. Users of the gem should not need to interact with
|
71
|
-
other classes.
|
72
|
-
|
73
|
-
- Serves as a container for the metadata needed to generate syntax files.
|
74
|
-
|
75
|
-
- Holds various attributes specifying the type of syntax files to
|
76
|
-
generate, the structure of the data files, and so forth.
|
77
|
-
|
78
|
-
Variable
|
79
|
-
Value
|
80
|
-
|
81
|
-
- Metadata classes holding information about variables in the data file.
|
82
|
-
|
83
|
-
- A Controller contains 1+ Variable objects.
|
84
|
-
|
85
|
-
- A Variable contains 0+ Value objects.
|
86
|
-
|
87
|
-
Maker
|
88
|
-
Maker_SAS
|
89
|
-
Maker_SPSS
|
90
|
-
Maker_STATA
|
91
|
-
Maker_STS
|
92
|
-
|
93
|
-
- Classes responsible for creating syntax.
|
94
|
-
|
95
|
-
- Maker provides methods that all classes have in common.
|
96
|
-
|
97
|
-
- The other classes inherit from Maker, overriding behavior as needed.
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
General behavior of the specific Maker classes:
|
102
|
-
|
103
|
-
- The classes all define a primary method: syntax().
|
104
|
-
|
105
|
-
- The syntax() method consists of calls to various other methods responsible
|
106
|
-
for generating sections of the syntax.
|
107
|
-
|
108
|
-
- Methods that generate sub-sections of syntax have names beginning with 'syn_'.
|
109
|
-
|
110
|
-
- All of the syntax-generating methods return a list of strings.
|
111
|
-
|
112
|
-
|
113
|
-
Notes on STS files:
|
114
|
-
|
115
|
-
1. Hierchical data.
|
116
|
-
Stat/Transfer does not directly support hierarchical data structures. The
|
117
|
-
workaround is to perform multiple invocations of Stat/Transfer, once per record
|
118
|
-
type. Each invocation must instruct Stat/Transfer to perform case selection to
|
119
|
-
filter the records such that a single record type is in scope, and must request
|
120
|
-
the variables appropriate for that record type.
|
121
|
-
|
122
|
-
2. Variable and value labels with quotes.
|
123
|
-
Stat/Transfer does not support escaping quotes within value labels. Therefore,
|
124
|
-
double quotes are represented by a pair of single quotes.
|
125
|
-
|
126
|
-
3. Only alphanumeric values are permitted for value labels.
|
127
|
-
Nonconforming values are skipped, with a comment added to the STS file that
|
1
|
+
This gem produces statistical package syntax files for fixed-column data files.
|
2
|
+
|
3
|
+
SAS
|
4
|
+
SPSS
|
5
|
+
Stata
|
6
|
+
Stat/Transfer STS metadata files
|
7
|
+
|
8
|
+
|
9
|
+
Metadata can be supplied to the Controller in two general ways:
|
10
|
+
|
11
|
+
- Programmatically, using the API provided by the Controller class.
|
12
|
+
|
13
|
+
- Via one or more YAML files -- typically just one YAML file, but the
|
14
|
+
Controller will accept multiple files and merge their content.
|
15
|
+
|
16
|
+
|
17
|
+
Basic usage:
|
18
|
+
|
19
|
+
require 'stats_package_syntax_file_generator'
|
20
|
+
|
21
|
+
# Supply metadata via one YAML file.
|
22
|
+
sfc = SyntaxFile::Controller.new(:yaml_files => 'metadata.yaml')
|
23
|
+
|
24
|
+
# Or via multiple YAML files.
|
25
|
+
sfc = SyntaxFile::Controller.new(:yaml_files => ['md1.yaml', 'md2.yaml'])
|
26
|
+
|
27
|
+
# Or programmatically.
|
28
|
+
# For a working example, see devel/api_example.rb.
|
29
|
+
|
30
|
+
# Generate all syntax files.
|
31
|
+
sfc.generate_syntax_files
|
32
|
+
|
33
|
+
# Generate a syntax file of a specific TYPE (spss, sas, stata).
|
34
|
+
sfc.generate_syntax_file('TYPE')
|
35
|
+
|
36
|
+
# Ditto, but get the syntax as a list of strings rather than writing a file.
|
37
|
+
syntax_lines = sfc.syntax('TYPE')
|
38
|
+
|
39
|
+
|
40
|
+
Running tests:
|
41
|
+
|
42
|
+
devel/run_all_checks.sh
|
43
|
+
|
44
|
+
|
45
|
+
Project structure:
|
46
|
+
|
47
|
+
devel/
|
48
|
+
# Developer area.
|
49
|
+
# Various scripts, plus the following:
|
50
|
+
|
51
|
+
input/
|
52
|
+
# YAML metadata used during development
|
53
|
+
# and in end-to-end acceptance testing.
|
54
|
+
|
55
|
+
output_expected/
|
56
|
+
# Acceptance testing: expected output.
|
57
|
+
|
58
|
+
output_result/
|
59
|
+
# Acceptance testing: directory where new output
|
60
|
+
# is written. This output is not included in Git.
|
61
|
+
|
62
|
+
lib/ # The syntax file utility itself.
|
63
|
+
tests/ # Unit test scripts and their YAML metadata.
|
64
|
+
|
65
|
+
|
66
|
+
Class overview:
|
67
|
+
|
68
|
+
Controller
|
69
|
+
|
70
|
+
- The API for the gem. Users of the gem should not need to interact with
|
71
|
+
other classes.
|
72
|
+
|
73
|
+
- Serves as a container for the metadata needed to generate syntax files.
|
74
|
+
|
75
|
+
- Holds various attributes specifying the type of syntax files to
|
76
|
+
generate, the structure of the data files, and so forth.
|
77
|
+
|
78
|
+
Variable
|
79
|
+
Value
|
80
|
+
|
81
|
+
- Metadata classes holding information about variables in the data file.
|
82
|
+
|
83
|
+
- A Controller contains 1+ Variable objects.
|
84
|
+
|
85
|
+
- A Variable contains 0+ Value objects.
|
86
|
+
|
87
|
+
Maker
|
88
|
+
Maker_SAS
|
89
|
+
Maker_SPSS
|
90
|
+
Maker_STATA
|
91
|
+
Maker_STS
|
92
|
+
|
93
|
+
- Classes responsible for creating syntax.
|
94
|
+
|
95
|
+
- Maker provides methods that all classes have in common.
|
96
|
+
|
97
|
+
- The other classes inherit from Maker, overriding behavior as needed.
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
General behavior of the specific Maker classes:
|
102
|
+
|
103
|
+
- The classes all define a primary method: syntax().
|
104
|
+
|
105
|
+
- The syntax() method consists of calls to various other methods responsible
|
106
|
+
for generating sections of the syntax.
|
107
|
+
|
108
|
+
- Methods that generate sub-sections of syntax have names beginning with 'syn_'.
|
109
|
+
|
110
|
+
- All of the syntax-generating methods return a list of strings.
|
111
|
+
|
112
|
+
|
113
|
+
Notes on STS files:
|
114
|
+
|
115
|
+
1. Hierchical data.
|
116
|
+
Stat/Transfer does not directly support hierarchical data structures. The
|
117
|
+
workaround is to perform multiple invocations of Stat/Transfer, once per record
|
118
|
+
type. Each invocation must instruct Stat/Transfer to perform case selection to
|
119
|
+
filter the records such that a single record type is in scope, and must request
|
120
|
+
the variables appropriate for that record type.
|
121
|
+
|
122
|
+
2. Variable and value labels with quotes.
|
123
|
+
Stat/Transfer does not support escaping quotes within value labels. Therefore,
|
124
|
+
double quotes are represented by a pair of single quotes.
|
125
|
+
|
126
|
+
3. Only alphanumeric values are permitted for value labels.
|
127
|
+
Nonconforming values are skipped, with a comment added to the STS file that
|
128
128
|
documents this action.
|
@@ -259,12 +259,11 @@ end
|
|
259
259
|
|
260
260
|
def var_fmt (var)
|
261
261
|
|
262
|
-
return 'str'
|
263
|
-
return
|
264
|
-
return '
|
265
|
-
return '
|
266
|
-
return '
|
267
|
-
return 'long' if var.width <= 7
|
262
|
+
return 'str' if var.is_string_var
|
263
|
+
return 'double' if var.is_double_var || var.implied_decimals > 0
|
264
|
+
return 'byte' if var.width <= 2
|
265
|
+
return 'int' if var.width <= 4
|
266
|
+
return 'long' if var.width <= 7
|
268
267
|
|
269
268
|
return 'double'
|
270
269
|
end
|
metadata
CHANGED
@@ -1,16 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stats_package_syntax_file_generator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Monty Hindman, Marcus Peterson, Colin Davis, Dan Elbert, Jayandra Pokharel
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-10-17 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description: A tool for producing statistical package syntax files for fixed-column
|
13
|
+
description: A tool for producing statistical package syntax files for fixed-column
|
14
|
+
data files
|
14
15
|
email: mpcit@umn.edu
|
15
16
|
executables: []
|
16
17
|
extensions: []
|
@@ -43,24 +44,24 @@ homepage: https://github.com/mnpopcenter/stats_package_syntax_file_generator
|
|
43
44
|
licenses:
|
44
45
|
- MPL-2.0
|
45
46
|
metadata: {}
|
46
|
-
post_install_message:
|
47
|
+
post_install_message:
|
47
48
|
rdoc_options: []
|
48
49
|
require_paths:
|
49
50
|
- lib
|
50
51
|
required_ruby_version: !ruby/object:Gem::Requirement
|
51
52
|
requirements:
|
52
|
-
- -
|
53
|
+
- - ">="
|
53
54
|
- !ruby/object:Gem::Version
|
54
55
|
version: '0'
|
55
56
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
56
57
|
requirements:
|
57
|
-
- -
|
58
|
+
- - ">="
|
58
59
|
- !ruby/object:Gem::Version
|
59
60
|
version: '0'
|
60
61
|
requirements: []
|
61
|
-
rubyforge_project:
|
62
|
-
rubygems_version: 2.4.
|
63
|
-
signing_key:
|
62
|
+
rubyforge_project: "[none]"
|
63
|
+
rubygems_version: 2.4.3
|
64
|
+
signing_key:
|
64
65
|
specification_version: 4
|
65
66
|
summary: Produces statistical package syntax files for fixed-column data.
|
66
67
|
test_files:
|