origen 0.0.1 → 0.0.2
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 +4 -4
- data/bin/ctags +0 -0
- data/bin/origen +165 -1
- data/bin/rgen +2 -0
- data/config/application.rb +141 -0
- data/config/commands.rb +72 -0
- data/config/development.rb +7 -0
- data/config/environment.rb +0 -0
- data/config/rgen.policy +7 -0
- data/config/rubocop/easy.yml +620 -0
- data/config/rubocop/easy_disabled.yml +271 -0
- data/config/rubocop/easy_enabled.yml +731 -0
- data/config/rubocop/strict.yml +620 -0
- data/config/rubocop/strict_disabled.yml +247 -0
- data/config/rubocop/strict_enabled.yml +755 -0
- data/config/users.rb +20 -0
- data/config/version.rb +1 -1
- data/helpers/url.rb +68 -0
- data/lib/c99/doc_interface.rb +56 -0
- data/lib/c99/j750_interface.rb +85 -0
- data/lib/c99/nvm.rb +89 -0
- data/lib/c99/target/mock2.rb +1 -0
- data/lib/c99/target/subdir/mock3.rb +1 -0
- data/lib/option_parser/optparse.rb +12 -0
- data/lib/origen/acronyms.rb +60 -0
- data/lib/origen/application/command_dispatcher.rb +12 -0
- data/lib/origen/application/configuration.rb +206 -0
- data/lib/origen/application/configuration_manager.rb +78 -0
- data/lib/origen/application/deployer.rb +367 -0
- data/lib/origen/application/environment.rb +186 -0
- data/lib/origen/application/lsf.rb +145 -0
- data/lib/origen/application/lsf_manager.rb +657 -0
- data/lib/origen/application/plugins_manager.rb +280 -0
- data/lib/origen/application/release.rb +359 -0
- data/lib/origen/application/runner.rb +246 -0
- data/lib/origen/application/statistics.rb +191 -0
- data/lib/origen/application/target.rb +374 -0
- data/lib/origen/application/version_tracker.rb +59 -0
- data/lib/origen/application/workspace_manager.rb +151 -0
- data/lib/origen/application.rb +746 -0
- data/lib/origen/bugs/bug.rb +36 -0
- data/lib/origen/bugs.rb +45 -0
- data/lib/origen/callbacks.rb +35 -0
- data/lib/origen/chip_mode.rb +118 -0
- data/lib/origen/chip_package.rb +461 -0
- data/lib/origen/client.rb +87 -0
- data/lib/origen/code_generators/actions.rb +258 -0
- data/lib/origen/code_generators/base.rb +57 -0
- data/lib/origen/code_generators/bundler.rb +17 -0
- data/lib/origen/code_generators/gem_setup.rb +49 -0
- data/lib/origen/code_generators/rake.rb +13 -0
- data/lib/origen/code_generators/rspec.rb +12 -0
- data/lib/origen/code_generators/semver.rb +39 -0
- data/lib/origen/code_generators/timever.rb +37 -0
- data/lib/origen/code_generators.rb +111 -0
- data/lib/origen/commands/add.rb +12 -0
- data/lib/origen/commands/compile.rb +62 -0
- data/lib/origen/commands/ctags.rb +9 -0
- data/lib/origen/commands/dispatch.rb +22 -0
- data/lib/origen/commands/environment.rb +11 -0
- data/lib/origen/commands/fetch.rb +63 -0
- data/lib/origen/commands/generate.rb +130 -0
- data/lib/origen/commands/interactive.rb +73 -0
- data/lib/origen/commands/lint.rb +82 -0
- data/lib/origen/commands/lsf.rb +93 -0
- data/lib/origen/commands/merge.rb +55 -0
- data/lib/origen/commands/modifications.rb +12 -0
- data/lib/origen/commands/new.rb +113 -0
- data/lib/origen/commands/plugin.rb +105 -0
- data/lib/origen/commands/program.rb +70 -0
- data/lib/origen/commands/rc.rb +442 -0
- data/lib/origen/commands/save.rb +56 -0
- data/lib/origen/commands/target.rb +27 -0
- data/lib/origen/commands/time.rb +127 -0
- data/lib/origen/commands/version.rb +17 -0
- data/lib/origen/commands/web.rb +221 -0
- data/lib/origen/commands.rb +272 -0
- data/lib/origen/commands_global.rb +76 -0
- data/lib/origen/controller.rb +94 -0
- data/lib/origen/core_ext/array.rb +23 -0
- data/lib/origen/core_ext/bignum.rb +36 -0
- data/lib/origen/core_ext/enumerable.rb +76 -0
- data/lib/origen/core_ext/fixnum.rb +46 -0
- data/lib/origen/core_ext/hash.rb +52 -0
- data/lib/origen/core_ext/module.rb +14 -0
- data/lib/origen/core_ext/numeric.rb +126 -0
- data/lib/origen/core_ext/object.rb +13 -0
- data/lib/origen/core_ext/range.rb +7 -0
- data/lib/origen/core_ext/string.rb +124 -0
- data/lib/origen/core_ext.rb +10 -0
- data/lib/origen/database/key_value_store.rb +111 -0
- data/lib/origen/database/key_value_stores.rb +108 -0
- data/lib/origen/database.rb +6 -0
- data/lib/origen/encodings.rb +102 -0
- data/lib/origen/features/feature.rb +22 -0
- data/lib/origen/features.rb +104 -0
- data/lib/origen/file_handler.rb +429 -0
- data/lib/origen/generator/comparator.rb +56 -0
- data/lib/origen/generator/compiler.rb +277 -0
- data/lib/origen/generator/flow.rb +49 -0
- data/lib/origen/generator/job.rb +131 -0
- data/lib/origen/generator/pattern.rb +356 -0
- data/lib/origen/generator/pattern_finder.rb +155 -0
- data/lib/origen/generator/pattern_iterator.rb +55 -0
- data/lib/origen/generator/renderer.rb +113 -0
- data/lib/origen/generator/resources.rb +40 -0
- data/lib/origen/generator/stage.rb +89 -0
- data/lib/origen/generator.rb +85 -0
- data/lib/origen/global_methods.rb +205 -0
- data/lib/origen/import_manager.rb +596 -0
- data/lib/origen/location/base.rb +116 -0
- data/lib/origen/location/map.rb +83 -0
- data/lib/origen/location.rb +6 -0
- data/lib/origen/log.rb +217 -0
- data/lib/origen/logger_methods.rb +56 -0
- data/lib/origen/mode.rb +61 -0
- data/lib/origen/model.rb +267 -0
- data/lib/origen/model_initializer.rb +45 -0
- data/lib/origen/nvm/block_array.rb +72 -0
- data/lib/origen/nvm.rb +6 -0
- data/lib/origen/parameters/live.rb +22 -0
- data/lib/origen/parameters/missing.rb +28 -0
- data/lib/origen/parameters/set.rb +144 -0
- data/lib/origen/parameters.rb +107 -0
- data/lib/origen/pdm.rb +218 -0
- data/lib/origen/pins/function_proxy.rb +36 -0
- data/lib/origen/pins/ground_pin.rb +6 -0
- data/lib/origen/pins/pin.rb +860 -0
- data/lib/origen/pins/pin_bank.rb +349 -0
- data/lib/origen/pins/pin_clock.rb +124 -0
- data/lib/origen/pins/pin_collection.rb +492 -0
- data/lib/origen/pins/pin_common.rb +206 -0
- data/lib/origen/pins/port.rb +268 -0
- data/lib/origen/pins/power_pin.rb +30 -0
- data/lib/origen/pins.rb +696 -0
- data/lib/origen/registers/bit.rb +562 -0
- data/lib/origen/registers/bit_collection.rb +787 -0
- data/lib/origen/registers/container.rb +288 -0
- data/lib/origen/registers/domain.rb +16 -0
- data/lib/origen/registers/reg.rb +1406 -0
- data/lib/origen/registers/reg_collection.rb +24 -0
- data/lib/origen/registers.rb +652 -0
- data/lib/origen/regression_manager.rb +251 -0
- data/lib/origen/remote_manager.rb +340 -0
- data/lib/origen/revision_control/base.rb +257 -0
- data/lib/origen/revision_control/design_sync.rb +276 -0
- data/lib/origen/revision_control/git.rb +243 -0
- data/lib/origen/revision_control/subversion.rb +6 -0
- data/lib/origen/revision_control.rb +44 -0
- data/lib/origen/ruby_version_check.rb +131 -0
- data/lib/origen/site_config.rb +61 -0
- data/lib/origen/specs/checkers.rb +103 -0
- data/lib/origen/specs/creation_info.rb +17 -0
- data/lib/origen/specs/doc_resource.rb +91 -0
- data/lib/origen/specs/exhibit.rb +17 -0
- data/lib/origen/specs/mode_select.rb +16 -0
- data/lib/origen/specs/note.rb +17 -0
- data/lib/origen/specs/override.rb +21 -0
- data/lib/origen/specs/power_supply.rb +13 -0
- data/lib/origen/specs/spec.rb +226 -0
- data/lib/origen/specs/version_history.rb +14 -0
- data/lib/origen/specs.rb +552 -0
- data/lib/origen/sub_blocks.rb +298 -0
- data/lib/origen/tester/api.rb +277 -0
- data/lib/origen/tester/bdm/bdm.rb +25 -0
- data/lib/origen/tester/command_based_tester.rb +46 -0
- data/lib/origen/tester/doc/doc.rb +226 -0
- data/lib/origen/tester/doc/generator/flow.rb +71 -0
- data/lib/origen/tester/doc/generator/flow_line.rb +203 -0
- data/lib/origen/tester/doc/generator/test.rb +68 -0
- data/lib/origen/tester/doc/generator/test_group.rb +66 -0
- data/lib/origen/tester/doc/generator/tests.rb +47 -0
- data/lib/origen/tester/doc/generator.rb +126 -0
- data/lib/origen/tester/doc/model.rb +162 -0
- data/lib/origen/tester/generator/flow_control_api.rb +606 -0
- data/lib/origen/tester/generator/identity_map.rb +25 -0
- data/lib/origen/tester/generator/placeholder.rb +13 -0
- data/lib/origen/tester/generator/test_numberer.rb +25 -0
- data/lib/origen/tester/generator.rb +271 -0
- data/lib/origen/tester/interface.rb +154 -0
- data/lib/origen/tester/j750/files.rb +45 -0
- data/lib/origen/tester/j750/generator/flow.rb +123 -0
- data/lib/origen/tester/j750/generator/flow_line.rb +288 -0
- data/lib/origen/tester/j750/generator/patgroup.rb +111 -0
- data/lib/origen/tester/j750/generator/patgroups.rb +41 -0
- data/lib/origen/tester/j750/generator/patset.rb +111 -0
- data/lib/origen/tester/j750/generator/patsets.rb +41 -0
- data/lib/origen/tester/j750/generator/templates/flow.txt.erb +9 -0
- data/lib/origen/tester/j750/generator/templates/instances.txt.erb +16 -0
- data/lib/origen/tester/j750/generator/templates/patgroups.txt.erb +8 -0
- data/lib/origen/tester/j750/generator/templates/patsets.txt.erb +10 -0
- data/lib/origen/tester/j750/generator/test_instance.rb +846 -0
- data/lib/origen/tester/j750/generator/test_instance_group.rb +60 -0
- data/lib/origen/tester/j750/generator/test_instances.rb +182 -0
- data/lib/origen/tester/j750/generator.rb +203 -0
- data/lib/origen/tester/j750/j750.rb +845 -0
- data/lib/origen/tester/j750/j750_hpt.rb +35 -0
- data/lib/origen/tester/j750/parser/ac_spec.rb +11 -0
- data/lib/origen/tester/j750/parser/ac_specs.rb +0 -0
- data/lib/origen/tester/j750/parser/dc_spec.rb +36 -0
- data/lib/origen/tester/j750/parser/dc_specs.rb +50 -0
- data/lib/origen/tester/j750/parser/descriptions.rb +340 -0
- data/lib/origen/tester/j750/parser/flow.rb +111 -0
- data/lib/origen/tester/j750/parser/flow_line.rb +207 -0
- data/lib/origen/tester/j750/parser/flows.rb +23 -0
- data/lib/origen/tester/j750/parser/pattern_set.rb +94 -0
- data/lib/origen/tester/j750/parser/pattern_sets.rb +33 -0
- data/lib/origen/tester/j750/parser/test_instance.rb +322 -0
- data/lib/origen/tester/j750/parser/test_instances.rb +26 -0
- data/lib/origen/tester/j750/parser/timeset.rb +15 -0
- data/lib/origen/tester/j750/parser/timesets.rb +0 -0
- data/lib/origen/tester/j750/parser.rb +104 -0
- data/lib/origen/tester/jlink/jlink.rb +33 -0
- data/lib/origen/tester/parser/description_lookup.rb +64 -0
- data/lib/origen/tester/parser/searchable_array.rb +32 -0
- data/lib/origen/tester/parser/searchable_hash.rb +32 -0
- data/lib/origen/tester/parser.rb +24 -0
- data/lib/origen/tester/time.rb +338 -0
- data/lib/origen/tester/timing.rb +253 -0
- data/lib/origen/tester/ultraflex/files.rb +45 -0
- data/lib/origen/tester/ultraflex/generator/flow.rb +119 -0
- data/lib/origen/tester/ultraflex/generator/flow_line.rb +269 -0
- data/lib/origen/tester/ultraflex/generator/patgroup.rb +111 -0
- data/lib/origen/tester/ultraflex/generator/patgroups.rb +41 -0
- data/lib/origen/tester/ultraflex/generator/patset.rb +111 -0
- data/lib/origen/tester/ultraflex/generator/patsets.rb +41 -0
- data/lib/origen/tester/ultraflex/generator/templates/flow.txt.erb +9 -0
- data/lib/origen/tester/ultraflex/generator/templates/instances.txt.erb +16 -0
- data/lib/origen/tester/ultraflex/generator/templates/patgroups.txt.erb +8 -0
- data/lib/origen/tester/ultraflex/generator/templates/patsets.txt.erb +10 -0
- data/lib/origen/tester/ultraflex/generator/test_instance.rb +622 -0
- data/lib/origen/tester/ultraflex/generator/test_instance_group.rb +60 -0
- data/lib/origen/tester/ultraflex/generator/test_instances.rb +174 -0
- data/lib/origen/tester/ultraflex/generator.rb +200 -0
- data/lib/origen/tester/ultraflex/parser/ac_spec.rb +11 -0
- data/lib/origen/tester/ultraflex/parser/ac_specs.rb +0 -0
- data/lib/origen/tester/ultraflex/parser/dc_spec.rb +36 -0
- data/lib/origen/tester/ultraflex/parser/dc_specs.rb +50 -0
- data/lib/origen/tester/ultraflex/parser/descriptions.rb +342 -0
- data/lib/origen/tester/ultraflex/parser/flow.rb +111 -0
- data/lib/origen/tester/ultraflex/parser/flow_line.rb +207 -0
- data/lib/origen/tester/ultraflex/parser/flows.rb +23 -0
- data/lib/origen/tester/ultraflex/parser/pattern_set.rb +94 -0
- data/lib/origen/tester/ultraflex/parser/pattern_sets.rb +33 -0
- data/lib/origen/tester/ultraflex/parser/test_instance.rb +262 -0
- data/lib/origen/tester/ultraflex/parser/test_instances.rb +26 -0
- data/lib/origen/tester/ultraflex/parser/timeset.rb +15 -0
- data/lib/origen/tester/ultraflex/parser/timesets.rb +0 -0
- data/lib/origen/tester/ultraflex/parser.rb +104 -0
- data/lib/origen/tester/ultraflex/ultraflex.rb +759 -0
- data/lib/origen/tester/v93k/generator/flow.rb +63 -0
- data/lib/origen/tester/v93k/generator/flow_node/print.rb +10 -0
- data/lib/origen/tester/v93k/generator/flow_node.rb +17 -0
- data/lib/origen/tester/v93k/generator/pattern.rb +16 -0
- data/lib/origen/tester/v93k/generator/pattern_master.rb +54 -0
- data/lib/origen/tester/v93k/generator/templates/_test_method.txt.erb +6 -0
- data/lib/origen/tester/v93k/generator/templates/_test_suite.txt.erb +11 -0
- data/lib/origen/tester/v93k/generator/templates/template.flow.erb +121 -0
- data/lib/origen/tester/v93k/generator/templates/template.pmfl.erb +9 -0
- data/lib/origen/tester/v93k/generator/test_function.rb +103 -0
- data/lib/origen/tester/v93k/generator/test_functions.rb +79 -0
- data/lib/origen/tester/v93k/generator/test_method.rb +46 -0
- data/lib/origen/tester/v93k/generator/test_methods.rb +75 -0
- data/lib/origen/tester/v93k/generator/test_suite.rb +54 -0
- data/lib/origen/tester/v93k/generator/test_suites.rb +65 -0
- data/lib/origen/tester/v93k/generator.rb +80 -0
- data/lib/origen/tester/v93k/v93k.rb +420 -0
- data/lib/origen/tester/vector.rb +86 -0
- data/lib/origen/tester/vector_generator.rb +633 -0
- data/lib/origen/tester/vector_pipeline.rb +150 -0
- data/lib/origen/tester.rb +56 -0
- data/lib/origen/top_level.rb +134 -0
- data/lib/origen/users/ldap.rb +65 -0
- data/lib/origen/users/user.rb +149 -0
- data/lib/origen/users.rb +30 -0
- data/lib/origen/utility/block_args.rb +93 -0
- data/lib/origen/utility/csv_data.rb +110 -0
- data/lib/origen/utility/design_sync.rb +494 -0
- data/lib/origen/utility/diff.rb +158 -0
- data/lib/origen/utility/input_capture.rb +121 -0
- data/lib/origen/utility/mailer.rb +143 -0
- data/lib/origen/utility/s_record.rb +205 -0
- data/lib/origen/utility/time_and_date.rb +30 -0
- data/lib/origen/utility.rb +12 -0
- data/lib/origen/version_checker.rb +117 -0
- data/lib/origen/version_string.rb +356 -0
- data/lib/origen.rb +648 -0
- data/lib/tasks/gem.rake +27 -22
- data/origen_site_config.yml +36 -0
- data/source_setup +17 -0
- data/spec/format/rgen_formatter.rb +14 -0
- data/templates/api_doc/README.txt.erb +24 -0
- data/templates/code_generators/gemfile_app.rb +4 -0
- data/templates/code_generators/gemfile_plugin.rb +6 -0
- data/templates/code_generators/gemspec.rb +33 -0
- data/templates/code_generators/rakefile.rb +10 -0
- data/templates/code_generators/spec_helper.rb +49 -0
- data/templates/code_generators/version.rb +8 -0
- data/templates/code_generators/version_time.rb +3 -0
- data/templates/git/gitignore.erb +33 -0
- data/templates/j750/_vt_flow.txt.erb +8 -0
- data/templates/j750/_vt_instances.txt.erb +4 -0
- data/templates/j750/program_sheet.txt.erb +9 -0
- data/templates/nanoc/Rules +74 -0
- data/templates/nanoc/config.yaml +77 -0
- data/templates/nanoc/content/favicon.ico +0 -0
- data/templates/nanoc/layouts/bootstrap.html.erb +63 -0
- data/templates/nanoc/layouts/bootstrap3.html.erb +71 -0
- data/templates/nanoc/layouts/freescale.html.erb +79 -0
- data/templates/nanoc/lib/bootstrap_filter.rb +49 -0
- data/templates/nanoc/lib/codeblocks_filter.rb +41 -0
- data/templates/nanoc/lib/default.rb +2 -0
- data/templates/nanoc/lib/gzip_filter.rb +16 -0
- data/templates/nanoc/lib/haml_code_filter.rb +41 -0
- data/templates/nanoc/lib/helpers.rb +1 -0
- data/templates/nanoc/lib/search_filter.rb +62 -0
- data/templates/nanoc_dynamic/content/search.js.erb +92 -0
- data/templates/shared/web/_logo.html +10 -0
- data/templates/test/_inline_sub.txt.erb +2 -0
- data/templates/test/environment.txt.erb +1 -0
- data/templates/test/inline.txt.erb +11 -0
- data/templates/test/inspections.txt.erb +19 -0
- data/templates/test/set1/_sub1.txt.erb +12 -0
- data/templates/test/set1/_sub4.txt.erb +1 -0
- data/templates/test/set1/_sub5.txt.erb +1 -0
- data/templates/test/set1/main.txt.erb +53 -0
- data/templates/test/set1/sub_dir/_sub2.txt.erb +20 -0
- data/templates/test/set1/sub_dir/_sub3.txt.erb +12 -0
- data/templates/test/set1/sub_dir/main2.txt.erb +4 -0
- data/templates/test/set2/template_with_no_erb_1.txt +9 -0
- data/templates/test/set2/template_with_no_erb_2.txt +9 -0
- data/templates/test/set3/_layout.html.erb +4 -0
- data/templates/test/set3/content.html.erb +6 -0
- data/templates/time/filter.rb.erb +15 -0
- data/templates/time/rules.rb.erb +45 -0
- metadata +639 -5
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
module Origen
|
|
2
|
+
module Utility
|
|
3
|
+
# A class to handle the parsing of Comma Separated Value (CSV) input data
|
|
4
|
+
# Field names are indicated on first line of file, separated by comma
|
|
5
|
+
# Field values are indicated on all lines after first line of file, separated by comma
|
|
6
|
+
# All lines must have same number of fields names and values
|
|
7
|
+
class CSV
|
|
8
|
+
# Supply a path to the CSV file, this should be a relative path from the top
|
|
9
|
+
# level of your project workspace (Origen.root)
|
|
10
|
+
def initialize(file)
|
|
11
|
+
@file = file
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
# Parses the CSV file and returns an array of hashes where each hash represents
|
|
15
|
+
# one line of data. Hash keys obtained from first line of field names.
|
|
16
|
+
# Optionally if block supplied, it will return a single line from CSV file at a time
|
|
17
|
+
#
|
|
18
|
+
# ==== Example
|
|
19
|
+
# csv = CSV.new("/path/to/data.csv")
|
|
20
|
+
#
|
|
21
|
+
# Process data yourself
|
|
22
|
+
# data = csv.parse
|
|
23
|
+
# data.each do |dataline|
|
|
24
|
+
# dataline.keys.each do |key|
|
|
25
|
+
# print "Key: #{key}, Value: #{dataline[key]}\n"
|
|
26
|
+
# end
|
|
27
|
+
# end
|
|
28
|
+
#
|
|
29
|
+
# Let parse process data (not much diff)
|
|
30
|
+
# csv.parse do |dataline|
|
|
31
|
+
# dataline.keys.each do |key|
|
|
32
|
+
# print "Key: #{key}, Value: #{dataline[key]}\n"
|
|
33
|
+
# end
|
|
34
|
+
# end
|
|
35
|
+
def parse(options = {})
|
|
36
|
+
csv_data = extract_csv_data(options)
|
|
37
|
+
if block_given? # doesn't do much at this point
|
|
38
|
+
csv_data.each do |dataset|
|
|
39
|
+
yield dataset
|
|
40
|
+
end
|
|
41
|
+
else
|
|
42
|
+
csv_data
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# Parses the data and returns only the field values (keys)
|
|
47
|
+
# defined in the first line of the file
|
|
48
|
+
# opens file but only reads first line
|
|
49
|
+
# ==== Example
|
|
50
|
+
# csv = CSV.new("/path/to/data.csv")
|
|
51
|
+
# field_names = csv.fields
|
|
52
|
+
#
|
|
53
|
+
def fields
|
|
54
|
+
extract_csv_data(field_names_only: true)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# Number of fields in file
|
|
58
|
+
def num_fields
|
|
59
|
+
fields.length
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
# Checks fields to ensure they exist
|
|
63
|
+
# Input: array of fields expected
|
|
64
|
+
def valid_fields?(check_fields = [])
|
|
65
|
+
fields.eql?(check_fields)
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
private
|
|
69
|
+
|
|
70
|
+
# Returns an array containing all data from given CSV file
|
|
71
|
+
def extract_csv_data(options = {}) # :nodoc:
|
|
72
|
+
options = { field_names_only: false, # whether to obtain field names only
|
|
73
|
+
comment_char: '#', # ignore lines that start with comment character
|
|
74
|
+
}.merge(options)
|
|
75
|
+
|
|
76
|
+
field_names = []
|
|
77
|
+
field_values = []
|
|
78
|
+
result = []
|
|
79
|
+
line_no = 1
|
|
80
|
+
File.readlines("#{Origen.root}/#{@file}").each do |line|
|
|
81
|
+
# Clean up line
|
|
82
|
+
line.strip!
|
|
83
|
+
if line =~ /^#{options[:comment_char]}/
|
|
84
|
+
line_no = 1 # reset line counter
|
|
85
|
+
next # skip comment lines
|
|
86
|
+
end
|
|
87
|
+
if line_no == 1 # Field names
|
|
88
|
+
field_names = line.split(',')
|
|
89
|
+
else # Field values
|
|
90
|
+
field_values = line.split(',')
|
|
91
|
+
if field_names.length != field_values.length
|
|
92
|
+
abort "ERROR! Invalid number of fields (#{field_values.length}) in CVS file on line # #{line_no}. Should be #{field_names.length}.\n"
|
|
93
|
+
end
|
|
94
|
+
temp_data = {}
|
|
95
|
+
field_names.each_index do |index|
|
|
96
|
+
temp_data[field_names[index]] = field_values[index]
|
|
97
|
+
end
|
|
98
|
+
result.push(temp_data)
|
|
99
|
+
end
|
|
100
|
+
if options[:field_names_only]
|
|
101
|
+
result = field_names
|
|
102
|
+
break # abort loop
|
|
103
|
+
end
|
|
104
|
+
line_no += 1
|
|
105
|
+
end
|
|
106
|
+
result
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
end
|
|
@@ -0,0 +1,494 @@
|
|
|
1
|
+
module Origen
|
|
2
|
+
module Utility
|
|
3
|
+
# Ruby API to interface with Design Sync
|
|
4
|
+
class DesignSync
|
|
5
|
+
# Tag the target which is an absolute path to a file or directory.
|
|
6
|
+
#
|
|
7
|
+
# ==== Options
|
|
8
|
+
#
|
|
9
|
+
# * :rec # Recursive, false by default
|
|
10
|
+
# * :delete # Delete the given tag from the target, false by default
|
|
11
|
+
# * :replace # Replace any existing version of the given tag, false by default
|
|
12
|
+
# * :exclude # Supply filenames to exclude or wildcard, e.g. "*.lst,*.S19"
|
|
13
|
+
#
|
|
14
|
+
# ==== Example
|
|
15
|
+
#
|
|
16
|
+
# tag(Origen.root, "my_release_001", :rec => true)
|
|
17
|
+
# tag("#{Origen.root}/top/top_block.rb", "my_release_001")
|
|
18
|
+
def tag(target, tag, options = {})
|
|
19
|
+
options = { rec: false, # Set true to tag recursively
|
|
20
|
+
delete: false,
|
|
21
|
+
replace: false
|
|
22
|
+
}.merge(options)
|
|
23
|
+
cmd = "dssc tag #{tag} #{exclude(options)} #{options[:replace] ? '-replace' : ''} #{rec(options)} #{options[:delete] ? '-delete' : ''} #{target}"
|
|
24
|
+
if options[:debug]
|
|
25
|
+
puts '**** DesignSync Debug ****'
|
|
26
|
+
puts cmd
|
|
27
|
+
else
|
|
28
|
+
system(cmd)
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# Import a file to the local workspace from another vault, where the vault
|
|
33
|
+
# argument must include the full path to the requested file. You can optionally
|
|
34
|
+
# supply a destination for where you want the file to end up, if no destination
|
|
35
|
+
# is supplied the file will end up in the PWD.
|
|
36
|
+
#
|
|
37
|
+
# ==== Example
|
|
38
|
+
#
|
|
39
|
+
# # Import this file and save it in Origen.root
|
|
40
|
+
# file = "design_sync.rb"
|
|
41
|
+
# vault = "sync://sync-15088:15088/Projects/common_tester_blocks/origen/lib/sys"
|
|
42
|
+
# version = "v0.1.0" # Version can be any valid DS identifier, e.g. a version number or tag
|
|
43
|
+
#
|
|
44
|
+
# import(file, vault, version, Origen.root)
|
|
45
|
+
def import(file, vault, version, destination = false)
|
|
46
|
+
puts 'Importing from DesignSync...'
|
|
47
|
+
puts "#{vault}/#{file} #{version}"
|
|
48
|
+
unless sys("dssc import -version #{version} -force #{vault} #{file}")[0] =~ /Success/
|
|
49
|
+
fail "Error importing #{file} from Design Sync"
|
|
50
|
+
end
|
|
51
|
+
if Origen.running_on_windows?
|
|
52
|
+
sys("move /Y #{file} #{destination}/.") if destination
|
|
53
|
+
else
|
|
54
|
+
sys("mv -f #{file} #{destination}/.") if destination
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# Check out a specific target which should be an absolute path to the target file, or
|
|
59
|
+
# wildcard expression.
|
|
60
|
+
#
|
|
61
|
+
# ==== Options:
|
|
62
|
+
#
|
|
63
|
+
# * :rec # Do a recursive checkout, false by default
|
|
64
|
+
# * :lock # Check out with a lock (overrides get option due to DesignSync get/lock incompatibility)
|
|
65
|
+
# * :version # Specific tag or version number, will get latest by default
|
|
66
|
+
# * :force # Force check out, false by default
|
|
67
|
+
# * :verbose # Display output to terminal, false by default
|
|
68
|
+
# * :get # Fetch locally editable copies, true by default (unless lock is set)
|
|
69
|
+
#
|
|
70
|
+
# ==== Example
|
|
71
|
+
#
|
|
72
|
+
# # Checkout everything in Origen.root
|
|
73
|
+
# check_out("#{Origen.root}/*", :rec => true)
|
|
74
|
+
def check_out(target, options = {})
|
|
75
|
+
options = {
|
|
76
|
+
get: true
|
|
77
|
+
}.merge(options)
|
|
78
|
+
cmd = "dssc co #{rec(options)} #{get(options)} #{loc(options)} #{ver(options)} #{force(options)} -nocomment #{target}"
|
|
79
|
+
launch(cmd, options[:verbose])
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
# Check in a specific target which should be an absolute path to the target file, or
|
|
83
|
+
# wildcard expression.
|
|
84
|
+
#
|
|
85
|
+
# ==== Options:
|
|
86
|
+
#
|
|
87
|
+
# * :rec # Do a recursive check-in, false by default
|
|
88
|
+
# * :comment # Supply a comment to go with the check-in
|
|
89
|
+
# * :new # Allow check in of new files (i.e. add the file to revision control)
|
|
90
|
+
# * :verbose # Display output to terminal, false by default
|
|
91
|
+
# * :skip # Allow check in to skip over a newer version of the file if it exists
|
|
92
|
+
# * :keep # Keep editable copy of the files post check-in, false by default
|
|
93
|
+
#
|
|
94
|
+
# ==== Example
|
|
95
|
+
#
|
|
96
|
+
# # Check-in everything in Origen.root
|
|
97
|
+
# check_in("#{Origen.root}/*", :rec => true, :com => "Periodic checkin, still in development")
|
|
98
|
+
def check_in(target, options = {})
|
|
99
|
+
options = {
|
|
100
|
+
keep: true
|
|
101
|
+
}.merge(options)
|
|
102
|
+
# FYI: for debug use '-dryrun' option to 'dssc ci' command
|
|
103
|
+
cmd = "dssc ci #{keep(options)} #{rec(options)} #{new(options)} #{com(options)} #{branch(options)} #{options[:skip] ? '-skip' : ''} #{target}"
|
|
104
|
+
launch(cmd, options[:verbose])
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
# Check in the contents of the given directory to a remote vault location, that is a vault location
|
|
108
|
+
# that is not associated with the workspace that the given files are in.
|
|
109
|
+
#
|
|
110
|
+
# Anything found in the given directory will be checked in, even files which are not currently under
|
|
111
|
+
# revision control.
|
|
112
|
+
#
|
|
113
|
+
# No attempt will be made to merge the current vault contents with the local data, the local data
|
|
114
|
+
# will always be checked in as lastest.
|
|
115
|
+
#
|
|
116
|
+
# A tag can be optionally supplied and if present will be applied to the files post check in.
|
|
117
|
+
#
|
|
118
|
+
# @example
|
|
119
|
+
#
|
|
120
|
+
# ds.remote_check_in("#{Origen.root}/output/j750", :vault => "sync://sync-15088:15088/Projects/common_tester_blocks/origen_training/j750", :tag => Origen.app.version)
|
|
121
|
+
def remote_check_in(dir, options = {})
|
|
122
|
+
Origen.deprecate 'Use Origen::RevisionControl::DesignSync.remote_check_in instead'
|
|
123
|
+
options = {
|
|
124
|
+
verbose: true,
|
|
125
|
+
rec: true,
|
|
126
|
+
keep: true,
|
|
127
|
+
new: true,
|
|
128
|
+
skip: true,
|
|
129
|
+
replace: true
|
|
130
|
+
}.merge(options)
|
|
131
|
+
|
|
132
|
+
dir = Pathname.new(dir)
|
|
133
|
+
fail "Directory does not exist: #{dir}" unless dir.exist?
|
|
134
|
+
fail "Only directories are supported by remote_check_in, this is not a directory: #{dir}" unless dir.directory?
|
|
135
|
+
fail 'No vault option supplied to remote_check_in!' unless options[:vault]
|
|
136
|
+
scratch = Pathname.new("#{Origen.app.workspace_manager.imports_directory}/design_sync/scratch")
|
|
137
|
+
FileUtils.rm_rf(scratch) if scratch.exist?
|
|
138
|
+
FileUtils.mkdir_p(scratch)
|
|
139
|
+
FileUtils.cp_r("#{dir}/.", scratch)
|
|
140
|
+
remove_dot_syncs!(scratch)
|
|
141
|
+
launch("dssc setvault #{options[:vault]} #{scratch}", options[:verbose])
|
|
142
|
+
check_in(scratch, options)
|
|
143
|
+
tag(scratch, options[:tag], options) if options[:tag]
|
|
144
|
+
FileUtils.rm_rf(scratch)
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
# Recursively remove all .SYNC directories from the given directory
|
|
148
|
+
def remove_dot_syncs!(dir, _options = {})
|
|
149
|
+
Origen.deprecate 'Use Origen::RevisionControl::DesignSync.remove_dot_syncs! instead'
|
|
150
|
+
dir = Pathname.new(dir)
|
|
151
|
+
fail "Directory does not exist: #{dir}" unless dir.exist?
|
|
152
|
+
fail "Only directories are supported by remove_dot_syncs, this is not a directory: #{dir}" unless dir.directory?
|
|
153
|
+
Dir.glob("#{dir}/**/.SYNC").sort.each do |dot_sync|
|
|
154
|
+
FileUtils.rm_rf(dot_sync)
|
|
155
|
+
end
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
# Cancel a checkout of a specific target which should be an absolute path to the target file,
|
|
159
|
+
# or wildcard expression
|
|
160
|
+
#
|
|
161
|
+
# ==== Options:
|
|
162
|
+
#
|
|
163
|
+
# * :rec # Do a recursive cancel, false by default
|
|
164
|
+
# * :force # Force cancel (overwrite local edits), false by default
|
|
165
|
+
# * :exclude # Supply filenames to exclude or wildcard, e.g. "*.lst,*.S19"
|
|
166
|
+
# * :keep # Keep editable copy of the files post cancel, false by default
|
|
167
|
+
#
|
|
168
|
+
# ==== Example
|
|
169
|
+
#
|
|
170
|
+
# # Cancel every checkout in Origen.root
|
|
171
|
+
# cancel("#{Origen.root}/*", :rec => true, :force => true)
|
|
172
|
+
def cancel(_target, options = {})
|
|
173
|
+
# Note "-verbose" is not a valid option for dssc cancel
|
|
174
|
+
cmd = "dssc cancel #{keep(options)} #{rec(options)} #{force(options)} #{exclude(options)}"
|
|
175
|
+
launch(cmd)
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
# Almost the same as DesignSync#check_out but accepts some different options.
|
|
179
|
+
#
|
|
180
|
+
# ==== Options:
|
|
181
|
+
#
|
|
182
|
+
# * :rec # Do a recursive populate, false by default
|
|
183
|
+
# * :version # Specific tag or version number, will get latest by default
|
|
184
|
+
# * :force # Force populate (overwrite local edits), false by default
|
|
185
|
+
# * :unify # Unify the workspace (remove any retired files you currently have checked out)
|
|
186
|
+
# * :exclude # Supply filenames to exclude or wildcard, e.g. "*.lst,*.S19"
|
|
187
|
+
# * :verbose # Display output to terminal, false by default
|
|
188
|
+
# * :get # Fetch locally editable copies, true by default
|
|
189
|
+
# * :merge # Merge local edits into latest files, false by default
|
|
190
|
+
def populate(target, options = {})
|
|
191
|
+
options = { unify: true,
|
|
192
|
+
incremental: false,
|
|
193
|
+
replace: false,
|
|
194
|
+
get: true,
|
|
195
|
+
merge: false
|
|
196
|
+
}.merge(options)
|
|
197
|
+
inc = options[:incremental] ? '-inc' : ''
|
|
198
|
+
replace = options[:replace] ? '-replace' : ''
|
|
199
|
+
cmd = "dssc pop #{inc} #{replace} #{rec(options)} #{force(options)} #{merge(options)} #{get(options)} #{ver(options)} #{uni(options)} #{exclude(options)} #{target}"
|
|
200
|
+
successful = launch(cmd, options[:verbose])
|
|
201
|
+
unless successful
|
|
202
|
+
fail "Something went wrong when populating #{target} from DesignSync!"
|
|
203
|
+
end
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
# Check if the supplied directory has any modified objects, will reflect the result from the
|
|
207
|
+
# last call unless :refresh => true. Returns true or false.
|
|
208
|
+
# See DesignSync#modified_objects for available options.
|
|
209
|
+
#
|
|
210
|
+
# ==== Example
|
|
211
|
+
#
|
|
212
|
+
# modified_objects? # Takes a while to run while the workspace is queried
|
|
213
|
+
# modified_objects? # Runs very quickly and returns the cached answer
|
|
214
|
+
# modified_objects?(:refresh => true) # Takes a while to run while the workspace is queried
|
|
215
|
+
def modified_objects?(*args)
|
|
216
|
+
modified_objects(*args).size > 0
|
|
217
|
+
end
|
|
218
|
+
|
|
219
|
+
# Returns the selector for the given object, which should be an absolute path to a
|
|
220
|
+
# file or directory
|
|
221
|
+
def selector(target)
|
|
222
|
+
sys("dssc url selector #{target}")[0]
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
# Returns an array of paths to modified files, caches result for performance, set :refresh => true
|
|
226
|
+
# to clear cache. The target should be an absolute path to the directory you want to query.
|
|
227
|
+
#
|
|
228
|
+
# ==== Options:
|
|
229
|
+
#
|
|
230
|
+
# * :rec # Do a recursive search, false by default
|
|
231
|
+
# * :exclude # Supply filenames to exclude or wildcard, e.g. "*.lst,*.S19"
|
|
232
|
+
# * :refresh # Force a new search, false by default
|
|
233
|
+
#
|
|
234
|
+
# ==== Example
|
|
235
|
+
#
|
|
236
|
+
# # Get all modified files in my project workspace
|
|
237
|
+
# files = modified_objects(Origen.root, :rec => true)
|
|
238
|
+
#
|
|
239
|
+
# NOTE: -unmanaged and -managed are mutually exclusive, specifying both does neither!
|
|
240
|
+
# -unmanaged : show only objects not under revision control
|
|
241
|
+
# -managed : show only objects under revision control
|
|
242
|
+
# -modified : show locally modified files in workspace (includes unmanaged objects)
|
|
243
|
+
# -changed : shows not up-to-date files. Includes both locally modified and newer verions in vault.
|
|
244
|
+
# Overrides -modified.
|
|
245
|
+
|
|
246
|
+
def modified_objects(target, options = {})
|
|
247
|
+
options = {
|
|
248
|
+
managed: true, # by default handle managed (to permit for unmanaged case)
|
|
249
|
+
remote: false, # includes files possibly modified by others in repository
|
|
250
|
+
}.merge(options)
|
|
251
|
+
# The result of this method is cached for future calls (method called twice actually)
|
|
252
|
+
@objects = nil if options[:refresh]
|
|
253
|
+
@needs_update_objects = nil if options[:refresh]
|
|
254
|
+
|
|
255
|
+
if options[:remote]
|
|
256
|
+
return @needs_update_objects if @needs_update_objects
|
|
257
|
+
else
|
|
258
|
+
return @objects if @objects
|
|
259
|
+
end
|
|
260
|
+
|
|
261
|
+
# Since DesignSync does not supply an option to only list files that need update (!), have to run with
|
|
262
|
+
# -changed option then again without and difference the 2 arrays!
|
|
263
|
+
if options[:remote]
|
|
264
|
+
all_objects = sys("dssc ls #{rec(options)} #{exclude(options)} #{managed(options)} #{dssc_path(options)} -report N -modified #{unmanaged(options)} -changed -format text #{target}").reject do |item|
|
|
265
|
+
# removes extraneous lines
|
|
266
|
+
item =~ /^(Name|Directory|---)/
|
|
267
|
+
end
|
|
268
|
+
all_objects.map! do |object|
|
|
269
|
+
object.strip! # Strip off any whitespace from all objects
|
|
270
|
+
object.sub!(/^#{full_path_prefix}/, '')
|
|
271
|
+
object.sub('|', ':')
|
|
272
|
+
end
|
|
273
|
+
end
|
|
274
|
+
|
|
275
|
+
@objects = sys("dssc ls #{rec(options)} #{exclude(options)} #{managed(options)} #{dssc_path(options)} -report N -modified #{unmanaged(options)} -format text #{target}").reject do |item|
|
|
276
|
+
# removes extraneous lines
|
|
277
|
+
item =~ /^(Name|Directory|---)/
|
|
278
|
+
end
|
|
279
|
+
@objects.map! do |object|
|
|
280
|
+
object.strip! # Strip off any whitespace from all objects
|
|
281
|
+
object.sub!(/^#{full_path_prefix}/, '')
|
|
282
|
+
object.sub('|', ':')
|
|
283
|
+
end
|
|
284
|
+
|
|
285
|
+
# Now difference the lists if remote desired
|
|
286
|
+
if options[:remote]
|
|
287
|
+
return @needs_update_objects = all_objects - @objects
|
|
288
|
+
else
|
|
289
|
+
return @objects
|
|
290
|
+
end
|
|
291
|
+
end
|
|
292
|
+
|
|
293
|
+
def full_path_prefix
|
|
294
|
+
@full_path_prefix ||= begin
|
|
295
|
+
if Origen.running_on_windows?
|
|
296
|
+
'file:///'
|
|
297
|
+
else
|
|
298
|
+
'file://'
|
|
299
|
+
end
|
|
300
|
+
end
|
|
301
|
+
end
|
|
302
|
+
|
|
303
|
+
# Check if the supplied directory has any changed objects vs the previous tag
|
|
304
|
+
# See DesignSync#changed_objects for available options.
|
|
305
|
+
def changed_objects?(*args)
|
|
306
|
+
objects = changed_objects(*args)
|
|
307
|
+
objects[:added].size > 0 || objects[:removed].size > 0 || objects[:changed].size > 0
|
|
308
|
+
end
|
|
309
|
+
|
|
310
|
+
# Returns a hash containing files that have changed vs. the previous tag, this is
|
|
311
|
+
# organized as follows:
|
|
312
|
+
#
|
|
313
|
+
# {
|
|
314
|
+
# :added => [], # Paths to files that have been added since the previous tag
|
|
315
|
+
# :removed => [], # Paths to files that have been removed since the previous tag
|
|
316
|
+
# :changed => [], # Paths to files that have changed since the previous tag
|
|
317
|
+
# }
|
|
318
|
+
def changed_objects(target, previous_tag, options = {})
|
|
319
|
+
options = {
|
|
320
|
+
}.merge(options)
|
|
321
|
+
# We need to parse the following data from the output, ignore everything else
|
|
322
|
+
# which will mostly refer to un-managed files.
|
|
323
|
+
#
|
|
324
|
+
# Added since previous version...
|
|
325
|
+
# 1.12 First only source_setup
|
|
326
|
+
# Removed since previous version...
|
|
327
|
+
# 1.13 Second only lib/history
|
|
328
|
+
# Modified since previous version...
|
|
329
|
+
# 1.32 1.31 Different versions lib/origen/application.rb
|
|
330
|
+
# Modified since previous version including a local edit...
|
|
331
|
+
# 1.7 (Locally Modified) 1.7 Different states lib/origen/commands/rc.rb
|
|
332
|
+
objects = {
|
|
333
|
+
added: [], removed: [], changed: []
|
|
334
|
+
}
|
|
335
|
+
sys("dssc compare -rec -path -report silent -selector #{previous_tag} #{target}").each do |line|
|
|
336
|
+
unless line =~ /Unmanaged/
|
|
337
|
+
# http://www.rubular.com/r/GoNYB75upB
|
|
338
|
+
if line =~ /\s*(\S+)\s+First only\s+(\S+)\s*/
|
|
339
|
+
objects[:added] << Regexp.last_match[2]
|
|
340
|
+
# http://www.rubular.com/r/Xvh32Lm4hS
|
|
341
|
+
elsif line =~ /\s*(\S+)\s+Second only\s+(\S+)\s*/
|
|
342
|
+
objects[:removed] << Regexp.last_match[2]
|
|
343
|
+
# http://www.rubular.com/r/tvTHod9Mye
|
|
344
|
+
elsif line =~ /\s*\S+\s+(\(Locally Modified\))?\s*(\S+)\s+Different (versions|states)\s+(\S+)\s*/
|
|
345
|
+
objects[:changed] << Regexp.last_match[4]
|
|
346
|
+
end
|
|
347
|
+
end
|
|
348
|
+
end
|
|
349
|
+
objects
|
|
350
|
+
end
|
|
351
|
+
|
|
352
|
+
def diff_cmd(options = {})
|
|
353
|
+
if options[:version]
|
|
354
|
+
"dssc diff -gui -ver #{options[:version]}"
|
|
355
|
+
else
|
|
356
|
+
'dssc diff -gui'
|
|
357
|
+
end
|
|
358
|
+
end
|
|
359
|
+
|
|
360
|
+
# Returns true if the given file is known to Design Sync
|
|
361
|
+
#
|
|
362
|
+
# ==== Example
|
|
363
|
+
#
|
|
364
|
+
# managed_by_design_sync?("#{Origen.root}/config/application.rb")
|
|
365
|
+
def managed_by_design_sync?(path, _options = {})
|
|
366
|
+
res = sys "dssc url vault #{path}"
|
|
367
|
+
if res.empty?
|
|
368
|
+
false
|
|
369
|
+
else
|
|
370
|
+
if res.first =~ /^file:/ || res.first =~ /There is no object with that name/
|
|
371
|
+
false
|
|
372
|
+
else
|
|
373
|
+
true
|
|
374
|
+
end
|
|
375
|
+
end
|
|
376
|
+
end
|
|
377
|
+
|
|
378
|
+
# Will recursively move back up the directory tree from the given
|
|
379
|
+
# directory and return the first one that is not part of a Design Sync
|
|
380
|
+
# workspace.
|
|
381
|
+
#
|
|
382
|
+
# The supplied pathname should be an absolute Pathname instance.
|
|
383
|
+
def container_directory(pathname)
|
|
384
|
+
if managed_by_design_sync?(pathname)
|
|
385
|
+
container_directory(pathname.parent)
|
|
386
|
+
else
|
|
387
|
+
pathname
|
|
388
|
+
end
|
|
389
|
+
end
|
|
390
|
+
|
|
391
|
+
# Initializes the given directory with the given vault reference
|
|
392
|
+
def initialize_dir(dir, vault)
|
|
393
|
+
Dir.chdir dir do
|
|
394
|
+
sys "dssc setvault #{vault} ."
|
|
395
|
+
end
|
|
396
|
+
end
|
|
397
|
+
|
|
398
|
+
# Returns the vault reference to give local file or directory
|
|
399
|
+
def vault(file_or_dir)
|
|
400
|
+
(sys "dssc url vault #{file_or_dir}").first
|
|
401
|
+
end
|
|
402
|
+
|
|
403
|
+
private
|
|
404
|
+
|
|
405
|
+
# This will return true if the command has run successfully without errors
|
|
406
|
+
def launch(cmd, verbose = false) # :nodoc:
|
|
407
|
+
if verbose
|
|
408
|
+
$stdout.sync = true
|
|
409
|
+
puts cmd
|
|
410
|
+
system cmd
|
|
411
|
+
else
|
|
412
|
+
`#{cmd}`
|
|
413
|
+
$CHILD_STATUS.success?
|
|
414
|
+
end
|
|
415
|
+
end
|
|
416
|
+
|
|
417
|
+
# Make a sys call, returning the output in an array
|
|
418
|
+
def sys(call) # :nodoc:
|
|
419
|
+
output = `#{call}`.split("\n")
|
|
420
|
+
# Screen out some common redundant DS output before handing back
|
|
421
|
+
output.reject do |item|
|
|
422
|
+
item =~ /^Logging/ || item == '' ||
|
|
423
|
+
item =~ /V(\d+\.\d+-\d+|\d.\d+)/ # Screen out something like "V5.1-1205" or "V6R2010"
|
|
424
|
+
end
|
|
425
|
+
end
|
|
426
|
+
|
|
427
|
+
def exclude(options) # :nodoc:
|
|
428
|
+
options[:exclude] ? "-exclude '#{options[:exclude]}'" : ''
|
|
429
|
+
end
|
|
430
|
+
|
|
431
|
+
def rec(options) # :nodoc:
|
|
432
|
+
options[:rec] ? '-rec' : ''
|
|
433
|
+
end
|
|
434
|
+
|
|
435
|
+
def force(options) # :nodoc:
|
|
436
|
+
options[:force] ? '-force' : ''
|
|
437
|
+
end
|
|
438
|
+
|
|
439
|
+
def uni(options) # :nodoc:
|
|
440
|
+
(options[:uni] || options[:unify]) ? '-uni' : ''
|
|
441
|
+
end
|
|
442
|
+
|
|
443
|
+
def get(options) # :nodoc:
|
|
444
|
+
# lock option overrides get option
|
|
445
|
+
# due to incompatibility in DesignSync
|
|
446
|
+
if !(options[:lock] || options[:loc])
|
|
447
|
+
options[:get] ? '-get' : ''
|
|
448
|
+
else
|
|
449
|
+
''
|
|
450
|
+
end
|
|
451
|
+
end
|
|
452
|
+
|
|
453
|
+
def loc(options) # :nodoc:
|
|
454
|
+
(options[:lock] || options[:loc]) ? '-loc' : '-get'
|
|
455
|
+
end
|
|
456
|
+
|
|
457
|
+
def keep(options) # :nodoc:
|
|
458
|
+
(options[:keep]) ? '-keep' : ''
|
|
459
|
+
end
|
|
460
|
+
|
|
461
|
+
def merge(options) # :nodoc:
|
|
462
|
+
(options[:merge]) ? '-merge' : ''
|
|
463
|
+
end
|
|
464
|
+
|
|
465
|
+
def ver(options) # :nodoc:
|
|
466
|
+
options[:version] ? "-ver #{options[:version]}" : ''
|
|
467
|
+
end
|
|
468
|
+
|
|
469
|
+
def branch(options) # :nodoc:
|
|
470
|
+
options[:branch] ? "-branch #{options[:branch]}" : ''
|
|
471
|
+
end
|
|
472
|
+
|
|
473
|
+
def new(options) # :nodoc:
|
|
474
|
+
options[:new] ? '-new' : ''
|
|
475
|
+
end
|
|
476
|
+
|
|
477
|
+
def com(options) # :nodoc:
|
|
478
|
+
options[:comment] ? "-com \"#{options[:comment]}\"" : '-comment /null'
|
|
479
|
+
end
|
|
480
|
+
|
|
481
|
+
def unmanaged(options) # :nodoc:
|
|
482
|
+
options[:unmanaged] ? '-unmanaged' : ''
|
|
483
|
+
end
|
|
484
|
+
|
|
485
|
+
def managed(options) # :nodoc:
|
|
486
|
+
options[:managed] ? '-managed' : ''
|
|
487
|
+
end
|
|
488
|
+
|
|
489
|
+
def dssc_path(options) # :nodoc:
|
|
490
|
+
options[:fullpath] ? '-fullpath' : '-path'
|
|
491
|
+
end
|
|
492
|
+
end
|
|
493
|
+
end
|
|
494
|
+
end
|