Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7622747
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T04:31:49+00:00 2026-05-31T04:31:49+00:00

I’ve got some a basic framework for a webapp (some static pages, user authentication,

  • 0

I’ve got some a basic framework for a webapp (some static pages, user authentication, basic testing with rpec). I’d like to use this as a foundation for future webapps. I’ve named my project “framework,” so if I fork it, I’ll have about a dozen instances where I have to replace the term “Framework” with the name of the new app I’m creating. This project is as github.com/bnd5k/framework. The README file contains a list of the files where I need to make the change. I can make those changes by hand by hand, but I’d prefer to automate this process. I figure that the easiest thing to do would be to include a rake file in Framework. So, I created rake file called renamer.rake. My rake file is based on this post: How to search file text for a pattern and replace it with a given value. Here’s what I came up with.

task :rename do

  file_names = ['config/environments/test.rb', 'config/environments/production.rb', 
    'config/environment.rb']
  file_names.each do |file_name|
    text = File.read(file_name)
    puts text.gsub("Framework", "funktrunkgunk")
  end
end

This code works insofar as it replaces the term “framework” with a different term, but it only does to in the console. I need it to actually change the contents of the files. What do I need to do? Do I need to open the each file instead of just read it?

FYI this code only lists a few files (just so I can test out whether this method works) and the replacement term will ultimately be a variable, not “funktrunkgunk”. Once I get this part down, I’d like to have it setup so that anyone can clone the framework repo to their machine, cd into the framework directory, start rails server, then go to local host on their browser to rename the file from there. I’ll setup public/index.html to be a basic page that contains a form field where the user can enter their own name for the app. Once the user clicks a “Name App” button , it’ll run the rake file. Does that sound feasible?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T04:31:51+00:00Added an answer on May 31, 2026 at 4:31 am

    You need to write the changed text out to the file again.

    File.open(file_name, 'w') { |f| f << text.gsub("Framework", "funktrunkgunk") }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I’ve created a basic framework for webapps (some static pages, user authentication, unit/integration testing
Got some code that is not mine and its producing this warning atm: iehtmlwin.cpp(264)
Got some basic problem again. I need to modify a function that previously returned
I've got some basic questions about C++. Consider the following code in which I
I've got some (I think) pretty basic code for creating cell content from a
I am a newbie for facebook apps...Just now starting with some basic code got
I'm trying to perform some basic AD User managment tasks in C# using .Net
I think I have got some grasp over basic WPF fundaes. Now I want
I'm attempting to put together some basic report screens. I've got some fairly complicated
So I am trying to put together a small lightweight framework for some basic

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.