Open stevekinney opened 10 years ago
Looks like y'all are doing good work in standards_organization!
To ease the transition between the text file and the standards structure, here is a snippet to parse that file and write it into the standards:
# a tree structure to make it easier to parse the text file TabTree = Struct.new :value, :parent, :children do def initialize(value, parent, children=[]) super end def root? !parent end def leaf? children.empty? end def add_child(value) if value.start_with? "\t" child = children.last || raise("Check indentation for #{value.inspect}") child.add_child value[1..-1] else children << TabTree.new(value, self) end end def ancestry return [] if root? || parent.root? [parent, *parent.ancestry] end end # load lib root_dir = '/Users/josh/code/jsl/standard' $LOAD_PATH.unshift "#{root_dir}/lib" require 'pp' require 'standards' # translate indentation to tree structure root = TabTree.new nil, nil File.foreach("#{root_dir}/standards_organization") .reject { |line| line == "\n" } .each_with_object(root) .each { |line, root| root.add_child line.chomp } # translate tree structure to standards structure def add_standards(structure, tree) if tree.leaf? && !tree.root? structure.add_standard standard: tree.value, tags: tree.ancestry.map(&:value) end tree.children.each { |child| add_standards structure, child } end structure = Standards::Structure.new add_standards structure, root pp structure.to_hash # print out so # overwrite standards.json with new standards Standards::Persistence.dump "#{root_dir}/standards.json", structure # >> {:standards=> # >> [{:id=>1, # >> :standard=>"Run a Ruby program from the command line.", # >> :tags=>["Basics", "Ruby", "Languages"]}, # >> {:id=>2, # >> :standard=>"Assign an object to a variable.", # >> :tags=>["Basics", "Ruby", "Languages"]}, # >> {:id=>3, # >> :standard=>"Call a method on an object.", # >> :tags=>["Basics", "Ruby", "Languages"]}, # >> {:id=>4, # >> :standard=>"Demonstrate that Ruby's primitives are actually objects.", # >> :tags=>["Basics", "Ruby", "Languages"]}, # >> {:id=>5, # >> :standard=>"Open an interactive prompt using Pry.", # >> :tags=>["Basics", "Ruby", "Languages"]}, # >> {:id=>6, # >> :standard=>"Load a file into Pry.", # >> :tags=>["Basics", "Ruby", "Languages"]}, # >> {:id=>7, # >> :standard=> # >> "Demonstrate that all methods return a value either implicitly or explicitly.", # >> :tags=>["Basics", "Ruby", "Languages"]}, # >> {:id=>8, # >> :standard=> # >> "Demonstrate that Ruby expressions are evaluated from right to left. ", # >> :tags=>["Basics", "Ruby", "Languages"]}, # >> {:id=>9, # >> :standard=>"Appropriately name variables in Ruby.", # >> :tags=>["Basics", "Ruby", "Languages"]}, # >> {:id=>10, # >> :standard=> # >> "Explain and demonstrate the difference between assignment (=) and equality (==).", # >> :tags=>["Basics", "Ruby", "Languages"]}, # >> {:id=>11, # >> :standard=>"Explain the difference between nil, 0, [], and \"\". ", # >> :tags=>["Basics", "Ruby", "Languages"]}, # >> {:id=>12, # >> :standard=>"Define truthy and falsy, and identify falsy values. ", # >> :tags=>["Basics", "Ruby", "Languages"]}, # >> {:id=>13, # >> :standard=>"Access a substring from a string using a range.", # >> :tags=>["Strings", "Basics", "Ruby", "Languages"]}, # >> {:id=>14, # >> :standard=>"Interpolate Ruby expressions into strings.", # >> :tags=>["Strings", "Basics", "Ruby", "Languages"]}, # >> {:id=>15, # >> :standard=> # >> "Demonstrate the difference between single- and double-quotes in Ruby.", # >> :tags=>["Strings", "Basics", "Ruby", "Languages"]}, # >> {:id=>16, # >> :standard=> # >> "Demonstrate the correct use of positive and negative index numbers in both strings and arrays. ", # >> :tags=>["Strings", "Basics", "Ruby", "Languages"]}, # >> {:id=>17, # >> :standard=>"Explain the difference between symbols and strings in Ruby.", # >> :tags=>["Strings", "Basics", "Ruby", "Languages"]}, # >> {:id=>18, # >> :standard=>"Explain how a block works.", # >> :tags=>["Blocks", "Basics", "Ruby", "Languages"]}, # >> {:id=>19, # >> :standard=>"Specify and use block parameters. ", # >> :tags=>["Blocks", "Basics", "Ruby", "Languages"]}, # >> {:id=>20, # >> :standard=>"Use an array to hold a collection of objects. ", # >> :tags=>["Arrays", "Basics", "Ruby", "Languages"]}, # >> {:id=>21, # >> :standard=> # >> "Access elements of an array using #first, #last, or index numbers inside of [].", # >> :tags=>["Arrays", "Basics", "Ruby", "Languages"]}, # >> {:id=>22, # >> :standard=>"Add elements to an array using #push or <<.", # >> :tags=>["Arrays", "Basics", "Ruby", "Languages"]}, # >> {:id=>23, # >> :standard=>"Explain the purpose, structure, and syntax of a hash. ", # >> :tags=>["Hashes", "Basics", "Ruby", "Languages"]}, # >> {:id=>24, # >> :standard=>"Define key and value as they relate to hashes. ", # >> :tags=>["Hashes", "Basics", "Ruby", "Languages"]}, # >> {:id=>25, # >> :standard=> # >> "Write and recognize hashes with both hash-rocket syntax and JSON-style syntax.", # >> :tags=>["Hashes", "Basics", "Ruby", "Languages"]}, # >> {:id=>26, # >> :standard=>"Access values in a hash using the syntax hash[key].", # >> :tags=>["Hashes", "Basics", "Ruby", "Languages"]}, # >> {:id=>27, # >> :standard=> # >> "Access all of the keys (hash.keys) or all of the values (hash.values) of a hash. ", # >> :tags=>["Hashes", "Basics", "Ruby", "Languages"]}, # >> {:id=>28, # >> :standard=>"Explain the purpose of a conditional statement.", # >> :tags=>["Conditionals", "Basics", "Ruby", "Languages"]}, # >> {:id=>29, # >> :standard=> # >> "Use conditional operators >, <, <=, >=, ==, != to return true or false.", # >> :tags=>["Conditionals", "Basics", "Ruby", "Languages"]}, # >> {:id=>30, # >> :standard=> # >> "Write if/elsif/else statements using correct syntax (one if, one or more elsif, one else).", # >> :tags=>["Conditionals", "Basics", "Ruby", "Languages"]}, # >> {:id=>31, # >> :standard=>"Write ternary statements.", # >> :tags=>["Conditionals", "Basics", "Ruby", "Languages"]}, # >> {:id=>32, # >> :standard=>"Write one-line if statements.", # >> :tags=>["Conditionals", "Basics", "Ruby", "Languages"]}, # >> {:id=>33, # >> :standard=>"Explain the execution flow of a conditional statement. ", # >> :tags=>["Conditionals", "Basics", "Ruby", "Languages"]}, # >> {:id=>34, # >> :standard=>"Explain the purpose of a class.", # >> :tags=>["Classes", "Basics", "Ruby", "Languages"]}, # >> {:id=>35, # >> :standard=>"Define a class with correct syntax.", # >> :tags=>["Classes", "Basics", "Ruby", "Languages"]}, # >> {:id=>36, # >> :standard=>"Define attributes for instances of a class.", # >> :tags=>["Classes", "Basics", "Ruby", "Languages"]}, # >> {:id=>37, # >> :standard=> # >> "Access and/or change attributes using attr_accessor, attr_writer, and attr_reader. ", # >> :tags=>["Classes", "Basics", "Ruby", "Languages"]}, # >> {:id=>38, # >> :standard=> # >> "Explain what attr_accessor, attr_writer, and attr_reader are shorthand for. ", # >> :tags=>["Classes", "Basics", "Ruby", "Languages"]}, # >> {:id=>39, # >> :standard=> # >> "Create an instance of a class and assign attributes to that instance.", # >> :tags=>["Classes", "Basics", "Ruby", "Languages"]}, # >> {:id=>40, # >> :standard=>"Define an instance method using correct syntax.", # >> :tags=>["Writing Methods", "Basics", "Ruby", "Languages"]}, # >> {:id=>41, # >> :standard=>"Define a class method using correct syntax.", # >> :tags=>["Writing Methods", "Basics", "Ruby", "Languages"]}, # >> {:id=>42, # >> :standard=>"Define methods that accept arguments. ", # >> :tags=>["Writing Methods", "Basics", "Ruby", "Languages"]}, # >> {:id=>43, # >> :standard=>"Iterate through a collection of objects using #each.", # >> :tags=>["Enumerable Methods", "Ruby", "Languages"]}, # >> {:id=>44, # >> :standard=> # >> "Iterate through a collection and return a new array using #map or #collect.", # >> :tags=>["Enumerable Methods", "Ruby", "Languages"]}, # >> {:id=>45, # >> :standard=>"Shuffle the order of elements in an array using #shuffle.", # >> :tags=>["Enumerable Methods", "Ruby", "Languages"]}, # >> {:id=>46, # >> :standard=>"Sort an array numerically or alphabetically using #sort. ", # >> :tags=>["Enumerable Methods", "Ruby", "Languages"]}, # >> {:id=>47, # >> :standard=>"Sort an array by a characteristic using #sort_by. ", # >> :tags=>["Enumerable Methods", "Ruby", "Languages"]}, # >> {:id=>48, # >> :standard=>"Install a gem. ", # >> :tags=>["Gems", "Ruby", "Languages"]}, # >> {:id=>49, # >> :standard=>"Write HTML forms using type, name, and value attributes.", # >> :tags=>["HTML/CSS", "Languages"]}, # >> {:id=>50, # >> :standard=>"Build a basic HTML page using common tags.", # >> :tags=>["HTML/CSS", "Languages"]}, # >> {:id=>51, # >> :standard=>"Describe the difference between a `class` and `id` in HTML.", # >> :tags=>["HTML/CSS", "Languages"]}, # >> {:id=>52, # >> :standard=> # >> "Define the difference between block and inline elements in HTML.", # >> :tags=>["HTML/CSS", "Languages"]}, # >> {:id=>53, # >> :standard=>"Use CSS selectors to target specific elements.", # >> :tags=>["HTML/CSS", "Languages"]}, # >> {:id=>54, # >> :standard=>"Lay out page elements using CSS.", # >> :tags=>["HTML/CSS", "Languages"]}, # >> {:id=>55, # >> :standard=>"Style HTML markup using CSS.", # >> :tags=>["HTML/CSS", "Languages"]}, # >> {:id=>56, # >> :standard=>"Explain rule specificity in CSS.", # >> :tags=>["HTML/CSS", "Languages"]}, # >> {:id=>57, # >> :standard=>"Use pseudo selectors to target specific elements on a page.", # >> :tags=>["HTML/CSS", "Languages"]}, # >> {:id=>58, # >> :standard=>"Demonstrate an understanding of the box model in CSS.", # >> :tags=>["HTML/CSS", "Languages"]}, # >> {:id=>59, # >> :standard=>"Use vendor prefixes for non-standardized CSS properties.", # >> :tags=>["HTML/CSS", "Languages"]}, # >> {:id=>60, # >> :standard=>"Animate elements using CSS transitions and transformations.", # >> :tags=>["HTML/CSS", "Languages"]}, # >> {:id=>61, # >> :standard=> # >> "Implement responsive design using media-queries and breakpoints.", # >> :tags=>["HTML/CSS", "Languages"]}, # >> {:id=>62, # >> :standard=>"Use SASS to compile CSS.", # >> :tags=>["HTML/CSS", "Languages"]}, # >> {:id=>63, # >> :standard=>"Demonstrate the basic structure of an HTML document.", # >> :tags=>["HTML/CSS", "Languages"]}, # >> {:id=>64, # >> :standard=> # >> "Explain that <head></head> contains information about scripts, stylesheets, the document title, meta information, etc.", # >> :tags=>["HTML/CSS", "Languages"]}, # >> {:id=>65, # >> :standard=>"Explain that <body></body> contains the content of the page.", # >> :tags=>["HTML/CSS", "Languages"]}, # >> {:id=>66, :standard=>"JavaScript", :tags=>["Languages"]}, # >> {:id=>67, :standard=>"Environment", :tags=>["Tools"]}, # >> {:id=>68, # >> :standard=>"Explain the purpose of git and Github.", # >> :tags=>["Git", "Tools"]}, # >> {:id=>69, # >> :standard=> # >> "Manipulate git configuration (user.name, user.email, alias.--, github.user, github.token) from both the command line and from .gitconfig file. ", # >> :tags=>["Git", "Tools"]}, # >> {:id=>70, # >> :standard=>"Initialize a new git repository. ", # >> :tags=>["Git", "Tools"]}, # >> {:id=>71, # >> :standard=> # >> "Move files to staging area with `git add .`, `git add -A`, and `git add <filename/directory>`.", # >> :tags=>["Git", "Tools"]}, # >> {:id=>72, # >> :standard=> # >> "Commit files and directories using `git commit -m <message>` or `git commit`. ", # >> :tags=>["Git", "Tools"]}, # >> {:id=>73, # >> :standard=> # >> "Check the status of the working directory and staging area with `git status` and interpret the output.", # >> :tags=>["Git", "Tools"]}, # >> {:id=>74, # >> :standard=>"View previous commits with `git log`. ", # >> :tags=>["Git", "Tools"]}, # >> {:id=>75, # >> :standard=> # >> "Create and checkout a new branch with `git checkout -b <branchname>`. ", # >> :tags=>["Git", "Tools"]}, # >> {:id=>76, # >> :standard=>"Switch between branches with `git checkout <branchname>`. ", # >> :tags=>["Git", "Tools"]}, # >> {:id=>77, # >> :standard=> # >> "Merge local branches to local master with `git merge <branchname>`. ", # >> :tags=>["Git", "Tools"]}, # >> {:id=>78, # >> :standard=>"Create a remote on Github and push a repository. ", # >> :tags=>["Git", "Tools"]}, # >> {:id=>79, :standard=>"Clone a git repository. ", :tags=>["Git", "Tools"]}, # >> {:id=>80, # >> :standard=> # >> "Create .gitignore file and add relevant files and directories.", # >> :tags=>["Git", "Tools"]}, # >> {:id=>81, :standard=>"Fork a repo on Github. ", :tags=>["Git", "Tools"]}, # >> {:id=>82, # >> :standard=> # >> "Employ best practices for working collaboratively on software projects using Git and GitHub.", # >> :tags=>["Git", "Tools"]}, # >> {:id=>83, # >> :standard=>"Set up workflows for peer-reviewing code in pull requests. ", # >> :tags=>["Git", "Tools"]}, # >> {:id=>84, # >> :standard=>"Create, track, and manage issues, bugs, and features.", # >> :tags=>["Git", "Tools"]}, # >> {:id=>85, # >> :standard=>"Refactor commit history using `git rebase`.", # >> :tags=>["Git", "Tools"]}, # >> {:id=>86, # >> :standard=> # >> "List and define the purpose of each of the verbs used in HTTP requests.", # >> :tags=>["HTTP, APIs, JSON", "Tools"]}, # >> {:id=>87, # >> :standard=>"Define what makes HTTP a stateless protocol.", # >> :tags=>["HTTP, APIs, JSON", "Tools"]}, # >> {:id=>88, # >> :standard=>"Dissect a URL into protocol, server, and path.", # >> :tags=>["HTTP, APIs, JSON", "Tools"]}, # >> {:id=>89, # >> :standard=>"Describe the difference between an HTTP request and response.", # >> :tags=>["HTTP, APIs, JSON", "Tools"]}, # >> {:id=>90, # >> :standard=> # >> "Describe the difference between client-side and server-side code.", # >> :tags=>["HTTP, APIs, JSON", "Tools"]}, # >> {:id=>91, # >> :standard=>"Test HTTP responses in web applications.", # >> :tags=>["HTTP, APIs, JSON", "Tools"]}, # >> {:id=>92, # >> :standard=>"Process tools (guard, rake, use of libraries)", # >> :tags=>["Tools"]}, # >> {:id=>93, :standard=>"Cron", :tags=>["DevOps", "Tools"]}, # >> {:id=>94, :standard=>"SQL", :tags=>["Databases", "Tools"]}, # >> {:id=>95, :standard=>"Redis", :tags=>["No SQL", "Databases", "Tools"]}, # >> {:id=>96, # >> :standard=>"Sanitizing input", # >> :tags=>["Security", "Web Applications"]}, # >> {:id=>97, # >> :standard=>"Authorization & Authentication", # >> :tags=>["Web Applications"]}, # >> {:id=>98, :standard=>"Images", :tags=>["Uploads", "Web Applications"]}, # >> {:id=>99, :standard=>"Files", :tags=>["Uploads", "Web Applications"]}, # >> {:id=>100, # >> :standard=>"Set up a web app using Sinatra. ", # >> :tags=>["Sinatra", "Frameworks", "Web Applications"]}, # >> {:id=>101, # >> :standard=>"Route requests using HTTP verbs.", # >> :tags=>["Sinatra", "Frameworks", "Web Applications"]}, # >> {:id=>102, # >> :standard=> # >> "Pass data from controller to views in the form of local and instance variables.", # >> :tags=>["Sinatra", "Frameworks", "Web Applications"]}, # >> {:id=>103, # >> :standard=>"Write HTML with embedded ruby code (ERB).", # >> :tags=>["Sinatra", "Frameworks", "Web Applications"]}, # >> {:id=>104, # >> :standard=> # >> "Access data passed through forms and URLs from the params hash. ", # >> :tags=>["Sinatra", "Frameworks", "Web Applications"]}, # >> {:id=>105, :standard=>"Rails", :tags=>["Frameworks", "Web Applications"]}, # >> {:id=>106, :standard=>"Ember", :tags=>["Frameworks", "Web Applications"]}, # >> {:id=>107, :standard=>"Pub/Sub", :tags=>["Web Applications"]}, # >> {:id=>108, # >> :standard=>"Explain and demonstrate TDD workflow. ", # >> :tags=>["In design", "Testing", "Software Design"]}, # >> {:id=>109, # >> :standard=>"Create and run a Minitest suite.", # >> :tags=>["Minitest", "Ruby", "In practice", "Testing", "Software Design"]}, # >> {:id=>110, # >> :standard=> # >> "Write assertions in Minitest (assert, assert_equal, assert_respond_to, assert_instance_of).", # >> :tags=>["Minitest", "Ruby", "In practice", "Testing", "Software Design"]}, # >> {:id=>111, # >> :standard=>"Read, interpret, and fix error messages. ", # >> :tags=>["Minitest", "Ruby", "In practice", "Testing", "Software Design"]}, # >> {:id=>112, # >> :standard=>"Read, interpret, and fix failure messages. ", # >> :tags=>["Minitest", "Ruby", "In practice", "Testing", "Software Design"]}, # >> {:id=>113, :standard=>"Design Patterns", :tags=>["OOP", "Software Design"]}, # >> {:id=>114, :standard=>"MVC", :tags=>["OOP", "Software Design"]}, # >> {:id=>115, # >> :standard=>"Separation of Responsibilties", # >> :tags=>["OOP", "Software Design"]}, # >> {:id=>116, :standard=>"SOLID", :tags=>["OOP", "Software Design"]}, # >> {:id=>117, # >> :standard=>"Service-Oriented Architecture", # >> :tags=>["Software Design"]}, # >> {:id=>118, :standard=>"Performance", :tags=>["Software Design"]}, # >> {:id=>119, :standard=>"User Stories", :tags=>["Agile", "Processes"]}, # >> {:id=>120, :standard=>"User Experience", :tags=>["Processes"]}, # >> {:id=>121, :standard=>"Workflow", :tags=>["Processes"]}, # >> {:id=>122, # >> :standard=> # >> "Ask questions to both gain knowledge and clarify understanding. ", # >> :tags=>["Thinking & Learning", "Processes"]}, # >> {:id=>123, # >> :standard=>"Know how to get help (Google, peers, instructors, mentors).", # >> :tags=>["Thinking & Learning", "Processes"]}, # >> {:id=>124, # >> :standard=>"Be comfortable being uncomfortable. ", # >> :tags=>["Thinking & Learning", "Processes"]}, # >> {:id=>125, # >> :standard=>"Make mistakes without feeling incompetent. ", # >> :tags=>["Thinking & Learning", "Processes"]}, # >> {:id=>126, :standard=>"Professional Competencies ", :tags=>["Processes"]}]}
Looks like y'all are doing good work in standards_organization!
To ease the transition between the text file and the standards structure, here is a snippet to parse that file and write it into the standards: