Git Product home page Git Product logo

combine_files's Introduction

合并 json 数据

从多个文件中获取特定的数据,合并到一个文件中

require "json"

tests = []
Dir["source/**/**.side"].each do |file_path|
  test_case = JSON.parse(File.read(file_path))
  tests << test_case["tests"]
end

udesk_atar = JSON.parse(File.read("udesk_atar.side"))
udesk_atar["tests"] = tests.flatten.uniq

File.open("udesk_atar.side", "w") { |f| f.write udesk_atar.to_json }

puts `cat udesk_atar.side`.split(",")

问题出处

合并由多个人使用 selenium ide 录制的的测试用例

命令行脚本

where ruby
#!/usr/bin/env ruby

require "json"

tests = []
Dir["source/**/**.side"].each do |file_path|
  test_case = JSON.parse(File.read(file_path))
  tests << test_case["tests"]
end

udesk_atar = JSON.parse(File.read("udesk_atar.side"))
udesk_atar["tests"] = tests.flatten.uniq

File.open("udesk_atar.side", "w") { |f| f.write udesk_atar.to_json }
chmod +x udesk_atar

https://cobwwweb.com/add-console-to-ruby-project

https://cobwwweb.com/command-line-scripts-using-ruby

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.