{"action":"opened","number":2558,"pull_request":{"url":"https://api.github.com/repos/alphagov/smart-answers/pulls/2558","id":72025415,"html_url":"https://github.com/alphagov/smart-answers/pull/2558","diff_url":"https://github.com/alphagov/smart-answers/pull/2558.diff","patch_url":"https://github.com/alphagov/smart-answers/pull/2558.patch","issue_url":"https://api.github.com/repos/alphagov/smart-answers/issues/2558","number":2558,"state":"open","locked":false,"title":"Move calculators into flow directories","user":{"login":"floehopper","id":3169,"avatar_url":"https://avatars.githubusercontent.com/u/3169?v=3","gravatar_id":"","url":"https://api.github.com/users/floehopper","html_url":"https://github.com/floehopper","followers_url":"https://api.github.com/users/floehopper/followers","following_url":"https://api.github.com/users/floehopper/following{/other_user}","gists_url":"https://api.github.com/users/floehopper/gists{/gist_id}","starred_url":"https://api.github.com/users/floehopper/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/floehopper/subscriptions","organizations_url":"https://api.github.com/users/floehopper/orgs","repos_url":"https://api.github.com/users/floehopper/repos","events_url":"https://api.github.com/users/floehopper/events{/privacy}","received_events_url":"https://api.github.com/users/floehopper/received_events","type":"User","site_admin":false},"body":"### Description\r\n\r\nThe distinction between `lib/smart_answers` and `lib/smart_answer_flows` was (originally) intended as making a distinction between flow-specific (\"application\") code and generic (\"library\") code.\r\n\r\nAlthough I don't much like the way this is \"implemented\" in terms of the current directory structure, I do think it's a useful concept. I also think there is value in keeping all the files relating to a specific flow close together - partly because I think of an individual flow as a mini application in its own right.\r\n\r\nHowever, there are currently a bunch of *flow-specific* classes under `lib/smart_answers/calculators`. This PR moves these \"calculator\" classes into the relevant flow's directory in order that all the files relating to a specific flow are in one place.\r\n\r\nFor \"calculator\" classes used in multiple flows, I would envisage moving them to the `lib/smart_answer_flows/shared` directory c.f. `lib/smart_answer_flows/shared/minimum_wage.rb`.\r\n\r\n### Example\r\n\r\n`lib/smart_answer/calculators/commodity_code_calculator.rb` -> `lib/smart_answer_flows/additional-commodity-code/calculator.rb`\r\n\r\n`SmartAnswer::Calculators:CommodityCodeCalculator` -> `SmartAnswer::AdditionalCommodityCodeFlow::Calculator`\r\n\r\nThis leaves us with the following directory structure:\r\n\r\n```\r\nlib\r\n└── smart_answer_flows\r\n    ├── <flow-name>.rb # flow (\"controller\")\r\n    └── <flow-name>\r\n        ├── <flow-name>.govspeak.erb # start page template\r\n        ├── calculator.rb # policy/rules/calculations (\"model\")\r\n        ├── questions\r\n        │   ├── question_1.govspeak.erb # question page template\r\n        │   └── question_2.govspeak.erb # question page template\r\n        └── outcomes\r\n            ├── outcome_1.govspeak.erb # outcome page template\r\n            └── outcome_2.govspeak.erb # outcome page template\r\n```\r\n\r\n### Scope\r\n\r\nThere are many things wrong with the project's directory structure and name-spacing in the app, but I do not plan to fix them all in this PR. The aim of this PR is to improve matters in a good direction by taking a relatively small step. I'm not suggesting that the directory structure implemented in this PR is without flaws, just that it is an incremental improvement on what we have at the moment.\r\n\r\n### Future plans\r\n\r\nThe following directory structure illustrates the direction in which I'm heading. However, none of this is set in stone and I don't think this PR ties us into any particular approach. While I think it's useful to discuss our plans so that we're all on the same page, I'm slightly wary about thinking too far ahead.\r\n\r\n```\r\nlib\r\n└── smart_answer_flows\r\n    └── <flow-name>\r\n        ├── models\r\n        │   └── policy.rb\r\n        ├── controllers\r\n        │   └── flow.rb\r\n        └── views\r\n            ├── start.govspeak.erb\r\n            ├── questions\r\n            │   ├── question_1.govspeak.erb\r\n            │   └── question_2.govspeak.erb\r\n            └── outcomes\r\n                ├── outcome_1.govspeak.erb\r\n                └── outcome_2.govspeak.erb\r\n```\r\n\r\nFor what it's worth, here are some of the *other* many things that are wrong with the directory structure and name-spacing:\r\n\r\n* Directory structure not mirroring namespaces (breaks Rails auto-loading).\r\n* Directory names with hyphens instead of underscores (also breaks Rails auto-loading).\r\n* Some generic (\"library\") code is under the `app` directory and some is under the `lib` directory.\r\n","created_at":"2016-05-31T14:28:29Z","updated_at":"2016-05-31T14:28:29Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/alphagov/smart-answers/pulls/2558/commits","review_comments_url":"https://api.github.com/repos/alphagov/smart-answers/pulls/2558/comments","review_comment_url":"https://api.github.com/repos/alphagov/smart-answers/pulls/comments{/number}","comments_url":"https://api.github.com/repos/alphagov/smart-answers/issues/2558/comments","statuses_url":"https://api.github.com/repos/alphagov/smart-answers/statuses/0ddfc5f58f9d160329f8cfc76ce32a88ee1868d4","head":{"label":"alphagov:move-calculators-into-flow-directories","ref":"move-calculators-into-flow-directories","sha":"0ddfc5f58f9d160329f8cfc76ce32a88ee1868d4","user":{"login":"alphagov","id":596977,"avatar_url":"https://avatars.githubusercontent.com/u/596977?v=3","gravatar_id":"","url":"https://api.github.com/users/alphagov","html_url":"https://github.com/alphagov","followers_url":"https://api.github.com/users/alphagov/followers","following_url":"https://api.github.com/users/alphagov/following{/other_user}","gists_url":"https://api.github.com/users/alphagov/gists{/gist_id}","starred_url":"https://api.github.com/users/alphagov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alphagov/subscriptions","organizations_url":"https://api.github.com/users/alphagov/orgs","repos_url":"https://api.github.com/users/alphagov/repos","events_url":"https://api.github.com/users/alphagov/events{/privacy}","received_events_url":"https://api.github.com/users/alphagov/received_events","type":"Organization","site_admin":false},"repo":{"id":2651887,"name":"smart-answers","full_name":"alphagov/smart-answers","owner":{"login":"alphagov","id":596977,"avatar_url":"https://avatars.githubusercontent.com/u/596977?v=3","gravatar_id":"","url":"https://api.github.com/users/alphagov","html_url":"https://github.com/alphagov","followers_url":"https://api.github.com/users/alphagov/followers","following_url":"https://api.github.com/users/alphagov/following{/other_user}","gists_url":"https://api.github.com/users/alphagov/gists{/gist_id}","starred_url":"https://api.github.com/users/alphagov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alphagov/subscriptions","organizations_url":"https://api.github.com/users/alphagov/orgs","repos_url":"https://api.github.com/users/alphagov/repos","events_url":"https://api.github.com/users/alphagov/events{/privacy}","received_events_url":"https://api.github.com/users/alphagov/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/alphagov/smart-answers","description":"smart-answers","fork":false,"url":"https://api.github.com/repos/alphagov/smart-answers","forks_url":"https://api.github.com/repos/alphagov/smart-answers/forks","keys_url":"https://api.github.com/repos/alphagov/smart-answers/keys{/key_id}","collaborators_url":"https://api.github.com/repos/alphagov/smart-answers/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/alphagov/smart-answers/teams","hooks_url":"https://api.github.com/repos/alphagov/smart-answers/hooks","issue_events_url":"https://api.github.com/repos/alphagov/smart-answers/issues/events{/number}","events_url":"https://api.github.com/repos/alphagov/smart-answers/events","assignees_url":"https://api.github.com/repos/alphagov/smart-answers/assignees{/user}","branches_url":"https://api.github.com/repos/alphagov/smart-answers/branches{/branch}","tags_url":"https://api.github.com/repos/alphagov/smart-answers/tags","blobs_url":"https://api.github.com/repos/alphagov/smart-answers/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/alphagov/smart-answers/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/alphagov/smart-answers/git/refs{/sha}","trees_url":"https://api.github.com/repos/alphagov/smart-answers/git/trees{/sha}","statuses_url":"https://api.github.com/repos/alphagov/smart-answers/statuses/{sha}","languages_url":"https://api.github.com/repos/alphagov/smart-answers/languages","stargazers_url":"https://api.github.com/repos/alphagov/smart-answers/stargazers","contributors_url":"https://api.github.com/repos/alphagov/smart-answers/contributors","subscribers_url":"https://api.github.com/repos/alphagov/smart-answers/subscribers","subscription_url":"https://api.github.com/repos/alphagov/smart-answers/subscription","commits_url":"https://api.github.com/repos/alphagov/smart-answers/commits{/sha}","git_commits_url":"https://api.github.com/repos/alphagov/smart-answers/git/commits{/sha}","comments_url":"https://api.github.com/repos/alphagov/smart-answers/comments{/number}","issue_comment_url":"https://api.github.com/repos/alphagov/smart-answers/issues/comments{/number}","contents_url":"https://api.github.com/repos/alphagov/smart-answers/contents/{+path}","compare_url":"https://api.github.com/repos/alphagov/smart-answers/compare/{base}...{head}","merges_url":"https://api.github.com/repos/alphagov/smart-answers/merges","archive_url":"https://api.github.com/repos/alphagov/smart-answers/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/alphagov/smart-answers/downloads","issues_url":"https://api.github.com/repos/alphagov/smart-answers/issues{/number}","pulls_url":"https://api.github.com/repos/alphagov/smart-answers/pulls{/number}","milestones_url":"https://api.github.com/repos/alphagov/smart-answers/milestones{/number}","notifications_url":"https://api.github.com/repos/alphagov/smart-answers/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/alphagov/smart-answers/labels{/name}","releases_url":"https://api.github.com/repos/alphagov/smart-answers/releases{/id}","deployments_url":"https://api.github.com/repos/alphagov/smart-answers/deployments","created_at":"2011-10-26T15:39:01Z","updated_at":"2016-04-19T07:13:06Z","pushed_at":"2016-05-31T14:06:46Z","git_url":"git://github.com/alphagov/smart-answers.git","ssh_url":"git@github.com:alphagov/smart-answers.git","clone_url":"https://github.com/alphagov/smart-answers.git","svn_url":"https://github.com/alphagov/smart-answers","homepage":"","size":48907,"stargazers_count":78,"watchers_count":78,"language":"HTML","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":49,"mirror_url":null,"open_issues_count":18,"forks":49,"open_issues":18,"watchers":78,"default_branch":"master"}},"base":{"label":"alphagov:master","ref":"master","sha":"6504c77cdc2164cbcc7b5af9dd8d91ed77af32f6","user":{"login":"alphagov","id":596977,"avatar_url":"https://avatars.githubusercontent.com/u/596977?v=3","gravatar_id":"","url":"https://api.github.com/users/alphagov","html_url":"https://github.com/alphagov","followers_url":"https://api.github.com/users/alphagov/followers","following_url":"https://api.github.com/users/alphagov/following{/other_user}","gists_url":"https://api.github.com/users/alphagov/gists{/gist_id}","starred_url":"https://api.github.com/users/alphagov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alphagov/subscriptions","organizations_url":"https://api.github.com/users/alphagov/orgs","repos_url":"https://api.github.com/users/alphagov/repos","events_url":"https://api.github.com/users/alphagov/events{/privacy}","received_events_url":"https://api.github.com/users/alphagov/received_events","type":"Organization","site_admin":false},"repo":{"id":2651887,"name":"smart-answers","full_name":"alphagov/smart-answers","owner":{"login":"alphagov","id":596977,"avatar_url":"https://avatars.githubusercontent.com/u/596977?v=3","gravatar_id":"","url":"https://api.github.com/users/alphagov","html_url":"https://github.com/alphagov","followers_url":"https://api.github.com/users/alphagov/followers","following_url":"https://api.github.com/users/alphagov/following{/other_user}","gists_url":"https://api.github.com/users/alphagov/gists{/gist_id}","starred_url":"https://api.github.com/users/alphagov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alphagov/subscriptions","organizations_url":"https://api.github.com/users/alphagov/orgs","repos_url":"https://api.github.com/users/alphagov/repos","events_url":"https://api.github.com/users/alphagov/events{/privacy}","received_events_url":"https://api.github.com/users/alphagov/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/alphagov/smart-answers","description":"smart-answers","fork":false,"url":"https://api.github.com/repos/alphagov/smart-answers","forks_url":"https://api.github.com/repos/alphagov/smart-answers/forks","keys_url":"https://api.github.com/repos/alphagov/smart-answers/keys{/key_id}","collaborators_url":"https://api.github.com/repos/alphagov/smart-answers/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/alphagov/smart-answers/teams","hooks_url":"https://api.github.com/repos/alphagov/smart-answers/hooks","issue_events_url":"https://api.github.com/repos/alphagov/smart-answers/issues/events{/number}","events_url":"https://api.github.com/repos/alphagov/smart-answers/events","assignees_url":"https://api.github.com/repos/alphagov/smart-answers/assignees{/user}","branches_url":"https://api.github.com/repos/alphagov/smart-answers/branches{/branch}","tags_url":"https://api.github.com/repos/alphagov/smart-answers/tags","blobs_url":"https://api.github.com/repos/alphagov/smart-answers/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/alphagov/smart-answers/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/alphagov/smart-answers/git/refs{/sha}","trees_url":"https://api.github.com/repos/alphagov/smart-answers/git/trees{/sha}","statuses_url":"https://api.github.com/repos/alphagov/smart-answers/statuses/{sha}","languages_url":"https://api.github.com/repos/alphagov/smart-answers/languages","stargazers_url":"https://api.github.com/repos/alphagov/smart-answers/stargazers","contributors_url":"https://api.github.com/repos/alphagov/smart-answers/contributors","subscribers_url":"https://api.github.com/repos/alphagov/smart-answers/subscribers","subscription_url":"https://api.github.com/repos/alphagov/smart-answers/subscription","commits_url":"https://api.github.com/repos/alphagov/smart-answers/commits{/sha}","git_commits_url":"https://api.github.com/repos/alphagov/smart-answers/git/commits{/sha}","comments_url":"https://api.github.com/repos/alphagov/smart-answers/comments{/number}","issue_comment_url":"https://api.github.com/repos/alphagov/smart-answers/issues/comments{/number}","contents_url":"https://api.github.com/repos/alphagov/smart-answers/contents/{+path}","compare_url":"https://api.github.com/repos/alphagov/smart-answers/compare/{base}...{head}","merges_url":"https://api.github.com/repos/alphagov/smart-answers/merges","archive_url":"https://api.github.com/repos/alphagov/smart-answers/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/alphagov/smart-answers/downloads","issues_url":"https://api.github.com/repos/alphagov/smart-answers/issues{/number}","pulls_url":"https://api.github.com/repos/alphagov/smart-answers/pulls{/number}","milestones_url":"https://api.github.com/repos/alphagov/smart-answers/milestones{/number}","notifications_url":"https://api.github.com/repos/alphagov/smart-answers/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/alphagov/smart-answers/labels{/name}","releases_url":"https://api.github.com/repos/alphagov/smart-answers/releases{/id}","deployments_url":"https://api.github.com/repos/alphagov/smart-answers/deployments","created_at":"2011-10-26T15:39:01Z","updated_at":"2016-04-19T07:13:06Z","pushed_at":"2016-05-31T14:06:46Z","git_url":"git://github.com/alphagov/smart-answers.git","ssh_url":"git@github.com:alphagov/smart-answers.git","clone_url":"https://github.com/alphagov/smart-answers.git","svn_url":"https://github.com/alphagov/smart-answers","homepage":"","size":48907,"stargazers_count":78,"watchers_count":78,"language":"HTML","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":49,"mirror_url":null,"open_issues_count":18,"forks":49,"open_issues":18,"watchers":78,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/alphagov/smart-answers/pulls/2558"},"html":{"href":"https://github.com/alphagov/smart-answers/pull/2558"},"issue":{"href":"https://api.github.com/repos/alphagov/smart-answers/issues/2558"},"comments":{"href":"https://api.github.com/repos/alphagov/smart-answers/issues/2558/comments"},"review_comments":{"href":"https://api.github.com/repos/alphagov/smart-answers/pulls/2558/comments"},"review_comment":{"href":"https://api.github.com/repos/alphagov/smart-answers/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/alphagov/smart-answers/pulls/2558/commits"},"statuses":{"href":"https://api.github.com/repos/alphagov/smart-answers/statuses/0ddfc5f58f9d160329f8cfc76ce32a88ee1868d4"}},"merged":false,"mergeable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"commits":7,"additions":1530,"deletions":1473,"changed_files":43}}
{"actor":{"display_login":"floehopper"}}